From patchwork Sat Feb 6 22:16:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 10749 Received: (qmail 37588 invoked by alias); 6 Feb 2016 22:16:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 37572 invoked by uid 89); 6 Feb 2016 22:16:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=sk:symbol, sk:symbol-, sk:a2b0d39, sk:foll-ex X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 06 Feb 2016 22:16:38 +0000 Received: by mail-wm0-f43.google.com with SMTP id p63so70777895wmp.1 for ; Sat, 06 Feb 2016 14:16:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rRSHCuEFIN21qbEnddC0+UM8H4af6738mHmwrDl0bfs=; b=kivwsU0789ojvrFd6EZqc2pVOsTmUQWQn49fGz0qZbXM2s+6NLF4gQgOUOoqgcl46g Rbh5BKPv2XtOI5jC5etkS3U/IHj+uzP7K2CyBmJRlAIAr1bKzebwxHEfbXx+BwfTlBXf e5Qj1Wi/+QVmIVezSgNVCuH4m4LYhWu6sHf+uPXI/6B+dWPrWCVUxa/NzU9sP9BhyO5A Hs/auO5g6lvpwGQaED5MLhCm+f7sEutcQWgkiu410fDMEZ8WndXSWgkPv5/ewpTIOMRO hIoGWBg98cl9DeW4t/aCZWkE7x/mJfePpjewJ6Em4Hhu3psolhtUgozW3S5QjOpKekVt 2W/A== X-Gm-Message-State: AG10YOTqIxgZa5ts5MHsLiL/HKKUso3r/2YsWaQzctbuP0+tyGMn8YHUX9m31Kz5dnHomQ== X-Received: by 10.28.156.73 with SMTP id f70mr24903951wme.52.1454796995621; Sat, 06 Feb 2016 14:16:35 -0800 (PST) Received: from localhost (host86-138-95-84.range86-138.btcentralplus.com. [86.138.95.84]) by smtp.gmail.com with ESMTPSA id 79sm5057374wmo.7.2016.02.06.14.16.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Feb 2016 14:16:34 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb: New maint info line-table command. Date: Sat, 6 Feb 2016 22:16:23 +0000 Message-Id: X-IsSubscribed: yes Add a new command 'maint info line-table' to display the contents of GDB's internal line table structure. Useful when trying to understand problems (within gdb) relating to line tables. gdb/ChangeLog: * symmisc.c (maintenance_info_line_tables): New function. (_initialize_symmisc): Register 'maint info line-table' command. * NEWS: Mention new command. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new 'maint info line-table' command. gdb/testsuite/ChangeLog: * gdb.base/maint.exp: New tests for 'maint info line-table'. --- gdb/ChangeLog | 6 +++ gdb/NEWS | 3 ++ gdb/doc/ChangeLog | 5 +++ gdb/doc/gdb.texinfo | 9 +++++ gdb/symmisc.c | 84 ++++++++++++++++++++++++++++++++++++++++ gdb/testsuite/ChangeLog | 4 ++ gdb/testsuite/gdb.base/maint.exp | 16 ++++++++ 7 files changed, 127 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a2b0d39..03366d3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2016-02-06 Andrew Burgess + + * symmisc.c (maintenance_info_line_tables): New function. + (_initialize_symmisc): Register 'maint info line-table' command. + * NEWS: Mention new command. + 2016-02-04 Yao Qi * remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to diff --git a/gdb/NEWS b/gdb/NEWS index 962eae4..b868791 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -98,6 +98,9 @@ maint set bfd-sharing maint show bfd-sharing Control the reuse of bfd objects. +maint info line-table FILENAME + Display the contents of GDB's internal line table data struture. + set debug bfd-cache show debug bfd-cache Control display of debugging info regarding bfd caching. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 05d2694..64465ba 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2016-02-06 Andrew Burgess + + * gdb.texinfo (Symbols): Document new 'maint info line-table' + command. + 2016-02-01 Doug Evans * gdb.texinfo (Value Sizes): Fix typo. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 2d09d13..c6aa683 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -17066,6 +17066,15 @@ line 1574. (@value{GDBP}) @end smallexample +@kindex maint info line-table +@cindex listing @value{GDBN}'s internal line tables +@cindex line tables, listing @value{GDBN}'s internal +@item maint info line-table @var{filename} + +List the @code{struct linetable} for the symtab with @var{filename}. +If @var{filename} is not given then the the @code{struct linetable} +that contains the current @var{pc} is given. + @kindex maint set symbol-cache-size @cindex symbol cache size @item maint set symbol-cache-size @var{size} diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 69b7e8e..eac7925 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -949,6 +949,84 @@ block_depth (struct block *block) } +/* Implement the 'maint info line-table' command. */ + +static void +maintenance_info_line_tables (char *arg, int from_tty) +{ + struct ui_out *uiout = current_uiout; + struct symtab *symtab = NULL; + struct linetable *linetable; + struct cleanup *table_cleanup; + int i; + + if (arg != NULL) + symtab = lookup_symtab (arg); + else + { + struct frame_info *frame; + CORE_ADDR pc; + + frame = get_selected_frame (_("No frame selected.")); + pc = get_frame_address_in_block (frame); + symtab = find_pc_line_symtab (pc); + } + + if (symtab == NULL) + { + if (arg) + error (_("No matching symbol table found for `%s'."), arg); + else + error (_("No matching symbol table found.")); + } + + linetable = SYMTAB_LINETABLE (symtab); + if (linetable == NULL) + error (_("Symbol table for `%s' has no line table."), + symtab_to_filename_for_display (symtab)); + if (linetable->nitems <= 0) + error (_("Line table for symbol table `%s' has no lines"), + symtab_to_filename_for_display (symtab)); + + ui_out_text (uiout, "Line table for `"); + ui_out_text (uiout, symtab_to_filename_for_display (symtab)); + ui_out_text (uiout, "':\n"); + + table_cleanup + = make_cleanup_ui_out_table_begin_end (uiout, 3, + linetable->nitems, + "line-table"); + + /* Leave space for 6 digits of index and line number. After that the + tables will just not format as well. */ + ui_out_table_header (uiout, 6, ui_left, "index", "INDEX"); + ui_out_table_header (uiout, 6, ui_right, "line", "LINE"); + ui_out_table_header (uiout, (sizeof (CORE_ADDR) * 2 + 2) + , ui_left, "address", "ADDRESS"); + ui_out_table_body (uiout); + + for (i = 0; i < linetable->nitems; ++i) + { + struct linetable_entry *item; + struct cleanup *row_cleanup; + + item = &linetable->item [i]; + + row_cleanup + = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + + ui_out_field_int (uiout, "index", i); + ui_out_field_int (uiout, "line", item->line); + ui_out_field_string (uiout, "address", core_addr_to_string (item->pc)); + + ui_out_text (uiout, "\n"); + do_cleanups (row_cleanup); + } + + do_cleanups (table_cleanup); +} + + /* Do early runtime initializations. */ void @@ -982,6 +1060,12 @@ linetables --- just the symbol table structures themselves.\n\ With an argument REGEXP, list the symbol tables with matching names."), &maintenanceinfolist); + add_cmd ("line-table", class_maintenance, maintenance_info_line_tables, _("\ +List line tables contents for specified symtab.\n\ +Given the filename of a symtab, list the contents of the\n\ +associated line table."), + &maintenanceinfolist); + add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs, _("\ Check consistency of currently expanded symtabs."), diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 046f112..e2015a8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-02-06 Andrew Burgess + + * gdb.base/maint.exp: New tests for 'maint info line-table'. + 2016-02-04 Yao Qi * gdb.base/foll-exec-mode.c: Include limits.h. diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 79924a7..93236ce 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -471,6 +471,22 @@ gdb_test "maint" \ "\"maintenance\" must be followed by the name of a maintenance command\\.\r\nList.*unambiguous\\..*" \ "maint w/o args" +gdb_test "maint info line-table" \ + "Line table for `\[^\n\r\]+${srcfile}':.*INDEX.*LINE.*ADDRESS.*" \ + "maint info line-table w/o a file name" + +gdb_test "maint info line-table ${srcfile}" \ + "Line table for `\[^\n\r\]+${srcfile}':.*INDEX.*LINE.*ADDRESS.*" \ + "maint info line-table with filename of current symtab" + +gdb_test "maint info line-table ${srcfile2}" \ + "Line table for `\[^\n\r\]+${srcfile2}':.*INDEX.*LINE.*ADDRESS.*" \ + "maint info line-table with filename of symtab that is not current" + +gdb_test "maint info line-table xxx.c" \ + "No matching symbol table found for `.*'." \ + "maint info line-table with invalid filename" + set timeout $oldtimeout #============test help on maint commands