From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22460 invoked by alias); 14 Aug 2012 13:00:15 -0000 Received: (qmail 22381 invoked by uid 22791); 14 Aug 2012 13:00:13 -0000 X-SWARE-Spam-Status: No, hits=-7.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Aug 2012 12:59:56 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 14 Aug 2012 05:59:55 -0700 X-ExtLoop1: 1 Received: from swsutil001.isw.intel.com ([10.237.237.11]) by AZSMGA002.ch.intel.com with ESMTP; 14 Aug 2012 05:59:53 -0700 Received: from ulslx001.iul.intel.com (ulslx001.iul.intel.com [172.28.207.63]) by swsutil001.isw.intel.com (8.13.6/8.13.6/MailSET/Hub) with ESMTP id q7ECxqVx029042; Tue, 14 Aug 2012 13:59:52 +0100 Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id q7ECxqif009904; Tue, 14 Aug 2012 14:59:52 +0200 Received: (from mmetzger@localhost) by ulslx001.iul.intel.com with id q7ECxq2H009900; Tue, 14 Aug 2012 14:59:52 +0200 From: markus.t.metzger@intel.com To: gdb-patches@sourceware.org Cc: markus.t.metzger@gmail.com, jan.kratochvil@redhat.com, palves@redhat.com, tromey@redhat.com, kettenis@gnu.org, Markus Metzger Subject: [patch v3 04/16] source, disasm: optionally prefix source lines with filename Date: Tue, 14 Aug 2012 13:01:00 -0000 Message-Id: <1344949171-9545-5-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1344949171-9545-1-git-send-email-markus.t.metzger@intel.com> References: <1344949171-9545-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00394.txt.bz2 From: Markus Metzger Add respective flags to print_source_lines () and gdb_disassembly () to prefix the source line with its file name. 2012-08-14 Markus Metzger * 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. --- gdb/disasm.c | 12 ++++++++---- gdb/disasm.h | 1 + gdb/source.c | 5 +++++ gdb/symtab.h | 5 ++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/disasm.c b/gdb/disasm.c index c5c35ea..2120add 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -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)); @@ -293,7 +297,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 { @@ -307,7 +311,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"); @@ -319,7 +323,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 @@ -327,7 +331,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; diff --git a/gdb/disasm.h b/gdb/disasm.h index 5b459f4..5ae71c9 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -23,6 +23,7 @@ #define DISASSEMBLY_RAW_INSN (0x1 << 1) #define DISASSEMBLY_OMIT_FNAME (0x1 << 2) #define DISASSEMBLY_PRECISE_INSN (0x1 << 3) +#define DISASSEMBLY_FILENAME (0x1 << 4) struct ui_out; struct ui_file; diff --git a/gdb/source.c b/gdb/source.c index d4616be..daf720d 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1336,6 +1336,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, ":"); + } sprintf (buf, "%d\t", current_source_line++); ui_out_text (uiout, buf); do diff --git a/gdb/symtab.h b/gdb/symtab.h index 750da2a..8642618 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1146,7 +1146,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, -- 1.7.1