Line | |
---|
1 | /*
|
---|
2 | * trace.c for mdb
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "mdb.h"
|
---|
6 | #include <stdio.h>
|
---|
7 | #include <sys/ptrace.h>
|
---|
8 | #include "proto.h"
|
---|
9 |
|
---|
10 | /* mdbtrace()
|
---|
11 | * Call ptrace and check for error if debugging running process
|
---|
12 | * Otherwise read 'core' file
|
---|
13 | */
|
---|
14 | PUBLIC long mdbtrace(req, pid, addr, data)
|
---|
15 | int req, pid;
|
---|
16 | long addr, data;
|
---|
17 | {
|
---|
18 | long val;
|
---|
19 | int i;
|
---|
20 | int segment;
|
---|
21 |
|
---|
22 | #ifdef DEBUG
|
---|
23 | if (debug) Printf("ptrace: req=%d pid=%d addr=%lx data=%lx\n",
|
---|
24 | req, pid, addr, data);
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | if (corepid < 0)
|
---|
28 | {
|
---|
29 | errno = 0;
|
---|
30 | /* Call normal ptrace and check for error */
|
---|
31 | val = ptrace(req, pid, addr, data);
|
---|
32 | if (errno != 0) {
|
---|
33 | do_error("mdb ptrace error ");
|
---|
34 | mdb_error("\n");
|
---|
35 | }
|
---|
36 | #ifdef DEBUG
|
---|
37 | if (debug) Printf("ptrace: val=>%lx\n", val);
|
---|
38 | #endif
|
---|
39 | return val;
|
---|
40 | }
|
---|
41 | else
|
---|
42 | return read_core(req, addr, data);
|
---|
43 | }
|
---|
44 |
|
---|
45 | /* Used by disassembler */
|
---|
46 | PUBLIC u32_t peek_dword(addr)
|
---|
47 | off_t addr;
|
---|
48 | {
|
---|
49 | return mdbtrace(T_GETINS, curpid, addr, 0L);
|
---|
50 | }
|
---|
51 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.