From: Andrew Cagney <ac131313@redhat.com>
To: Michael Snyder <msnyder@redhat.com>, Mark Kettenis <kettenis@chello.nl>
Cc: cgd@broadcom.com, Elena Zannoni <ezannoni@redhat.com>,
gdb-patches@sources.redhat.com,
Michael Elizabeth Chastain <mec@shout.net>
Subject: Re: [rfa:threads] Report when using libthread_db
Date: Thu, 21 Aug 2003 22:10:00 -0000 [thread overview]
Message-ID: <3F454362.50609@redhat.com> (raw)
In-Reply-To: <3F33B8ED.1000908@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 181 bytes --]
[I've committed this to cagney_x86i386-20030821-branch, debugging
threads without this is a pain]
Michael, Mark,
OK for 6.0 branch (probably a bit late) and/or mainline?
Andrew
[-- Attachment #2: mailbox-message://ac131313@movemail/fsf/gdb/patches#989141 --]
[-- Type: message/rfc822, Size: 8144 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 697 bytes --]
> At Thu, 7 Aug 2003 19:58:06 +0000 (UTC), "Andrew Cagney" wrote:
>
>> Anyone know how to get a version number from libthread_db, or it's
>> absolute path?
>
>
> looks like there are two ways one can do this:
>
> dlinfo() on Solaris (and other systems that have it -- but it doesn't
> appear common).
>
> dladdr() on systems that have it and this one is more widespread (incl
> solaris, linux at least with -D_GNU_SOURCE, and it looks like NetBSD
> has it as well).
Works for me!
...
Using host libthread_db library "/lib64/tls/libthread_db.so.1".
...
now if only there was also some sort of embedded revision/build string :-(
Michael, Mark, ok for mainline? Too risky for 6.0?
Andrew
[-- Attachment #2.1.2: diffs --]
[-- Type: text/plain, Size: 4081 bytes --]
2003-08-05 Andrew Cagney <cagney@redhat.com>
* thread-db.c (verbose_dlsym): New function.
(thread_db_load): Use verbose_dlsym
(thread_db_new_objfile): Print that libthread_db was loaded, and
that thread debugging was enabled.
Index: ./gdb/thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.33
diff -u -r1.33 thread-db.c
--- ./gdb/thread-db.c 5 Jun 2003 18:22:02 -0000 1.33
+++ ./gdb/thread-db.c 8 Aug 2003 14:42:47 -0000
@@ -375,6 +375,15 @@
target_beneath = target;
}
+static void *
+verbose_dlsym (void *handle, const char *name)
+{
+ void *sym = dlsym (handle, name);
+ if (sym == NULL)
+ warning ("Symbol \"%s\" not found in libthread_db: %s", name, dlerror ());
+ return sym;
+}
+
static int
thread_db_load (void)
{
@@ -394,47 +403,47 @@
/* Initialize pointers to the dynamic library functions we will use.
Essential functions first. */
- td_init_p = dlsym (handle, "td_init");
+ td_init_p = verbose_dlsym (handle, "td_init");
if (td_init_p == NULL)
return 0;
- td_ta_new_p = dlsym (handle, "td_ta_new");
+ td_ta_new_p = verbose_dlsym (handle, "td_ta_new");
if (td_ta_new_p == NULL)
return 0;
- td_ta_map_id2thr_p = dlsym (handle, "td_ta_map_id2thr");
+ td_ta_map_id2thr_p = verbose_dlsym (handle, "td_ta_map_id2thr");
if (td_ta_map_id2thr_p == NULL)
return 0;
- td_ta_map_lwp2thr_p = dlsym (handle, "td_ta_map_lwp2thr");
+ td_ta_map_lwp2thr_p = verbose_dlsym (handle, "td_ta_map_lwp2thr");
if (td_ta_map_lwp2thr_p == NULL)
return 0;
- td_ta_thr_iter_p = dlsym (handle, "td_ta_thr_iter");
+ td_ta_thr_iter_p = verbose_dlsym (handle, "td_ta_thr_iter");
if (td_ta_thr_iter_p == NULL)
return 0;
- td_thr_validate_p = dlsym (handle, "td_thr_validate");
+ td_thr_validate_p = verbose_dlsym (handle, "td_thr_validate");
if (td_thr_validate_p == NULL)
return 0;
- td_thr_get_info_p = dlsym (handle, "td_thr_get_info");
+ td_thr_get_info_p = verbose_dlsym (handle, "td_thr_get_info");
if (td_thr_get_info_p == NULL)
return 0;
- td_thr_getfpregs_p = dlsym (handle, "td_thr_getfpregs");
+ td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs");
if (td_thr_getfpregs_p == NULL)
return 0;
- td_thr_getgregs_p = dlsym (handle, "td_thr_getgregs");
+ td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs");
if (td_thr_getgregs_p == NULL)
return 0;
- td_thr_setfpregs_p = dlsym (handle, "td_thr_setfpregs");
+ td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs");
if (td_thr_setfpregs_p == NULL)
return 0;
- td_thr_setgregs_p = dlsym (handle, "td_thr_setgregs");
+ td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs");
if (td_thr_setgregs_p == NULL)
return 0;
@@ -587,6 +596,30 @@
{
td_err_e err;
+ /* First time through, report that libthread_db was successfuly
+ loaded. Can't print this in in thread_db_load as, at that stage,
+ the interpreter and it's console haven't started. The real
+ problem here is that libthread_db is loaded too early - it should
+ only be loaded when there is a program to debug. */
+ {
+ static int dejavu;
+ if (!dejavu)
+ {
+ Dl_info info;
+ const char *library = NULL;
+ /* Try dladdr. */
+ if (dladdr ((*td_ta_new_p), &info) != 0)
+ library = info.dli_fname;
+ /* Try dlinfo? */
+ if (library == NULL)
+ /* Paranoid - don't let a NULL path slip through. */
+ library = LIBTHREAD_DB_SO;
+ printf_unfiltered ("Using host libthread_db library \"%s\".\n",
+ library);
+ dejavu = 1;
+ }
+ }
+
/* Don't attempt to use thread_db on targets which can not run
(core files). */
if (objfile == NULL || !target_has_execution)
@@ -624,6 +657,8 @@
break;
case TD_OK:
+ printf_unfiltered ("[Thread debugging using libthread_db enabled]\n");
+
/* The thread library was detected. Activate the thread_db target. */
push_target (&thread_db_ops);
using_thread_db = 1;
next prev parent reply other threads:[~2003-08-21 22:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-05 19:26 Andrew Cagney
2003-08-07 19:57 ` Andrew Cagney
[not found] ` <mailpost.1060286286.1556@news-sj1-1>
2003-08-07 20:31 ` cgd
2003-08-08 14:51 ` Andrew Cagney
2003-08-21 22:10 ` Andrew Cagney [this message]
2003-08-21 22:47 ` Mark Kettenis
2003-08-05 19:51 Michael Elizabeth Chastain
2003-08-05 20:10 ` Elena Zannoni
2003-08-08 15:51 Michael Elizabeth Chastain
2003-08-22 19:40 Michael Elizabeth Chastain
2003-08-23 1:49 Michael Elizabeth Chastain
2003-09-04 17:24 ` Andrew Cagney
2003-09-05 15:42 ` Elena Zannoni
2003-09-08 2:28 Michael Elizabeth Chastain
2003-09-08 3:01 ` Daniel Jacobowitz
2003-09-09 14:29 ` Elena Zannoni
2003-09-08 3:05 Michael Elizabeth Chastain
2003-09-08 13:21 ` Andrew Cagney
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=3F454362.50609@redhat.com \
--to=ac131313@redhat.com \
--cc=cgd@broadcom.com \
--cc=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kettenis@chello.nl \
--cc=mec@shout.net \
--cc=msnyder@redhat.com \
/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