From: Kevin Buettner <kevinb@redhat.com>
To: rda@sources.redhat.com
Subject: [PATCH] Print diagnostics related to thread initialization failures
Date: Tue, 20 Apr 2004 20:35:00 -0000 [thread overview]
Message-ID: <20040420133513.291dc5cc@saguaro> (raw)
I've just committed the patch below.
* thread-db.c (lookup_sym): New function.
(thread_db_open): Print diagnostic message for failed dlopen()
call. Call lookup_sym() which will print diagnostic for failed
dlsym() call.
Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/rda/unix/thread-db.c,v
retrieving revision 1.2
diff -u -p -r1.2 thread-db.c
--- thread-db.c 7 Feb 2003 23:03:09 -0000 1.2
+++ thread-db.c 20 Apr 2004 20:32:04 -0000
@@ -740,6 +740,23 @@ thread_db_setgregs (const td_thrhandle_t
return thread_db_set_regset (&gregset_cache, th, gregset);
}
+/* Call dlsym() to find the address of a symbol. If symbol lookup fails,
+ print the reason to stderr. */
+
+static void *
+lookup_sym (void *dlhandle, char *symbol)
+{
+ void *addr;
+
+ addr = dlsym (dlhandle, symbol);
+
+ if (addr == NULL)
+ fprintf (stderr, "Symbol lookup of %s failed: %s\n",
+ symbol, dlerror ());
+
+ return addr;
+}
+
/* Function: thread_db_dlopen
Attach to the libthread_db library.
This function does all the dynamic library stuff (dlopen, dlsym).
@@ -755,45 +772,49 @@ thread_db_dlopen (void)
#endif
if ((dlhandle = dlopen (LIBTHREAD_DB_SO, RTLD_NOW)) == NULL)
- return -1; /* fail */
+ {
+ fprintf (stderr, "Unable to open %s: %s\n",
+ LIBTHREAD_DB_SO, dlerror ());
+ return -1; /* fail */
+ }
/* Initialize pointers to the dynamic library functions we will use.
*/
- if ((td_init_p = dlsym (dlhandle, "td_init")) == NULL)
+ if ((td_init_p = lookup_sym (dlhandle, "td_init")) == NULL)
return -1; /* fail */
- if ((td_ta_new_p = dlsym (dlhandle, "td_ta_new")) == NULL)
+ if ((td_ta_new_p = lookup_sym (dlhandle, "td_ta_new")) == NULL)
return -1; /* fail */
- if ((td_ta_delete_p = dlsym (dlhandle, "td_ta_delete")) == NULL)
+ if ((td_ta_delete_p = lookup_sym (dlhandle, "td_ta_delete")) == NULL)
return -1; /* fail */
- if ((td_ta_map_id2thr_p = dlsym (dlhandle, "td_ta_map_id2thr")) == NULL)
+ if ((td_ta_map_id2thr_p = lookup_sym (dlhandle, "td_ta_map_id2thr")) == NULL)
return -1; /* fail */
- if ((td_ta_map_lwp2thr_p = dlsym (dlhandle, "td_ta_map_lwp2thr")) == NULL)
+ if ((td_ta_map_lwp2thr_p = lookup_sym (dlhandle, "td_ta_map_lwp2thr")) == NULL)
return -1; /* fail */
- if ((td_ta_thr_iter_p = dlsym (dlhandle, "td_ta_thr_iter")) == NULL)
+ if ((td_ta_thr_iter_p = lookup_sym (dlhandle, "td_ta_thr_iter")) == NULL)
return -1; /* fail */
- if ((td_thr_validate_p = dlsym (dlhandle, "td_thr_validate")) == NULL)
+ if ((td_thr_validate_p = lookup_sym (dlhandle, "td_thr_validate")) == NULL)
return -1; /* fail */
- if ((td_thr_get_info_p = dlsym (dlhandle, "td_thr_get_info")) == NULL)
+ if ((td_thr_get_info_p = lookup_sym (dlhandle, "td_thr_get_info")) == NULL)
return -1; /* fail */
- if ((td_thr_getfpregs_p = dlsym (dlhandle, "td_thr_getfpregs")) == NULL)
+ if ((td_thr_getfpregs_p = lookup_sym (dlhandle, "td_thr_getfpregs")) == NULL)
return -1; /* fail */
- if ((td_thr_getgregs_p = dlsym (dlhandle, "td_thr_getgregs")) == NULL)
+ if ((td_thr_getgregs_p = lookup_sym (dlhandle, "td_thr_getgregs")) == NULL)
return -1; /* fail */
- if ((td_thr_setfpregs_p = dlsym (dlhandle, "td_thr_setfpregs")) == NULL)
+ if ((td_thr_setfpregs_p = lookup_sym (dlhandle, "td_thr_setfpregs")) == NULL)
return -1; /* fail */
- if ((td_thr_setgregs_p = dlsym (dlhandle, "td_thr_setgregs")) == NULL)
+ if ((td_thr_setgregs_p = lookup_sym (dlhandle, "td_thr_setgregs")) == NULL)
return -1; /* fail */
/* These are not essential. */
reply other threads:[~2004-04-20 20:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20040420133513.291dc5cc@saguaro \
--to=kevinb@redhat.com \
--cc=rda@sources.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).