1 /* Live and postmortem kernel debugging functions for FreeBSD.
2 Copyright 1996 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 * $FreeBSD: src/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c,v 1.17.4.3 2001/12/17 23:06:06 peter Exp $
22 * $DragonFly: src/gnu/usr.bin/binutils214/gdb/i386/Attic/kvm-fbsd.c,v 1.1 2004/02/01 08:53:04 dillon Exp $
25 #define _KERNEL_STRUCTURES
33 #include <sys/sysctl.h>
34 #include <sys/param.h>
38 #include <sys/globaldata.h>
39 #include "frame.h" /* required by inferior.h */
51 #include <vm/vm_param.h>
53 #include <machine/vmparam.h>
54 #include <machine/pcb.h>
55 #include <machine/tss.h>
56 #include <machine/frame.h>
57 #include <machine/globaldata.h>
59 static void kcore_files_info PARAMS ((struct target_ops *));
61 static void kcore_close PARAMS ((int));
63 static void get_kcore_registers PARAMS ((int));
65 static int kcore_xfer_kmem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
67 static int xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
69 static CORE_ADDR ksym_lookup PARAMS ((const char *));
71 static int read_pcb PARAMS ((int, CORE_ADDR));
73 static struct proc * curProc PARAMS ((void));
75 static int set_proc_context PARAMS ((CORE_ADDR paddr));
77 static void kcore_open PARAMS ((char *filename, int from_tty));
79 static void kcore_detach PARAMS ((char *args, int from_tty));
81 static void set_proc_cmd PARAMS ((char *arg, int from_tty));
83 static void set_cpu_cmd PARAMS ((char *arg, int from_tty));
85 static CORE_ADDR kvtophys PARAMS ((int, CORE_ADDR));
87 static int physrd PARAMS ((int, u_int, char*, int));
89 static int kvm_open PARAMS ((const char *efile, char *cfile, char *sfile,
90 int perm, char *errout));
92 static int kvm_close PARAMS ((int fd));
94 static int kvm_write PARAMS ((int core_kd, CORE_ADDR memaddr,
95 char *myaddr, int len));
97 static int kvm_read PARAMS ((int core_kd, CORE_ADDR memaddr,
98 char *myaddr, int len));
100 static int kvm_uread PARAMS ((int core_kd, struct proc *p,
101 CORE_ADDR memaddr, char *myaddr,
104 static int kernel_core_file_hook PARAMS ((int fd, CORE_ADDR addr,
105 char *buf, int len));
107 static struct kinfo_proc * kvm_getprocs PARAMS ((int cfd, int op,
108 CORE_ADDR proc, int *cnt));
110 extern struct target_ops kcore_ops; /* Forward decl */
112 /* Non-zero means we are debugging a kernel core file */
113 int kernel_debugging = 0;
114 int kernel_writablecore = 0;
116 static char *core_file;
117 static int core_kd = -1;
118 static struct proc *cur_proc;
119 static CORE_ADDR kernel_start;
123 static CORE_ADDR prv_space; /* per-cpu private space */
124 static int prv_space_size;
125 #define prv_start (prv_space + cpuid * prv_space_size)
128 * Read the "thing" at kernel address 'addr' into the space pointed to
129 * by point. The length of the "thing" is determined by the type of p.
130 * Result is non-zero if transfer fails.
132 #define kvread(addr, p) \
133 (target_read_memory ((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
138 * The following is FreeBSD-specific hackery to decode special frames
139 * and elide the assembly-language stub. This could be made faster by
140 * defining a frame_type field in the machine-dependent frame information,
141 * but we don't think that's too important right now.
143 enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
146 fbsd_kern_frame_saved_pc (fr)
147 struct frame_info *fr;
149 struct minimal_symbol *sym;
150 CORE_ADDR this_saved_pc;
151 enum frametype frametype;
153 this_saved_pc = read_memory_integer (fr->frame + 4, 4);
154 sym = lookup_minimal_symbol_by_pc (this_saved_pc);
155 frametype = tf_normal;
157 if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
159 else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
160 frametype = tf_interrupt;
161 else if (strcmp (SYMBOL_NAME(sym), "Xsyscall") == 0)
162 frametype = tf_syscall;
167 return (this_saved_pc);
169 #define oEIP offsetof(struct trapframe, tf_eip)
172 return (read_memory_integer (fr->frame + 8 + oEIP, 4));
175 return (read_memory_integer (fr->frame + 16 + oEIP, 4));
178 return (read_memory_integer (fr->frame + 8 + oEIP, 4));
187 struct minimal_symbol *sym;
189 sym = lookup_minimal_symbol (name, NULL, NULL);
191 error ("kernel symbol `%s' not found.", name);
193 return SYMBOL_VALUE_ADDRESS (sym);
199 CORE_ADDR td_ptr_addr;
201 CORE_ADDR p_ptr_addr;
204 td_ptr_addr = prv_start + offsetof(struct mdglobaldata, mi.gd_curthread);
205 if (kvread(td_ptr_addr, &td_ptr) != 0)
206 error ("cannot read thread pointer at %08x\n", td_ptr_addr);
207 p_ptr_addr = td_ptr + offsetof(struct thread, td_proc);
208 if (kvread(p_ptr_addr, &p_ptr) != 0)
209 error ("cannot read proc pointer at %08x\n", p_ptr_addr);
210 return((void *)p_ptr);
214 * Set the process context to that of the proc structure at
215 * system address paddr.
218 set_proc_context (paddr)
223 if (paddr < kernel_start)
226 cur_proc = (struct proc *)paddr;
227 printf("CURPROC %08x\n", cur_proc);
229 set_kernel_boundaries (cur_proc);
232 /* Fetch all registers from core file */
233 target_fetch_registers (-1);
235 /* Now, set up the frame cache, and print the top of stack */
236 flush_cached_frames ();
237 set_current_frame (create_new_frame (read_fp (), read_pc ()));
238 select_frame (get_current_frame (), 0);
242 /* Discard all vestiges of any previous core file
243 and mark data and stack spaces as empty. */
247 kcore_close (quitting)
250 inferior_pid = 0; /* Avoid confusion from thread stuff */
261 /* This routine opens and sets up the core file bfd */
264 kcore_open (filename, from_tty)
269 struct cleanup *old_chain;
275 target_preopen (from_tty);
277 unpush_target (&kcore_ops);
282 error ( (core_kd >= 0)?
283 "No core file specified. (Use `detach' to stop debugging a core file.)"
284 : "No core file specified.");
287 filename = tilde_expand (filename);
288 if (filename[0] != '/')
290 cp = concat (current_directory, "/", filename, NULL);
295 old_chain = make_cleanup (free, filename);
298 * gdb doesn't really do anything if the exec-file couldn't
299 * be opened (in that case exec_bfd is NULL). Usually that's
300 * no big deal, but kvm_open needs the exec-file's name,
301 * which results in dereferencing a NULL pointer, a real NO-NO !
302 * So, check here if the open of the exec-file succeeded.
304 if (exec_bfd == NULL) /* the open failed */
305 error ("kgdb could not open the exec-file, please check the name you used !");
307 core_kd = kvm_open (exec_bfd->filename, filename, NULL,
308 kernel_writablecore? O_RDWR : O_RDONLY, "kgdb: ");
310 perror_with_name (filename);
312 /* Looks semi-reasonable. Toss the old core file and work on the new. */
314 discard_cleanups (old_chain); /* Don't free filename any more */
315 core_file = filename;
316 ontop = !push_target (&kcore_ops);
318 kernel_start = bfd_get_start_address (exec_bfd); /* XXX */
320 /* print out the panic string if there is one */
321 if (kvread (ksym_lookup ("panicstr"), &addr) == 0
323 && target_read_memory (addr, buf, sizeof (buf)) == 0)
325 for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++)
326 if (!isascii (*cp) || (!isprint (*cp) && !isspace (*cp)))
330 printf ("panicstr: %s\n", buf);
333 /* Print all the panic messages if possible. */
334 if (symfile_objfile != NULL)
336 printf ("panic messages:\n---\n");
337 snprintf (buf, sizeof buf,
338 "/sbin/dmesg -N %s -M %s | \
339 /usr/bin/awk '/^(panic:|Fatal trap) / { printing = 1 } \
340 { if (printing) print $0 }'",
341 symfile_objfile->name, filename);
349 warning ("you won't be able to access this core file until you terminate\n\
350 your %s; do ``info files''", target_longname);
354 /* we may need this later */
355 cur_proc = (struct proc *)curProc ();
356 /* Now, set up the frame cache, and print the top of stack */
357 flush_cached_frames ();
358 set_current_frame (create_new_frame (read_fp (), read_pc ()));
359 select_frame (get_current_frame (), 0);
360 print_stack_frame (selected_frame, selected_frame_level, 1);
364 kcore_detach (args, from_tty)
369 error ("Too many arguments");
370 unpush_target (&kcore_ops);
371 reinit_frame_cache ();
373 printf_filtered ("No kernel core file now.\n");
376 /* Get the registers out of a core file. This is the machine-
377 independent part. Fetch_core_registers is the machine-dependent
378 part, typically implemented in the xm-file for each architecture. */
380 /* We just get all the registers, so we don't use regno. */
384 #define PCB_ADDR(uptr) ((char *)uptr + UPAGES * PAGE_SIZE - sizeof(struct pcb))
388 get_kcore_registers (int regno)
394 /* find the pcb for the current process */
395 if (cur_proc == NULL)
396 error ("cur_proc is NULL");
397 if (kvread(&cur_proc->p_thread, &td))
398 error ("cannot read cur_proc->p_thread at %p", cur_proc);
399 if (kvread(&td->td_pcb, &pcb))
400 error ("cannot read cur_proc->p_thread->td_pcb at %p", td);
402 * Hack, gdb using newer structures need to deal with older elements
403 * XXX look up the offset in the debug info ?
405 if (pcb == (void *)0xff800000) {
406 if (kvread(&td->td_pcb - 1, &pcb))
407 error ("cannot read cur_proc->p_thread->td_pcb at %p", td);
409 if (read_pcb(core_kd, (CORE_ADDR)pcb) < 0)
410 error ("cannot read pcb at %p", pcb);
415 struct target_ops *t;
417 printf ("\t`%s'\n", core_file);
423 static CORE_ADDR maxuseraddr;
424 struct minimal_symbol *sym;
426 if (maxuseraddr == 0)
428 sym = lookup_minimal_symbol ("PTmap", NULL, NULL);
430 maxuseraddr = VM_MAXUSER_ADDRESS;
432 maxuseraddr = SYMBOL_VALUE_ADDRESS (sym);
439 kcore_xfer_kmem (memaddr, myaddr, len, write, target)
444 struct target_ops *target;
449 if (memaddr >= ksym_maxuseraddr())
453 nu = xfer_umem (memaddr, myaddr, len, write);
459 if (memaddr != ksym_maxuseraddr())
465 ns = (write ? kvm_write : kvm_read) (core_kd, memaddr, myaddr, len);
473 xfer_umem (memaddr, myaddr, len, write)
477 int write; /* ignored */
482 if (cur_proc == NULL || kvread (cur_proc, &proc))
483 error ("cannot read proc at %#x", cur_proc);
484 n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ;
494 static CORE_ADDR kernbase;
495 struct minimal_symbol *sym;
499 sym = lookup_minimal_symbol ("kernbase", NULL, NULL);
503 kernbase = SYMBOL_VALUE_ADDRESS (sym);
509 #define KERNOFF (ksym_kernbase())
510 #define INKERNEL(x) ((x) >= KERNOFF)
512 static CORE_ADDR sbr;
513 static CORE_ADDR curpcb;
514 static int found_pcb;
517 static struct pcb pcb;
520 set_proc_cmd (char *arg, int from_tty)
523 struct kinfo_proc *kp;
527 error_no_arg ("proc address for new current process");
528 if (!kernel_debugging)
529 error ("not debugging kernel");
531 paddr = (CORE_ADDR)parse_and_eval_address (arg);
532 /* assume it's a proc pointer if it's in the kernel */
533 if (paddr >= kernel_start) {
534 if (set_proc_context(paddr))
535 error("invalid proc address");
537 kp = kvm_getprocs(core_kd, KERN_PROC_PID, paddr, &cnt);
539 error("invalid pid");
540 if (set_proc_context((CORE_ADDR)kp->kp_eproc.e_paddr))
541 error("invalid proc address");
548 CORE_ADDR td_ptr_addr;
550 CORE_ADDR pcb_ptr_addr;
553 td_ptr_addr = prv_start + offsetof(struct mdglobaldata, mi.gd_curthread);
554 td_ptr_addr = kvtophys(cfd, td_ptr_addr);
555 physrd(cfd, td_ptr_addr, (char *)&td_ptr, sizeof(CORE_ADDR));
556 pcb_ptr_addr = td_ptr + offsetof(struct thread, td_pcb);
557 pcb_ptr_addr = kvtophys(cfd, pcb_ptr_addr);
558 physrd(cfd, pcb_ptr_addr, (char *)&pcb_ptr, sizeof(CORE_ADDR));
563 set_cpu_cmd (arg, from_tty)
568 struct kinfo_proc *kp;
572 error_no_arg ("cpu number");
573 if (!kernel_debugging)
574 error ("not debugging kernel");
576 error ("not debugging SMP kernel");
578 cpu = (int)parse_and_eval_address (arg);
579 if (cpu < 0 || cpu > ncpus)
580 error ("cpu number out of range");
584 curpcb = findpcb(cfd);
587 paddr = ksym_lookup ("dumppcb") - KERNOFF;
589 paddr = kvtophys (cfd, curpcb);
590 read_pcb (cfd, paddr);
591 printf ("initial pcb at %lx\n", (unsigned long)paddr);
593 if ((cur_proc = curProc()))
594 target_fetch_registers (-1);
596 /* Now, set up the frame cache, and print the top of stack */
597 flush_cached_frames ();
598 set_current_frame (create_new_frame (read_fp (), read_pc ()));
599 select_frame (get_current_frame (), 0);
600 print_stack_frame (selected_frame, selected_frame_level, 1);
603 /* substitutes for the stuff in libkvm which doesn't work */
604 /* most of this was taken from the old kgdb */
606 /* we don't need all this stuff, but the call should look the same */
609 kvm_open (efile, cfile, sfile, perm, errout)
612 char *sfile; /* makes this kvm_open more compatible to the one in libkvm */
614 char *errout; /* makes this kvm_open more compatible to the one in libkvm */
620 if ((cfd = open (cfile, perm, 0)) < 0)
624 if ((stb.st_mode & S_IFMT) == S_IFCHR
625 && stb.st_rdev == makedev (2, 0))
628 kfd = open (_PATH_KMEM, perm, 0);
632 * Both UP and SMP use CPU_prvspace.
635 physrd(cfd, ksym_lookup("ncpus") - KERNOFF, (char *)&ncpus, sizeof(ncpus));
636 prv_space = ksym_lookup("CPU_prvspace");
637 prv_space_size = (int)ksym_lookup("gd_idlestack_top");
638 printf("%d cpu%s [%08x,%d]\n", ncpus, (ncpus == 1 ? "" : "s"), prv_space, prv_space_size);
641 physrd (cfd, ksym_lookup ("IdlePTD") - KERNOFF, (char*)&sbr, sizeof sbr);
642 printf ("IdlePTD at phsyical address 0x%08lx\n", (unsigned long)sbr);
643 curpcb = findpcb(cfd);
645 found_pcb = 1; /* for vtophys */
647 paddr = ksym_lookup ("dumppcb") - KERNOFF;
649 paddr = kvtophys (cfd, curpcb);
650 read_pcb (cfd, paddr);
651 printf ("initial pcb at physical address 0x%08lx\n", (unsigned long)paddr);
664 kvm_write (core_kd, memaddr, myaddr, len)
676 * Just like kvm_read, only we write.
679 if (lseek (kfd, (off_t)memaddr, 0) < 0
682 error ("kvm_write:invalid address (%x)", memaddr);
685 cc = write (kfd, myaddr, len);
688 error ("kvm_write:write failed");
692 error ("kvm_write:short write");
700 printf ("kvm_write not implemented for dead kernels\n");
707 kvm_read (core_kd, memaddr, myaddr, len)
712 return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
716 kvm_uread (core_kd, p, memaddr, myaddr, len)
718 register struct proc *p;
724 char procfile[MAXPATHLEN];
730 sprintf (procfile, "/proc/%d/mem", p->p_pid);
731 fd = open (procfile, O_RDONLY, 0);
734 error ("cannot open %s", procfile);
743 if (lseek (fd, (off_t)memaddr, 0) == -1 && errno != 0)
745 error ("invalid address (%x) in %s", memaddr, procfile);
748 amount = read (fd, cp, len);
751 error ("error reading %s", procfile);
756 error ("EOF reading %s", procfile);
765 return ((ssize_t) (cp - myaddr));
768 return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
771 static struct kinfo_proc kp;
774 * try to do what kvm_proclist in libkvm would do
777 kvm_proclist (cfd, pid, p, cnt)
783 for (; p != NULL; p = lp.p_list.le_next) {
784 if (!kvm_read(cfd, (CORE_ADDR)p, (char *)&lp, sizeof (lp)))
788 kp.kp_eproc.e_paddr = p;
797 * try to do what kvm_deadprocs in libkvm would do
799 static struct kinfo_proc *
800 kvm_deadprocs (cfd, pid, cnt)
803 CORE_ADDR allproc, zombproc;
806 allproc = ksym_lookup("allproc");
807 if (kvm_read(cfd, allproc, (char *)&p, sizeof (p)) == 0)
809 kvm_proclist (cfd, pid, p, cnt);
811 zombproc = ksym_lookup("zombproc");
812 if (kvm_read(cfd, zombproc, (char *)&p, sizeof (p)) == 0)
814 kvm_proclist (cfd, pid, p, cnt);
820 * try to do what kvm_getprocs in libkvm would do
822 static struct kinfo_proc *
823 kvm_getprocs (cfd, op, proc, cnt)
830 /* assume it's a pid */
831 if (devmem) { /* "live" kernel, use sysctl */
834 mib[2] = KERN_PROC_PID;
837 if (sysctl (mib, 4, &kp, &size, NULL, 0) < 0) {
848 return (kvm_deadprocs (cfd, (int)proc, cnt));
852 physrd (cfd, addr, dat, len)
858 if (lseek (cfd, (off_t)addr, L_SET) == -1)
860 return (read (cfd, dat, len));
870 static CORE_ADDR PTD = -1;
871 CORE_ADDR current_ptd;
874 * We may no longer have a linear system page table...
876 * Here's the scoop. IdlePTD contains the physical address
877 * of a page table directory that always maps the kernel.
878 * IdlePTD is in memory that is mapped 1-to-1, so we can
879 * find it easily given its 'virtual' address from ksym_lookup().
880 * For hysterical reasons, the value of IdlePTD is stored in sbr.
882 * To look up a kernel address, we first convert it to a 1st-level
883 * address and look it up in IdlePTD. This gives us the physical
884 * address of a page table page; we extract the 2nd-level part of
885 * VA and read the 2nd-level pte. Finally, we add the offset part
886 * of the VA into the physical address from the pte and return it.
888 * User addresses are a little more complicated. If we don't have
889 * a current PCB from read_pcb(), we use PTD, which is the (fixed)
890 * virtual address of the current ptd. Since it's NOT in 1-to-1
891 * kernel space, we must look it up using IdlePTD. If we do have
892 * a pcb, we get the ptd from pcb_ptd.
897 else if (found_pcb == 0)
900 PTD = kvtophys (fd, ksym_lookup ("PTD"));
904 current_ptd = pcb.pcb_cr3;
907 * Read the first-level page table (ptd).
909 v = current_ptd + ( (unsigned)addr >> PDRSHIFT) * sizeof pte;
910 if (physrd (fd, v, (char *)&pte, sizeof pte) < 0 || (pte&PG_V) == 0)
916 * No second-level page table; ptd describes one 4MB page.
917 * (We assume that the kernel wouldn't set PG_PS without enabling
918 * it cr0, and that the kernel doesn't support 36-bit physical
921 #define PAGE4M_MASK (NBPDR - 1)
922 #define PG_FRAME4M (~PAGE4M_MASK)
923 addr = (pte & PG_FRAME4M) + (addr & PAGE4M_MASK);
928 * Read the second-level page table.
930 v = (pte&PG_FRAME) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
931 if (physrd (fd, v, (char *) &pte, sizeof (pte)) < 0 || (pte&PG_V) == 0)
934 addr = (pte & PG_FRAME) + (addr & PAGE_MASK);
937 printf ("vtophys (%x) -> %x\n", oldaddr, addr);
943 read_pcb (int fd, CORE_ADDR pcbaddr)
949 /* need this for the `proc' command to work */
950 /* this is a bad hack XXX */
951 if (INKERNEL(pcbaddr))
952 npcbaddr = kvtophys(fd, pcbaddr);
956 if (physrd (fd, (CORE_ADDR)npcbaddr, (char *)&pcb, sizeof pcb) < 0) {
957 error ("cannot read pcb at %x\n", pcbaddr);
960 printf("PCB @%08x EIP=%08x ESP=%08x EBP=%08x\n", npcbaddr, pcb.pcb_eip, pcb.pcb_esp, pcb.pcb_ebp);
963 * get the register values out of the sys pcb and
964 * store them where `read_register' will find them.
967 * XXX many registers aren't available.
968 * XXX for the non-core case, the registers are stale - they are for
969 * the last context switch to the debugger.
970 * XXX gcc's register numbers aren't all #defined in tm-i386.h.
973 for (i = 0; i < 3; ++i) /* eax,ecx,edx */
974 supply_register (i, (char *)&noreg);
975 supply_register (3, (char *)&pcb.pcb_ebx);
976 supply_register (SP_REGNUM, (char *)&pcb.pcb_esp);
977 supply_register (FP_REGNUM, (char *)&pcb.pcb_ebp);
978 supply_register (6, (char *)&pcb.pcb_esi);
979 supply_register (7, (char *)&pcb.pcb_edi);
980 supply_register (PC_REGNUM, (char *)&pcb.pcb_eip);
981 for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */
982 supply_register (i, (char *)&noreg);
983 supply_register (15, (char *)&pcb.pcb_gs);
985 /* XXX 80387 registers? */
989 * read len bytes from kernel virtual address 'addr' into local
990 * buffer 'buf'. Return numbert of bytes if read ok, 0 otherwise. On read
991 * errors, portion of buffer not read is zeroed.
995 kernel_core_file_hook (fd, addr, buf, len)
1010 paddr = kvtophys (fd, addr);
1013 memset (buf, '\000', len);
1016 /* we can't read across a page boundary */
1017 i = min (len, PAGE_SIZE - (addr & PAGE_MASK));
1018 if ( (cc = physrd (fd, paddr, cp, i)) <= 0)
1020 memset (cp, '\000', len);
1030 static struct target_ops kcore_ops;
1033 _initialize_kcorelow()
1035 kcore_ops.to_shortname = "kcore";
1036 kcore_ops.to_longname = "Kernel core dump file";
1038 "Use a core file as a target. Specify the filename of the core file.";
1039 kcore_ops.to_open = kcore_open;
1040 kcore_ops.to_close = kcore_close;
1041 kcore_ops.to_attach = find_default_attach;
1042 kcore_ops.to_detach = kcore_detach;
1043 kcore_ops.to_fetch_registers = get_kcore_registers;
1044 kcore_ops.to_xfer_memory = kcore_xfer_kmem;
1045 kcore_ops.to_files_info = kcore_files_info;
1046 kcore_ops.to_create_inferior = find_default_create_inferior;
1047 kcore_ops.to_stratum = kcore_stratum;
1048 kcore_ops.to_has_memory = 1;
1049 kcore_ops.to_has_stack = 1;
1050 kcore_ops.to_has_registers = 1;
1051 kcore_ops.to_magic = OPS_MAGIC;
1053 add_target (&kcore_ops);
1054 add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
1055 add_com ("cpu", class_obscure, set_cpu_cmd, "Set current cpu");