From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 22B683951C8C for ; Thu, 13 Jan 2022 15:22:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 22B683951C8C X-IronPort-AV: E=McAfee;i="6200,9189,10225"; a="307372911" X-IronPort-AV: E=Sophos;i="5.88,286,1635231600"; d="scan'208";a="307372911" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2022 07:21:52 -0800 X-IronPort-AV: E=Sophos;i="5.88,286,1635231600"; d="scan'208";a="670541938" Received: from labpc2315.iul.intel.com (HELO localhost) ([172.28.50.57]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2022 07:21:51 -0800 From: Christina Schimpe To: gdb-patches@sourceware.org Subject: [PATCH 2/3] gdb: Add per-remote target variables for memory read and write config Date: Thu, 13 Jan 2022 16:21:17 +0100 Message-Id: <20220113152118.1465255-3-christina.schimpe@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113152118.1465255-1-christina.schimpe@intel.com> References: <20220113152118.1465255-1-christina.schimpe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 13 Jan 2022 15:22:37 -0000 This patch adds per-remote target variables for the configuration of memory read- and write packet size. It is a further change in addition to commit "gdb: Make global feature array a per-remote target array" to apply the fixme notes described in commit 5b6d1e4. The former global variables for that configuration are still available to allow the command line configuration for all future remote connections. Similar to the command line configuration of the per- remote target feature array, the commands - set remotewritesize (deprecated) - set remote memory-read-packet-size - set remote memory-write-packet-size will configure the current target (if available) and future remote connections. The show command will display the global configuration and the packet size of the current remote target, if available. It is required to adapt the test gdb.base/remote.exp which is failing for --target_board=native-extended-gdbserver. With that board GDB connects to gdbserver at gdb start time. Due to this patch two loggings "The target may not be able to.." are shown if the command 'set remote memory-write-packet-size fixed' is executed while a target is connected for the current inferior. To fix this, the clean_restart command is moved to a later time point of the test. It is sufficient to be connected to the server when "runto_main" is executed. Now the connection time is similar to a testrun with --target_board=native-gdbserver. To allow the user to distinguish between the packet-size configuration for future connections and for the currently selected target, the logging of the command 'set remote memory-write-packet-size fixed' is adapted. --- gdb/remote.c | 94 +++++++++++++++++++------------ gdb/testsuite/gdb.base/remote.exp | 7 ++- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 10f9226827..a270cb688c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -563,8 +563,31 @@ struct packet_config enum packet_support support; }; -/* This global array contains the default configuration for every new - per-remote target array. */ +/* User configurable variables for the number of characters in a + memory read/write packet. MIN (rsa->remote_packet_size, + rsa->sizeof_g_packet) is the default. Some targets need smaller + values (fifo overruns, et.al.) and some users need larger values + (speed up transfers). The variables ``preferred_*'' (the user + request), ``current_*'' (what was actually set) and ``forced_*'' + (Positive - a soft limit, negative - a hard limit). */ + +struct memory_packet_config +{ + const char *name; + long size; + int fixed_p; +}; + +/* These global variables contain the default configuration for every new + remote_feature object. */ +static memory_packet_config memory_read_packet_config = +{ + "memory-read-packet-size", +}; +static memory_packet_config memory_write_packet_config = +{ + "memory-write-packet-size", +}; static packet_config remote_protocol_packets[PACKET_MAX]; class remote_features @@ -573,6 +596,9 @@ class remote_features remote_features () { + m_memory_read_packet_config = memory_read_packet_config; + m_memory_write_packet_config = memory_write_packet_config; + std::copy (std::begin (remote_protocol_packets), std::end (remote_protocol_packets), std::begin (m_protocol_packets)); @@ -591,6 +617,9 @@ class remote_features void reset_all_packet_configs_support (void); + memory_packet_config m_memory_read_packet_config; + memory_packet_config m_memory_write_packet_config; + packet_config m_protocol_packets[PACKET_MAX]; }; @@ -1842,21 +1871,6 @@ show_remotebreak (struct ui_file *file, int from_tty, static unsigned int remote_address_size; -/* User configurable variables for the number of characters in a - memory read/write packet. MIN (rsa->remote_packet_size, - rsa->sizeof_g_packet) is the default. Some targets need smaller - values (fifo overruns, et.al.) and some users need larger values - (speed up transfers). The variables ``preferred_*'' (the user - request), ``current_*'' (what was actually set) and ``forced_*'' - (Positive - a soft limit, negative - a hard limit). */ - -struct memory_packet_config -{ - const char *name; - long size; - int fixed_p; -}; - /* The default max memory-write-packet-size, when the setting is "fixed". The 16k is historical. (It came from older GDB's using alloca for buffers and the knowledge (folklore?) that some hosts @@ -1922,7 +1936,8 @@ remote_target::get_memory_packet_size (struct memory_packet_config *config) something really big then do a sanity check. */ static void -set_memory_packet_size (const char *args, struct memory_packet_config *config) +set_memory_packet_size (const char *args, struct memory_packet_config *config, + bool target_connected) { int fixed_p = config->fixed_p; long size = config->size; @@ -1956,9 +1971,16 @@ set_memory_packet_size (const char *args, struct memory_packet_config *config) ? DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED : size); - if (! query (_("The target may not be able to correctly handle a %s\n" - "of %ld bytes. Change the packet size? "), - config->name, query_size)) + if (target_connected + && ! query (_("The target may not be able to correctly handle a %s\n" + "of %ld bytes. Change the packet size? "), + config->name, query_size)) + error (_("Packet size not changed.")); + else if (! target_connected + && ! query (_("Future targets may not be able to correctly " + "handle a %s\nof %ld bytes. Change the packet size " + "for future remote targets? "), + config->name, query_size)) error (_("Packet size not changed.")); } /* Update the config. */ @@ -1989,16 +2011,15 @@ show_memory_packet_size (struct memory_packet_config *config) } } -/* FIXME: needs to be per-remote-target. */ -static struct memory_packet_config memory_write_packet_config = -{ - "memory-write-packet-size", -}; - static void set_memory_write_packet_size (const char *args, int from_tty) { - set_memory_packet_size (args, &memory_write_packet_config); + remote_target *remote = get_current_remote_target (); + if (remote != nullptr) + set_memory_packet_size + (args, &remote->m_features.m_memory_write_packet_config, true); + + set_memory_packet_size (args, &memory_write_packet_config, false); } static void @@ -2060,19 +2081,18 @@ show_remote_packet_max_chars (struct ui_file *file, int from_tty, long remote_target::get_memory_write_packet_size () { - return get_memory_packet_size (&memory_write_packet_config); + return get_memory_packet_size (&m_features.m_memory_write_packet_config); } -/* FIXME: needs to be per-remote-target. */ -static struct memory_packet_config memory_read_packet_config = -{ - "memory-read-packet-size", -}; - static void set_memory_read_packet_size (const char *args, int from_tty) { - set_memory_packet_size (args, &memory_read_packet_config); + remote_target *remote = get_current_remote_target (); + if (remote != nullptr) + set_memory_packet_size + (args, &remote->m_features.m_memory_read_packet_config, true); + + set_memory_packet_size (args, &memory_read_packet_config, false); } static void @@ -2084,7 +2104,7 @@ show_memory_read_packet_size (const char *args, int from_tty) long remote_target::get_memory_read_packet_size () { - long size = get_memory_packet_size (&memory_read_packet_config); + long size = get_memory_packet_size (&m_features.m_memory_read_packet_config); /* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an extra buffer size argument before the memory read size can be diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp index 1f0869433f..31c5adfd0d 100644 --- a/gdb/testsuite/gdb.base/remote.exp +++ b/gdb/testsuite/gdb.base/remote.exp @@ -62,7 +62,7 @@ gdb_test "show remote memory-write-packet-size" \ set test "set remote memory-write-packet-size fixed" gdb_test_multiple $test $test { - -re "Change the packet size. .y or n. " { + -re "Change the packet size for future remote targets. .y or n. " { gdb_test_multiple "y" $test { -re "$gdb_prompt $" { pass $test @@ -70,6 +70,7 @@ gdb_test_multiple $test $test { } } } + gdb_test "show remote memory-write-packet-size" \ "The memory-write-packet-size is 0 \\(default\\). Packets are fixed at 16384 bytes\." \ "write-packet default fixed" @@ -129,8 +130,6 @@ proc gdb_load_timed {executable class writesize} { pass $test } -clean_restart $binfile - # These download tests won't actually download anything on !is_remote # target boards, but we run them anyway because it's simpler, and # harmless. @@ -155,6 +154,8 @@ gdb_load_timed $binfile "limit" 0 # Get the size of random_data table (defaults to 48K). set sizeof_random_data [get_sizeof "random_data" 48*1024] +clean_restart $binfile + # # Part THREE: Check the upload behavour # -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928