delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/02/04/08:09:14

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: pavenis AT lanet DOT lv
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>, djgpp-workers AT delorie DOT com
Date: Mon, 4 Feb 2002 15:09:07 +0200
MIME-Version: 1.0
Subject: Re: gcc-3.X and GDB
Message-ID: <3C5EA413.22359.4E7C12@localhost>
References: <3C5E827C DOT 11149 DOT 8DDF2 AT localhost>
In-reply-to: <Pine.SUN.3.91.1020204142928.10902D-100000@is>
X-mailer: Pegasus Mail for Windows (v4.01)
Reply-To: djgpp-workers AT delorie DOT com

On 4 Feb 2002 at 14:30, Eli Zaretskii wrote:

> 
> On Mon, 4 Feb 2002 pavenis AT lanet DOT lv wrote:
> 
> > Reproduced it under Linux:
> > 	- stripped debug information fromn one my static object library
> > 	- linked one executable (more that one C++ source file) with
> > 	  this library
> > 	- command 'where' showed wrong locations in main.cc for
> > 	  procedures in stripped library
> > 
> > It doesn't seem to happen with shared libraries though, but they are usualy
> > built with debug info.
> > 
> > Perhaps I should prepare some nice test example to be sent to GDB
> > mailing list. 
> 
> Yes, that would probably allow the maintainers to identify the bug much 
> faster.

Tried to build an short example under DJGPP . Unfortunatelly it's behaviour 
under Linux is different (however broken too). I'm including shell script
which creates source files, compiles them and runs gdb. Tested for DJGPP
with gcc-3.0.4 20020131, gcc-3.1 20020129 and gdb-5.1.1 release.
See a shell script at the end of a message
 
> > Anyway I think it could also be some problem in linker at time of merging
> > debug info from fultiple source files. 
> 
> If so, perhaps "objdump --debugging" will show enough information to find 
> the reason for GDB's misbehavior.
> 

It seems to be wrong, however I don't know exactly what should be there.

Andris

#! /bin/sh
#
#  This example ilustrates problems with debugging C++ sources
#  (GCC-3.X only. GCC-2.95.X and earlier were OK) for DJGPP.
#  Run it into an empty directory
#
# 	one should have at least 2 source files with stabs or
#	DWARF2 debugging info and LD should load at least one
#	object file without debug info after that
#
#	As result setting breakpoint to procedure in object
#	file without debug info shows wrong source file
#	and breakpoint does not work. The same with backtrace
#	(command 'where' in GDB, it seems to show nonsense
#	for all object files without debug info which linker
#       loaded after 2 files with either stabs or DWARF2 debug info
#
#	There seem to more problems as I cannot sent breakpoints
#  	in main() and foo2() and source info is not found for these
#	procedures
# 	
CC=gcc
CXX=gpp
#  Both stabs and DRARF2 debug info causes problem.
#  COFF debug infg seems to be OK
DBG=-gstabs+
#DBG=-gdwarf-2
#
$CC -v
#
cat >a.cc << 'EOF'
#include <cstdio>
int foo1 (void) 
{ 
	int * foo = (int *) 0x73456754; /* Try to segfault here  */
	printf ("a.cc: in foo1()\n");
	printf ("%d\n",*foo);
	return 0; 
}
EOF

cat >b.cc << 'EOF'
#include <cstdio>
int foo1 (void);
int foo2 (void)
{
	printf ("Result=%d\n",foo1 ());
	return 0;
}
EOF

cat >c.cc << 'EOF'
int foo2 (void);
int main (void)
{
	return foo2 ();
}
EOF

cat >gdb.ini << 'EOF'
b foo1
run
where
quit
EOF

gcc -O2 -c a.cc
gcc -O2 $DBG -c b.cc
gcc -O2 $DBG -c c.cc
$CXX -o example.exe b.cc c.cc a.cc
gdb example.exe




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019