summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-09-18 16:14:36 +0000
committerobrien <obrien@FreeBSD.org>2002-09-18 16:14:36 +0000
commit55e39b20ece65278fcfb67c725f9f4a475f5ed67 (patch)
tree586d75b06e769b9407ea2f5f0723e1964df883e0 /gnu
parentb1a7ec95a8c436a372ffbd98f7bc0dd1ac347451 (diff)
downloadFreeBSD-src-55e39b20ece65278fcfb67c725f9f4a475f5ed67.zip
FreeBSD-src-55e39b20ece65278fcfb67c725f9f4a475f5ed67.tar.gz
Stop using 3 distinct and far varied coding styles in a single file.
Pretend to actually adhere to the GNU coding standards.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/binutils/gdb/kvm-fbsd.c557
1 files changed, 277 insertions, 280 deletions
diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
index 27fe396..c4da7d0 100644
--- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
+++ b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
@@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* This way makes it easy to short-circut the whole bfd monster,
* and direct the inferior stuff to our libkvm implementation.
+ *
*/
#include <sys/param.h>
@@ -57,19 +58,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "gdbcore.h"
static void
-kcore_files_info PARAMS ((struct target_ops *));
+kcore_files_info (struct target_ops *);
static void
-kcore_close PARAMS ((int));
+kcore_close (int);
static void
-get_kcore_registers PARAMS ((int));
+get_kcore_registers (int);
static int
-xfer_mem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
+xfer_mem (CORE_ADDR, char *, int, int, struct target_ops *);
static int
-xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
+xfer_umem (CORE_ADDR, char *, int, int);
static char *core_file;
static kvm_t *core_kd;
@@ -81,16 +82,15 @@ static struct target_ops kcore_ops;
int kernel_debugging;
int kernel_writablecore;
-/*
- * Read the "thing" at kernel address 'addr' into the space pointed to
- * by point. The length of the "thing" is determined by the type of p.
- * Result is non-zero if transfer fails.
- */
+/* Read the "thing" at kernel address 'addr' into the space pointed to
+ by point. The length of the "thing" is determined by the type of p.
+ Result is non-zero if transfer fails. */
+
#define kvread(addr, p) \
-(target_read_memory((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
+ (target_read_memory ((CORE_ADDR) (addr), (char *) (p), sizeof (*(p))))
static CORE_ADDR
-ksym_kernbase()
+ksym_kernbase (void)
{
static CORE_ADDR kernbase;
struct minimal_symbol *sym;
@@ -107,94 +107,93 @@ ksym_kernbase()
return kernbase;
}
-#define KERNOFF (ksym_kernbase())
+#define KERNOFF (ksym_kernbase ())
#define INKERNEL(x) ((x) >= KERNOFF)
-
CORE_ADDR
-ksym_lookup(name)
- const char *name;
+ksym_lookup(const char *name)
{
struct minimal_symbol *sym;
- sym = lookup_minimal_symbol(name, NULL, NULL);
+ sym = lookup_minimal_symbol (name, NULL, NULL);
if (sym == NULL)
- error("kernel symbol `%s' not found.", name);
+ error ("kernel symbol `%s' not found.", name);
- return SYMBOL_VALUE_ADDRESS(sym);
+ return SYMBOL_VALUE_ADDRESS (sym);
}
-/*
- * Provide the address of an initial PCB to use.
- * If this is a crash dump, try for "dumppcb".
- * If no "dumppcb" or it's /dev/mem, use proc0.
- * Return the core address of the PCB we found.
- */
+/* Provide the address of an initial PCB to use.
+ If this is a crash dump, try for "dumppcb".
+ If no "dumppcb" or it's /dev/mem, use proc0.
+ Return the core address of the PCB we found. */
+
static CORE_ADDR
-initial_pcb()
+initial_pcb (void)
{
struct minimal_symbol *sym;
CORE_ADDR addr;
void *val;
- /* Make sure things are open... */
+ /* Make sure things are open... */
if (!core_kd || !core_file)
return (0);
- /* If this is NOT /dev/mem try for dumppcb. */
- if (strncmp(core_file, _PATH_DEV, sizeof _PATH_DEV - 1)) {
- sym = lookup_minimal_symbol("dumppcb", NULL, NULL);
- if (sym != NULL) {
- addr = SYMBOL_VALUE_ADDRESS(sym);
- return (addr);
- }
+ /* If this is NOT /dev/mem try for dumppcb. */
+ if (strncmp (core_file, _PATH_DEV, sizeof _PATH_DEV - 1))
+ {
+ sym = lookup_minimal_symbol ("dumppcb", NULL, NULL);
+ if (sym != NULL)
+ {
+ addr = SYMBOL_VALUE_ADDRESS (sym);
+ return (addr);
+ }
}
- /*
- * OK, just use thread0's pcb. Note that curproc might
- * not exist, and if it does, it will point to gdb.
- * Therefore, just use proc0 and let the user set
- * some other context if they care about it.
- */
- addr = ksym_lookup("thread0");
- if (kvread(addr, &val)) {
- error("cannot read thread0 pointer at %x\n", addr);
- val = 0;
- } else {
- /* Read the PCB address in thread structure. */
- addr += offsetof(struct thread, td_pcb);
- if (kvread(addr, &val)) {
- error("cannot read thread0->td_pcb pointer at %x\n", addr);
+ /* OK, just use thread0's pcb. Note that curproc might
+ not exist, and if it does, it will point to gdb.
+ Therefore, just use proc0 and let the user set
+ some other context if they care about it. */
+
+ addr = ksym_lookup ("thread0");
+ if (kvread (addr, &val))
+ {
+ error ("cannot read thread0 pointer at %x\n", addr);
val = 0;
}
- }
+ else
+ {
+ /* Read the PCB address in thread structure. */
+ addr += offsetof (struct thread, td_pcb);
+ if (kvread (addr, &val))
+ {
+ error ("cannot read thread0->td_pcb pointer at %x\n", addr);
+ val = 0;
+ }
+ }
- cur_proc = 0; /* thread0 is wholly in the kernel and cur_proc is
- * only used for reading user mem, so no point
- * in setting this up */
-
+ /* thread0 is wholly in the kernel and cur_proc is only used for
+ reading user mem, so no point in setting this up. */
+ cur_proc = 0;
return ((CORE_ADDR)val);
}
-/*
- * Set the current context to that of the PCB struct
- * at the system address passed.
- */
+/* Set the current context to that of the PCB struct at the system address
+ passed. */
+
static int
-set_context(addr)
- CORE_ADDR addr;
+set_context (CORE_ADDR addr)
{
CORE_ADDR procaddr = 0;
- if (kvread(addr, &cur_pcb))
- error("cannot read pcb at %#x", addr);
+ if (kvread (addr, &cur_pcb))
+ error ("cannot read pcb at %#x", addr);
- /* Fetch all registers from core file */
+ /* Fetch all registers from core file. */
target_fetch_registers (-1);
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames();
+ /* Now, set up the frame cache, and print the top of stack. */
+ flush_cached_frames ();
set_current_frame (create_new_frame (read_fp (), read_pc ()));
select_frame (get_current_frame (), 0);
return (0);
@@ -205,28 +204,26 @@ set_context(addr)
/* ARGSUSED */
static void
-kcore_close (quitting)
- int quitting;
+kcore_close (int quitting)
{
- inferior_ptid = null_ptid; /* Avoid confusion from thread stuff */
+ inferior_ptid = null_ptid; /* Avoid confusion from thread stuff. */
- if (core_kd) {
- kvm_close(core_kd);
- free(core_file);
- core_file = NULL;
- core_kd = NULL;
- }
+ if (core_kd)
+ {
+ kvm_close (core_kd);
+ free (core_file);
+ core_file = NULL;
+ core_kd = NULL;
+ }
}
/* This routine opens and sets up the core file bfd. */
static void
-kcore_open (filename, from_tty)
- char *filename; /* the core file */
- int from_tty;
+kcore_open (char *filename /* the core file */, int from_tty)
{
- kvm_t *kd;
+ kvm_t *kd;
const char *p;
struct cleanup *old_chain;
char buf[256], *cp;
@@ -235,61 +232,66 @@ kcore_open (filename, from_tty)
target_preopen (from_tty);
- /* The exec file is required for symbols. */
+ /* The exec file is required for symbols. */
if (exec_bfd == NULL)
- error("No kernel exec file specified");
+ error ("No kernel exec file specified");
- if (core_kd) {
- error ("No core file specified."
- " (Use `detach' to stop debugging a core file.)");
- return;
- }
+ if (core_kd)
+ {
+ error ("No core file specified."
+ " (Use `detach' to stop debugging a core file.)");
+ return;
+ }
- if (!filename) {
- error ("No core file specified.");
- return;
- }
+ if (!filename)
+ {
+ error ("No core file specified.");
+ return;
+ }
filename = tilde_expand (filename);
- if (filename[0] != '/') {
- cp = concat (current_directory, "/", filename, NULL);
- free (filename);
- filename = cp;
- }
+ if (filename[0] != '/')
+ {
+ cp = concat (current_directory, "/", filename, NULL);
+ free (filename);
+ filename = cp;
+ }
old_chain = make_cleanup (free, filename);
kd = kvm_open (bfd_get_filename(exec_bfd), filename, NULL,
kernel_writablecore ? O_RDWR: O_RDONLY, 0);
- if (kd == NULL) {
- perror_with_name (filename);
- return;
- }
+ if (kd == NULL)
+ {
+ perror_with_name (filename);
+ return;
+ }
/* Looks semi-reasonable. Toss the old core file and work on the new. */
- discard_cleanups (old_chain); /* Don't free filename any more */
+ discard_cleanups (old_chain); /* Don't free filename any more. */
core_file = filename;
unpush_target (&kcore_ops);
ontop = !push_target (&kcore_ops);
- /* Note unpush_target (above) calls kcore_close. */
+ /* Note unpush_target (above) calls kcore_close. */
core_kd = kd;
- /* print out the panic string if there is one */
- if (kvread(ksym_lookup("panicstr"), &addr) == 0 &&
+ /* Print out the panic string if there is one. */
+ if (kvread (ksym_lookup ("panicstr"), &addr) == 0 &&
addr != 0 &&
- target_read_memory(addr, buf, sizeof(buf)) == 0) {
-
- for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++)
- if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp)))
- *cp = '?';
- *cp = '\0';
- if (buf[0] != '\0')
- printf_filtered("panic: %s\n", buf);
- }
+ target_read_memory (addr, buf, sizeof(buf)) == 0)
+ {
- /* Print all the panic messages if possible. */
+ for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++)
+ if (!isascii (*cp) || (!isprint (*cp) && !isspace (*cp)))
+ *cp = '?';
+ *cp = '\0';
+ if (buf[0] != '\0')
+ printf_filtered ("panic: %s\n", buf);
+ }
+
+ /* Print all the panic messages if possible. */
if (symfile_objfile != NULL)
{
printf ("panic messages:\n---\n");
@@ -298,27 +300,25 @@ kcore_open (filename, from_tty)
/usr/bin/awk '/^(panic:|Fatal trap) / { printing = 1 } \
{ if (printing) print $0 }'",
symfile_objfile->name, filename);
- fflush(stdout);
+ fflush (stdout);
system (buf);
printf ("---\n");
}
- if (!ontop) {
- warning (
-"you won't be able to access this core file until you terminate\n\
-your %s; do ``info files''", target_longname);
- return;
- }
+ if (!ontop)
+ {
+ warning ("you won't be able to access this core file until you terminate\n"
+ "your %s; do ``info files''", target_longname);
+ return;
+ }
- /* Now, set up process context, and print the top of stack */
- (void)set_context(initial_pcb());
+ /* Now, set up process context, and print the top of stack. */
+ (void)set_context (initial_pcb());
print_stack_frame (selected_frame, selected_frame_level, 1);
}
static void
-kcore_detach (args, from_tty)
- char *args;
- int from_tty;
+kcore_detach (char *args, int from_tty)
{
if (args)
error ("Too many arguments");
@@ -335,13 +335,11 @@ kcore_detach (args, from_tty)
#define S0_REGNUM (T7_REGNUM+1)
#endif
-
-fetch_kcore_registers (pcbp)
- struct pcb *pcbp;
+fetch_kcore_registers (struct pcb *pcbp)
{
- /* First clear out any garbage. */
- memset(registers, '\0', REGISTER_BYTES);
+ /* First clear out any garbage. */
+ memset (registers, '\0', REGISTER_BYTES);
/* SP */
*(long *) &registers[REGISTER_BYTE (SP_REGNUM)] =
@@ -349,7 +347,7 @@ fetch_kcore_registers (pcbp)
/* S0 through S6 */
memcpy (&registers[REGISTER_BYTE (S0_REGNUM)],
- &pcbp->pcb_context[0], 7 * sizeof(long));
+ &pcbp->pcb_context[0], 7 * sizeof (long));
/* PC */
*(long *) &registers[REGISTER_BYTE (PC_REGNUM)] =
@@ -360,38 +358,38 @@ fetch_kcore_registers (pcbp)
CORE_ADDR
-fbsd_kern_frame_saved_pc (fi)
-struct frame_info *fi;
+fbsd_kern_frame_saved_pc (struct frame_info *fi)
{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
-
- this_saved_pc = alpha_frame_saved_pc (fi);
-
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
-
- if (sym != NULL &&
- (strcmp (SYMBOL_NAME(sym), "XentArith") == 0 ||
- strcmp (SYMBOL_NAME(sym), "XentIF") == 0 ||
- strcmp (SYMBOL_NAME(sym), "XentInt") == 0 ||
- strcmp (SYMBOL_NAME(sym), "XentMM") == 0 ||
- strcmp (SYMBOL_NAME(sym), "XentSys") == 0 ||
- strcmp (SYMBOL_NAME(sym), "XentUna") == 0 ||
- strcmp (SYMBOL_NAME(sym), "XentRestart") == 0)) {
- return (read_memory_integer (fi->frame + 32 * 8, 8));
- } else {
- return (this_saved_pc);
- }
+ struct minimal_symbol *sym;
+ CORE_ADDR this_saved_pc;
+
+ this_saved_pc = alpha_frame_saved_pc (fi);
+
+ sym = lookup_minimal_symbol_by_pc (this_saved_pc);
+
+ if (sym != NULL &&
+ (strcmp (SYMBOL_NAME (sym), "XentArith") == 0 ||
+ strcmp (SYMBOL_NAME (sym), "XentIF") == 0 ||
+ strcmp (SYMBOL_NAME (sym), "XentInt") == 0 ||
+ strcmp (SYMBOL_NAME (sym), "XentMM") == 0 ||
+ strcmp (SYMBOL_NAME (sym), "XentSys") == 0 ||
+ strcmp (SYMBOL_NAME (sym), "XentUna") == 0 ||
+ strcmp (SYMBOL_NAME (sym), "XentRestart") == 0))
+ {
+ return (read_memory_integer (fi->frame + 32 * 8, 8));
+ }
+ else
+ {
+ return (this_saved_pc);
+ }
}
#endif /* __alpha__ */
#ifdef __i386__
-
-
static CORE_ADDR
-ksym_maxuseraddr()
+ksym_maxuseraddr (void)
{
static CORE_ADDR maxuseraddr;
struct minimal_symbol *sym;
@@ -409,62 +407,60 @@ ksym_maxuseraddr()
}
-/*
- * Symbol names of kernel entry points. Use special frames.
- */
+/* Symbol names of kernel entry points. Use special frames. */
#define KSYM_TRAP "calltrap"
#define KSYM_INTR "Xintr"
#define KSYM_FASTINTR "Xfastintr"
#define KSYM_OLDSYSCALL "Xlcall_syscall"
#define KSYM_SYSCALL "Xint0x80_syscall"
-
-/*
- * The following is FreeBSD-specific hackery to decode special frames
- * and elide the assembly-language stub. This could be made faster by
- * defining a frame_type field in the machine-dependent frame information,
- * but we don't think that's too important right now.
- */
+/* The following is FreeBSD-specific hackery to decode special frames
+ and elide the assembly-language stub. This could be made faster by
+ defining a frame_type field in the machine-dependent frame information,
+ but we don't think that's too important right now. */
enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
CORE_ADDR
-fbsd_kern_frame_saved_pc (fr)
-struct frame_info *fr;
+fbsd_kern_frame_saved_pc (struct frame_info *fr)
{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), KSYM_TRAP) == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), KSYM_INTR,
- strlen(KSYM_INTR)) == 0 || strncmp (SYMBOL_NAME(sym),
- KSYM_FASTINTR, strlen(KSYM_FASTINTR)) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), KSYM_SYSCALL) == 0 ||
- strcmp (SYMBOL_NAME(sym), KSYM_OLDSYSCALL) == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (this_saved_pc);
-#define oEIP offsetof(struct trapframe, tf_eip)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 12 + oEIP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
+ struct minimal_symbol *sym;
+ CORE_ADDR this_saved_pc;
+ enum frametype frametype;
+
+ this_saved_pc = read_memory_integer (fr->frame + 4, 4);
+ sym = lookup_minimal_symbol_by_pc (this_saved_pc);
+ frametype = tf_normal;
+ if (sym != NULL)
+ {
+ if (strcmp (SYMBOL_NAME (sym), KSYM_TRAP) == 0)
+ frametype = tf_trap;
+ else
+ if (strncmp (SYMBOL_NAME (sym), KSYM_INTR,
+ strlen (KSYM_INTR)) == 0 || strncmp (SYMBOL_NAME(sym),
+ KSYM_FASTINTR, strlen (KSYM_FASTINTR)) == 0)
+ frametype = tf_interrupt;
+ else
+ if (strcmp (SYMBOL_NAME (sym), KSYM_SYSCALL) == 0 ||
+ strcmp (SYMBOL_NAME (sym), KSYM_OLDSYSCALL) == 0)
+ frametype = tf_syscall;
+ }
+
+ switch (frametype)
+ {
+ case tf_normal:
+ return (this_saved_pc);
+#define oEIP offsetof (struct trapframe, tf_eip)
+
+ case tf_trap:
+ return (read_memory_integer (fr->frame + 8 + oEIP, 4));
+
+ case tf_interrupt:
+ return (read_memory_integer (fr->frame + 12 + oEIP, 4));
+
+ case tf_syscall:
+ return (read_memory_integer (fr->frame + 8 + oEIP, 4));
#undef oEIP
- }
+ }
}
static int
@@ -473,10 +469,8 @@ fetch_kcore_registers (struct pcb *pcb)
int i;
int noreg;
- /*
- * get the register values out of the sys pcb and
- * store them where `read_register' will find them.
- */
+ /* Get the register values out of the sys pcb and store them where
+ `read_register' will find them. */
/*
* XXX many registers aren't available.
* XXX for the non-core case, the registers are stale - they are for
@@ -487,22 +481,40 @@ fetch_kcore_registers (struct pcb *pcb)
for (i = 0; i < 3; ++i) /* eax,ecx,edx */
supply_register (i, (char *)&noreg);
- supply_register (3, (char *)&pcb->pcb_ebx);
- supply_register (SP_REGNUM, (char *)&pcb->pcb_esp);
- supply_register (FP_REGNUM, (char *)&pcb->pcb_ebp);
- supply_register (6, (char *)&pcb->pcb_esi);
- supply_register (7, (char *)&pcb->pcb_edi);
- supply_register (PC_REGNUM, (char *)&pcb->pcb_eip);
+ supply_register (3, (char *) &pcb->pcb_ebx);
+ supply_register (SP_REGNUM, (char *) &pcb->pcb_esp);
+ supply_register (FP_REGNUM, (char *) &pcb->pcb_ebp);
+ supply_register (6, (char *) &pcb->pcb_esi);
+ supply_register (7, (char *) &pcb->pcb_edi);
+ supply_register (PC_REGNUM, (char *) &pcb->pcb_eip);
for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */
- supply_register (i, (char *)&noreg);
- supply_register (15, (char *)&pcb->pcb_gs);
+ supply_register (i, (char *) &noreg);
+ supply_register (15, (char *) &pcb->pcb_gs);
- /* XXX 80387 registers? */
+ /* XXX 80387 registers? */
}
#endif /* __i386__ */
+#ifdef __sparc64__
+
+/*
+#include "sparc/tm-sp64.h"
+*/
+
+fetch_kcore_registers (struct pcb *pcbp)
+{
+}
+
+
+CORE_ADDR
+fbsd_kern_frame_saved_pc (struct frame_info *fi)
+{
+ return NULL;
+}
+
+#endif /* __sparc64__ */
/* Get the registers out of a core file. This is the machine-
independent part. Fetch_core_registers is the machine-dependent
@@ -512,20 +524,15 @@ fetch_kcore_registers (struct pcb *pcb)
/* ARGSUSED */
static void
-get_kcore_registers (regno)
- int regno;
+get_kcore_registers (int regno)
{
- /*
- * XXX - Only read the pcb when set_context() is called.
- * When looking at a live kernel this may be a problem,
- * but the user can do another "proc" or "pcb" command to
- * grab a new copy of the pcb...
- */
+ /* XXX - Only read the pcb when set_context() is called.
+ When looking at a live kernel this may be a problem,
+ but the user can do another "proc" or "pcb" command to
+ grab a new copy of the pcb... */
- /*
- * Zero out register set then fill in the ones we know about.
- */
+ /* Zero out register set then fill in the ones we know about. */
fetch_kcore_registers (&cur_pcb);
}
@@ -537,40 +544,34 @@ kcore_files_info (t)
}
/* If mourn is being called in all the right places, this could be say
- `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
+ `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
static int
-ignore (addr, contents)
- CORE_ADDR addr;
- char *contents;
+ignore (CORE_ADDR addr, char *contents)
{
return 0;
}
static int
-xfer_kmem (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target;
+xfer_kmem (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct target_ops *target)
{
int n;
- if (!INKERNEL(memaddr))
- return xfer_umem(memaddr, myaddr, len, write);
+ if (!INKERNEL (memaddr))
+ return xfer_umem (memaddr, myaddr, len, write);
if (core_kd == NULL)
return 0;
if (write)
- n = kvm_write(core_kd, memaddr, myaddr, len);
+ n = kvm_write (core_kd, memaddr, myaddr, len);
else
n = kvm_read (core_kd, memaddr, myaddr, len) ;
if (n < 0) {
fprintf_unfiltered (gdb_stderr, "can not access 0x%x, %s\n",
- memaddr, kvm_geterr(core_kd));
+ memaddr, kvm_geterr (core_kd));
n = 0;
}
@@ -579,23 +580,20 @@ xfer_kmem (memaddr, myaddr, len, write, target)
static int
-xfer_umem (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write; /* ignored */
+xfer_umem (CORE_ADDR memaddr, char *myaddr, int len, int write /* ignored */)
{
int n = 0;
- if (cur_proc == 0) {
- error("---Can't read userspace from dump, or kernel process---\n");
- return 0;
- }
+ if (cur_proc == 0)
+ {
+ error ("---Can't read userspace from dump, or kernel process---\n");
+ return 0;
+ }
if (write)
- error("kvm_uwrite unimplemented\n");
+ error ("kvm_uwrite unimplemented\n");
else
- n = kvm_uread(core_kd, cur_proc, memaddr, myaddr, len) ;
+ n = kvm_uread (core_kd, cur_proc, memaddr, myaddr, len) ;
if (n < 0)
return 0;
@@ -604,8 +602,7 @@ xfer_umem (memaddr, myaddr, len, write)
}
static void
-set_proc_cmd(arg)
- char *arg;
+set_proc_cmd (char *arg)
{
CORE_ADDR addr, pid_addr, first_td;
void *val;
@@ -614,49 +611,49 @@ set_proc_cmd(arg)
pid_t pid;
if (!arg)
- error_no_arg("proc address for the new context");
+ error_no_arg ("proc address for the new context");
if (core_kd == NULL)
- error("no kernel core file");
+ error ("no kernel core file");
- addr = (CORE_ADDR)parse_and_eval_address(arg);
+ addr = (CORE_ADDR) parse_and_eval_address (arg);
- if (!INKERNEL(addr)) {
- kp = kvm_getprocs(core_kd, KERN_PROC_PID, addr, &cnt);
- if (!cnt) {
- error("invalid pid");
- }
- addr = (CORE_ADDR)kp->ki_paddr;
- cur_proc = kp;
- } else {
- /* update cur_proc */
- pid_addr = addr + offsetof(struct proc, p_pid);
- if (kvread(pid_addr, &pid))
- error("cannot read pid ptr");
- cur_proc = kvm_getprocs(core_kd, KERN_PROC_PID, pid, &cnt);
- if (!cnt) {
- error("invalid pid");
- }
- }
+ if (!INKERNEL (addr))
+ {
+ kp = kvm_getprocs (core_kd, KERN_PROC_PID, addr, &cnt);
+ if (!cnt)
+ error ("invalid pid");
+ addr = (CORE_ADDR)kp->ki_paddr;
+ cur_proc = kp;
+ }
+ else
+ {
+ /* Update cur_proc. */
+ pid_addr = addr + offsetof (struct proc, p_pid);
+ if (kvread (pid_addr, &pid))
+ error ("cannot read pid ptr");
+ cur_proc = kvm_getprocs (core_kd, KERN_PROC_PID, pid, &cnt);
+ if (!cnt)
+ error("invalid pid");
+ }
- /* Find the first thread in the process XXXKSE */
- addr += offsetof(struct proc, p_threads.tqh_first);
- if (kvread(addr, &first_td))
- error("cannot read thread ptr");
+ /* Find the first thread in the process. XXXKSE */
+ addr += offsetof (struct proc, p_threads.tqh_first);
+ if (kvread (addr, &first_td))
+ error ("cannot read thread ptr");
/* Read the PCB address in thread structure. */
- addr = first_td + offsetof(struct thread, td_pcb);
- if (kvread(addr, &val))
+ addr = first_td + offsetof (struct thread, td_pcb);
+ if (kvread (addr, &val))
error("cannot read pcb ptr");
/* Read the PCB address in proc structure. */
- if (set_context((CORE_ADDR)val))
- error("invalid proc address");
+ if (set_context ((CORE_ADDR) val))
+ error ("invalid proc address");
}
-
void
-_initialize_kcorelow()
+_initialize_kcorelow (void)
{
kcore_ops.to_shortname = "kcore";
kcore_ops.to_longname = "Kernel core dump file";
OpenPOWER on IntegriCloud