From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.50) id 1EgOmS-0007zP-GA for garchives@archives.gentoo.org; Sun, 27 Nov 2005 15:49:32 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.5/8.13.5) with SMTP id jARFlpsl005694; Sun, 27 Nov 2005 15:47:51 GMT Received: from skinny.southernlinux.net (ns2.rednecks.net [64.192.52.5]) by robin.gentoo.org (8.13.5/8.13.5) with ESMTP id jARFiZKW023962 for ; Sun, 27 Nov 2005 15:44:35 GMT Received: (qmail 8274 invoked by uid 210); 27 Nov 2005 10:37:41 -0500 Received: from 64.192.53.57 by skinny (envelope-from , uid 201) with qmail-scanner-1.25st (clamdscan: 0.82/1195. f-prot: 4.4.2/3.14.11. spamassassin: 3.0.2. perlscan: 1.25st. Clear:RC:1(64.192.53.57):. Processed in 0.061301 secs); 27 Nov 2005 15:37:41 -0000 Received: from unknown (HELO montgomery-57.epproach.net) (64.192.53.57) by 0 with SMTP; 27 Nov 2005 10:37:41 -0500 Subject: Re: [gentoo-dev] Re: Split ELF Debug (default or not?) From: Ned Ludd To: gentoo-dev@lists.gentoo.org In-Reply-To: <1133104957.15135.22.camel@capella.catmur.co.uk> References: <1133027430.5317.307.camel@localhost> <1133094251.5422.356.camel@localhost> <1133096987.26860.5.camel@home.yosifov.net> <1133098829.5422.409.camel@localhost> <1133104957.15135.22.camel@capella.catmur.co.uk> Content-Type: text/plain Organization: Gentoo Linux Date: Sun, 27 Nov 2005 10:44:30 -0500 Message-Id: <1133106270.5422.451.camel@localhost> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Archives-Salt: d95968ef-226d-487c-a68a-9f53d2d3dc5a X-Archives-Hash: dddbfcecedf2132a5f59d66df550e1df On Sun, 2005-11-27 at 15:22 +0000, Edward Catmur wrote: > On Sun, 2005-11-27 at 08:40 -0500, Ned Ludd wrote: > > On Sun, 2005-11-27 at 15:09 +0200, Ivan Yosifov wrote: > > > And one more thing. For proper debugging, don't I need the source to be > > > present ? > > > > -g3 -ggdb embeds the source code in the debug info so I don't see the > > point. > > It doesn't; at least not with gcc 3.4.4. It does embed function > prototypes and macro definitions, though. > > Ed Catmur Eh? solar@simple ~ $ gcc -g3 -nopie -ggdb segfault_me.c -o segfault_me solar@simple ~ $ paxctl -permsx segfault_me solar@simple ~ $ gdb -q ./segfault_me Using host libthread_db library "/lib/libthread_db.so.1". (gdb) b main Breakpoint 1 at 0x804853d: file segfault_me.c, line 25. (gdb) step The program is not being run. (gdb) r Starting program: /home/solar/segfault_me Breakpoint 1, main () at segfault_me.c:25 25 foo(); (gdb) step foo () at segfault_me.c:17 17 int i = 0; (gdb) 18 for (i = 0 ; i < 3; i++) { (gdb) 19 printf("Just an example %d\n", i); (gdb) Just an example 0 18 for (i = 0 ; i < 3; i++) { (gdb) 19 printf("Just an example %d\n", i); (gdb) Just an example 1 18 for (i = 0 ; i < 3; i++) { (gdb) 19 printf("Just an example %d\n", i); (gdb) Just an example 2 18 for (i = 0 ; i < 3; i++) { (gdb) 21 bar(); (gdb) bar () at segfault_me.c:13 13 baz(); (gdb) baz () at segfault_me.c:9 9 atexit(break_self); (gdb) 10 } (gdb) bar () at segfault_me.c:14 14 } (gdb) foo () at segfault_me.c:22 22 } (gdb) main () at segfault_me.c:26 26 return 0; (gdb) 27 } (gdb) 0x400407b6 in __libc_start_main () from /lib/libc.so.6 (gdb) Single stepping until exit from function __libc_start_main, which has no line number information. Program received signal SIGSEGV, Segmentation fault. 0x40050681 in kill () from /lib/libc.so.6 (gdb) solar@simple ~ $ cat segfault_me.c #include #include void break_self() { kill(getpid(), SIGSEGV); } int baz() { atexit(break_self); } void bar() { baz(); } void foo() { int i; for (i = 0 ; i < 3; i++) { printf("Just an example %d\n", i); } bar(); } int main() { foo(); return 0; } # While single stepping sure looks like source code to me. solar@simple ~ $ gcc -v 2>&1 | tail -n 1 gcc version 3.4.4 (Gentoo Hardened 3.4.4, HTB-3.4.4_pre-1.00, ssp-3.4.4-1.0, pie-8.7.8) -- Ned Ludd Gentoo Linux -- gentoo-dev@gentoo.org mailing list