1132624Smarcel/*
2132624Smarcel * Copyright (c) 2004 Marcel Moolenaar
3132624Smarcel * All rights reserved.
4132624Smarcel *
5132624Smarcel * Redistribution and use in source and binary forms, with or without
6132624Smarcel * modification, are permitted provided that the following conditions
7132624Smarcel * are met:
8132624Smarcel *
9132624Smarcel * 1. Redistributions of source code must retain the above copyright
10132624Smarcel *    notice, this list of conditions and the following disclaimer.
11132624Smarcel * 2. Redistributions in binary form must reproduce the above copyright
12132624Smarcel *    notice, this list of conditions and the following disclaimer in the
13132624Smarcel *    documentation and/or other materials provided with the distribution.
14132624Smarcel *
15132624Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16132624Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17132624Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18132624Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19132624Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20132624Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21132624Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22132624Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23132624Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24132624Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25132624Smarcel *
26132624Smarcel * $FreeBSD$
27132624Smarcel */
28132624Smarcel
29132624Smarcel#ifndef _KGDB_H_
30132624Smarcel#define	_KGDB_H_
31132624Smarcel
32149954Smarcelstruct thread_info;
33142151Skan
34132624Smarcelextern kvm_t *kvm;
35132624Smarcel
36132624Smarcelstruct kthr {
37132624Smarcel	struct kthr	*next;
38142151Skan	uintptr_t	paddr;
39132624Smarcel	uintptr_t	kaddr;
40132624Smarcel	uintptr_t	kstack;
41132624Smarcel	uintptr_t	pcb;
42132624Smarcel	int		tid;
43142151Skan	int		pid;
44173681Sjhb	u_char		cpu;
45132624Smarcel};
46132624Smarcel
47132624Smarcelextern struct kthr *curkthr;
48132624Smarcel
49178670Sjhbvoid initialize_kld_target(void);
50178670Sjhbvoid initialize_kgdb_target(void);
51178670Sjhbvoid kgdb_dmesg(void);
52178670Sjhbvoid kgdb_trgt_new_objfile(struct objfile *);
53132624Smarcelvoid kgdb_trgt_fetch_registers(int);
54132624Smarcelvoid kgdb_trgt_store_registers(int);
55178670Sjhbvoid kld_init(void);
56178670Sjhbvoid kld_new_objfile(struct objfile *);
57132624Smarcel
58149954Smarcelframe_unwind_sniffer_ftype kgdb_trgt_trapframe_sniffer;
59149954Smarcel
60132624Smarcelstruct kthr *kgdb_thr_first(void);
61132624Smarcelstruct kthr *kgdb_thr_init(void);
62142151Skanstruct kthr *kgdb_thr_lookup_tid(int);
63142151Skanstruct kthr *kgdb_thr_lookup_pid(int);
64142151Skanstruct kthr *kgdb_thr_lookup_paddr(uintptr_t);
65142151Skanstruct kthr *kgdb_thr_lookup_taddr(uintptr_t);
66132624Smarcelstruct kthr *kgdb_thr_next(struct kthr *);
67132624Smarcelstruct kthr *kgdb_thr_select(struct kthr *);
68142151Skanchar        *kgdb_thr_extra_thread_info(int);
69132624Smarcel
70210852SjhbCORE_ADDR kgdb_lookup(const char *sym);
71178670SjhbCORE_ADDR kgdb_parse_1(const char *, int);
72167142Skib
73178670Sjhb#define	kgdb_parse(exp)		kgdb_parse_1((exp), 0)
74178670Sjhb#define	kgdb_parse_quiet(exp)	kgdb_parse_1((exp), 1)
75178670Sjhb
76132624Smarcel#endif /* _KGDB_H_ */
77