Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/common/mdb/mdb_target.h
+++ new/usr/src/cmd/mdb/common/mdb/mdb_target.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 + *
26 + * Copyright 2018 Joyent, Inc.
25 27 */
26 28
27 29 #ifndef _MDB_TARGET_H
28 30 #define _MDB_TARGET_H
29 31
30 32 #include <sys/utsname.h>
31 33 #include <sys/types.h>
32 34 #include <gelf.h>
33 35
34 36 #ifdef __cplusplus
35 37 extern "C" {
36 38 #endif
37 39
38 40 /*
39 41 * Forward declaration of the target structure: the target itself is defined in
40 42 * mdb_tgt_impl.h and is opaque with respect to callers of this interface.
41 43 */
42 44
43 45 struct mdb_tgt;
44 46 struct mdb_arg;
45 47 struct ctf_file;
46 48
47 49 typedef struct mdb_tgt mdb_tgt_t;
48 50
49 51 extern void mdb_create_builtin_tgts(void);
50 52 extern void mdb_create_loadable_disasms(void);
51 53
52 54 /*
53 55 * Target Constructors
54 56 *
55 57 * These functions are used to create a complete debugger target. The
56 58 * constructor is passed as an argument to mdb_tgt_create().
57 59 */
58 60
59 61 extern int mdb_value_tgt_create(mdb_tgt_t *, int, const char *[]);
60 62 #ifndef _KMDB
61 63 extern int mdb_kvm_tgt_create(mdb_tgt_t *, int, const char *[]);
62 64 extern int mdb_proc_tgt_create(mdb_tgt_t *, int, const char *[]);
63 65 extern int mdb_kproc_tgt_create(mdb_tgt_t *, int, const char *[]);
64 66 extern int mdb_rawfile_tgt_create(mdb_tgt_t *, int, const char *[]);
65 67 #else
66 68 extern int kmdb_kvm_create(mdb_tgt_t *, int, const char *[]);
67 69 #endif
68 70
69 71 /*
70 72 * Targets are created by calling mdb_tgt_create() with an optional set of
71 73 * target flags, an argument list, and a target constructor (see above):
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
72 74 */
73 75
74 76 #define MDB_TGT_F_RDWR 0x0001 /* Open for writing (else read-only) */
75 77 #define MDB_TGT_F_ALLOWIO 0x0002 /* Allow I/O mem access (live only) */
76 78 #define MDB_TGT_F_FORCE 0x0004 /* Force open (even if non-exclusive) */
77 79 #define MDB_TGT_F_PRELOAD 0x0008 /* Preload all symbol tables */
78 80 #define MDB_TGT_F_NOLOAD 0x0010 /* Do not do load-object processing */
79 81 #define MDB_TGT_F_NOSTOP 0x0020 /* Do not stop target on attach */
80 82 #define MDB_TGT_F_STEP 0x0040 /* Single-step is pending */
81 83 #define MDB_TGT_F_STEP_OUT 0x0080 /* Step-out is pending */
82 -#define MDB_TGT_F_STEP_BRANCH 0x0100 /* Step-branch is pending */
83 -#define MDB_TGT_F_NEXT 0x0200 /* Step-over is pending */
84 -#define MDB_TGT_F_CONT 0x0400 /* Continue is pending */
85 -#define MDB_TGT_F_BUSY 0x0800 /* Target is busy executing */
86 -#define MDB_TGT_F_ASIO 0x1000 /* Use t_aread and t_awrite for i/o */
87 -#define MDB_TGT_F_UNLOAD 0x2000 /* Unload has been requested */
88 -#define MDB_TGT_F_ALL 0x3fff /* Mask of all valid flags */
84 +#define MDB_TGT_F_NEXT 0x0100 /* Step-over is pending */
85 +#define MDB_TGT_F_CONT 0x0200 /* Continue is pending */
86 +#define MDB_TGT_F_BUSY 0x0400 /* Target is busy executing */
87 +#define MDB_TGT_F_ASIO 0x0800 /* Use t_aread and t_awrite for i/o */
88 +#define MDB_TGT_F_UNLOAD 0x1000 /* Unload has been requested */
89 +#define MDB_TGT_F_ALL 0x1fff /* Mask of all valid flags */
89 90
90 91 typedef int mdb_tgt_ctor_f(mdb_tgt_t *, int, const char *[]);
91 92
92 93 extern mdb_tgt_t *mdb_tgt_create(mdb_tgt_ctor_f *, int, int, const char *[]);
93 94 extern void mdb_tgt_destroy(mdb_tgt_t *);
94 95
95 96 extern int mdb_tgt_getflags(mdb_tgt_t *);
96 97 extern int mdb_tgt_setflags(mdb_tgt_t *, int);
97 98 extern int mdb_tgt_setcontext(mdb_tgt_t *, void *);
98 99
99 100 /*
100 101 * Targets are activated and de-activated by the debugger framework. An
101 102 * activation occurs after construction when the target becomes the current
102 103 * target in the debugger. A target is de-activated prior to its destructor
103 104 * being called by mdb_tgt_destroy, or when another target is activated.
104 105 * These callbacks are suitable for loading support modules and other tasks.
105 106 */
106 107 extern void mdb_tgt_activate(mdb_tgt_t *);
107 108
108 109 /*
109 110 * Prior to issuing a new command prompt, the debugger framework calls the
110 111 * target's periodic callback to allow it to load new modules or perform
111 112 * other background tasks.
112 113 */
113 114 extern void mdb_tgt_periodic(mdb_tgt_t *);
114 115
115 116 /*
116 117 * Convenience functions for accessing miscellaneous target information.
117 118 */
118 119 extern const char *mdb_tgt_name(mdb_tgt_t *);
119 120 extern const char *mdb_tgt_isa(mdb_tgt_t *);
120 121 extern const char *mdb_tgt_platform(mdb_tgt_t *);
121 122 extern int mdb_tgt_uname(mdb_tgt_t *, struct utsname *);
122 123 extern int mdb_tgt_dmodel(mdb_tgt_t *);
123 124
124 125 /*
125 126 * Address Space Interface
126 127 *
127 128 * Each target can provide access to a set of address spaces, which may include
128 129 * a primary virtual address space, a physical address space, an object file
129 130 * address space (where virtual addresses are converted to file offsets in an
130 131 * object file), and an I/O port address space. Additionally, the target can
131 132 * provide access to alternate address spaces, which are identified by the
132 133 * opaque mdb_tgt_as_t type. If the 'as' parameter to mdb_tgt_aread or
133 134 * mdb_tgt_awrite is one of the listed constants, these calls are equivalent
134 135 * to mdb_tgt_{v|p|f|io}read or write.
135 136 */
136 137
137 138 typedef void * mdb_tgt_as_t; /* Opaque address space id */
138 139 typedef uint64_t mdb_tgt_addr_t; /* Generic unsigned address */
139 140 typedef uint64_t physaddr_t; /* Physical memory address */
140 141
141 142 #define MDB_TGT_AS_VIRT ((mdb_tgt_as_t)-1L) /* Virtual address space */
142 143 #define MDB_TGT_AS_PHYS ((mdb_tgt_as_t)-2L) /* Physical address space */
143 144 #define MDB_TGT_AS_FILE ((mdb_tgt_as_t)-3L) /* Object file address space */
144 145 #define MDB_TGT_AS_IO ((mdb_tgt_as_t)-4L) /* I/o address space */
145 146
146 147 extern ssize_t mdb_tgt_aread(mdb_tgt_t *, mdb_tgt_as_t,
147 148 void *, size_t, mdb_tgt_addr_t);
148 149
149 150 extern ssize_t mdb_tgt_awrite(mdb_tgt_t *, mdb_tgt_as_t,
150 151 const void *, size_t, mdb_tgt_addr_t);
151 152
152 153 extern ssize_t mdb_tgt_vread(mdb_tgt_t *, void *, size_t, uintptr_t);
153 154 extern ssize_t mdb_tgt_vwrite(mdb_tgt_t *, const void *, size_t, uintptr_t);
154 155 extern ssize_t mdb_tgt_pread(mdb_tgt_t *, void *, size_t, physaddr_t);
155 156 extern ssize_t mdb_tgt_pwrite(mdb_tgt_t *, const void *, size_t, physaddr_t);
156 157 extern ssize_t mdb_tgt_fread(mdb_tgt_t *, void *, size_t, uintptr_t);
157 158 extern ssize_t mdb_tgt_fwrite(mdb_tgt_t *, const void *, size_t, uintptr_t);
158 159 extern ssize_t mdb_tgt_ioread(mdb_tgt_t *, void *, size_t, uintptr_t);
159 160 extern ssize_t mdb_tgt_iowrite(mdb_tgt_t *, const void *, size_t, uintptr_t);
160 161
161 162 /*
162 163 * Convert an address-space's virtual address to the corresponding
163 164 * physical address (only useful for kernel targets):
164 165 */
165 166 extern int mdb_tgt_vtop(mdb_tgt_t *, mdb_tgt_as_t, uintptr_t, physaddr_t *);
166 167
167 168 /*
168 169 * Convenience functions for reading and writing null-terminated
169 170 * strings from any of the target address spaces:
170 171 */
171 172 extern ssize_t mdb_tgt_readstr(mdb_tgt_t *, mdb_tgt_as_t,
172 173 char *, size_t, mdb_tgt_addr_t);
173 174
174 175 extern ssize_t mdb_tgt_writestr(mdb_tgt_t *, mdb_tgt_as_t,
175 176 const char *, mdb_tgt_addr_t);
176 177
177 178 /*
178 179 * Symbol Table Interface
179 180 *
180 181 * Each target can provide access to one or more symbol tables, which can be
181 182 * iterated over, or used to lookup symbols by either name or address. The
182 183 * target can support a primary executable and primary dynamic symbol table,
183 184 * a symbol table for its run-time link-editor, and symbol tables for one or
184 185 * more loaded objects. A symbol is uniquely identified by an object name,
185 186 * a symbol table id, and a symbol id. Symbols can be discovered by iterating
186 187 * over them, looking them up by name, or looking them up by address.
187 188 */
188 189
189 190 typedef struct mdb_syminfo {
190 191 uint_t sym_table; /* Symbol table id (see symbol_iter, below) */
191 192 uint_t sym_id; /* Symbol identifier */
192 193 } mdb_syminfo_t;
193 194
194 195 /*
195 196 * Reserved object names for mdb_tgt_lookup_by_name():
196 197 */
197 198 #define MDB_TGT_OBJ_EXEC ((const char *)0L) /* Executable symbols */
198 199 #define MDB_TGT_OBJ_RTLD ((const char *)1L) /* Ldso/krtld symbols */
199 200 #define MDB_TGT_OBJ_EVERY ((const char *)-1L) /* All known symbols */
200 201
201 202 extern int mdb_tgt_lookup_by_scope(mdb_tgt_t *, const char *,
202 203 GElf_Sym *, mdb_syminfo_t *);
203 204
204 205 extern int mdb_tgt_lookup_by_name(mdb_tgt_t *, const char *,
205 206 const char *, GElf_Sym *, mdb_syminfo_t *);
206 207
207 208 /*
208 209 * Flag bit passed to mdb_tgt_lookup_by_addr():
209 210 */
210 211 #define MDB_TGT_SYM_FUZZY 0 /* Match closest address */
211 212 #define MDB_TGT_SYM_EXACT 1 /* Match exact address only */
212 213
213 214 #define MDB_TGT_SYM_NAMLEN 1024 /* Recommended max symbol name length */
214 215
215 216 extern int mdb_tgt_lookup_by_addr(mdb_tgt_t *, uintptr_t, uint_t,
216 217 char *, size_t, GElf_Sym *, mdb_syminfo_t *);
217 218
218 219 /*
219 220 * Callback function prototype for mdb_tgt_symbol_iter():
220 221 */
221 222 typedef int mdb_tgt_sym_f(void *, const GElf_Sym *, const char *,
222 223 const mdb_syminfo_t *sip, const char *);
223 224
224 225 /*
225 226 * Values for selecting symbol tables with mdb_tgt_symbol_iter():
226 227 */
227 228 #define MDB_TGT_PRVSYM 0 /* User's private symbol table */
228 229 #define MDB_TGT_SYMTAB 1 /* Normal symbol table (.symtab) */
229 230 #define MDB_TGT_DYNSYM 2 /* Dynamic symbol table (.dynsym) */
230 231
231 232 /*
232 233 * Values for selecting symbols of interest by binding and type. These flags
233 234 * can be used to construct a bitmask to pass to mdb_tgt_symbol_iter(). The
234 235 * module API has its own slightly different names for these values. If you are
235 236 * adding a new flag here, you should consider exposing it in the module API.
236 237 * If you are changing these flags and their meanings, you will need to update
237 238 * the module API implementation to account for those changes.
238 239 */
239 240 #define MDB_TGT_BIND_LOCAL 0x0001 /* Local (static-scope) symbols */
240 241 #define MDB_TGT_BIND_GLOBAL 0x0002 /* Global symbols */
241 242 #define MDB_TGT_BIND_WEAK 0x0004 /* Weak binding symbols */
242 243
243 244 #define MDB_TGT_BIND_ANY 0x0007 /* Any of the above */
244 245
245 246 #define MDB_TGT_TYPE_NOTYPE 0x0100 /* Symbol has no type */
246 247 #define MDB_TGT_TYPE_OBJECT 0x0200 /* Symbol refers to data */
247 248 #define MDB_TGT_TYPE_FUNC 0x0400 /* Symbol refers to text */
248 249 #define MDB_TGT_TYPE_SECT 0x0800 /* Symbol refers to a section */
249 250 #define MDB_TGT_TYPE_FILE 0x1000 /* Symbol refers to a source file */
250 251 #define MDB_TGT_TYPE_COMMON 0x2000 /* Symbol refers to a common block */
251 252 #define MDB_TGT_TYPE_TLS 0x4000 /* Symbol refers to TLS */
252 253
253 254 #define MDB_TGT_TYPE_ANY 0x7f00 /* Any of the above */
254 255
255 256 extern int mdb_tgt_symbol_iter(mdb_tgt_t *, const char *, uint_t, uint_t,
256 257 mdb_tgt_sym_f *, void *);
257 258
258 259 /*
259 260 * Convenience functions for reading and writing at the address specified
260 261 * by a given object file and symbol name:
261 262 */
262 263 extern ssize_t mdb_tgt_readsym(mdb_tgt_t *, mdb_tgt_as_t, void *, size_t,
263 264 const char *, const char *);
264 265
265 266 extern ssize_t mdb_tgt_writesym(mdb_tgt_t *, mdb_tgt_as_t, const void *, size_t,
266 267 const char *, const char *);
267 268
268 269 /*
269 270 * Virtual Address Mapping and Load Object interface
270 271 *
271 272 * These interfaces allow the caller to iterate over the various virtual
272 273 * address space mappings, or only those mappings corresponding to load objects.
273 274 * The mapping name (MDB_TGT_MAPSZ) is defined to be large enough for a string
274 275 * of length MAXPATHLEN, plus space for "LM`<lmid>" where lmid is a hex number.
275 276 */
276 277
277 278 #define MDB_TGT_MAPSZ 1048 /* Maximum length of mapping name */
278 279
279 280 #define MDB_TGT_MAP_R 0x01 /* Mapping is readable */
280 281 #define MDB_TGT_MAP_W 0x02 /* Mapping is writeable */
281 282 #define MDB_TGT_MAP_X 0x04 /* Mapping is executable */
282 283 #define MDB_TGT_MAP_SHMEM 0x08 /* Mapping is shared memory */
283 284 #define MDB_TGT_MAP_STACK 0x10 /* Mapping is a stack of some kind */
284 285 #define MDB_TGT_MAP_HEAP 0x20 /* Mapping is a heap of some kind */
285 286 #define MDB_TGT_MAP_ANON 0x40 /* Mapping is anonymous memory */
286 287
287 288 typedef struct mdb_map {
288 289 char map_name[MDB_TGT_MAPSZ]; /* Name of mapped object */
289 290 uintptr_t map_base; /* Virtual address of base of mapping */
290 291 size_t map_size; /* Size of mapping in bytes */
291 292 uint_t map_flags; /* Flags (see above) */
292 293 } mdb_map_t;
293 294
294 295 typedef int mdb_tgt_map_f(void *, const mdb_map_t *, const char *);
295 296
296 297 extern int mdb_tgt_mapping_iter(mdb_tgt_t *, mdb_tgt_map_f *, void *);
297 298 extern int mdb_tgt_object_iter(mdb_tgt_t *, mdb_tgt_map_f *, void *);
298 299
299 300 extern const mdb_map_t *mdb_tgt_addr_to_map(mdb_tgt_t *, uintptr_t);
300 301 extern const mdb_map_t *mdb_tgt_name_to_map(mdb_tgt_t *, const char *);
301 302
302 303 extern struct ctf_file *mdb_tgt_addr_to_ctf(mdb_tgt_t *, uintptr_t);
303 304 extern struct ctf_file *mdb_tgt_name_to_ctf(mdb_tgt_t *, const char *);
304 305
305 306 /*
306 307 * Execution Control Interface
307 308 *
308 309 * For in-situ debugging, we provide a relatively simple interface for target
309 310 * execution control. The target can be continued, or the representative
310 311 * thread of control can be single-stepped. Once the target has stopped, the
311 312 * status of the representative thread is returned (this status can also be
312 313 * obtained using mdb_tgt_status()). Upon continue, the target's internal list
313 314 * of software event specifiers determines what types of events will cause the
314 315 * target to stop and transfer control back to the debugger. The target
315 316 * allows any number of virtual event specifiers to be registered, along with
316 317 * an associated callback. These virtual specifiers are layered on top of
317 318 * underlying software event specifiers that are private to the target. The
318 319 * virtual event specifier list can be manipulated by the functions described
319 320 * below. We currently support the following types of traced events:
320 321 * breakpoints, watchpoints, system call entry, system call exit, signals,
321 322 * and machine faults.
322 323 */
323 324
324 325 typedef uintptr_t mdb_tgt_tid_t; /* Opaque thread identifier */
325 326
326 327 typedef struct mdb_tgt_status {
327 328 mdb_tgt_tid_t st_tid; /* Id of thread in question */
328 329 uintptr_t st_pc; /* Program counter, if stopped */
329 330 uint_t st_state; /* Program state (see below) */
330 331 uint_t st_flags; /* Status flags (see below) */
331 332 } mdb_tgt_status_t;
332 333
333 334 /*
334 335 * Program state (st_state):
335 336 * (MDB_STATE_* definitions in the module API need to be in sync with these)
336 337 */
337 338 #define MDB_TGT_IDLE 0 /* Target is idle (not running yet) */
338 339 #define MDB_TGT_RUNNING 1 /* Target is currently executing */
339 340 #define MDB_TGT_STOPPED 2 /* Target is stopped */
340 341 #define MDB_TGT_UNDEAD 3 /* Target is undead (zombie) */
341 342 #define MDB_TGT_DEAD 4 /* Target is dead (core dump) */
342 343 #define MDB_TGT_LOST 5 /* Target lost by debugger */
343 344
344 345 /*
↓ open down ↓ |
246 lines elided |
↑ open up ↑ |
345 346 * Status flags (st_flags):
346 347 */
347 348 #define MDB_TGT_ISTOP 0x1 /* Stop on event of interest */
348 349 #define MDB_TGT_DSTOP 0x2 /* Stop directive is pending */
349 350 #define MDB_TGT_BUSY 0x4 /* Busy in debugger */
350 351
351 352 extern int mdb_tgt_status(mdb_tgt_t *, mdb_tgt_status_t *);
352 353 extern int mdb_tgt_run(mdb_tgt_t *, int, const struct mdb_arg *);
353 354 extern int mdb_tgt_step(mdb_tgt_t *, mdb_tgt_status_t *);
354 355 extern int mdb_tgt_step_out(mdb_tgt_t *, mdb_tgt_status_t *);
355 -extern int mdb_tgt_step_branch(mdb_tgt_t *, mdb_tgt_status_t *);
356 356 extern int mdb_tgt_next(mdb_tgt_t *, mdb_tgt_status_t *);
357 357 extern int mdb_tgt_continue(mdb_tgt_t *, mdb_tgt_status_t *);
358 358 extern int mdb_tgt_signal(mdb_tgt_t *, int);
359 359
360 360 /*
361 361 * Iterating through the specifier list yields the integer id (VID) and private
362 362 * data pointer for each specifier.
363 363 */
364 364 typedef int mdb_tgt_vespec_f(mdb_tgt_t *, void *, int, void *);
365 365
366 366 /*
367 367 * Each event specifier is defined to be in one of the following states. The
368 368 * state transitions are discussed in detail in the comments in mdb_target.c.
369 369 */
370 370 #define MDB_TGT_SPEC_IDLE 1 /* Inactive (e.g. object not loaded) */
371 371 #define MDB_TGT_SPEC_ACTIVE 2 /* Active but not armed in target */
372 372 #define MDB_TGT_SPEC_ARMED 3 /* Active and armed (e.g. bkpt set) */
373 373 #define MDB_TGT_SPEC_ERROR 4 /* Failed to arm event */
374 374
375 375 /*
376 376 * Event specifiers may also have one or more of the following additional
377 377 * properties (spec_flags bits):
378 378 */
379 379 #define MDB_TGT_SPEC_INTERNAL 0x0001 /* Internal to target implementation */
380 380 #define MDB_TGT_SPEC_SILENT 0x0002 /* Do not describe when matched */
381 381 #define MDB_TGT_SPEC_TEMPORARY 0x0004 /* Delete next time target stops */
382 382 #define MDB_TGT_SPEC_MATCHED 0x0008 /* Specifier matched at last stop */
383 383 #define MDB_TGT_SPEC_DISABLED 0x0010 /* Specifier cannot be armed */
384 384 #define MDB_TGT_SPEC_DELETED 0x0020 /* Specifier has been deleted */
385 385 #define MDB_TGT_SPEC_AUTODEL 0x0040 /* Delete when match limit reached */
386 386 #define MDB_TGT_SPEC_AUTODIS 0x0080 /* Disable when match limit reached */
387 387 #define MDB_TGT_SPEC_AUTOSTOP 0x0100 /* Stop when match limit reached */
388 388 #define MDB_TGT_SPEC_STICKY 0x0200 /* Do not delete as part of :z */
389 389
390 390 #define MDB_TGT_SPEC_HIDDEN (MDB_TGT_SPEC_INTERNAL | MDB_TGT_SPEC_SILENT)
391 391
392 392 typedef struct mdb_tgt_spec_desc {
393 393 int spec_id; /* Event specifier id (VID) */
394 394 uint_t spec_flags; /* Flags (see above) */
395 395 uint_t spec_hits; /* Count of number of times matched */
396 396 uint_t spec_limit; /* Limit on number of times matched */
397 397 int spec_state; /* State (see above) */
398 398 int spec_errno; /* Last error code (if IDLE or ERROR) */
399 399 uintptr_t spec_base; /* Start of affected memory region */
400 400 size_t spec_size; /* Size of affected memory region */
401 401 void *spec_data; /* Callback private data */
402 402 } mdb_tgt_spec_desc_t;
403 403
404 404 /*
405 405 * The target provides functions to convert a VID into the private data pointer,
406 406 * or a complete description of the event specifier and its state.
407 407 */
408 408 extern void *mdb_tgt_vespec_data(mdb_tgt_t *, int);
409 409 extern char *mdb_tgt_vespec_info(mdb_tgt_t *, int,
410 410 mdb_tgt_spec_desc_t *, char *, size_t);
411 411
412 412 /*
413 413 * The common target layer provides functions to iterate over the list of
414 414 * registered event specifiers, modify or disable them, and delete them.
415 415 */
416 416 extern int mdb_tgt_vespec_iter(mdb_tgt_t *, mdb_tgt_vespec_f *, void *);
417 417 extern int mdb_tgt_vespec_modify(mdb_tgt_t *, int, uint_t, uint_t, void *);
418 418 extern int mdb_tgt_vespec_enable(mdb_tgt_t *, int);
419 419 extern int mdb_tgt_vespec_disable(mdb_tgt_t *, int);
420 420 extern int mdb_tgt_vespec_delete(mdb_tgt_t *, int);
421 421
422 422 /*
423 423 * The mdb_tgt_add_* functions are used to add software event specifiers to the
424 424 * target. The caller provides a bitmask of flags (spec_flags above), callback
425 425 * function pointer, and callback data as arguments. Whenever a matching event
426 426 * is detected, a software event callback function is invoked. The callback
427 427 * receives a pointer to the target, the VID of the corresponding event
428 428 * specifier, and a private data pointer as arguments. If no callback is
429 429 * desired, the caller can specify a pointer to the no_se_f default callback.
430 430 * Unlike other target layer functions, the mdb_tgt_add_* interfaces return the
431 431 * VID of the new event (which may be positive or negative), or 0 if the new
432 432 * event could not be created.
433 433 */
434 434 typedef void mdb_tgt_se_f(mdb_tgt_t *, int, void *);
435 435 extern void no_se_f(mdb_tgt_t *, int, void *);
436 436
437 437 /*
438 438 * Breakpoints can be set at a specified virtual address or using MDB's
439 439 * symbol notation:
440 440 */
441 441 extern int mdb_tgt_add_vbrkpt(mdb_tgt_t *, uintptr_t,
442 442 int, mdb_tgt_se_f *, void *);
443 443
444 444 extern int mdb_tgt_add_sbrkpt(mdb_tgt_t *, const char *,
445 445 int, mdb_tgt_se_f *, void *);
446 446
447 447 /*
448 448 * Watchpoints can be set at physical, virtual, or I/O port addresses for any
449 449 * combination of read, write, or execute operations.
450 450 */
451 451 #define MDB_TGT_WA_R 0x1 /* Read watchpoint */
452 452 #define MDB_TGT_WA_W 0x2 /* Write watchpoint */
453 453 #define MDB_TGT_WA_X 0x4 /* Execute watchpoint */
454 454
455 455 #define MDB_TGT_WA_RWX (MDB_TGT_WA_R | MDB_TGT_WA_W | MDB_TGT_WA_X)
456 456
457 457 extern int mdb_tgt_add_pwapt(mdb_tgt_t *, physaddr_t, size_t, uint_t,
458 458 int, mdb_tgt_se_f *, void *);
459 459
460 460 extern int mdb_tgt_add_vwapt(mdb_tgt_t *, uintptr_t, size_t, uint_t,
461 461 int, mdb_tgt_se_f *, void *);
462 462
463 463 extern int mdb_tgt_add_iowapt(mdb_tgt_t *, uintptr_t, size_t, uint_t,
464 464 int, mdb_tgt_se_f *, void *);
465 465
466 466 /*
467 467 * For user process debugging, tracepoints can be set on entry or exit from
468 468 * a system call, or on receipt of a software signal or fault.
469 469 */
470 470 extern int mdb_tgt_add_sysenter(mdb_tgt_t *, int, int, mdb_tgt_se_f *, void *);
471 471 extern int mdb_tgt_add_sysexit(mdb_tgt_t *, int, int, mdb_tgt_se_f *, void *);
472 472 extern int mdb_tgt_add_signal(mdb_tgt_t *, int, int, mdb_tgt_se_f *, void *);
473 473 extern int mdb_tgt_add_fault(mdb_tgt_t *, int, int, mdb_tgt_se_f *, void *);
474 474
475 475 /*
476 476 * Machine Register Interface
477 477 *
478 478 * The machine registers for a given thread can be manipulated using the
479 479 * getareg and putareg interface; the caller must know the naming convention
480 480 * for registers for the given target architecture. For the purposes of
481 481 * this interface, we declare the register container to be the largest
482 482 * current integer container.
483 483 */
484 484
485 485 typedef uint64_t mdb_tgt_reg_t;
486 486
487 487 extern int mdb_tgt_getareg(mdb_tgt_t *, mdb_tgt_tid_t,
488 488 const char *, mdb_tgt_reg_t *);
489 489
490 490 extern int mdb_tgt_putareg(mdb_tgt_t *, mdb_tgt_tid_t,
491 491 const char *, mdb_tgt_reg_t);
492 492
493 493 /*
494 494 * Stack Interface
495 495 *
496 496 * The target stack interface provides the ability to iterate backward through
497 497 * the frames of an execution stack. For the purposes of this interface, the
498 498 * mdb_tgt_gregset (general purpose register set) is an opaque type: there must
499 499 * be an implicit contract between the target implementation and any debugger
500 500 * modules that must interpret the contents of this structure. The callback
501 501 * function is provided with the only elements of a stack frame which we can
502 502 * reasonably abstract: the virtual address corresponding to a program counter
503 503 * value, and an array of arguments passed to the function call represented by
504 504 * this frame. The rest of the frame is presumed to be contained within the
505 505 * mdb_tgt_gregset_t, and is architecture-specific.
506 506 */
507 507
508 508 typedef struct mdb_tgt_gregset mdb_tgt_gregset_t;
509 509
510 510 typedef int mdb_tgt_stack_f(void *, uintptr_t, uint_t, const long *,
511 511 const mdb_tgt_gregset_t *);
512 512 typedef int mdb_tgt_stack_iter_f(mdb_tgt_t *, const mdb_tgt_gregset_t *,
513 513 mdb_tgt_stack_f *, void *);
514 514
515 515 extern mdb_tgt_stack_iter_f mdb_tgt_stack_iter;
516 516
517 517 /*
518 518 * External Data Interface
519 519 *
520 520 * The external data interface provides each target with the ability to export
521 521 * a set of named buffers that contain data which is associated with the
522 522 * target, but is somehow not accessible through one of its address spaces and
523 523 * does not correspond to a machine register. A process credential is an
524 524 * example of such a buffer: the credential is associated with the given
525 525 * process, but is stored in the kernel (not the process's address space) and
526 526 * thus is not accessible through any other target interface. Since it is
527 527 * exported via /proc, the user process target can export this information as a
528 528 * named buffer for target-specific dcmds to consume.
529 529 */
530 530
531 531 typedef int mdb_tgt_xdata_f(void *, const char *, const char *, size_t);
532 532
533 533 extern int mdb_tgt_xdata_iter(mdb_tgt_t *, mdb_tgt_xdata_f *, void *);
534 534 extern ssize_t mdb_tgt_getxdata(mdb_tgt_t *, const char *, void *, size_t);
535 535
536 536 #ifdef __cplusplus
537 537 }
538 538 #endif
539 539
540 540 #endif /* _MDB_TARGET_H */
↓ open down ↓ |
175 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX