From f0fce3b80b0f045dc926074f3378c7418e64757e Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sat, 11 Apr 1998 05:43:33 +0000 Subject: [PATCH] Fri Apr 10 22:36:28 1998 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) Update support for x86 Solaris 2. * config/i386/tm-i386sol2.h, nm-i386sol2.h: New configuration files for x86 Solaris 2. * config/i386/i386sol2.mt, i386sol2.mh: Use them. * config/sparc/tm-sun4sol2.h (PROCFS_GET_CARRY): New macro, extract carry flag from a given regset. (IS_STATIC_TRANSFORM_NAME): New macro, check if a symbol name is a SunPro transformed name. * i386-tdep.c (sunpro_static_transform_name): New function to extract the source name from a SunPro transformed name. * inferior.h (procfs_first_available, procfs_get_pid_fd): Add prototypes. * infrun.c (wait_for_inferior): Handle breakpoint hit in signal handler without intervening stop in sigtramp. * procfs.c (procfs_lwp_creation_handler): Use PROCFS_GET_CARRY instead of direct access to the status register. (procfs_get_pid_fd): New function, returns procfs fd for a given pid. * sol-thread.c (ps_lgetLDT): New function, returns LDT for a given lwpid. (sol_find_new_threads): Handle failed libthread_db initialization gracefully. * stabsread.c (define_symbol): Use IS_STATIC_TRANSFORM_NAME to check for a SunPro transformed symbol name. --- gdb/ChangeLog | 28 +++++++++++++++ gdb/config/sparc/tm-sun4sol2.h | 7 +++- gdb/infrun.c | 12 +++++-- gdb/procfs.c | 16 +++++++-- gdb/sol-thread.c | 66 ++++++++++++++++++++++++++++++++-- gdb/stabsread.c | 4 +-- 6 files changed, 123 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37bda15dbcd..93eabca069a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,29 @@ +Fri Apr 10 22:36:28 1998 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + Update support for x86 Solaris 2. + * config/i386/tm-i386sol2.h, nm-i386sol2.h: New configuration + files for x86 Solaris 2. + * config/i386/i386sol2.mt, i386sol2.mh: Use them. + * config/sparc/tm-sun4sol2.h (PROCFS_GET_CARRY): New macro, extract + carry flag from a given regset. + (IS_STATIC_TRANSFORM_NAME): New macro, check if a symbol name + is a SunPro transformed name. + * i386-tdep.c (sunpro_static_transform_name): New function to + extract the source name from a SunPro transformed name. + * inferior.h (procfs_first_available, procfs_get_pid_fd): + Add prototypes. + * infrun.c (wait_for_inferior): Handle breakpoint hit in + signal handler without intervening stop in sigtramp. + * procfs.c (procfs_lwp_creation_handler): Use PROCFS_GET_CARRY + instead of direct access to the status register. + (procfs_get_pid_fd): New function, returns procfs fd for a given pid. + * sol-thread.c (ps_lgetLDT): New function, returns LDT for a given + lwpid. + (sol_find_new_threads): Handle failed libthread_db initialization + gracefully. + * stabsread.c (define_symbol): Use IS_STATIC_TRANSFORM_NAME + to check for a SunPro transformed symbol name. + Fri Apr 10 10:35:35 1998 John Metzler * utils.c (fmthex): A formatting function for hexdumps @@ -53,9 +79,11 @@ Mon Apr 6 09:17:48 1998 Andrew Cagney using MAX_REGISTER_RAW_SIZE. Sat Apr 4 10:05:00 1998 Dawn Perchik + * infrun.c: Fix prototype of signals_info to match static funtion. Thu Apr 2 12:47:41 1998 Frank Ch. Eigler + * sol-thread.c (sol_thread_store_registers): Save & restore new value of single updated register to prevent accidental clobbering. diff --git a/gdb/config/sparc/tm-sun4sol2.h b/gdb/config/sparc/tm-sun4sol2.h index dcfe7920f14..7bab6e6778a 100644 --- a/gdb/config/sparc/tm-sun4sol2.h +++ b/gdb/config/sparc/tm-sun4sol2.h @@ -1,5 +1,6 @@ /* Macro definitions for GDB for a Sun 4 running Solaris 2 - Copyright 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright 1989, 1992, 1993, 1994, 1995, 1997, 1998 + Free Software Foundation, Inc. This file is part of GDB. @@ -66,6 +67,7 @@ get_longjmp_target PARAMS ((CORE_ADDR *)); extern char *sunpro_static_transform_name PARAMS ((char *)); #define STATIC_TRANSFORM_NAME(x) sunpro_static_transform_name (x) +#define IS_STATIC_TRANSFORM_NAME(name) ((name)[0] == '$') #define FAULTED_USE_SIGINFO @@ -76,6 +78,9 @@ extern char *sunpro_static_transform_name PARAMS ((char *)); #define PIDGET(pid) ((pid) & 0xffff) #define TIDGET(pid) (((pid) >> 16) & 0xffff) +/* Macro to extract carry from given regset. */ +#define PROCFS_GET_CARRY(regset) ((regset)[R_PSR] & PS_FLAG_CARRY) + #ifdef HAVE_THREAD_DB_LIB extern char *solaris_pid_to_str PARAMS ((int pid)); diff --git a/gdb/infrun.c b/gdb/infrun.c index 9c5d1ea8c8c..f1eaaabbf4a 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -903,9 +903,15 @@ wait_for_inferior () Don't confuse that with hitting the breakpoint. What we check for is that 1) stepping is going on and 2) the pc before the last insn does not match - the address of the breakpoint before the current pc. */ - (prev_pc != stop_pc - DECR_PC_AFTER_BREAK - && CURRENTLY_STEPPING ()) : + the address of the breakpoint before the current pc + and 3) we didn't hit a breakpoint in a signal handler + without an intervening stop in sigtramp, which is + detected by a new stack pointer value below + any usual function calling stack adjustments. */ + (CURRENTLY_STEPPING () + && prev_pc != stop_pc - DECR_PC_AFTER_BREAK + && !(step_range_end + && read_sp () INNER_THAN (step_sp - 16))) : 0) ); /* Following in case break condition called a diff --git a/gdb/procfs.c b/gdb/procfs.c index e8215a523be..01fa4fd65a0 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1,5 +1,5 @@ /* Machine independent support for SVR4 /proc (process file system) for GDB. - Copyright 1991, 1992-96, 1997 Free Software Foundation, Inc. + Copyright 1991, 1992-97, 1998 Free Software Foundation, Inc. Written by Fred Fish at Cygnus Support. Changes for sysv4.2mp procfs compatibility by Geoffrey Noer at Cygnus Solutions. @@ -5218,7 +5218,7 @@ procfs_lwp_creation_handler (pi, syscall_num, why, rtnvalp, statvalp) /* If lwp_create failed, then nothing interesting happened. Continue the process and go back to sleep. */ - if (pi->prstatus.pr_reg[R_PSR] & PS_FLAG_CARRY) + if (PROCFS_GET_CARRY (pi->prstatus.pr_reg)) { /* _lwp_create failed */ pi->prrun.pr_flags &= PRSTEP; pi->prrun.pr_flags |= PRCFAULT; @@ -5504,6 +5504,18 @@ procfs_first_available () return -1; } +int +procfs_get_pid_fd (pid) + int pid; +{ + struct procinfo *pi = find_procinfo (pid, 1); + + if (pi == NULL) + return -1; + + return pi->ctl_fd; +} + /* Send a SIGINT to the process group. This acts just like the user typed a ^C on the controlling terminal. diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index fbbbbcb02b2..d6062642eac 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -1,5 +1,5 @@ /* Low level interface for debugging Solaris threads for GDB, the GNU debugger. - Copyright 1996 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of GDB. @@ -717,7 +717,7 @@ sol_thread_store_registers (regno) error ("sol_thread_store_registers: td_thr_getfpregs %s", td_err_string (val)); - /* restore register value */ + /* restore new register value */ memcpy(& registers[REGISTER_BYTE(regno)], old_value, REGISTER_SIZE); #if 0 @@ -1244,6 +1244,64 @@ ps_lsetfpregs (const struct ps_prochandle *ph, lwpid_t lwpid, return PS_OK; } + +#ifdef TM_I386SOL2_H + +/* Get local descriptor table. */ + +#include +#include +#include + +static int nldt_allocated = 0; +static struct ssd *ldt_bufp = NULL; + +ps_err_e +ps_lgetLDT (const struct ps_prochandle *ph, lwpid_t lwpid, + struct ssd *pldt) +{ + gregset_t gregset; + int lwp_fd; + ps_err_e val; + int nldt; + int i; + + /* Get procfs file descriptor for the LWP. */ + lwp_fd = procfs_get_pid_fd (BUILD_LWP (lwpid, PIDGET (inferior_pid))); + if (lwp_fd < 0) + return PS_BADLID; + + /* Fetch registers und LDT descriptors. */ + if (ioctl (lwp_fd, PIOCGREG, &gregset) == -1) + return PS_ERR; + + if (ioctl (lwp_fd, PIOCNLDT, &nldt) == -1) + return PS_ERR; + + if (nldt_allocated < nldt) + { + ldt_bufp + = (struct ssd *) xrealloc (ldt_bufp, (nldt + 1) * sizeof (struct ssd)); + nldt_allocated = nldt; + } + + if (ioctl (lwp_fd, PIOCLDT, ldt_bufp) == -1) + return PS_ERR; + + /* Search LDT for the LWP via register GS. */ + for (i = 0; i < nldt; i++) + { + if (ldt_bufp[i].sel == gregset[GS]) + { + *pldt = ldt_bufp[i]; + return PS_OK; + } + } + + /* LDT not found. */ + return PS_ERR; +} +#endif /* TM_I386SOL2_H */ /* Convert a pid to printable form. */ @@ -1306,6 +1364,10 @@ sol_find_new_threads_callback(th, ignored) void sol_find_new_threads() { + /* don't do anything if init failed to resolve the libthread_db library */ + if (!procfs_suppress_run) + return; + if (inferior_pid == -1) { printf_filtered("No process.\n"); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index ac848b928fe..bfbcc016c38 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1878,7 +1878,7 @@ define_symbol (valu, string, desc, type, objfile) SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_VALUE_ADDRESS (sym) = valu; #ifdef STATIC_TRANSFORM_NAME - if (SYMBOL_NAME (sym)[0] == '$') + if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym))) { struct minimal_symbol *msym; msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile); @@ -2006,7 +2006,7 @@ define_symbol (valu, string, desc, type, objfile) SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_VALUE_ADDRESS (sym) = valu; #ifdef STATIC_TRANSFORM_NAME - if (SYMBOL_NAME (sym)[0] == '$') + if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym))) { struct minimal_symbol *msym; msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile); -- 2.30.2