linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Re: Help w/ gdb
@ 2000-02-16 19:11 Pierre Sarrazin
  2000-02-16 19:31 ` Kevin Buettner
  2000-02-26 16:23 ` Kevin Buettner
  0 siblings, 2 replies; 10+ messages in thread
From: Pierre Sarrazin @ 2000-02-16 19:11 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: kev


I read the "Help w/ gdb" thread and I have found that one of the
proposed solutions solves one problem that I had on LinuxPPC R5:
I recompiled my small example program with -gdwarf-2 (and gcc 2.95.2)
instead of just -g and then I was able to step into the shared library
function call correctly.

Kevin Buettner, suggested this fix last month in
http://lists.linuxppc.org/listarcs/linuxppc-dev/200001/msg00245.html


However, the problem persists in a different form when I try the
fix with a larger program and larger library (compiled with gcc 2.95.2
with -fPIC and -gdwarf-2). In gdb, I want to step into the statement

  return ((int (*) (void)) functionPtrs[0])();

and I end up with this:

0xfd1859c in InitInterfaceCorrection ()
    at
/usr/local/lib/gcc-lib/powerpc-unknown-linux-gnu/2.95.2/../../../../include/g++-3/stl_alloc.h:518
518             return(_S_chunk_alloc(__size, __nobjs));

If I then give the "next" command, the program continues until it exits.
InitInterfaceCorrection() is the correct function name. Its first
statement is:

  int error = InitInterfaceCorrection_X(NULL, NULL);


Here is the bug report I sent to the GDB mailing list on 21 Jan 2000,
which includes the example program. Note however that since then I
have upgraded to gcc/g++ 2.95.2.

I am still using gdb 4.17.0.11 (which came with LinuxPPC R5).

===========================================================================

GDB does not step correctly into a runtime-loaded function under
LinuxPPC R5. The problem does not occur under RedHat 5.2 on a Pentium.

The Power Macintosh has the following characterics:
- kernel 2.2.6-15apmac #1 Mon May 31 03:54:09 EDT 1999
- /lib/libc-2.1.1.so
- GNU gdb 4.17.0.11
- gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

Here is the main program (prog.c):

---------------------------------------------------------------------------
#include <assert.h>
#include <stddef.h>
#include <dlfcn.h>

int main(int argc, char *argv[])
{
        void *handle;
        void (*function)(void);

        handle = dlopen("./libfoo.so", RTLD_NOW);
        assert(handle != NULL);
        function = dlsym(handle, "library_function");
        assert(dlerror() == NULL && function != NULL);

        (*function)();

        dlclose(handle);
        return 0;
}
---------------------------------------------------------------------------


Here is the library source file (libfoo.c):

---------------------------------------------------------------------------
#include <stdio.h>

void library_function(void)
{
        printf("This is library_function()\n");
        printf("--------------------------\n");
}
---------------------------------------------------------------------------


Here is the Makefile:

---------------------------------------------------------------------------
CFLAGS=-fPIC -g -Wall

all: libfoo.so prog

libfoo.so: libfoo.o
        gcc -shared libfoo.o -o libfoo.so

libfoo.o: libfoo.c
        gcc $(CFLAGS) -c libfoo.c

prog: prog.o
        gcc -rdynamic -o prog prog.o -ldl

prog.o: prog.c
        gcc $(CFLAGS) -c prog.c

clean:
        rm -f prog lib*.so *.o core
---------------------------------------------------------------------------


The program executes fine by itself, as well as in GDB without
breakpoints.

Here is the scenario.  I enter GDB and set a breakpoint on this line
of prog.c:

        (*function)();

Then I run the program and GDB stops on that line. I give the "step"
command and get this:

---------------------------------------------------------------------------
(gdb) break 15
Breakpoint 1 at 0x1800734: file prog.c, line 15.
(gdb) run
Starting program: /home/sarrazip/pgm/bug-gdb-dll/prog

Breakpoint 1, main (argc=1, argv=0x7ffffbd4) at prog.c:15
15              (*function)();
(gdb) step
0x161a61c in library_function () at libfoo.c:7
7       }
(gdb) next
This is library_function()
--------------------------
main (argc=1, argv=0x7ffffbd4) at prog.c:17
17              dlclose(handle);
(gdb)
---------------------------------------------------------------------------


On a Pentium machine running RedHat Linux 5.2, the "step" works fine:
it stops on line 5 of libfoo.c, i.e., the first printf() statement.
This Pentium machine has the following characteristics:
- kernel 2.0.36 #1 Tue Oct 13 22:17:11 EDT 1998
- /lib/libc-2.0.7.so
- GNU gdb 4.17.0.4
- gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

