From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gIW/NRK6l2E+fgAAWB0awg (envelope-from ) for ; Fri, 19 Nov 2021 09:52:02 -0500 Received: by simark.ca (Postfix, from userid 112) id DA43A1F0CE; Fri, 19 Nov 2021 09:52:02 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 184FF1EDEE for ; Fri, 19 Nov 2021 09:52:02 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D5BD3857C50 for ; Fri, 19 Nov 2021 14:52:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D5BD3857C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637333521; bh=0ddIl/UHqlWgZaEGPa12V74l1IwHDVOQak0mZfjrHsI=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LWYCKu0FBuF6NhcNqidZKSuvtVJeFwqU/SN78ajctbDwUF3/2PGjRfZ3HqvQHwY2N QyjfXRK9i8wl6VySqT3OD39SA+Cw2RC4MBGkeiLhjgYtn2jkln0PG37X8BqfggNYTE aTO3lCK4Untsuub4BBY6aYJ4Gt7Cy3nHNEr8Bp5o= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id B891F385800C for ; Fri, 19 Nov 2021 14:51:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B891F385800C Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B3E841FD3C for ; Fri, 19 Nov 2021 14:51:40 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3E2813B32 for ; Fri, 19 Nov 2021 14:51:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hzjrJvy5l2EMDgAAMHmgww (envelope-from ) for ; Fri, 19 Nov 2021 14:51:40 +0000 Subject: [PING^2][PATCH][gdb/symtab] Support -readnow during reread To: gdb-patches@sourceware.org References: <20211011144448.GA12732@delia.home> <126ea3c2-e448-bc5d-7ac4-4d41be6e1740@suse.de> Message-ID: <4834e002-53c6-743c-6018-af3ff383eb57@suse.de> Date: Fri, 19 Nov 2021 15:51:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <126ea3c2-e448-bc5d-7ac4-4d41be6e1740@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 10/28/21 10:53 AM, Tom de Vries via Gdb-patches wrote: > On 10/11/21 4:44 PM, Tom de Vries via Gdb-patches wrote: >> Hi, >> >> When running test-case gdb.base/cached-source-file.exp with target board >> readnow, we run into: >> ... >> FAIL: gdb.base/cached-source-file.exp: rerun program (the program exited) >> ... >> >> The problem is that when rereading, the readnow is ignored. >> >> Fix this by copying the readnow handling code from symbol_file_add_with_addrs >> to reread_symbols. >> >> Tested on x86_64-linux. >> >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26800 >> >> Any comments? >> > Ping. Thanks, - Tom >> [gdb/symtab] Support -readnow during reread >> >> --- >> gdb/infcmd.c | 4 ++-- >> gdb/remote.c | 2 +- >> gdb/symfile.c | 17 +++++++++++++++-- >> gdb/symtab.h | 2 +- >> gdb/testsuite/gdb.ada/exec_changed.exp | 8 -------- >> gdb/testsuite/gdb.base/cached-source-file.exp | 18 +++++++++++------- >> gdb/testsuite/gdb.base/reread.exp | 8 -------- >> 7 files changed, 30 insertions(+), 29 deletions(-) >> >> diff --git a/gdb/infcmd.c b/gdb/infcmd.c >> index b55a56c020d..ee7f107ab1b 100644 >> --- a/gdb/infcmd.c >> +++ b/gdb/infcmd.c >> @@ -395,7 +395,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how) >> to check again here. Since reopen_exec_file doesn't do anything >> if the timestamp hasn't changed, I don't see the harm. */ >> reopen_exec_file (); >> - reread_symbols (); >> + reread_symbols (from_tty); >> >> gdb::unique_xmalloc_ptr stripped = strip_bg_char (args, &async_exec); >> args = stripped.get (); >> @@ -2396,7 +2396,7 @@ setup_inferior (int from_tty) >> else >> { >> reopen_exec_file (); >> - reread_symbols (); >> + reread_symbols (from_tty); >> } >> >> /* Take any necessary post-attaching actions for this platform. */ >> diff --git a/gdb/remote.c b/gdb/remote.c >> index d5eb40ce578..1fba8549ee4 100644 >> --- a/gdb/remote.c >> +++ b/gdb/remote.c >> @@ -5688,7 +5688,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p) >> >> remote_fileio_reset (); >> reopen_exec_file (); >> - reread_symbols (); >> + reread_symbols (from_tty); >> >> remote_target *remote >> = (extended_p ? new extended_remote_target () : new remote_target ()); >> diff --git a/gdb/symfile.c b/gdb/symfile.c >> index 9e5c2d48881..89469a3d3dc 100644 >> --- a/gdb/symfile.c >> +++ b/gdb/symfile.c >> @@ -1797,7 +1797,7 @@ load_command (const char *arg, int from_tty) >> /* The user might be reloading because the binary has changed. Take >> this opportunity to check. */ >> reopen_exec_file (); >> - reread_symbols (); >> + reread_symbols (from_tty); >> >> std::string temp; >> if (arg == NULL) >> @@ -2411,7 +2411,7 @@ remove_symbol_file_command (const char *args, int from_tty) >> /* Re-read symbols if a symbol-file has changed. */ >> >> void >> -reread_symbols (void) >> +reread_symbols (int from_tty) >> { >> long new_modtime; >> struct stat new_statbuf; >> @@ -2588,6 +2588,19 @@ reread_symbols (void) >> >> read_symbols (objfile, 0); >> >> + if ((objfile->flags & OBJF_READNOW)) >> + { >> + const int mainline = objfile->flags & OBJF_MAINLINE; >> + const int should_print = (print_symbol_loading_p (from_tty, mainline, 1) >> + && readnow_symbol_files); >> + if (should_print) >> + printf_filtered (_("Expanding full symbols from %ps...\n"), >> + styled_string (file_name_style.style (), >> + objfile_name (objfile))); >> + >> + objfile->expand_all_symtabs (); >> + } >> + >> if (!objfile_has_symbols (objfile)) >> { >> wrap_here (""); >> diff --git a/gdb/symtab.h b/gdb/symtab.h >> index 61f20b25a7b..a9e01cc967c 100644 >> --- a/gdb/symtab.h >> +++ b/gdb/symtab.h >> @@ -1847,7 +1847,7 @@ extern struct compunit_symtab * >> >> extern bool find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *); >> >> -extern void reread_symbols (void); >> +extern void reread_symbols (int from_tty); >> >> /* Look up a type named NAME in STRUCT_DOMAIN in the current language. >> The type returned must not be opaque -- i.e., must have at least one field >> diff --git a/gdb/testsuite/gdb.ada/exec_changed.exp b/gdb/testsuite/gdb.ada/exec_changed.exp >> index 8cbc29f8fdd..d08e1ce1555 100644 >> --- a/gdb/testsuite/gdb.ada/exec_changed.exp >> +++ b/gdb/testsuite/gdb.ada/exec_changed.exp >> @@ -51,8 +51,6 @@ gdb_reinitialize_dir $srcdir/$subdir >> gdb_test "shell mv ${binfile} ${common_binfile}" ".*" "" >> gdb_load ${common_binfile} >> >> -set readnow_p [readnow ${common_binfile}] >> - >> # Start the program, we should land in the program main procedure >> if { [gdb_start_cmd] < 0 } { >> untested start >> @@ -78,9 +76,6 @@ gdb_test "shell touch ${common_binfile}" ".*" "" >> if { [gdb_start_cmd] < 0 } { >> fail "start second" >> } else { >> - if { $readnow_p } { >> - setup_kfail "gdb/26800" *-*-* >> - } >> gdb_test "" \ >> "second \\(\\) at .*second.adb.*" \ >> "start second" >> @@ -108,9 +103,6 @@ if { [gdb_start_cmd] < 0 } { >> gdb_test_no_output "set \$check_gdb_running = 0" "check gdb running" >> fail "start just first" >> } else { >> - if { $readnow_p } { >> - setup_kfail "gdb/26800" *-*-* >> - } >> gdb_test "" \ >> "first \\(\\) at .*first.adb.*" \ >> "start just first" >> diff --git a/gdb/testsuite/gdb.base/cached-source-file.exp b/gdb/testsuite/gdb.base/cached-source-file.exp >> index 13965d93b65..3b0166aa18d 100644 >> --- a/gdb/testsuite/gdb.base/cached-source-file.exp >> +++ b/gdb/testsuite/gdb.base/cached-source-file.exp >> @@ -84,13 +84,17 @@ if { [gdb_compile "${srcfile}" "${binfile}" executable {debug}] != "" } { >> # Rerun the program. This should not only force GDB to reload the >> # source cache, but also to break at BP_LINE again, which now has >> # different contents. >> -gdb_test_multiple "run" "rerun program" { >> - -re {The program being debugged has been started already\.\r\nStart it from the beginning\? \(y or n\) $} { >> - set binregex [string_to_regexp $binfile] >> - gdb_test "y" "\\`$binregex\\' has changed; re-reading symbols\.\r\nStarting program: ${binregex}.*" \ >> - "rerun program" >> - } >> -} >> +set q \ >> + [multi_line \ >> + "The program being debugged has been started already\\." \ >> + "Start it from the beginning\\? \\(y or n\\) "] >> +set binregex [string_to_regexp $binfile] >> +set re \ >> + [multi_line \ >> + "\\`$binregex\\' has changed; re-reading symbols\\.(" \ >> + "Expanding full symbols from $binfile\\.\\.\\.)?" \ >> + "Starting program: ${binregex}.*"] >> +gdb_test "run" $re "rerun program" $q y >> >> # Again, perform the listing and check that the line indeed has >> # changed for GDB. >> diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp >> index 7ab30f2fde0..3d4b484182d 100644 >> --- a/gdb/testsuite/gdb.base/reread.exp >> +++ b/gdb/testsuite/gdb.base/reread.exp >> @@ -60,8 +60,6 @@ foreach_with_prefix opts { "" "pie" } { >> gdb_rename_execfile ${binfile1} ${binfile} >> gdb_load ${binfile} >> >> - set readnow_p [readnow ${binfile}] >> - >> # Set a breakpoint at foo >> >> gdb_test "break foo" \ >> @@ -92,9 +90,6 @@ foreach_with_prefix opts { "" "pie" } { >> unsupported $test >> } else { >> gdb_run_cmd >> - if { $readnow_p } { >> - setup_kfail "gdb/26800" *-*-* >> - } >> gdb_test "" "Breakpoint.* foo .* at .*:9.*" $test >> } >> >> @@ -131,9 +126,6 @@ foreach_with_prefix opts { "" "pie" } { >> gdb_rename_execfile ${binfile} ${binfile1} >> gdb_rename_execfile ${binfile2} ${binfile} >> gdb_run_cmd >> - if { $readnow_p } { >> - setup_kfail "gdb/26800" *-*-* >> - } >> gdb_test "" "Breakpoint.* foo .* at .*:9.*" \ >> "second pass: run to foo() second time" >> } >>