Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mathieu Lacage <Mathieu.Lacage@sophia.inria.fr>
To: gdb@sourceware.org
Subject: gdb and dynamic loader namespaces
Date: Mon, 08 Jan 2007 15:11:00 -0000	[thread overview]
Message-ID: <1168268998.21818.44.camel@garfield.inria.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

hi,

While playing a bit with the dlmopen (this is the stock glibc coming
with a FC5 system) function, it occured to me that gdb 6.6 does not seem
to be able to deal with code loaded in a process through this function.
The attached test program shows that, indeed an extra binary is loaded
in my process address space but gdb seems unable to place a breakpoint
in any of the functions defined in this binary (something like "b
gtk_window_new"). 

So, I tried to figure out how I could fix this in gdb: a bit of
debugging shows that gdb is notified of dlmopen calls through the
r_debug structure since "set stop-on-solib-events 1" triggers correctly
an event upon dlmopen. The question then is why gdb does not add the new
binary to its map. Maybe someone more knowledgeable than me about the
layout of the gdb code source could point me to the piece of code which
updates and manipulates the gdb map of binaries used during symbol
lookup ? (I am using an x86 linux system)

I apologize before hand if this email is off-topic,

regards,
Mathieu
-- 

[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 1209 bytes --]

#define _GNU_SOURCE

#include <dlfcn.h>
#include <link.h>
#include <stdio.h>

static void print_map (struct link_map *map)
{
  struct link_map *tmp;
  for (tmp = map; tmp != 0; tmp = tmp->l_next)
    {
      printf ("  0x%lx: \"%s\"\n", tmp->l_addr, tmp->l_name?tmp->l_name:"null");
    }
}

int main (int argc, char *argv[])
{
  void * handle;
  struct link_map *map;
  dlerror ();
  handle = dlopen (NULL, RTLD_LAZY);
  if (handle == NULL) 
    {
      printf ("error getting handle for main binary: %s\n", dlerror ());
      goto error;
    }
  if (dlinfo (handle, RTLD_DI_LINKMAP, &map) == -1) 
    {
      printf ("error getting link map: %s\n", dlerror ());
      goto error;
    }

  printf ("map before dlmopen\n");
  print_map (map);

  void *module = dlmopen (LM_ID_NEWLM, "/usr/lib/libgtk-x11-2.0.so", RTLD_NOW);	
  if (module == 0) {
    printf ("error=\"%s\"", dlerror ());
    return;
  }


  printf ("default map after dlmopen\n");
  print_map (map);


  if (dlinfo (module, RTLD_DI_LINKMAP, &map) == -1) 
    {
      printf ("error getting 2nd link map: %s\n", dlerror ());
      goto error;
    }

  printf ("2nd map after dlmopen\n");
  print_map (map);


  return 0;
 error:
  return -1;
}

             reply	other threads:[~2007-01-08 15:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-08 15:11 Mathieu Lacage [this message]
2007-01-08 15:15 ` Daniel Jacobowitz
2007-01-08 16:45   ` mathieu lacage
2007-01-08 17:57     ` Daniel Jacobowitz
2007-01-09  7:58   ` Mathieu Lacage
2007-01-09 13:41     ` Daniel Jacobowitz
2007-03-20 13:59       ` mathieu lacage

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=1168268998.21818.44.camel@garfield.inria.fr \
    --to=mathieu.lacage@sophia.inria.fr \
    --cc=gdb@sourceware.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