* disasm.h (DISASSEMBLY_FILENAME): New macro.
authorMarkus Metzger <mmetzger@sourceware.org>
Tue, 13 Nov 2012 15:35:43 +0000 (15:35 +0000)
committerMarkus Metzger <mmetzger@sourceware.org>
Tue, 13 Nov 2012 15:35:43 +0000 (15:35 +0000)
* disasm.c (do_mixed_source_and_assembly): Pass filename flag on
to print_source_lines ().
* symtab.h (PRINT_SOURCE_LINES_FILENAME): New print source lines
flag.
* source.c (print_source_lines_base): Prefix source line with
filename if PRINT_SOURCE_LINES_FILENAME flag is set.

gdb/ChangeLog
gdb/disasm.c
gdb/disasm.h
gdb/source.c
gdb/symtab.h

index 498b6a7df7050664d311ce0f51e93ef0582c9e24..f90311a833abf041031e9aeb06887ca525143e10 100644 (file)
@@ -1,3 +1,13 @@
+2012-11-13 Markus Metzger <markus.t.metzger@intel.com>
+
+       * disasm.h (DISASSEMBLY_FILENAME): New macro.
+       * disasm.c (do_mixed_source_and_assembly): Pass filename flag on
+       to print_source_lines ().
+       * symtab.h (PRINT_SOURCE_LINES_FILENAME): New print source lines
+       flag.
+       * source.c (print_source_lines_base): Prefix source line with
+       filename if PRINT_SOURCE_LINES_FILENAME flag is set.
+
 2012-11-13 Markus Metzger <markus.t.metzger@intel.com>
 
        * symtab.h (print_source_lines_flags): New enum.
index e3d3349200e64455ceed3aeac44b696ce201f417..25d87d70846df775195940e41a530d2e12367e9e 100644 (file)
@@ -204,10 +204,14 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
   int out_of_order = 0;
   int next_line = 0;
   int num_displayed = 0;
+  enum print_source_lines_flags psl_flags = 0;
   struct cleanup *ui_out_chain;
   struct cleanup *ui_out_tuple_chain = make_cleanup (null_cleanup, 0);
   struct cleanup *ui_out_list_chain = make_cleanup (null_cleanup, 0);
 
+  if (flags & DISASSEMBLY_FILENAME)
+    psl_flags |= PRINT_SOURCE_LINES_FILENAME;
+
   mle = (struct dis_line_entry *) alloca (nlines
                                          * sizeof (struct dis_line_entry));
 
@@ -275,7 +279,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
                  ui_out_tuple_chain
                    = make_cleanup_ui_out_tuple_begin_end (uiout,
                                                           "src_and_asm_line");
-                 print_source_lines (symtab, next_line, mle[i].line + 1, 0);
+                 print_source_lines (symtab, next_line, mle[i].line + 1, psl_flags);
                }
              else
                {
@@ -289,7 +293,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
                        = make_cleanup_ui_out_tuple_begin_end (uiout,
                                                               "src_and_asm_line");
                      print_source_lines (symtab, next_line, next_line + 1,
-                                         0);
+                                         psl_flags);
                      ui_out_list_chain_line
                        = make_cleanup_ui_out_list_begin_end (uiout,
                                                              "line_asm_insn");
@@ -301,7 +305,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
                  ui_out_tuple_chain
                    = make_cleanup_ui_out_tuple_begin_end (uiout,
                                                           "src_and_asm_line");
-                 print_source_lines (symtab, next_line, mle[i].line + 1, 0);
+                 print_source_lines (symtab, next_line, mle[i].line + 1, psl_flags);
                }
            }
          else
@@ -309,7 +313,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
              ui_out_tuple_chain
                = make_cleanup_ui_out_tuple_begin_end (uiout,
                                                       "src_and_asm_line");
-             print_source_lines (symtab, mle[i].line, mle[i].line + 1, 0);
+             print_source_lines (symtab, mle[i].line, mle[i].line + 1, psl_flags);
            }
 
          next_line = mle[i].line + 1;
index 646ee8eeb3678a6358c8f3e7377491531cc10a18..a254642ba9c3b35c3e8bd3639bba953d99af01cd 100644 (file)
@@ -22,6 +22,7 @@
 #define DISASSEMBLY_SOURCE     (0x1 << 0)
 #define DISASSEMBLY_RAW_INSN   (0x1 << 1)
 #define DISASSEMBLY_OMIT_FNAME (0x1 << 2)
+#define DISASSEMBLY_FILENAME   (0x1 << 3)
 
 struct ui_out;
 struct ui_file;
index 2fe2e50671178dddcb5d5d66360052975c87fe00..7e14fc6ebcfbec7cde047a80c3274477a9fe59dc 100644 (file)
@@ -1345,6 +1345,11 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
       if (c == EOF)
        break;
       last_line_listed = current_source_line;
+      if (flags & PRINT_SOURCE_LINES_FILENAME)
+        {
+          ui_out_text (uiout, s->filename);
+          ui_out_text (uiout, ":");
+        }
       xsnprintf (buf, sizeof (buf), "%d\t", current_source_line++);
       ui_out_text (uiout, buf);
       do
index 3b87c96a015948e61b30e84c34563ddd0e8c12b0..0d24cb5d0d3b394091a5aae3729855747ea2c5e7 100644 (file)
@@ -1167,7 +1167,10 @@ extern int identify_source_line (struct symtab *, int, int, CORE_ADDR);
 enum print_source_lines_flags
   {
     /* Do not print an error message.  */
-    PRINT_SOURCE_LINES_NOERROR = (1 << 0)
+    PRINT_SOURCE_LINES_NOERROR = (1 << 0),
+
+    /* Print the filename in front of the source lines.  */
+    PRINT_SOURCE_LINES_FILENAME = (1 << 1)
   };
 
 extern void print_source_lines (struct symtab *, int, int,