http://sourceware.org/ml/gdb-patches/2012-10/msg00083.html
authorAndrew Burgess <aburgess@broadcom.com>
Fri, 9 Nov 2012 13:23:33 +0000 (13:23 +0000)
committerAndrew Burgess <aburgess@broadcom.com>
Fri, 9 Nov 2012 13:23:33 +0000 (13:23 +0000)
gdb/ChangeLog

        * source.c (print_source_lines_base): Add fullname field giving
        full path to file in mi output.
        * NEWS: Mention the new fullname field.

gdb/doc/ChangeLog

        * gdb.texinfo (GDB/MI Data Manipulation): Add fullname field to
        the example -data-disassemble output.  Extend the description of
        the -data-disassemble results to document all fields.  Document
        the cli disassemble command as being related to -data-disassemble.

gdb/testsuite/ChangeLog

        * gdb.mi/mi-disassemble.exp: Expect fullname field in mi
        disassembly output.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/source.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-disassemble.exp

index b7943653236532d622248b6d0bdee515bc912e5a..3a87a2c93e19c692553fa349efbd3a2c64a0832e 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-09  Andrew Burgess  <aburgess@broadcom.com>
+
+       * source.c (print_source_lines_base): Add fullname field giving
+       full path to file in mi output.
+       * NEWS: Mention the new fullname field.
+
 2012-11-09  Yao Qi  <yao@codesourcery.com>
 
        * NEWS: Mention the fix to the ambiguity of 'fo' command.
index 8567742628d3aa1aa8e1ff1d350756069ea31502..4a1988db0e55fe8e3378186206fb58997a7abc4d 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -66,6 +66,9 @@ py [command]
      async record "=record-started" and "=record-stopped".
   ** Memory changes are now notified using new async record
      "=memory-changed".
+  ** The data-disassemble command response will include a "fullname" field
+     containing the absolute file name when GDB can determine it and source
+     has been requested.
 
 *** Changes in GDB 7.5
 
index 3e993dddbb8fb633d85423e5bcfb2a035fa18f0a..2fc837b901b9c26397de61a33df6ed9b560fda1f 100644 (file)
@@ -1,3 +1,10 @@
+2012-11-09  Andrew Burgess  <aburgess@broadcom.com>
+
+       * gdb.texinfo (GDB/MI Data Manipulation): Add fullname field to
+       the example -data-disassemble output.  Extend the description of
+       the -data-disassemble results to document all fields.  Document
+       the cli disassemble command as being related to -data-disassemble.
+
 2012-11-09  Yao Qi  <yao@codesourcery.com>
 
        PR gdb/14777.
index 50fc1234982abe4bb7a9d3166bc30dc9d22b406b..ce5415d56c8f646100dc81abf3d2cb606eb60c7c 100644 (file)
@@ -30707,21 +30707,65 @@ mixed source and disassembly with raw opcodes).
 
 @subsubheading Result
 
-The output for each instruction is composed of four fields:
+The result of the @code{-data-disassemble} command will be a list named
+@samp{asm_insns}, the contents of this list depend on the @var{mode}
+used with the @code{-data-disassemble} command.
 
-@itemize @bullet
-@item Address
-@item Func-name
-@item Offset
-@item Instruction
-@end itemize
+For modes 0 and 2 the @samp{asm_insns} list contains tuples with the
+following fields:
 
-Note that whatever included in the instruction field, is not manipulated
-directly by @sc{gdb/mi}, i.e., it is not possible to adjust its format.
+@table @code
+@item address
+The address at which this instruction was disassembled.
+
+@item func-name
+The name of the function this instruction is within.
+
+@item offset
+The decimal offset in bytes from the start of @samp{func-name}.
+
+@item inst
+The text disassembly for this @samp{address}.
+
+@item opcodes
+This field is only present for mode 2.  This contains the raw opcode
+bytes for the @samp{inst} field.
+
+@end table
+
+For modes 1 and 3 the @samp{asm_insns} list contains tuples named
+@samp{src_and_asm_line}, each of which has the following fields:
+
+@table @code
+@item line
+The line number within @samp{file}.
+
+@item file
+The file name from the compilation unit.  This might be an absolute
+file name or a relative file name depending on the compile command
+used.
+
+@item fullname
+This field is optional.  If it is present it will contain an absolute
+file name of @samp{file}.  If this field is not present then
+@value{GDBN} was unable to determine the absolute file name.
+
+@item line_asm_insn
+This is a list of tuples containing the disassembly for @samp{line} in
+@samp{file}.  The fields of each tuple are the same as for
+@code{-data-disassemble} in @var{mode} 0 and 2, so @samp{address},
+@samp{func-name}, @samp{offset}, @samp{inst}, and optionally
+@samp{opcodes}.
+
+@end table
+
+Note that whatever included in the @samp{inst} field, is not
+manipulated directly by @sc{gdb/mi}, i.e., it is not possible to
+adjust its format.
 
 @subsubheading @value{GDBN} Command
 
-There's no direct mapping from this command to the CLI.
+The corresponding @value{GDBN} command is @samp{disassemble}.
 
 @subsubheading Example
 