--
Pierre Sarrazin <sarrazip@machinasapiens.com>

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <1000117223224.ZM16757@saguaro.lan>]
* Re: Help w/ gdb
@ 2000-01-16 20:41 D.J. Barrow
  0 siblings, 0 replies; 10+ messages in thread
From: D.J. Barrow @ 2000-01-16 20:41 UTC (permalink / raw)
  To: Kevin Buettner, linuxppc-dev


It helps gdb a lot not to compile with optimisation.
e.g. compiling -g -O2 on powerpc stops gcc copying
parameters passed in registers onto the stack
to aid debugging, this results in stack traces &
viewing passed in parameters frequently being rubbish.

Mind you in a project as large as mosizza there may be
inline functions which gcc may refuse to compile
without optimisation.
In short if you can compile for debugging without
using -O2 do so or at least try to compile all the
code
of intrest without the -O2 flag.


--- Kevin Buettner <kev@primenet.com> wrote:
> 
> On Jan 15, 11:12pm, Sean Chitwood wrote:
> 
> > I periodically ask this question here because I
> have never found a
> > more appropriate audience or satisfactory answer.
> > 
> > I am attempting to help w/ the mozilla project,
> but I am having
> > little success due to the following problem.  When
> I attempt to
> > debug an assert/crash as I bring up the stack
> trace I notice that
> > some of the frames point only to the ending curly
> brace of a
> > function (Not always the one it says is being
> debugged).  I cannot
> > examine variables, or learn anything else
> productive about the
> > situation.  I realize I am not familiar w/ gdb, I
> am primarily
> > familiar w/ windows GUI based debuggers, so I
> figure I am missing a
> > configuration setting, but for the life of me I
> can't figure out
> > what it is.  I do know that I am keeping the
> source and binary files
> > synced, so that shouldn't be it.  It seems to load
> the symbols
> > correctly (no complaining about missing symbols),
> butother than that
> > I seem to be clueless.
> 
> I think this is a bug in either the linker or in gdb
> itself.  (If it's
> the bug I'm thinking of, the bug is actually in the
> linker, but is
> more easily worked around in gdb.) Get the gdb
> sources and take a look
> at config/powerpc/tm-linux.h.  Now search for the
> line
> 
> #define SOFUN_ADDRESS_MAYBE_MISSING
> 
> Is it there?  (I'm guessing not.) Try adding the
> above line to
> tm-linux.h and then rebuild gdb.
> 
> Let me know if it fixes your problem.
> 
> Thanks,
> 
> Kevin
> 
> -- 
> Kevin Buettner
> kev@primenet.com, kevinb@cygnus.com
> 
> 

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Mac-On-Linux Mailing Lists
@ 2000-01-15 21:36 Dan Burcaw
  2000-01-16  7:12 ` Help w/ gdb Sean Chitwood
  0 siblings, 1 reply; 10+ messages in thread
From: Dan Burcaw @ 2000-01-15 21:36 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linuxppc-user, yellowdog-general, yellowdog-devel



I'm pleased to announce that Terra Soft Solutions, makers of Yellow Dog
Linux, has setup two mailing lists for developers and users of the
Mac-On-Linux software.

We've setup two lists -- mol-general and mol-devel -- after consulting
with Samuel Rydh, the MOL author.

For information on subscription, please visist
http://lists.yellowdoglinux.com.

Regards,
Dan

Terra Soft Solutions, Inc.
 Yellow Dog Linux
 "The Ultimate Companion for a Dedicated Server"
 http://www.yellowdoglinux.com/
 
 Black Lab Linux
 Workstations and advanced, Parallel Solutions
 http://www.blacklablinux.com/


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-02-26 16:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-02-16 19:11 Help w/ gdb Pierre Sarrazin
2000-02-16 19:31 ` Kevin Buettner
2000-02-26 16:23 ` Kevin Buettner
     [not found] <1000117223224.ZM16757@saguaro.lan>
2000-01-18  0:40 ` Sean Chitwood
2000-01-18  2:04   ` Kevin Buettner
  -- strict thread matches above, loose matches on Subject: below --
2000-01-16 20:41 D.J. Barrow
2000-01-15 21:36 Mac-On-Linux Mailing Lists Dan Burcaw
2000-01-16  7:12 ` Help w/ gdb Sean Chitwood
2000-01-16 16:46   ` Kevin Buettner
2000-01-17 22:02     ` Sean Chitwood
2000-02-26 16:35   ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).