From 36cc36a0ec0c1918dad9e6f15be4de1e565889be Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sat, 29 Mar 2008 17:46:03 +0000 Subject: [PATCH] Change kgdb_parse() to use wrapped versions of parse_expression() and evaluate_expression() so that any errors are caught and cause the function to return to 0. Otherwise the errors posted an exception (via longjmp()) that aborted the current operation. This fixes the kld handling for older kernels (6.x and 7.x) that don't have the full pathname stored in the kernel linker. MFC after: 3 days --- gnu/usr.bin/gdb/kgdb/main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gnu/usr.bin/gdb/kgdb/main.c b/gnu/usr.bin/gdb/kgdb/main.c index 5e1c9c6b268..77627630af0 100644 --- a/gnu/usr.bin/gdb/kgdb/main.c +++ b/gnu/usr.bin/gdb/kgdb/main.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include extern void (*init_ui_hook)(char *); @@ -188,13 +189,15 @@ kgdb_parse(const char *exp) char *s; CORE_ADDR n; - s = strdup(exp); - old_chain = make_cleanup(free_current_contents, &expr); - expr = parse_expression(s); - val = (expr != NULL) ? evaluate_expression(expr) : NULL; - n = (val != NULL) ? value_as_address(val) : 0; + n = 0; + s = xstrdup(exp); + old_chain = make_cleanup(xfree, s); + if (gdb_parse_exp_1(&s, NULL, 0, &expr) && *s == '\0') { + make_cleanup(free_current_contents, &expr); + if (gdb_evaluate_expression(expr, &val)) + n = value_as_address(val); + } do_cleanups(old_chain); - free(s); return (n); }