@@ -30785,15 +30829,15 @@ Disassemble 3 instructions from the start of @code{main} in mixed mode:
 -data-disassemble -f basics.c -l 32 -n 3 -- 1
 ^done,asm_insns=[
 src_and_asm_line=@{line="31",
-file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
-  testsuite/gdb.mi/basics.c",line_asm_insn=[
-@{address="0x000107bc",func-name="main",offset="0",
-inst="save  %sp, -112, %sp"@}]@},
+file="../../../src/gdb/testsuite/gdb.mi/basics.c",
+fullname="/absolute/path/to/src/gdb/testsuite/gdb.mi/basics.c",
+line_asm_insn=[@{address="0x000107bc",
+func-name="main",offset="0",inst="save  %sp, -112, %sp"@}]@},
 src_and_asm_line=@{line="32",
-file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
-  testsuite/gdb.mi/basics.c",line_asm_insn=[
-@{address="0x000107c0",func-name="main",offset="4",
-inst="mov  2, %o0"@},
+file="../../../src/gdb/testsuite/gdb.mi/basics.c",
+fullname="/absolute/path/to/src/gdb/testsuite/gdb.mi/basics.c",
+line_asm_insn=[@{address="0x000107c0",
+func-name="main",offset="4",inst="mov  2, %o0"@},
 @{address="0x000107c4",func-name="main",offset="8",
 inst="sethi  %hi(0x11800), %o2"@}]@}]
 (gdb)
index 307fecc402a88399c06431fcee2807ae847e4cf8..9813c43faa1fc27733efea383829677aaa8cefac 100644 (file)
@@ -1301,6 +1301,13 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
          ui_out_field_int (uiout, "line", line);
          ui_out_text (uiout, "\tin ");
          ui_out_field_string (uiout, "file", s->filename);
+         if (ui_out_is_mi_like_p (uiout))
+           {
+             const char *fullname = symtab_to_fullname (s);
+
+             if (fullname != NULL)
+               ui_out_field_string (uiout, "fullname", fullname);
+           }
          ui_out_text (uiout, "\n");
        }
 
index 9d2d1146a38d0ebc9612b1f557ed4c61122c4dab..26f2b3f08f4e31470e9c5f5669266f62c4c14170 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-09  Andrew Burgess  <aburgess@broadcom.com>
+
+       * gdb.mi/mi-disassemble.exp: Expect fullname field in mi
+       disassembly output.
+
 2012-11-09  Pedro Alves  <palves@redhat.com>
 
        PR gdb/14306
index 377ffdeeb01c6cb172db204051eaee87f2876a13..695521a6647b2d5c58fbab7255c0e1f36fdaae9f 100644 (file)
@@ -115,6 +115,7 @@ proc test_disassembly_mixed {} {
     global mi_gdb_prompt
     global hex
     global decimal
+    global fullname_syntax
 
     set line_callee2_head       [gdb_get_line_number "callee2 ("]
     set line_callee2_open_brace [expr $line_callee2_head + 1]
@@ -125,7 +126,7 @@ proc test_disassembly_mixed {} {
     # -data-disassembly -s $pc -e "$pc+8" -- 1
 
     mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 1" \
-           "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \
+           "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \
              "data-disassemble file, line assembly mixed"
 
     #
@@ -134,7 +135,7 @@ proc test_disassembly_mixed {} {
     # which we are now, even if we have specified that the range is only 2 insns.
     #
     mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 1" \
-           "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \
+           "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\\\]" \
              "data-disassemble range assembly mixed"
 }
 
@@ -142,6 +143,7 @@ proc test_disassembly_mixed_with_opcodes {} {
     global mi_gdb_prompt
     global hex
     global decimal
+    global fullname_syntax
 
     set line_callee2_head       [gdb_get_line_number "callee2 ("]
     set line_callee2_open_brace [expr $line_callee2_head + 1]
@@ -152,7 +154,7 @@ proc test_disassembly_mixed_with_opcodes {} {
     # -data-disassembly -s $pc -e "$pc+8" -- 3
 
     mi_gdb_test "002-data-disassemble -f basics.c -l $line_callee2_open_brace -- 3" \
-           "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",opcodes=\".*\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
+           "002\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_callee2_open_brace\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"callee2\",offset=\"0\",opcodes=\".*\",inst=\".*\"\}.*\\\]\}.*,src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[.*\{address=\"$hex\",func-name=\"callee2\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
              "data-disassemble file, line assembly mixed with opcodes"
 
     #
@@ -161,7 +163,7 @@ proc test_disassembly_mixed_with_opcodes {} {
     # which we are now, even if we have specified that the range is only 2 insns.
     #
     mi_gdb_test "003-data-disassemble -s \$pc -e \"\$pc+4\" -- 3" \
-           "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
+           "003\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}.*\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",opcodes=\".*\",inst=\".*\"\}\\\]\}\\\]" \
              "data-disassemble range assembly mixed with opcodes"
 }
 
@@ -169,6 +171,7 @@ proc test_disassembly_mixed_lines_limit {} {
     global mi_gdb_prompt
     global hex
     global decimal
+    global fullname_syntax
 
     set line_main_head       [gdb_get_line_number "main ("]
     set line_main_open_brace [expr $line_main_head + 1]
@@ -182,15 +185,15 @@ proc test_disassembly_mixed_lines_limit {} {
 
     mi_gdb_test "print/x \$pc" "" ""
     mi_gdb_test "222-data-disassemble  -f basics.c -l $line_main_body -n 20 -- 1" \
-           "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \
+           "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \
               "data-disassemble file, line, number assembly mixed"
 
     mi_gdb_test "222-data-disassemble  -f basics.c -l $line_main_body -n 0 -- 1" \
-           "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_main_open_brace\",file=\".*basics.c\",line_asm_insn=\\\[\\\]\}\\\]" \
+           "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$line_main_open_brace\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\\\]\}\\\]" \
               "data-disassemble file, line, number (zero lines) assembly mixed"
 
     mi_gdb_test "222-data-disassemble  -f basics.c -l $line_main_body -n 50 -- 1" \
-           "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\}.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \
+           "222\\^done,asm_insns=\\\[src_and_asm_line=\{line=\"$decimal\",file=\".*basics.c\",fullname=\"${fullname_syntax}basics.c\",line_asm_insn=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\}.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]\}\]" \
               "data-disassemble file, line, number (more than main lines) assembly mixed"
 }