NetBSD Problem Report #58895

From martin@aprisoft.de  Thu Dec 12 11:01:21 2024
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 1F9451A923C
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 12 Dec 2024 11:01:21 +0000 (UTC)
Message-Id: <20241212110112.8E88C5CC79F@emmas.aprisoft.de>
Date: Thu, 12 Dec 2024 12:01:12 +0100 (CET)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: gdb can't find frames in a debuged gdb
X-Send-Pr-Version: 3.95

>Number:         58895
>Category:       toolchain
>Synopsis:       gdb can't find frames in a debuged gdb
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 12 11:05:00 +0000 2024
>Originator:     Martin Husemann
>Release:        NetBSD 10.99.12
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD martins.aprisoft.de 10.99.12 NetBSD 10.99.12 (GENERIC) #251: Mon Nov 25 18:30:20 CET 2024 martin@martins.aprisoft.de:/home/martin/current/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

Trying to debug gdb does not work well:

[~] martin@martins > gdb gdb
GNU gdb (GDB) 15.1
[..]
Reading symbols from gdb...
Reading symbols from /usr/libdata/debug//usr/bin/gdb.debug...
(gdb) break main
Breakpoint 1 at 0x5ec09c: file /home/martin/current/src/external/gpl3/gdb/bin/gdb/../../dist/gdb/gdb.c, line 30.
(gdb) run
Starting program: /usr/bin/gdb 

Breakpoint 1, main ()
    at /home/martin/current/src/external/gpl3/gdb/bin/gdb/../../dist/gdb/gdb.c:30
30	  gdb_assert (is_main_thread ());
(gdb) n
34	  memset (&args, 0, sizeof args);
(gdb) n
35	  args.argc = argc;
(gdb) p args
No symbol "args" in current context.
(gdb) 

Things called from gdb e.g. in libc or libcurses are debuggable.
Other C++ programs are debugable:

[/tmp] martin@martins > cat test.c 
#include <iostream>
#include <math.h>

int main(int argc, char **argv)
{
	auto a = sin(0.5f);
	std::cout << "my sin value: " << a << std::endl;
	return 0;
}
[/tmp] martin@martins > cat test.c 
#include <iostream>
#include <math.h>

int main(int argc, char **argv)
{
	auto a = sin(0.5f);
	std::cout << "my sin value: " << a << std::endl;
	return 0;
}
[/tmp] martin@martins > gdb a.out 
GNU gdb (GDB) 15.1
[..]
Reading symbols from a.out...
(gdb) break main
Breakpoint 1 at 0x4014b2: file test.cc, line 6.
(gdb) run
Starting program: /tmp/a.out 

Breakpoint 1, main (argc=1, argv=0x7f7fff913898) at test.cc:6
6		auto a = sin(0.5f);
(gdb) n
7		std::cout << "my sin value: " << a << std::endl;
(gdb) p a
$1 = 0.47942553860420301


>How-To-Repeat:
s/a

>Fix:
n/a

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.