aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdb.texinfo14
-rw-r--r--gdb/macrocmd.c10
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/macscp.exp18
6 files changed, 50 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5dd33b2..b9b24d1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * macrocmd.c (info_macro_command): Print -Dname=value if LINE is zero.
+
2009-04-27 Tom Tromey <tromey@redhat.com>
* c-exp.y (yylex): Handle '[' and ']' like '(' and ')'.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index b4d1ba8..2a0277d 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (Macros): Note command-line for `info macro'. Append
+ a new part on command-line defined macros.
+
2009-04-25 Eli Zaretskii <eliz@gnu.org>
* gdb.texinfo (Machine Code) <disassemble-next-line>: Improve and
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7ae9e1c..57bd084 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -8382,7 +8382,7 @@ can be any string of tokens.
@cindex definition, showing a macro's
@item info macro @var{macro}
Show the definition of the macro named @var{macro}, and describe the
-source location where that definition was established.
+source location or compiler command-line where that definition was established.
@kindex macro define
@cindex user-defined macros
@@ -8547,6 +8547,18 @@ $2 = 0
(@value{GDBP})
@end smallexample
+In addition to source files, macros can be defined on the compilation command
+line using the @option{-D@var{name}=@var{value}} syntax. For macros defined in
+such a way, @value{GDBN} displays the location of their definition as line zero
+of the source file submitted to the compiler.
+
+@smallexample
+(@value{GDBP}) info macro __STDC__
+Defined at /home/jimb/gdb/macros/play/sample.c:0
+-D__STDC__=1
+(@value{GDBP})
+@end smallexample
+
@node Tracepoints
@chapter Tracepoints
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 9d301e4..355efe0 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -158,7 +158,10 @@ info_macro_command (char *name, int from_tty)
fprintf_filtered (gdb_stdout, "Defined at ");
show_pp_source_pos (gdb_stdout, file, line);
- fprintf_filtered (gdb_stdout, "#define %s", name);
+ if (line != 0)
+ fprintf_filtered (gdb_stdout, "#define %s", name);
+ else
+ fprintf_filtered (gdb_stdout, "-D%s", name);
if (d->kind == macro_function_like)
{
int i;
@@ -172,7 +175,10 @@ info_macro_command (char *name, int from_tty)
}
fputs_filtered (")", gdb_stdout);
}
- fprintf_filtered (gdb_stdout, " %s\n", d->replacement);
+ if (line != 0)
+ fprintf_filtered (gdb_stdout, " %s\n", d->replacement);
+ else
+ fprintf_filtered (gdb_stdout, "=%s\n", d->replacement);
}
else
{
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 61aee21..11e4815 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-29 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/macscp.exp: New `options' parameter `-DFROM_COMMANDLINE'.
+ (info_macro): Remova `decimal' declaration. New variable `nonzero'.
+ Replace all uses of `decimal' by `nonzero'.
+ (info macro FROM_COMMANDLINE): New test.
+
2009-04-27 Tom Tromey <tromey@redhat.com>
* gdb.base/printcmds.exp (test_printf): Test comma operator in [].
diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
index 7086e90..351c0ec 100644
--- a/gdb/testsuite/gdb.base/macscp.exp
+++ b/gdb/testsuite/gdb.base/macscp.exp
@@ -26,7 +26,7 @@ set testfile "macscp"
set objfile ${objdir}/${subdir}/${testfile}.o
set binfile ${objdir}/${subdir}/${testfile}
-set options { debug }
+set options { debug additional_flags=-DFROM_COMMANDLINE=ARG}
get_compiler_info ${binfile}
if [test_compiler_info gcc*] {
@@ -67,19 +67,22 @@ gdb_load ${binfile}
proc info_macro {macro} {
global gdb_prompt
- global decimal
set filepat {macscp[0-9]+\.[ch]}
set definition {}
set location {}
+ # Line number zero is set for macros defined from the compiler command-line.
+ # Such macros are not being tested by this function.
+ set nonzero {[1-9][0-9]*}
+
send_gdb "info macro ${macro}\n"
set debug_me 0
if {$debug_me} {exp_internal 1}
gdb_expect {
- -re "Defined at \[^\r\n\]*(${filepat}):${decimal}\[\r\n\]" {
+ -re "Defined at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" {
# `location' and `definition' should be empty when we see
# this message.
if {[llength $location] == 0 && [llength $definition] == 0} {
@@ -101,7 +104,7 @@ proc info_macro {macro} {
set definition {}
}
}
- -re "^\[\r\n\]* included at \[^\r\n\]*(${filepat}):${decimal}\[\r\n\]" {
+ -re "^\[\r\n\]* included at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" {
# `location' should *not* be empty when we see this
# message. It should have recorded at least the initial
# `Defined at ' message (for definitions) or ` at' message
@@ -114,7 +117,7 @@ proc info_macro {macro} {
set definition {}
}
}
- -re "^\[\r\n\]*at \[^\r\n\]*(${filepat}):${decimal}\[\r\n\]" {
+ -re "^\[\r\n\]*at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" {
# This appears after a `has no definition' message.
# `location' should be empty when we see it.
if {[string compare $definition undefined] == 0 \
@@ -205,6 +208,11 @@ list_and_check_macro macscp2_2 WHERE {macscp2.h macscp1.c {before macscp2_2}}
list_and_check_macro macscp3_2 WHERE {macscp3.h macscp1.c {before macscp3_2}}
+# Assuming the current position inside program by `list' from above.
+gdb_test "info macro FROM_COMMANDLINE" \
+ "Defined at \[^\r\n\]*:0\r\n-DFROM_COMMANDLINE=ARG"
+
+
# Although GDB's macro table structures distinguish between multiple
# #inclusions of the same file, GDB's other structures don't. So the
# `list' command here doesn't reliably select one #inclusion or the