xref: /dflybsd-src/gnu/usr.bin/gdb/kgdb/trgt.c (revision c33252afc5aa9790d4820b568316e03d695f6a65)
18b6a428fSSimon Schubert /*
28b6a428fSSimon Schubert  * Copyright (c) 2004 Marcel Moolenaar
38b6a428fSSimon Schubert  * All rights reserved.
48b6a428fSSimon Schubert  *
58b6a428fSSimon Schubert  * Redistribution and use in source and binary forms, with or without
68b6a428fSSimon Schubert  * modification, are permitted provided that the following conditions
78b6a428fSSimon Schubert  * are met:
88b6a428fSSimon Schubert  *
98b6a428fSSimon Schubert  * 1. Redistributions of source code must retain the above copyright
108b6a428fSSimon Schubert  *    notice, this list of conditions and the following disclaimer.
118b6a428fSSimon Schubert  * 2. Redistributions in binary form must reproduce the above copyright
128b6a428fSSimon Schubert  *    notice, this list of conditions and the following disclaimer in the
138b6a428fSSimon Schubert  *    documentation and/or other materials provided with the distribution.
148b6a428fSSimon Schubert  *
158b6a428fSSimon Schubert  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168b6a428fSSimon Schubert  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178b6a428fSSimon Schubert  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188b6a428fSSimon Schubert  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198b6a428fSSimon Schubert  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208b6a428fSSimon Schubert  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218b6a428fSSimon Schubert  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228b6a428fSSimon Schubert  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238b6a428fSSimon Schubert  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248b6a428fSSimon Schubert  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258b6a428fSSimon Schubert  *
26f17ea84bSSimon Schubert  * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.12 2008/05/01 20:36:48 jhb Exp $
278b6a428fSSimon Schubert  */
288b6a428fSSimon Schubert 
298b6a428fSSimon Schubert #include <sys/cdefs.h>
308b6a428fSSimon Schubert 
318b6a428fSSimon Schubert #include <sys/param.h>
328b6a428fSSimon Schubert #include <sys/sysctl.h>
338b6a428fSSimon Schubert #include <sys/user.h>
34f17ea84bSSimon Schubert #include <err.h>
35f17ea84bSSimon Schubert #include <fcntl.h>
368b6a428fSSimon Schubert #include <kvm.h>
378b6a428fSSimon Schubert 
388b6a428fSSimon Schubert #include <defs.h>
39f17ea84bSSimon Schubert #include <readline/readline.h>
40f17ea84bSSimon Schubert #include <readline/tilde.h>
418b6a428fSSimon Schubert #include <command.h>
42f17ea84bSSimon Schubert #include <exec.h>
438b6a428fSSimon Schubert #include <frame-unwind.h>
44f17ea84bSSimon Schubert #include <gdb.h>
45f17ea84bSSimon Schubert #include <gdbcore.h>
468b6a428fSSimon Schubert #include <gdbthread.h>
478b6a428fSSimon Schubert #include <inferior.h>
48f17ea84bSSimon Schubert #include <language.h>
498b6a428fSSimon Schubert #include <regcache.h>
50f17ea84bSSimon Schubert #include <solib.h>
518b6a428fSSimon Schubert #include <target.h>
52f17ea84bSSimon Schubert #include <ui-out.h>
53f17ea84bSSimon Schubert #include <observer.h>
54*c33252afSJohn Marino #include <arch-utils.h>
558b6a428fSSimon Schubert 
568b6a428fSSimon Schubert #include "kgdb.h"
578b6a428fSSimon Schubert 
58f17ea84bSSimon Schubert static void	kgdb_core_cleanup(void *);
59f17ea84bSSimon Schubert 
60f17ea84bSSimon Schubert static char *vmcore;
618b6a428fSSimon Schubert static struct target_ops kgdb_trgt_ops;
628b6a428fSSimon Schubert 
63f17ea84bSSimon Schubert kvm_t *kvm;
64f17ea84bSSimon Schubert static char kvm_err[_POSIX2_LINE_MAX];
65f17ea84bSSimon Schubert 
66f17ea84bSSimon Schubert #define	KERNOFF		(kgdb_kernbase ())
67f17ea84bSSimon Schubert #define	INKERNEL(x)	((x) >= KERNOFF)
68f17ea84bSSimon Schubert 
69f17ea84bSSimon Schubert static CORE_ADDR
kgdb_kernbase(void)70f17ea84bSSimon Schubert kgdb_kernbase (void)
71f17ea84bSSimon Schubert {
72f17ea84bSSimon Schubert 	static CORE_ADDR kernbase;
73f17ea84bSSimon Schubert 	struct minimal_symbol *sym;
74f17ea84bSSimon Schubert 
75f17ea84bSSimon Schubert 	if (kernbase == 0) {
76f17ea84bSSimon Schubert 		sym = lookup_minimal_symbol ("kernbase", NULL, NULL);
77f17ea84bSSimon Schubert 		if (sym == NULL) {
78f17ea84bSSimon Schubert 			kernbase = KERNBASE;
79f17ea84bSSimon Schubert 		} else {
80f17ea84bSSimon Schubert 			kernbase = SYMBOL_VALUE_ADDRESS (sym);
81f17ea84bSSimon Schubert 		}
82f17ea84bSSimon Schubert 	}
83f17ea84bSSimon Schubert 	return kernbase;
84f17ea84bSSimon Schubert }
85f17ea84bSSimon Schubert 
86f17ea84bSSimon Schubert static void
kgdb_trgt_open(char * filename,int from_tty)87f17ea84bSSimon Schubert kgdb_trgt_open(char *filename, int from_tty)
88f17ea84bSSimon Schubert {
89f17ea84bSSimon Schubert 	struct cleanup *old_chain;
90f17ea84bSSimon Schubert 	struct kthr *kt;
91a938cc15SJohn Marino 	struct inferior *inf8;
92a938cc15SJohn Marino 	struct program_space *pspace;
93f17ea84bSSimon Schubert 	kvm_t *nkvm;
94f17ea84bSSimon Schubert 	char *temp;
95a938cc15SJohn Marino 	int first_inferior = 1;
96*c33252afSJohn Marino 	struct gdbarch_info info;
97*c33252afSJohn Marino 	struct gdbarch *kgdbarch;
98f17ea84bSSimon Schubert 
99f17ea84bSSimon Schubert 	target_preopen (from_tty);
100f17ea84bSSimon Schubert 	if (!filename)
101f17ea84bSSimon Schubert 		error ("No vmcore file specified.");
102f17ea84bSSimon Schubert 	if (!exec_bfd)
103f17ea84bSSimon Schubert 		error ("Can't open a vmcore without a kernel");
104f17ea84bSSimon Schubert 
105f17ea84bSSimon Schubert 	filename = tilde_expand (filename);
106f17ea84bSSimon Schubert 	if (filename[0] != '/') {
107f17ea84bSSimon Schubert 		temp = concat (current_directory, "/", filename, NULL);
108f17ea84bSSimon Schubert 		xfree(filename);
109f17ea84bSSimon Schubert 		filename = temp;
110f17ea84bSSimon Schubert 	}
111f17ea84bSSimon Schubert 
112f17ea84bSSimon Schubert 	old_chain = make_cleanup (xfree, filename);
113f17ea84bSSimon Schubert 
114f17ea84bSSimon Schubert 	nkvm = kvm_openfiles(bfd_get_filename(exec_bfd), filename, NULL,
115f17ea84bSSimon Schubert 	    write_files ? O_RDWR : O_RDONLY, kvm_err);
116f17ea84bSSimon Schubert 	if (nkvm == NULL)
117f17ea84bSSimon Schubert 		error ("Failed to open vmcore: %s", kvm_err);
118f17ea84bSSimon Schubert 
119f17ea84bSSimon Schubert 	/* Don't free the filename now and close any previous vmcore. */
120f17ea84bSSimon Schubert 	discard_cleanups(old_chain);
121f17ea84bSSimon Schubert 	unpush_target(&kgdb_trgt_ops);
122f17ea84bSSimon Schubert 
123f17ea84bSSimon Schubert 	kvm = nkvm;
124f17ea84bSSimon Schubert 	vmcore = filename;
125f17ea84bSSimon Schubert 	old_chain = make_cleanup(kgdb_core_cleanup, NULL);
126f17ea84bSSimon Schubert 
127a938cc15SJohn Marino 	push_target (&kgdb_trgt_ops);
128f17ea84bSSimon Schubert 	discard_cleanups (old_chain);
129f17ea84bSSimon Schubert 
130f17ea84bSSimon Schubert 	kgdb_dmesg();
131f17ea84bSSimon Schubert 
132*c33252afSJohn Marino 	gdbarch_info_init (&info);
133*c33252afSJohn Marino #if defined (__i386__)
134*c33252afSJohn Marino 	info.bfd_arch_info = bfd_scan_arch ("i386");
135*c33252afSJohn Marino #elif defined (__x86_64__)
136*c33252afSJohn Marino 	info.bfd_arch_info = bfd_scan_arch ("i386:x86-64");
137*c33252afSJohn Marino #else
138*c33252afSJohn Marino #error platform not recognized
139*c33252afSJohn Marino #endif
140*c33252afSJohn Marino 	info.byte_order = BFD_ENDIAN_LITTLE;
141*c33252afSJohn Marino 	gdbarch_info_fill (&info);
142*c33252afSJohn Marino 	kgdbarch = gdbarch_find_by_info (info);
143*c33252afSJohn Marino 
144f17ea84bSSimon Schubert 	init_thread_list();
145f17ea84bSSimon Schubert 	kt = kgdb_thr_init();
146f17ea84bSSimon Schubert 	while (kt != NULL) {
147a938cc15SJohn Marino 		if (!in_inferior_list(kt->pid)) {
148a938cc15SJohn Marino                      if (first_inferior) {
149a938cc15SJohn Marino                        first_inferior = 0;
15093c24908SJohn Marino                        inf8 = current_inferior();
15193c24908SJohn Marino                        inf8->pid = kt->pid;
152*c33252afSJohn Marino                        inf8->attach_flag = 1;
15393c24908SJohn Marino                        inferior_appeared (inf8, kt->pid);
154a938cc15SJohn Marino                        pspace = current_program_space;
155a938cc15SJohn Marino                        pspace->ebfd = 0;
156a938cc15SJohn Marino                        pspace->ebfd_mtime = 0;
157a938cc15SJohn Marino                      } else {
15893c24908SJohn Marino                        inf8 = add_inferior(kt->pid);
159*c33252afSJohn Marino                        inf8->attach_flag = 0;
160a938cc15SJohn Marino                        pspace = add_program_space(new_address_space());
161a938cc15SJohn Marino                        pspace->symfile_object_file = symfile_objfile;
162a938cc15SJohn Marino                        pspace->objfiles = object_files;
163a938cc15SJohn Marino                      }
164a938cc15SJohn Marino                      inf8->pspace = pspace;
165a938cc15SJohn Marino                      inf8->aspace = pspace->aspace;
166*c33252afSJohn Marino                      inf8->fake_pid_p = 0;
167*c33252afSJohn Marino                      inf8->gdbarch = kgdbarch;
168a938cc15SJohn Marino                 }
169*c33252afSJohn Marino 		add_thread(ptid_build(kt->pid, kt->lwpid, kt->tid));
170f17ea84bSSimon Schubert 		kt = kgdb_thr_next(kt);
171f17ea84bSSimon Schubert 	}
172f17ea84bSSimon Schubert 	if (curkthr != 0)
173*c33252afSJohn Marino 		inferior_ptid = ptid_build(curkthr->pid, curkthr->lwpid,
174*c33252afSJohn Marino 			curkthr->tid);
175f17ea84bSSimon Schubert 
176*c33252afSJohn Marino 	frame_unwind_prepend_unwinder(kgdbarch, &kgdb_trgt_trapframe_unwind);
177939fa31eSMatthew Dillon 
178*c33252afSJohn Marino 	kld_init(kgdbarch);
179f17ea84bSSimon Schubert 	reinit_frame_cache();
180f17ea84bSSimon Schubert 	select_frame (get_current_frame());
181*c33252afSJohn Marino 	print_stack_frame(get_selected_frame(NULL), 0, SRC_AND_LOC);
182f17ea84bSSimon Schubert }
183f17ea84bSSimon Schubert 
184f17ea84bSSimon Schubert static void
kgdb_trgt_close(int quitting)185f17ea84bSSimon Schubert kgdb_trgt_close(int quitting)
186f17ea84bSSimon Schubert {
187f17ea84bSSimon Schubert 
188f17ea84bSSimon Schubert 	if (kvm != NULL) {
189f17ea84bSSimon Schubert 		inferior_ptid = null_ptid;
190f17ea84bSSimon Schubert 		clear_solib();
191f17ea84bSSimon Schubert 		if (kvm_close(kvm) != 0)
192f17ea84bSSimon Schubert 			warning("cannot close \"%s\": %s", vmcore,
193f17ea84bSSimon Schubert 			    kvm_geterr(kvm));
194f17ea84bSSimon Schubert 		kvm = NULL;
195f17ea84bSSimon Schubert 		xfree(vmcore);
196f17ea84bSSimon Schubert 		vmcore = NULL;
197f17ea84bSSimon Schubert 	}
198f17ea84bSSimon Schubert }
199f17ea84bSSimon Schubert 
200f17ea84bSSimon Schubert static void
kgdb_core_cleanup(void * arg)201f17ea84bSSimon Schubert kgdb_core_cleanup(void *arg)
202f17ea84bSSimon Schubert {
203f17ea84bSSimon Schubert 
204f17ea84bSSimon Schubert 	kgdb_trgt_close(0);
205f17ea84bSSimon Schubert }
206f17ea84bSSimon Schubert 
207f17ea84bSSimon Schubert static void
kgdb_trgt_detach(struct target_ops * target,char * args,int from_tty)208f17ea84bSSimon Schubert kgdb_trgt_detach(struct target_ops *target, char *args, int from_tty)
209f17ea84bSSimon Schubert {
210f17ea84bSSimon Schubert 
211f17ea84bSSimon Schubert 	if (args)
212f17ea84bSSimon Schubert 		error ("Too many arguments");
213f17ea84bSSimon Schubert 	unpush_target(target);
214f17ea84bSSimon Schubert 	reinit_frame_cache();
215f17ea84bSSimon Schubert 	if (from_tty)
216f17ea84bSSimon Schubert 		printf_filtered("No vmcore file now.\n");
217f17ea84bSSimon Schubert }
218f17ea84bSSimon Schubert 
2198b6a428fSSimon Schubert static char *
kgdb_trgt_extra_thread_info(struct thread_info * ti)2208b6a428fSSimon Schubert kgdb_trgt_extra_thread_info(struct thread_info *ti)
2218b6a428fSSimon Schubert {
2228b6a428fSSimon Schubert 
223f17ea84bSSimon Schubert 	return (kgdb_thr_extra_thread_info(ptid_get_tid(ti->ptid)));
2248b6a428fSSimon Schubert }
2258b6a428fSSimon Schubert 
2268b6a428fSSimon Schubert static void
kgdb_trgt_files_info(struct target_ops * target)2278b6a428fSSimon Schubert kgdb_trgt_files_info(struct target_ops *target)
2288b6a428fSSimon Schubert {
2298b6a428fSSimon Schubert 
230f17ea84bSSimon Schubert 	printf_filtered ("\t`%s', ", vmcore);
231f17ea84bSSimon Schubert 	wrap_here ("        ");
232f17ea84bSSimon Schubert 	printf_filtered ("file type %s.\n", "DragonFly kernel vmcore");
2338b6a428fSSimon Schubert }
2348b6a428fSSimon Schubert 
2358b6a428fSSimon Schubert static void
kgdb_trgt_find_new_threads(struct target_ops * target_ops)236f17ea84bSSimon Schubert kgdb_trgt_find_new_threads(struct target_ops *target_ops)
2378b6a428fSSimon Schubert {
2388b6a428fSSimon Schubert 	struct target_ops *tb;
2398b6a428fSSimon Schubert 
2408b6a428fSSimon Schubert 	if (kvm != NULL)
2418b6a428fSSimon Schubert 		return;
2428b6a428fSSimon Schubert 
243f17ea84bSSimon Schubert 	tb = find_target_beneath(target_ops);
2448b6a428fSSimon Schubert 	if (tb->to_find_new_threads != NULL)
245f17ea84bSSimon Schubert 		tb->to_find_new_threads(target_ops);
2468b6a428fSSimon Schubert }
2478b6a428fSSimon Schubert 
2488b6a428fSSimon Schubert static char *
kgdb_trgt_pid_to_str(struct target_ops * target_ops __unused,ptid_t ptid)249f17ea84bSSimon Schubert kgdb_trgt_pid_to_str(struct target_ops *target_ops __unused, ptid_t ptid)
2508b6a428fSSimon Schubert {
251f17ea84bSSimon Schubert 	return (kgdb_thr_pid_to_str(ptid));
2528b6a428fSSimon Schubert }
2538b6a428fSSimon Schubert 
2548b6a428fSSimon Schubert static int
kgdb_trgt_thread_alive(struct target_ops * target_ops __unused,ptid_t ptid)255f17ea84bSSimon Schubert kgdb_trgt_thread_alive(struct target_ops *target_ops __unused, ptid_t ptid)
2568b6a428fSSimon Schubert {
2578b6a428fSSimon Schubert 	return (kgdb_thr_lookup_tid(ptid_get_tid(ptid)) != NULL);
2588b6a428fSSimon Schubert }
2598b6a428fSSimon Schubert 
2600c3d4888SSimon Schubert static LONGEST
kgdb_trgt_xfer_partial(struct target_ops * ops,enum target_object object,const char * annex,gdb_byte * readbuf,const gdb_byte * writebuf,ULONGEST offset,LONGEST len)2610c3d4888SSimon Schubert kgdb_trgt_xfer_partial(struct target_ops *ops, enum target_object object,
2620c3d4888SSimon Schubert 		       const char *annex, gdb_byte *readbuf,
2630c3d4888SSimon Schubert 		       const gdb_byte *writebuf,
2640c3d4888SSimon Schubert 		       ULONGEST offset, LONGEST len)
2658b6a428fSSimon Schubert {
2668b6a428fSSimon Schubert 	if (kvm != NULL) {
2678b6a428fSSimon Schubert 		if (len == 0)
2688b6a428fSSimon Schubert 			return (0);
2690c3d4888SSimon Schubert 		if (writebuf != NULL)
2700c3d4888SSimon Schubert 			return (kvm_write(kvm, offset, writebuf, len));
2710c3d4888SSimon Schubert 		if (readbuf != NULL)
2720c3d4888SSimon Schubert 			return (kvm_read(kvm, offset, readbuf, len));
2738b6a428fSSimon Schubert 	}
2740c3d4888SSimon Schubert 	return (ops->beneath->to_xfer_partial(ops->beneath, object, annex,
2750c3d4888SSimon Schubert 					      readbuf, writebuf, offset, len));
2768b6a428fSSimon Schubert }
2778b6a428fSSimon Schubert 
278f17ea84bSSimon Schubert static void
kgdb_switch_to_thread(struct kthr * thr)279f17ea84bSSimon Schubert kgdb_switch_to_thread(struct kthr *thr)
2808b6a428fSSimon Schubert {
281f17ea84bSSimon Schubert 	char buf[16];
282*c33252afSJohn Marino 	CORE_ADDR thread_id;
283f17ea84bSSimon Schubert 	char *err;
2848b6a428fSSimon Schubert 
285*c33252afSJohn Marino 	thread_id = thr->tid;
286f17ea84bSSimon Schubert 	if (thread_id == 0)
287f17ea84bSSimon Schubert 		error ("invalid tid");
288*c33252afSJohn Marino 	snprintf(buf, sizeof(buf), "%lu", thread_id);
289e9e05faaSJohn Marino 	if (!gdb_thread_select(current_uiout, buf, &err))
290f17ea84bSSimon Schubert 		error ("%s", err);
291f17ea84bSSimon Schubert }
292f17ea84bSSimon Schubert 
293f17ea84bSSimon Schubert static void
kgdb_set_proc_cmd(char * arg,int from_tty)294f17ea84bSSimon Schubert kgdb_set_proc_cmd (char *arg, int from_tty)
295f17ea84bSSimon Schubert {
296f17ea84bSSimon Schubert 	CORE_ADDR addr;
297f17ea84bSSimon Schubert 	struct kthr *thr;
298f17ea84bSSimon Schubert 
299f17ea84bSSimon Schubert 	if (!arg)
300f17ea84bSSimon Schubert 		error_no_arg ("proc address for the new context");
301f17ea84bSSimon Schubert 
302f17ea84bSSimon Schubert 	if (kvm == NULL)
303f17ea84bSSimon Schubert 		error ("only supported for core file target");
304f17ea84bSSimon Schubert 
305f17ea84bSSimon Schubert 	addr = (CORE_ADDR) parse_and_eval_address (arg);
306f17ea84bSSimon Schubert 
307f17ea84bSSimon Schubert 	if (!INKERNEL (addr)) {
308f17ea84bSSimon Schubert 		thr = kgdb_thr_lookup_pid((int)addr);
309f17ea84bSSimon Schubert 		if (thr == NULL)
310f17ea84bSSimon Schubert 			error ("invalid pid");
311f17ea84bSSimon Schubert 	} else {
312f17ea84bSSimon Schubert 		thr = kgdb_thr_lookup_paddr(addr);
313f17ea84bSSimon Schubert 		if (thr == NULL)
314f17ea84bSSimon Schubert 			error("invalid proc address");
315f17ea84bSSimon Schubert 	}
316f17ea84bSSimon Schubert 	kgdb_switch_to_thread(thr);
317f17ea84bSSimon Schubert }
318f17ea84bSSimon Schubert 
319f17ea84bSSimon Schubert static void
kgdb_set_tid_cmd(char * arg,int from_tty)320f17ea84bSSimon Schubert kgdb_set_tid_cmd (char *arg, int from_tty)
321f17ea84bSSimon Schubert {
322f17ea84bSSimon Schubert 	CORE_ADDR addr;
323f17ea84bSSimon Schubert 	struct kthr *thr;
324f17ea84bSSimon Schubert 
325f17ea84bSSimon Schubert 	if (!arg)
326f17ea84bSSimon Schubert 		error_no_arg ("Thread address for the new context");
327f17ea84bSSimon Schubert 
328f17ea84bSSimon Schubert 	addr = (CORE_ADDR) parse_and_eval_address (arg);
329f17ea84bSSimon Schubert 	thr = kgdb_thr_lookup_taddr(addr);
330f17ea84bSSimon Schubert 
331f17ea84bSSimon Schubert 	if (thr == NULL)
332f17ea84bSSimon Schubert 		error("invalid thread address");
333f17ea84bSSimon Schubert 
334f17ea84bSSimon Schubert 	kgdb_switch_to_thread(thr);
335f17ea84bSSimon Schubert }
336f17ea84bSSimon Schubert 
337f17ea84bSSimon Schubert int fbsdcoreops_suppress_target = 1;
338f17ea84bSSimon Schubert 
339f17ea84bSSimon Schubert void
initialize_kgdb_target(void)340f17ea84bSSimon Schubert initialize_kgdb_target(void)
341f17ea84bSSimon Schubert {
3428b6a428fSSimon Schubert 	kgdb_trgt_ops.to_magic = OPS_MAGIC;
3438b6a428fSSimon Schubert 	kgdb_trgt_ops.to_shortname = "kernel";
344f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_longname = "kernel core dump file";
345f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_doc =
346f17ea84bSSimon Schubert     "Use a vmcore file as a target.  Specify the filename of the vmcore file.";
3470c3d3a6fSJohn Marino 	kgdb_trgt_ops.to_stratum = process_stratum;
348f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_has_registers = default_child_has_registers;
349f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_has_memory = default_child_has_memory;
350f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_has_stack = default_child_has_stack;
3518b6a428fSSimon Schubert 
352f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_open = kgdb_trgt_open;
353f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_close = kgdb_trgt_close;
354f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_attach = find_default_attach;
355f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_detach = kgdb_trgt_detach;
3568b6a428fSSimon Schubert 	kgdb_trgt_ops.to_extra_thread_info = kgdb_trgt_extra_thread_info;
3578b6a428fSSimon Schubert 	kgdb_trgt_ops.to_fetch_registers = kgdb_trgt_fetch_registers;
3588b6a428fSSimon Schubert 	kgdb_trgt_ops.to_files_info = kgdb_trgt_files_info;
3598b6a428fSSimon Schubert 	kgdb_trgt_ops.to_find_new_threads = kgdb_trgt_find_new_threads;
3608b6a428fSSimon Schubert 	kgdb_trgt_ops.to_pid_to_str = kgdb_trgt_pid_to_str;
361f17ea84bSSimon Schubert 	/*
362f17ea84bSSimon Schubert 	kgdb_trgt_ops.to_store_registers = NULL;
363f17ea84bSSimon Schubert 	*/
3648b6a428fSSimon Schubert 	kgdb_trgt_ops.to_thread_alive = kgdb_trgt_thread_alive;
3650c3d4888SSimon Schubert 	kgdb_trgt_ops.to_xfer_partial = kgdb_trgt_xfer_partial;
3668b6a428fSSimon Schubert 	add_target(&kgdb_trgt_ops);
3678b6a428fSSimon Schubert 
368f17ea84bSSimon Schubert 	add_com ("proc", class_obscure, kgdb_set_proc_cmd,
369f17ea84bSSimon Schubert 	   "Set current process context");
370f17ea84bSSimon Schubert 	add_com ("tid", class_obscure, kgdb_set_tid_cmd,
371f17ea84bSSimon Schubert 	   "Set current thread context");
3728b6a428fSSimon Schubert }
373