summaryrefslogtreecommitdiff
path: root/usr.bin/pmdb
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-03-29 00:03:01 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-03-29 00:03:01 +0000
commit2a22a9fbaac80d0b016349d295d3d15ae42cfd30 (patch)
treea68e60b5aec35d2997be9af3e19441cc05c37fb8 /usr.bin/pmdb
parent49bd19dbd2e547c87d083c64cf4998afcb72f3cb (diff)
implement memory examine command. takes both symbol or address
Diffstat (limited to 'usr.bin/pmdb')
-rw-r--r--usr.bin/pmdb/pmdb.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/usr.bin/pmdb/pmdb.c b/usr.bin/pmdb/pmdb.c
index 3c1d6b70286..3f46697dc3f 100644
--- a/usr.bin/pmdb/pmdb.c
+++ b/usr.bin/pmdb/pmdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmdb.c,v 1.13 2003/03/28 23:33:27 mickey Exp $ */
+/* $OpenBSD: pmdb.c,v 1.14 2003/03/29 00:03:00 mickey Exp $ */
/*
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
* All rights reserved.
@@ -45,12 +45,14 @@
static int cmd_show_registers(int, char **, void *);
static int cmd_show_backtrace(int, char **, void *);
+static int cmd_examine(int, char **, void *);
static int cmd_quit(int, char **, void *);
struct clit cmds[] = {
/* debugging info commands. */
{ "regs", "show registers", 0, 0, cmd_show_registers, (void *)-1 },
{ "trace", "show backtrace", 0, 0, cmd_show_backtrace, (void *)-1 },
+ { "x", "examine memory", 1, 16, cmd_examine, (void *)-1 },
/* Process handling commands. */
{ "run", "run process", 0, 0, cmd_process_run, (void *)-1 },
@@ -332,6 +334,36 @@ cmd_quit(int argc, char **argv, void *arg)
return (1);
}
+static int
+cmd_examine(int argc, char **argv, void *arg)
+{
+ struct pstate *ps = arg;
+ char buf[256];
+ reg addr, val;
+ int i;
+
+ for (i = 1; argv[i]; i++) {
+
+ addr = strtoul(argv[i], NULL, 0);
+ if (!addr) { /* assume it's a symbol */
+ if (sym_lookup(ps, argv[i], &addr)) {
+ warn( "Can't find: %s", argv[i]);
+ return (0);
+ }
+ }
+
+ if (process_read(ps, addr, &val, sizeof(val))) {
+ warn("Can't read process contents at 0x%lx", addr);
+ return (0);
+ }
+
+ printf("%s:\t%s\n", argv[i],
+ sym_print(ps, val, buf, sizeof(buf)));
+ }
+
+ return (0);
+}
+
/*
* Perform command completion.
* Pretty simple. if there are spaces in "buf", the last string is a symbol