source: trunk/minix/commands/mdb/trace.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 895 bytes
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 */
14PUBLIC long mdbtrace(req, pid, addr, data)
15int req, pid;
16long 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 */
46PUBLIC u32_t peek_dword(addr)
47off_t addr;
48{
49 return mdbtrace(T_GETINS, curpid, addr, 0L);
50}
51
Note: See TracBrowser for help on using the repository browser.