From 749bab0110ddc56835bfe70765675577e3dea05a Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 9 Feb 2015 14:59:09 +0000 Subject: [PATCH] proc-service, extern "C" libthread_db.so calls symbols in the client (GDB), through the proc-service interface. These routines must have extern "C" linkage so their symbol names are not mangled when GDB is built as a C++ program. On the GDBserver side, we were missing fallback declarations for all these symbols. gdb/ChangeLog: 2015-02-27 Pedro Alves * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP. gdb/gdbserver/ChangeLog: 2015-02-27 Pedro Alves * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP. [!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare. [!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread) ps_ptwrite, ps_lgetregs, ps_lsetregs, ps_lgetfpregs) (ps_lsetfpregs, ps_getpid) (ps_get_thread_area, ps_pglobal_lookup, ps_pstop, ps_pcontinue) (ps_lstop, ps_lcontinue, ps_lgetxregsize, ps_lgetxregs) (ps_lsetxregs, ps_plog): Declare. --- gdb/ChangeLog | 4 ++ gdb/gdb_proc_service.h | 11 +++++ gdb/gdbserver/ChangeLog | 11 +++++ gdb/gdbserver/gdb_proc_service.h | 79 ++++++++++++++++++++++++++++++++ gdb/gdbserver/proc-service.c | 4 +- 5 files changed, 107 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3709441857a..06df1388cda 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2015-02-27 Pedro Alves + + * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP. + 2015-02-27 Pedro Alves * common/agent.h (IPA_SYM_EXPORTED_NAME): New. diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h index 2c633b3e4b4..e7369911a11 100644 --- a/gdb/gdb_proc_service.h +++ b/gdb/gdb_proc_service.h @@ -22,8 +22,15 @@ #include #ifdef HAVE_PROC_SERVICE_H + +/* glibc's proc_service.h doesn't wrap itself with extern "C". Need + to do it ourselves. */ +EXTERN_C_PUSH + #include +EXTERN_C_POP + #else /* HAVE_PROC_SERVICE_H */ /* The following fallback definitions have been imported and adjusted @@ -55,6 +62,8 @@ #include "gregset.h" +EXTERN_C_PUSH + /* Functions in this interface return one of these status codes. */ typedef enum { @@ -150,6 +159,8 @@ extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid, /* Log a message (sends to gdb_stderr). */ extern void ps_plog (const char *fmt, ...); +EXTERN_C_POP + #endif /* HAVE_PROC_SERVICE_H */ /* Fix-up some broken systems. */ diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 384314a5295..7ba137b8249 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2015-02-27 Pedro Alves + + * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP. + [!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare. + [!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread) + ps_ptwrite, ps_lgetregs, ps_lsetregs, ps_lgetfpregs) + (ps_lsetfpregs, ps_getpid) + (ps_get_thread_area, ps_pglobal_lookup, ps_pstop, ps_pcontinue) + (ps_lstop, ps_lcontinue, ps_lgetxregsize, ps_lgetxregs) + (ps_lsetxregs, ps_plog): Declare. + 2015-02-27 Pedro Alves * linux-amd64-ipa.c (gdb_agent_get_raw_reg): Use diff --git a/gdb/gdbserver/gdb_proc_service.h b/gdb/gdbserver/gdb_proc_service.h index 1f3e2775864..2dcfa5bb1f2 100644 --- a/gdb/gdbserver/gdb_proc_service.h +++ b/gdb/gdbserver/gdb_proc_service.h @@ -22,7 +22,15 @@ #include #ifdef HAVE_PROC_SERVICE_H + +/* glibc's proc_service.h doesn't wrap itself with extern "C". Need + to do it ourselves. */ +EXTERN_C_PUSH + #include + +EXTERN_C_POP + #else #ifdef HAVE_SYS_PROCFS_H @@ -38,6 +46,8 @@ # endif #endif +EXTERN_C_PUSH + typedef enum { PS_OK, /* Success. */ @@ -61,6 +71,75 @@ typedef void *psaddr_t; typedef elf_gregset_t prgregset_t; #endif +/* This type is opaque in this interface. It's defined by the user of + libthread_db. GDB's version is defined below. */ +struct ps_prochandle; + + +/* Read or write process memory at the given address. */ +extern ps_err_e ps_pdread (struct ps_prochandle *, + psaddr_t, void *, size_t); +extern ps_err_e ps_pdwrite (struct ps_prochandle *, + psaddr_t, const void *, size_t); +extern ps_err_e ps_ptread (struct ps_prochandle *, + psaddr_t, void *, size_t); +extern ps_err_e ps_ptwrite (struct ps_prochandle *, + psaddr_t, const void *, size_t); + + +/* Get and set the given LWP's general or FPU register set. */ +extern ps_err_e ps_lgetregs (struct ps_prochandle *, + lwpid_t, prgregset_t); +extern ps_err_e ps_lsetregs (struct ps_prochandle *, + lwpid_t, const prgregset_t); +extern ps_err_e ps_lgetfpregs (struct ps_prochandle *, + lwpid_t, prfpregset_t *); +extern ps_err_e ps_lsetfpregs (struct ps_prochandle *, + lwpid_t, const prfpregset_t *); + +/* Return the PID of the process. */ +extern pid_t ps_getpid (struct ps_prochandle *); + +/* Fetch the special per-thread address associated with the given LWP. + This call is only used on a few platforms (most use a normal register). + The meaning of the `int' parameter is machine-dependent. */ +extern ps_err_e ps_get_thread_area (const struct ps_prochandle *, + lwpid_t, int, psaddr_t *); + + +/* Look up the named symbol in the named DSO in the symbol tables + associated with the process being debugged, filling in *SYM_ADDR + with the corresponding run-time address. */ +extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *, + const char *object_name, + const char *sym_name, + psaddr_t *sym_addr); + + +/* Stop or continue the entire process. */ +extern ps_err_e ps_pstop (struct ps_prochandle *); +extern ps_err_e ps_pcontinue (struct ps_prochandle *); + +/* Stop or continue the given LWP alone. */ +extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t); +extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t); + +/* The following are only defined in/called by Solaris. */ + +/* Get size of extra register set. */ +extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph, + lwpid_t lwpid, int *xregsize); +/* Get extra register set. */ +extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid, + caddr_t xregset); +extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid, + caddr_t xregset); + +/* Log a message (sends to gdb_stderr). */ +extern void ps_plog (const char *fmt, ...); + +EXTERN_C_POP + #endif /* HAVE_PROC_SERVICE_H */ /* Structure that identifies the target process. */ diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c index b181ae56405..f36e3fb600d 100644 --- a/gdb/gdbserver/proc-service.c +++ b/gdb/gdbserver/proc-service.c @@ -135,7 +135,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset) process PH and store them in FPREGSET. */ ps_err_e -ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) +ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prfpregset_t *fpregset) { /* Unneeded. */ return PS_ERR; @@ -145,7 +145,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) process PH from FPREGSET. */ ps_err_e -ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) +ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prfpregset_t *fpregset) { /* Unneeded. */ return PS_ERR; -- 2.30.2