diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/pmdb/pmdb.c | 34 |
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 |