/* Solaris threads debugging interface.
- Copyright (C) 1996-2005, 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 1996-2013 Free Software Foundation, Inc.
This file is part of GDB.
if (td_err_table[i].num == errcode)
return td_err_table[i].str;
- sprintf (buf, "Unknown libthread_db error code: %d", errcode);
+ xsnprintf (buf, sizeof (buf), "Unknown libthread_db error code: %d",
+ errcode);
return buf;
}
if (td_thr_state_table[i].num == statecode)
return td_thr_state_table[i].str;
- sprintf (buf, "Unknown libthread_db state code: %d", statecode);
+ xsnprintf (buf, sizeof (buf), "Unknown libthread_db state code: %d",
+ statecode);
return buf;
}
gdb_fpregset_t *fpregset_p = &fpregset;
struct target_ops *beneath = find_target_beneath (ops);
-#if 0
- int xregsize;
- caddr_t xregset;
-#endif
-
if (!is_thread (inferior_ptid))
{
/* It's an LWP; pass the request on to the layer beneath. */
supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset_p);
-
-#if 0
- /* FIXME: libthread_db doesn't seem to handle this right. */
- val = td_thr_getxregsize (&thandle, &xregsize);
- if (val != TD_OK && val != TD_NOXREGS)
- error (_("sol_thread_fetch_registers: td_thr_getxregsize %s"),
- td_err_string (val));
-
- if (val == TD_OK)
- {
- xregset = alloca (xregsize);
- val = td_thr_getxregs (&thandle, xregset);
- if (val != TD_OK)
- error (_("sol_thread_fetch_registers: td_thr_getxregs %s"),
- td_err_string (val));
- }
-#endif
}
static void
td_err_e val;
prgregset_t gregset;
prfpregset_t fpregset;
-#if 0
- int xregsize;
- caddr_t xregset;
-#endif
if (!is_thread (inferior_ptid))
{
/* Restore new register value. */
regcache_raw_supply (regcache, regnum, old_value);
-
-#if 0
- /* FIXME: libthread_db doesn't seem to handle this right. */
- val = td_thr_getxregsize (&thandle, &xregsize);
- if (val != TD_OK && val != TD_NOXREGS)
- error (_("sol_thread_store_registers: td_thr_getxregsize %s"),
- td_err_string (val));
-
- if (val == TD_OK)
- {
- xregset = alloca (xregsize);
- val = td_thr_getxregs (&thandle, xregset);
- if (val != TD_OK)
- error (_("sol_thread_store_registers: td_thr_getxregs %s"),
- td_err_string (val));
- }
-#endif
}
fill_gregset (regcache, (gdb_gregset_t *) &gregset, regnum);
if (val != TD_OK)
error (_("sol_thread_store_registers: td_thr_setfpregs %s"),
td_err_string (val));
-
-#if 0
- /* FIXME: libthread_db doesn't seem to handle this right. */
- val = td_thr_getxregsize (&thandle, &xregsize);
- if (val != TD_OK && val != TD_NOXREGS)
- error (_("sol_thread_store_registers: td_thr_getxregsize %s"),
- td_err_string (val));
-
- /* ??? Should probably do something about writing the xregs here,
- but what are they? */
-#endif
}
/* Perform partial transfers on OBJECT. See target_read_partial and
static ps_err_e
rw_common (int dowrite, const struct ps_prochandle *ph, gdb_ps_addr_t addr,
- char *buf, int size)
+ gdb_byte *buf, int size)
{
int ret;
struct cleanup *old_chain;
#endif
if (dowrite)
- ret = target_write_memory (addr, buf, size);
+ ret = target_write_memory (addr, (gdb_byte *) buf, size);
else
- ret = target_read_memory (addr, buf, size);
+ ret = target_read_memory (addr, (gdb_byte *) buf, size);
do_cleanups (old_chain);
ps_pdwrite (gdb_ps_prochandle_t ph, gdb_ps_addr_t addr,
gdb_ps_write_buf_t buf, gdb_ps_size_t size)
{
- return rw_common (1, ph, addr, (char *) buf, size);
+ return rw_common (1, ph, addr, (gdb_byte *) buf, size);
}
/* Copies SIZE bytes from target process .text segment to debugger memory. */
ps_ptwrite (gdb_ps_prochandle_t ph, gdb_ps_addr_t addr,
gdb_ps_write_buf_t buf, gdb_ps_size_t size)
{
- return rw_common (1, ph, addr, (char *) buf, size);
+ return rw_common (1, ph, addr, (gdb_byte *) buf, size);
}
/* Get general-purpose registers for LWP. */
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
ps_err_e
ps_lgetxregsize (gdb_ps_prochandle_t ph, lwpid_t lwpid, int *xregsize)
{
-#if 0
- int lwp_fd;
- int regsize;
- ps_err_e val;
-
- val = get_lwp_fd (ph, lwpid, &lwp_fd);
- if (val != PS_OK)
- return val;
-
- if (ioctl (lwp_fd, PIOCGXREGSIZE, ®size))
- {
- if (errno == EINVAL)
- return PS_NOFREGS; /* XXX Wrong code, but this is the closest
- thing in proc_service.h */
-
- print_sys_errmsg ("ps_lgetxregsize (): PIOCGXREGSIZE", errno);
- return PS_ERR;
- }
-#endif
-
return PS_OK;
}
ps_err_e
ps_lgetxregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, caddr_t xregset)
{
-#if 0
- int lwp_fd;
- ps_err_e val;
-
- val = get_lwp_fd (ph, lwpid, &lwp_fd);
- if (val != PS_OK)
- return val;
-
- if (ioctl (lwp_fd, PIOCGXREG, xregset))
- {
- print_sys_errmsg ("ps_lgetxregs (): PIOCGXREG", errno);
- return PS_ERR;
- }
-#endif
-
return PS_OK;
}
ps_err_e
ps_lsetxregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, caddr_t xregset)
{
-#if 0
- int lwp_fd;
- ps_err_e val;
-
- val = get_lwp_fd (ph, lwpid, &lwp_fd);
- if (val != PS_OK)
- return val;
-
- if (ioctl (lwp_fd, PIOCSXREG, xregset))
- {
- print_sys_errmsg ("ps_lsetxregs (): PIOCSXREG", errno);
- return PS_ERR;
- }
-#endif
-
return PS_OK;
}
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);
lwp = thread_to_lwp (ptid, -2);
if (PIDGET (lwp) == -1)
- sprintf (buf, "Thread %ld (defunct)", GET_THREAD (ptid));
+ xsnprintf (buf, sizeof (buf), "Thread %ld (defunct)",
+ GET_THREAD (ptid));
else if (PIDGET (lwp) != -2)
- sprintf (buf, "Thread %ld (LWP %ld)",
+ xsnprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
GET_THREAD (ptid), GET_LWP (lwp));
else
- sprintf (buf, "Thread %ld ", GET_THREAD (ptid));
+ xsnprintf (buf, sizeof (buf), "Thread %ld ", GET_THREAD (ptid));
}
else if (GET_LWP (ptid) != 0)
- sprintf (buf, "LWP %ld ", GET_LWP (ptid));
+ xsnprintf (buf, sizeof (buf), "LWP %ld ", GET_LWP (ptid));
else
- sprintf (buf, "process %d ", PIDGET (ptid));
+ xsnprintf (buf, sizeof (buf), "process %d ", PIDGET (ptid));
return buf;
}
/* Print thr_create start function. */
if (ti.ti_startfunc != 0)
{
- struct minimal_symbol *msym;
- msym = lookup_minimal_symbol_by_pc (ti.ti_startfunc);
- if (msym)
- printf_filtered (" startfunc: %s\n",
- SYMBOL_PRINT_NAME (msym));
- else
- printf_filtered (" startfunc: %s\n",
- paddress (target_gdbarch, ti.ti_startfunc));
+ const struct bound_minimal_symbol msym
+ = lookup_minimal_symbol_by_pc (ti.ti_startfunc);
+
+ printf_filtered (" startfunc=%s",
+ msym.minsym
+ ? SYMBOL_PRINT_NAME (msym.minsym)
+ : paddress (target_gdbarch (), ti.ti_startfunc));
}
/* If thread is asleep, print function that went to sleep. */
if (ti.ti_state == TD_THR_SLEEP)
{
- struct minimal_symbol *msym;
- msym = lookup_minimal_symbol_by_pc (ti.ti_pc);
- if (msym)
- printf_filtered (" - Sleep func: %s\n",
- SYMBOL_PRINT_NAME (msym));
- else
- printf_filtered (" - Sleep func: %s\n",
- paddress (target_gdbarch, ti.ti_startfunc));
+ const struct bound_minimal_symbol msym
+ = lookup_minimal_symbol_by_pc (ti.ti_pc);
+
+ printf_filtered (" sleepfunc=%s",
+ msym.minsym
+ ? SYMBOL_PRINT_NAME (msym.minsym)
+ : paddress (target_gdbarch (), ti.ti_pc));
}
- /* Wrap up line, if necessary. */
- if (ti.ti_state != TD_THR_SLEEP && ti.ti_startfunc == 0)
- printf_filtered ("\n"); /* don't you hate counting newlines? */
+ printf_filtered ("\n");
}
else
warning (_("info sol-thread: failed to get info for thread."));
resolve (td_thr_getgregs);
resolve (td_thr_setgregs);
- add_target (&sol_thread_ops);
+ complete_target_initialization (&sol_thread_ops);
add_cmd ("sol-threads", class_maintenance, info_solthreads,
_("Show info on Solaris user threads."), &maintenanceinfolist);