This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "inferior.h"
if (lp->status != 0
&& WIFSTOPPED (lp->status) && WSTOPSIG (lp->status) == SIGTRAP
&& breakpoint_inserted_here_p (read_pc_pid (lp->ptid) -
- DECR_PC_AFTER_BREAK))
+ gdbarch_decr_pc_after_break
+ (current_gdbarch)))
{
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
target_pid_to_str (lp->ptid));
/* Back up the PC if necessary. */
- if (DECR_PC_AFTER_BREAK)
- write_pc_pid (read_pc_pid (lp->ptid) - DECR_PC_AFTER_BREAK, lp->ptid);
+ if (gdbarch_decr_pc_after_break (current_gdbarch))
+ write_pc_pid (read_pc_pid (lp->ptid) - gdbarch_decr_pc_after_break
+ (current_gdbarch),
+ lp->ptid);
/* Throw away the SIGTRAP. */
lp->status = 0;
gdb_fpxregset_t fpxregs;
#endif
unsigned long lwp = ptid_get_lwp (ptid);
- struct gdbarch *gdbarch = current_gdbarch;
+ struct regcache *regcache = get_thread_regcache (ptid);
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
const struct regset *regset;
int core_regset_p;
+ struct cleanup *old_chain;
+
+ old_chain = save_inferior_ptid ();
+ inferior_ptid = ptid;
+ target_fetch_registers (regcache, -1);
+ do_cleanups (old_chain);
core_regset_p = gdbarch_regset_from_core_section_p (gdbarch);
if (core_regset_p
&& (regset = gdbarch_regset_from_core_section (gdbarch, ".reg",
sizeof (gregs))) != NULL
&& regset->collect_regset != NULL)
- regset->collect_regset (regset, current_regcache, -1,
+ regset->collect_regset (regset, regcache, -1,
&gregs, sizeof (gregs));
else
- fill_gregset (current_regcache, &gregs, -1);
+ fill_gregset (regcache, &gregs, -1);
note_data = (char *) elfcore_write_prstatus (obfd,
note_data,
&& (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
sizeof (fpregs))) != NULL
&& regset->collect_regset != NULL)
- regset->collect_regset (regset, current_regcache, -1,
+ regset->collect_regset (regset, regcache, -1,
&fpregs, sizeof (fpregs));
else
- fill_fpregset (current_regcache, &fpregs, -1);
+ fill_fpregset (regcache, &fpregs, -1);
note_data = (char *) elfcore_write_prfpreg (obfd,
note_data,
&& (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp",
sizeof (fpxregs))) != NULL
&& regset->collect_regset != NULL)
- regset->collect_regset (regset, current_regcache, -1,
+ regset->collect_regset (regset, regcache, -1,
&fpxregs, sizeof (fpxregs));
else
- fill_fpxregset (current_regcache, &fpxregs, -1);
+ fill_fpxregset (regcache, &fpxregs, -1);
note_data = (char *) elfcore_write_prxfpreg (obfd,
note_data,
linux_nat_corefile_thread_callback (struct lwp_info *ti, void *data)
{
struct linux_nat_corefile_thread_data *args = data;
- ptid_t saved_ptid = inferior_ptid;
- inferior_ptid = ti->ptid;
- registers_changed ();
- /* FIXME should not be necessary; fill_gregset should do it automatically. */
- target_fetch_registers (current_regcache, -1);
args->note_data = linux_nat_do_thread_registers (args->obfd,
ti->ptid,
args->note_data,
args->note_size);
args->num_notes++;
- inferior_ptid = saved_ptid;
- registers_changed ();
- /* FIXME should not be necessary; fill_gregset should do it automatically. */
- target_fetch_registers (current_regcache, -1);
return 0;
}
linux_nat_do_registers (bfd *obfd, ptid_t ptid,
char *note_data, int *note_size)
{
- registers_changed ();
- /* FIXME should not be necessary; fill_gregset should do it automatically. */
- target_fetch_registers (current_regcache, -1);
return linux_nat_do_thread_registers (obfd,
ptid_build (ptid_get_pid (inferior_ptid),
ptid_get_pid (inferior_ptid),
0),
note_data, note_size);
- return note_data;
}
/* Fills the "to_make_corefile_note" target vector. Builds the note
{
struct linux_nat_corefile_thread_data thread_args;
struct cleanup *old_chain;
+ /* The variable size must be >= sizeof (prpsinfo_t.pr_fname). */
char fname[16] = { '\0' };
+ /* The variable size must be >= sizeof (prpsinfo_t.pr_psargs). */
char psargs[80] = { '\0' };
char *note_data = NULL;
ptid_t current_ptid = inferior_ptid;
strncpy (psargs, get_exec_file (0), sizeof (psargs));
if (get_inferior_args ())
{
- strncat (psargs, " ", sizeof (psargs) - strlen (psargs));
- strncat (psargs, get_inferior_args (),
- sizeof (psargs) - strlen (psargs));
+ char *string_end;
+ char *psargs_end = psargs + sizeof (psargs);
+
+ /* linux_elfcore_write_prpsinfo () handles zero unterminated
+ strings fine. */
+ string_end = memchr (psargs, 0, sizeof (psargs));
+ if (string_end != NULL)
+ {
+ *string_end++ = ' ';
+ strncpy (string_end, get_inferior_args (),
+ psargs_end - string_end);
+ }
}
note_data = (char *) elfcore_write_prpsinfo (obfd,
note_data,
char permissions[8], device[8], filename[MAXPATHLEN];
printf_filtered (_("Mapped address spaces:\n\n"));
- if (TARGET_ADDR_BIT == 32)
+ if (gdbarch_addr_bit (current_gdbarch) == 32)
{
printf_filtered ("\t%10s %10s %10s %10s %7s\n",
"Start Addr",
a generic local_address_string instead to print out
the addresses; that makes sense to me, too. */
- if (TARGET_ADDR_BIT == 32)
+ if (gdbarch_addr_bit (current_gdbarch) == 32)
{
printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
(unsigned long) addr, /* FIXME: pr_addr */
{
int itmp;
char ctmp;
+ long ltmp;
if (fscanf (procfile, "%d ", &itmp) > 0)
printf_filtered (_("Process: %d\n"), itmp);
- if (fscanf (procfile, "%s ", &buffer[0]) > 0)
+ if (fscanf (procfile, "(%[^)]) ", &buffer[0]) > 0)
printf_filtered (_("Exec file: %s\n"), buffer);
if (fscanf (procfile, "%c ", &ctmp) > 0)
printf_filtered (_("State: %c\n"), ctmp);
printf_filtered (_("TTY: %d\n"), itmp);
if (fscanf (procfile, "%d ", &itmp) > 0)
printf_filtered (_("TTY owner process group: %d\n"), itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Flags: 0x%x\n"), itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Minor faults (no memory page): %u\n"),
- (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Minor faults, children: %u\n"),
- (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Major faults (memory page faults): %u\n"),
- (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Major faults, children: %u\n"),
- (unsigned int) itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered ("utime: %d\n", itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered ("stime: %d\n", itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered ("utime, children: %d\n", itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered ("stime, children: %d\n", itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered (_("jiffies remaining in current time slice: %d\n"),
- itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered ("'nice' value: %d\n", itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("jiffies until next timeout: %u\n"),
- (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered ("jiffies until next SIGALRM: %u\n",
- (unsigned int) itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered (_("start time (jiffies since system boot): %d\n"),
- itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Virtual memory size: %u\n"),
- (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Resident set size: %u\n"), (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered ("rlim: %u\n", (unsigned int) itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Start of text: 0x%x\n"), itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("End of text: 0x%x\n"), itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0)
- printf_filtered (_("Start of stack: 0x%x\n"), itmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Flags: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Minor faults (no memory page): %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Minor faults, children: %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Major faults (memory page faults): %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Major faults, children: %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("utime: %ld\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("stime: %ld\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("utime, children: %ld\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("stime, children: %ld\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("jiffies remaining in current time slice: %ld\n"),
+ ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("'nice' value: %ld\n"), ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("jiffies until next timeout: %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("jiffies until next SIGALRM: %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("start time (jiffies since system boot): %ld\n"),
+ ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Virtual memory size: %lu\n"),
+ (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Resident set size: %lu\n"), (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("rlim: %lu\n"), (unsigned long) ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Start of text: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("End of text: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0)
+ printf_filtered (_("Start of stack: 0x%lx\n"), ltmp);
#if 0 /* Don't know how architecture-dependent the rest is...
Anyway the signal bitmap info is available from "status". */
- if (fscanf (procfile, "%u ", &itmp) > 0) /* FIXME arch? */
- printf_filtered (_("Kernel stack pointer: 0x%x\n"), itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0) /* FIXME arch? */
- printf_filtered (_("Kernel instr pointer: 0x%x\n"), itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered (_("Pending signals bitmap: 0x%x\n"), itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered (_("Blocked signals bitmap: 0x%x\n"), itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered (_("Ignored signals bitmap: 0x%x\n"), itmp);
- if (fscanf (procfile, "%d ", &itmp) > 0)
- printf_filtered (_("Catched signals bitmap: 0x%x\n"), itmp);
- if (fscanf (procfile, "%u ", &itmp) > 0) /* FIXME arch? */
- printf_filtered (_("wchan (system call): 0x%x\n"), itmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0) /* FIXME arch? */
+ printf_filtered (_("Kernel stack pointer: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0) /* FIXME arch? */
+ printf_filtered (_("Kernel instr pointer: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("Pending signals bitmap: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("Blocked signals bitmap: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("Ignored signals bitmap: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%ld ", <mp) > 0)
+ printf_filtered (_("Catched signals bitmap: 0x%lx\n"), ltmp);
+ if (fscanf (procfile, "%lu ", <mp) > 0) /* FIXME arch? */
+ printf_filtered (_("wchan (system call): 0x%lx\n"), ltmp);
#endif
fclose (procfile);
}