linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Pierre Sarrazin <sarrazip@machinasapiens.com>
To: linuxppc-dev@lists.linuxppc.org
Cc: kev@primenet.com
Subject: Re: Help w/ gdb
Date: Wed, 16 Feb 2000 14:11:58 -0500	[thread overview]
Message-ID: <38AAF67E.36D2@machinasapiens.com> (raw)


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/

             reply	other threads:[~2000-02-16 19:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-16 19:11 Pierre Sarrazin [this message]
2000-02-16 19:31 ` Help w/ gdb 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=38AAF67E.36D2@machinasapiens.com \
    --to=sarrazip@machinasapiens.com \
    --cc=kev@primenet.com \
    --cc=linuxppc-dev@lists.linuxppc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).