Back to index

glibc  2.9
td_symbol_list.c
Go to the documentation of this file.
00001 /* Return list of symbols the library can request.
00002    Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <assert.h>
00022 #include <gnu/lib-names.h>
00023 #include "thread_dbP.h"
00024 
00025 
00026 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
00027 # define DOT "."            /* PPC64 requires . prefix on code symbols.  */
00028 #else
00029 # define DOT                /* No prefix.  */
00030 #endif
00031 
00032 static const char *symbol_list_arr[] =
00033 {
00034 # define DB_STRUCT(type) \
00035   [SYM_SIZEOF_##type] = "_thread_db_sizeof_" #type,
00036 # define DB_STRUCT_FIELD(type, field) \
00037   [SYM_##type##_FIELD_##field] = "_thread_db_" #type "_" #field,
00038 # define DB_SYMBOL(name) \
00039   [SYM_##name] = #name,
00040 # define DB_FUNCTION(name) \
00041   [SYM_##name] = DOT #name,
00042 # define DB_VARIABLE(name) \
00043   [SYM_##name] = #name, \
00044   [SYM_DESC_##name] = "_thread_db_" #name,
00045 # include "structs.def"
00046 # undef DB_STRUCT
00047 # undef DB_FUNCTION
00048 # undef DB_SYMBOL
00049 # undef DB_VARIABLE
00050 
00051   [SYM_TH_UNIQUE_CONST_THREAD_AREA] = "_thread_db_const_thread_area",
00052   [SYM_TH_UNIQUE_REGISTER64] = "_thread_db_register64",
00053   [SYM_TH_UNIQUE_REGISTER32] = "_thread_db_register32",
00054   [SYM_TH_UNIQUE_REGISTER32_THREAD_AREA] = "_thread_db_register32_thread_area",
00055   [SYM_TH_UNIQUE_REGISTER64_THREAD_AREA] = "_thread_db_register64_thread_area",
00056 
00057   [SYM_NUM_MESSAGES] = NULL
00058 };
00059 
00060 
00061 const char **
00062 td_symbol_list (void)
00063 {
00064   return symbol_list_arr;
00065 }
00066 
00067 
00068 ps_err_e
00069 td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr)
00070 {
00071   ps_err_e result;
00072   assert (idx >= 0 && idx < SYM_NUM_MESSAGES);
00073   result = ps_pglobal_lookup (ps, LIBPTHREAD_SO, symbol_list_arr[idx],
00074                            sym_addr);
00075 
00076 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
00077   /* For PowerPC, 64-bit uses dot symbols but 32-bit does not.
00078      We could be a 64-bit libthread_db debugging a 32-bit libpthread.  */
00079   if (result == PS_NOSYM && symbol_list_arr[idx][0] == '.')
00080     result = ps_pglobal_lookup (ps, LIBPTHREAD_SO, &symbol_list_arr[idx][1],
00081                             sym_addr);
00082 #endif
00083 
00084   return result;
00085 }