This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Only try to load libthread_db when we load libpthread.

On Monday 10 October 2011 06:01:00, Doug Evans wrote:
> On Fri, Oct 7, 2011 at 4:09 AM, Pedro Alves <> wrote:
> > Well, at least things should work the same as before, which IMO
> > is good thing as it makes this change an optimization only.
> That's the intent.
> > Still breaks activating thread_db when debugging cores of
> > static executables.

> It turns out things work today accidentally.
> At least I doubt it's by design. :-)

Yeah.  :-)

> My previous patch didn't work because it skipped calling
> check_for_thread_db when the new_objfile observer was called for
> vsyscall (which incidentally is called by the inferior_created
> observer for vsyscall, heh).
> [Which explains why it didn't surprise me when my before-test failed,
> that's a pretty unexpected way to load libthread_db.]
> How about this.

This version goes back to breaking the "file right_executable" core
or attach cases (with static binaries) that the previous patch
fixed.  :-)  You need _both_ the observer, and the OBJF_MAINLINE thing.
The observer handles the case of loading the static executable into gdb before
loading the core or attaching to a process (gdb exec -c core), and
the OBJF_MAINLINE thing handles the opposite scenario (gdb -c core; file exec).

> +/* This function is called via the inferior_created observer.
> +   This handles the case of debugging statically linked executables.  */

As mentioned before, !cores are handled by:

static void
linux_child_post_attach (int pid)
  linux_enable_event_reporting (pid_to_ptid (pid));
  check_for_thread_db ();
  linux_enable_tracesysgood (pid_to_ptid (pid));

static void
linux_child_post_startup_inferior (ptid_t ptid)
  linux_enable_event_reporting (ptid);
  check_for_thread_db ();
  linux_enable_tracesysgood (ptid);

So this handles the case of debugging _cores_ of statically
linked executables, as those don't use linux-nat.c.  With this
new observer, we could even remove those two check_for_thread_db
calls above.

> +
> +static void
> +thread_db_inferior_created (struct target_ops *target, int from_tty)

This is okay with me with the OBJF_MAINLINE changes merged back in,
and the comment mentioned above adjusted.


Pedro Alves

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]