From patchwork Fri Jun 14 23:01:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 33144 Received: (qmail 15392 invoked by alias); 14 Jun 2019 23:01:54 -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 15330 invoked by uid 89); 14 Jun 2019 23:01:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=beg X-HELO: mail-wr1-f51.google.com Received: from mail-wr1-f51.google.com (HELO mail-wr1-f51.google.com) (209.85.221.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jun 2019 23:01:50 +0000 Received: by mail-wr1-f51.google.com with SMTP id x4so4082745wrt.6 for ; Fri, 14 Jun 2019 16:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=YsB0xgQ8wabclW/bOnKuDL9vVM+meFvaFW2d2vL/ARY=; b=D6wz9OGKRokGU5AGlZwAsYetvckeKT928jj6fcTKnHzG4JB9QX/DZ7MNKwWv2J6ZOD y2PGMvplSvWflu9K2EL57BBzapwqf45hAajLH9TA/+ca5zeFEcRPypu3yOfEiV88ly+L jfpwTgdK4rZ3IQsdQT4yB/wBI7BKF8YNEFMJ91N9A0RiQ9HjkcPR8mqIi1Bw5LeRICzp OMa5Y4/dsoYgmRwk0+DXzBxDlKnBhJD1YQfR9obLs+jgPHRYI4sd/7G63B21gZ3ihFLJ m2He5qn/guR/2ZMRmbsxdpkjHQlIDt4Er+aRkacdWN08CTzd1g4jSUy2pLyF8D1ZPrqa QayQ== Return-Path: Received: from localhost (host86-180-62-212.range86-180.btcentralplus.com. [86.180.62.212]) by smtp.gmail.com with ESMTPSA id w14sm3353606wrk.44.2019.06.14.16.01.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 16:01:47 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/4] gdb: Don't allow annotations to influence what else GDB prints Date: Sat, 15 Jun 2019 00:01:40 +0100 Message-Id: <6736ab7a7a8e79368ccc1f9a798a5aeba576211a.1560553051.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: <87v9x8mdkf.fsf@tromey.com> X-IsSubscribed: yes The annotations should be additional information printed by GDB to be consumed by users (GUIs), but GDB shouldn't reduce what it prints based on whether annotations are on or not. However, this is what happens for annotate_source_line. This commit makes annotate_source_line a void function that simply outputs the annotation information, GDB will then print the contents of the source line to the terminal in the normal way. Some tests needed to be updated after this commit. gdb/ChangeLog: * annotate.c (annotate_source_line): Change return type to void, update implementation to match. * annotate.h (annotate_source_line): Change return type to void, update header comment. * stack.c (print_frame_info): Don't change what frame information is printed based on whether annotations are on or not. gdb/testsuite/ChangeLog: * gdb.base/annota1.exp: Update expected results. * gdb.cp/annota2.exp: Likewise. * gdb.cp/annota3.exp: Likewise. --- gdb/ChangeLog | 9 ++++++ gdb/annotate.c | 8 ++--- gdb/annotate.h | 7 ++--- gdb/stack.c | 60 ++++++++++++++++++-------------------- gdb/testsuite/ChangeLog | 6 ++++ gdb/testsuite/gdb.base/annota1.exp | 4 +-- gdb/testsuite/gdb.cp/annota2.exp | 1 + gdb/testsuite/gdb.cp/annota3.exp | 2 +- 8 files changed, 52 insertions(+), 45 deletions(-) diff --git a/gdb/annotate.c b/gdb/annotate.c index 84f8129b22d..8d8a0196fb0 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -434,7 +434,7 @@ annotate_source (const char *filename, int line, int character, int mid, /* See annotate.h. */ -bool +void annotate_source_line (struct symtab *s, int line, int mid_statement, CORE_ADDR pc) { @@ -443,17 +443,15 @@ annotate_source_line (struct symtab *s, int line, int mid_statement, if (s->line_charpos == nullptr) open_source_file_with_line_charpos (s); if (s->fullname == nullptr) - return false; + return; /* Don't index off the end of the line_charpos array. */ if (line > s->nlines) - return false; + return; annotate_source (s->fullname, line, s->line_charpos[line - 1], mid_statement, get_objfile_arch (SYMTAB_OBJFILE (s)), pc); - return true; } - return false; } diff --git a/gdb/annotate.h b/gdb/annotate.h index 9683b7e09ac..5e9f11d6053 100644 --- a/gdb/annotate.h +++ b/gdb/annotate.h @@ -92,11 +92,8 @@ struct annotate_arg_emitter character position. MID_STATEMENT is nonzero if the PC is not at the beginning of that - line. - - Return true if successful, false if the file could not be found or - annotations are turned off. */ -extern bool annotate_source_line (struct symtab *s, int line, + line. */ +extern void annotate_source_line (struct symtab *s, int line, int mid_statement, CORE_ADDR pc); extern void annotate_frame_begin (int, struct gdbarch *, CORE_ADDR); diff --git a/gdb/stack.c b/gdb/stack.c index f471efe3df7..b3d113d3b42 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -965,45 +965,41 @@ print_frame_info (const frame_print_options &fp_opts, { int mid_statement = ((print_what == SRC_LINE) && frame_show_address (frame, sal)); - bool done = annotate_source_line (sal.symtab, sal.line, mid_statement, - get_frame_pc (frame)); + annotate_source_line (sal.symtab, sal.line, mid_statement, + get_frame_pc (frame)); - if (!done) + if (deprecated_print_frame_info_listing_hook) + deprecated_print_frame_info_listing_hook (sal.symtab, sal.line, + sal.line + 1, 0); + else { - if (deprecated_print_frame_info_listing_hook) - deprecated_print_frame_info_listing_hook (sal.symtab, - sal.line, - sal.line + 1, 0); - else - { - struct value_print_options opts; - - get_user_print_options (&opts); - /* We used to do this earlier, but that is clearly - wrong. This function is used by many different - parts of gdb, including normal_stop in infrun.c, - which uses this to print out the current PC - when we stepi/nexti into the middle of a source - line. Only the command line really wants this - behavior. Other UIs probably would like the - ability to decide for themselves if it is desired. */ - if (opts.addressprint && mid_statement) - { - uiout->field_core_addr ("addr", - gdbarch, get_frame_pc (frame)); - uiout->text ("\t"); - } + struct value_print_options opts; - print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); + get_user_print_options (&opts); + /* We used to do this earlier, but that is clearly + wrong. This function is used by many different + parts of gdb, including normal_stop in infrun.c, + which uses this to print out the current PC + when we stepi/nexti into the middle of a source + line. Only the command line really wants this + behavior. Other UIs probably would like the + ability to decide for themselves if it is desired. */ + if (opts.addressprint && mid_statement) + { + uiout->field_core_addr ("addr", + gdbarch, get_frame_pc (frame)); + uiout->text ("\t"); } - } - /* If disassemble-next-line is set to on and there is line debug - messages, output assembly codes for next line. */ - if (disassemble_next_line == AUTO_BOOLEAN_TRUE) - do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end); + print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); + } } + /* If disassemble-next-line is set to on and there is line debug + messages, output assembly codes for next line. */ + if (disassemble_next_line == AUTO_BOOLEAN_TRUE) + do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end); + if (set_current_sal) { CORE_ADDR pc; diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index dfa30831e64..3d379f0fd49 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -268,10 +268,10 @@ if [target_info exists gdb,nosignals] { unsupported "backtrace @ signal handler" } else { gdb_test_multiple "signal SIGUSR1" "send SIGUSR1" { - -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n${escapedsrcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { + -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n${escapedsrcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n$decimal\[^\r\n\]+\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { pass "send SIGUSR1" } - -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*${srcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { + -re "\r\n\032\032post-prompt\r\nContinuing with signal SIGUSR1.\r\n\r\n\032\032starting\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)+\r\n\r\n\032\032breakpoint 2\r\n\r\nBreakpoint 2, \r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nhandle_USR1\r\n\032\032frame-args\r\n \\(\r\n\032\032arg-begin\r\nsig\r\n\032\032arg-name-end\r\n=\r\n\032\032arg-value -\r\n$decimal\r\n\032\032arg-end\r\n\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*${srcfile}\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source.*annota1.c:.*:.*:beg:$hex\r\n$decimal\[^\r\n\]+\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { setup_xfail "*-*-*" 1270 fail "send SIGUSR1" } diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp index 745f4617160..6699de01a3b 100644 --- a/gdb/testsuite/gdb.cp/annota2.exp +++ b/gdb/testsuite/gdb.cp/annota2.exp @@ -243,6 +243,7 @@ set pat [multi_line "" \ "" \ "" \ "\032\032source .*$srcfile.*beg:$hex" \ + "$decimal\[^\r\n\]+" \ "" \ "\032\032frame-end" \ "" \ diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp index 3b506e2a82c..8f9a1456912 100644 --- a/gdb/testsuite/gdb.cp/annota3.exp +++ b/gdb/testsuite/gdb.cp/annota3.exp @@ -164,7 +164,7 @@ gdb_expect_list "set watch on a.x" "$gdb_prompt$" { # annotate-watchpoint # gdb_test_multiple "next" "watch triggered on a.x" { - -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n(\032\032frame-begin 0 0x\[0-9a-z\]+\r\n|)main \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n(\032\032frame-begin 0 0x\[0-9a-z\]+\r\n|)main \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n$decimal\[^\r\n\]+\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" { pass "watch triggered on a.x" } }