RFA: fix macro expansion bug
Tom Tromey
tromey@redhat.com
Thu Dec 11 23:41:00 GMT 2008
>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
>> +gdb_test "macro expand siginfo.si_addr" \
>> + "expands to: siginfo. fields.fault.si_addr" \
Pedro> Just curious, as it's just a visual annoyance: do you know where
Pedro> this space comes from? Do we store the definition with the space for
Pedro> some reason? We don't get that extra space if the define came
Pedro> from the code, instead of from a 'macro define'.
Here's a patch to fix it.
This requires a minor tweak to the previous patch's test case, but
otherwise nothing.
As with the previous, I'm sending this through the regression tester,
but I don't expect problems. Ok if it passes?
Tom
2008-12-11 Tom Tromey <tromey@redhat.com>
* macrocmd.c (macro_define_command): Skip whitespace after
macro name.
(print_one_macro): Print space after macro name.
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 56e9a48..fa639d1 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -315,13 +315,17 @@ macro_define_command (char *exp, int from_tty)
}
/* Skip the closing paren. */
++exp;
+ skip_ws (&exp);
macro_define_function (macro_main (macro_user_macros), -1, name,
new_macro.argc, (const char **) new_macro.argv,
exp);
}
else
- macro_define_object (macro_main (macro_user_macros), -1, name, exp);
+ {
+ skip_ws (&exp);
+ macro_define_object (macro_main (macro_user_macros), -1, name, exp);
+ }
do_cleanups (cleanup_chain);
}
@@ -358,9 +362,7 @@ print_one_macro (const char *name, const struct macro_definition *macro,
macro->argv[i]);
fprintf_filtered (gdb_stdout, ")");
}
- /* Note that we don't need a leading space here -- "macro define"
- provided it. */
- fprintf_filtered (gdb_stdout, "%s\n", macro->replacement);
+ fprintf_filtered (gdb_stdout, " %s\n", macro->replacement);
}
More information about the Gdb-patches
mailing list