37 #include "readline/readline.h" 38 #include <sys/param.h> 40 #ifdef HAVE_SYS_USER_H 70 char errbuf[_POSIX2_LINE_MAX];
71 char *execfile = NULL;
73 char *filename = NULL;
81 filename = tilde_expand (arg);
82 if (filename[0] !=
'/')
91 temp_kd = kvm_openfiles (execfile, filename, NULL,
94 error ((
"%s"), errbuf);
128 ssize_t nbytes = len;
131 nbytes = kvm_read (
core_kd, addr, readbuf, nbytes);
132 if (writebuf && nbytes > 0)
133 nbytes = kvm_write (
core_kd, addr, writebuf, nbytes);
139 const char *annex,
gdb_byte *readbuf,
182 if (kvm_read (
core_kd, (
unsigned long) paddr, &pcb,
sizeof pcb) == -1)
203 memset (nl, 0,
sizeof nl);
204 nl[0].n_name =
"_dumppcb";
206 if (kvm_nlist (
core_kd, nl) == -1)
209 if (nl[0].n_value != 0)
221 memset (nl, 0,
sizeof nl);
222 nl[0].n_name =
"_proc0paddr";
224 if (kvm_nlist (
core_kd, nl) == -1)
227 if (nl[0].n_value != 0)
232 if (kvm_read (
core_kd, nl[0].n_value, &paddr,
sizeof paddr) == -1)
239 #ifdef HAVE_STRUCT_THREAD_TD_PCB 245 memset (nl, 0,
sizeof nl);
246 nl[0].n_name =
"_thread0";
248 if (kvm_nlist (
core_kd, nl) == -1)
251 if (nl[0].n_value != 0)
256 nl[0].n_value += offsetof (
struct thread, td_pcb);
257 if (kvm_read (
core_kd, nl[0].n_value, &paddr,
sizeof paddr) == -1)
266 error (
_(
"Cannot find a valid PCB"));
279 #ifndef HAVE_STRUCT_THREAD_TD_PCB 290 error (
_(
"No kernel memory image."));
293 #ifdef HAVE_STRUCT_LWP 294 addr += offsetof (
struct lwp, l_addr);
296 addr += offsetof (
struct proc, p_addr);
318 error (
_(
"No kernel memory image."));
362 Optionally specify the filename of a core dump.");
379 Generic command for manipulating the kernel memory interface."),
382 #ifndef HAVE_STRUCT_THREAD_TD_PCB void error_no_arg(const char *why)
void add_target(struct target_ops *t)
static void bsd_kvm_open(const char *arg, int from_tty)
static int(* bsd_kvm_supply_pcb)(struct regcache *regcache, struct pcb *pcb)
static ptid_t bsd_kvm_ptid
struct cmd_list_element * bsd_kvm_cmdlist
struct frame_info * get_selected_frame(const char *message)
static void bsd_kvm_cmd(const char *arg, int fromtty)
int(* to_has_memory)(struct target_ops *)
void warning(const char *fmt,...)
regcache(gdbarch *gdbarch)
int(* to_has_stack)(struct target_ops *)
void push_target(struct target_ops *t)
void delete_thread_silent(ptid_t)
char * get_exec_file(int err)
int unpush_target(struct target_ops *t)
void * memset(T *s, int c, size_t n)=delete
static enum target_xfer_status bsd_kvm_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
void(* to_close)(struct target_ops *)
const char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * cmdlist
void target_fetch_registers(struct regcache *regcache, int regno)
struct regcache * get_current_regcache(void)
void printf_filtered(const char *format,...)
ptid_t ptid_build(int pid, long lwp, long tid)
void(* to_files_info)(struct target_ops *) TARGET_DEFAULT_IGNORE()
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static void bsd_kvm_proc_cmd(const char *arg, int fromtty)
static LONGEST bsd_kvm_xfer_memory(CORE_ADDR addr, ULONGEST len, gdb_byte *readbuf, const gdb_byte *writebuf)
static void bsd_kvm_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
struct thread_info * add_thread_silent(ptid_t ptid)
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
static void bsd_kvm_close(struct target_ops *self)
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
int xsnprintf(char *str, size_t size, const char *format,...)
CORE_ADDR parse_and_eval_address(const char *exp)
static const char * bsd_kvm_pid_to_str(struct target_ops *ops, ptid_t ptid)
static const char * bsd_kvm_corefile
void(* to_open)(const char *, int)
static constexpr ptid_t lwp
static int bsd_kvm_return_one(struct target_ops *ops)
const char * to_shortname
static void bsd_kvm_files_info(struct target_ops *ops)
unsigned long long ULONGEST
static struct pcb * bsd_kvm_paddr
void bsd_kvm_add_target(int(*supply_pcb)(struct regcache *, struct pcb *))
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
void target_preopen(int from_tty)
void reinit_frame_cache(void)
static int bsd_kvm_thread_alive(struct target_ops *ops, ptid_t ptid)
static void bsd_kvm_pcb_cmd(const char *arg, int fromtty)
int(* to_has_registers)(struct target_ops *)
void error(const char *fmt,...)
static struct target_ops bsd_kvm_ops
static int bsd_kvm_fetch_pcb(struct regcache *regcache, struct pcb *paddr)