From patchwork Mon Mar 6 15:31:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66032 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 237C13854806 for ; Mon, 6 Mar 2023 15:32:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 237C13854806 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678116754; bh=eL3mdRKfSOdbQeDZwIBz/qU+bN8SikfzangJsCJNiZk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dFPZ7EnA/T4+19EqMwQttXhMGCaSioPHH33Vzm93LQczLheLQOI2eHYexS/Z7ypu6 WQeaQMErJRF9VjzMSUuv0uZGj2JxHZ/PLNH4AElfGsz3VivcN8v1Ke7WjZ1kSr3y2u zTeTvCyOFP4KFgONirVqZqtq8wX0QUmPGuZRVFBw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9F3003858C66 for ; Mon, 6 Mar 2023 15:32:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F3003858C66 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-WtXSWMAxPhyO2FL01NH9MQ-1; Mon, 06 Mar 2023 10:32:03 -0500 X-MC-Unique: WtXSWMAxPhyO2FL01NH9MQ-1 Received: by mail-ed1-f69.google.com with SMTP id c1-20020a0564021f8100b004acbe232c03so14148133edc.9 for ; Mon, 06 Mar 2023 07:32:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eL3mdRKfSOdbQeDZwIBz/qU+bN8SikfzangJsCJNiZk=; b=C3IdiZVgQiHr2Q04+LMMnL2Ygf/T59cLQNSkDRWhmKDeeLmZ2m0m1Y4eYj66y+uOiJ BWCfqCxNNHp05q95dxO8PaNE9mosPiroQT4xOb+s5llB5nMb/JX6DXQI4Alp45YUO7aI 53oKrVAVskC/6SWcfWl9pNkgRXTQdyIamkhhbPatbskHthAnuP/dgy/4HFJNC8SlhG7z /CsonAmWLPb/lrM2DRnwG8tJJOau1JzYxzli0RsJUMSHD4VjL9oXnjlixJx09gc12Gjl Xg75iSvaz1CwFYuXfO1oShO4VFl13ImcK/IZA9FRKgmHvFgzfYfGb8anwSwp0lDej/nB fdxQ== X-Gm-Message-State: AO0yUKUAsUqBiCBE9i+AlZAbTjYIwG/bElrhH6p+zwJG123vTCliZh6I 64lYk0nLyZll9q8UtbpN5GSkAEjJ2qqet91nsqMzOgzREbyaWGeAxctU85edD2JISOlXoXuctWB 4jjp+p5Dar0Gw62htrRBfhxjXUishnqX/uwfNGh04QtyJrlL4EMfudnp1GpOiM7tEciiptLw/T2 ta7PNbEA== X-Received: by 2002:a17:907:7ea5:b0:8a5:3d1e:6302 with SMTP id qb37-20020a1709077ea500b008a53d1e6302mr13300971ejc.56.1678116722234; Mon, 06 Mar 2023 07:32:02 -0800 (PST) X-Google-Smtp-Source: AK7set/jV+Bv18rA7qDHcTrjj0StNooK80ia/LYE2Bvmg8RpvAujbQ9bX9KLwDdUZ1wZWGxiQ3c8qw== X-Received: by 2002:a17:907:7ea5:b0:8a5:3d1e:6302 with SMTP id qb37-20020a1709077ea500b008a53d1e6302mr13300941ejc.56.1678116721712; Mon, 06 Mar 2023 07:32:01 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id x8-20020a170906440800b008e8e975e185sm4696476ejo.32.2023.03.06.07.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:32:01 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 1/5] gdb/gdbarch: remove unused 'invalid=True' from gdbarch_components.py Date: Mon, 6 Mar 2023 15:31:53 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Due to the algorithm used to generate verify_gdbarch in gdbarch.py, if a component has a predicate, then a validation check will never be generated. There are a bunch of components that are declared with both a predicate AND have 'invalid=True' set. The 'invalid=True' has no effect. In this commit I clean things up by removing all these additional 'invalid=True' lines. There's no change in any of the generated files after this commit. --- gdb/gdbarch_components.py | 64 --------------------------------------- 1 file changed, 64 deletions(-) diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index caa65c334ec..656c6a9f905 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -374,7 +374,6 @@ Function( name="read_pc", params=[("readable_regcache *", "regcache")], predicate=True, - invalid=True, ) Function( @@ -382,7 +381,6 @@ Function( name="write_pc", params=[("struct regcache *", "regcache"), ("CORE_ADDR", "val")], predicate=True, - invalid=True, ) Method( @@ -411,7 +409,6 @@ Method( ("gdb_byte *", "buf"), ], predicate=True, - invalid=True, ) Method( @@ -425,7 +422,6 @@ never be called. name="pseudo_register_read_value", params=[("readable_regcache *", "regcache"), ("int", "cookednum")], predicate=True, - invalid=True, ) Method( @@ -437,7 +433,6 @@ Method( ("const gdb_byte *", "buf"), ], predicate=True, - invalid=True, ) Value( @@ -469,7 +464,6 @@ Return -1 if something goes wrong, 0 otherwise. name="ax_pseudo_register_collect", params=[("struct agent_expr *", "ax"), ("int", "reg")], predicate=True, - invalid=True, ) Method( @@ -482,7 +476,6 @@ Return -1 if something goes wrong, 0 otherwise. name="ax_pseudo_register_push_stack", params=[("struct agent_expr *", "ax"), ("int", "reg")], predicate=True, - invalid=True, ) Method( @@ -495,7 +488,6 @@ UIOUT is the output stream where the handler will place information. name="report_signal_info", params=[("struct ui_out *", "uiout"), ("enum gdb_signal", "siggnal")], predicate=True, - invalid=True, ) Value( @@ -649,7 +641,6 @@ Method( ("CORE_ADDR", "struct_addr"), ], predicate=True, - invalid=True, ) Value( @@ -673,7 +664,6 @@ Method( ("struct regcache *", "regcache"), ], predicate=True, - invalid=True, ) Method( @@ -721,7 +711,6 @@ Method( ("const char *", "args"), ], predicate=True, - invalid=True, ) Method( @@ -763,7 +752,6 @@ FRAME corresponds to the longjmp frame. name="get_longjmp_target", params=[("frame_info_ptr", "frame"), ("CORE_ADDR *", "pc")], predicate=True, - invalid=True, ) Value( @@ -845,7 +833,6 @@ Method( name="integer_to_address", params=[("struct type *", "type"), ("const gdb_byte *", "buf")], predicate=True, - invalid=True, ) Method( @@ -952,7 +939,6 @@ Method( name="skip_main_prologue", params=[("CORE_ADDR", "ip")], predicate=True, - invalid=True, ) Method( @@ -973,7 +959,6 @@ is not used. name="skip_entrypoint", params=[("CORE_ADDR", "ip")], predicate=True, - invalid=True, ) Function( @@ -1034,7 +1019,6 @@ Method( name="adjust_breakpoint_address", params=[("CORE_ADDR", "bpaddr")], predicate=True, - invalid=True, ) Method( @@ -1094,7 +1078,6 @@ Fetch the target specific address used to represent a load module. name="fetch_tls_load_module_address", params=[("struct objfile *", "objfile")], predicate=True, - invalid=True, ) Method( @@ -1109,7 +1092,6 @@ be zero for statically linked multithreaded inferiors. name="get_thread_local_address", params=[("ptid_t", "ptid"), ("CORE_ADDR", "lm_addr"), ("CORE_ADDR", "offset")], predicate=True, - invalid=True, ) Value( @@ -1143,7 +1125,6 @@ frame-base. Enable frame-base before frame-unwind. name="frame_num_args", params=[("frame_info_ptr", "frame")], predicate=True, - invalid=True, ) Method( @@ -1151,7 +1132,6 @@ Method( name="frame_align", params=[("CORE_ADDR", "address")], predicate=True, - invalid=True, ) Method( @@ -1314,7 +1294,6 @@ past a conditional branch to self. name="software_single_step", params=[("struct regcache *", "regcache")], predicate=True, - invalid=True, ) Method( @@ -1326,7 +1305,6 @@ further single-step is needed before the instruction finishes. name="single_step_through_delay", params=[("frame_info_ptr", "frame")], predicate=True, - invalid=True, ) Function( @@ -1425,7 +1403,6 @@ the main symbol table and DWARF-2 records. name="elf_make_msymbol_special", params=[("asymbol *", "sym"), ("struct minimal_symbol *", "msym")], predicate=True, - invalid=True, ) Function( @@ -1513,7 +1490,6 @@ Function( name="address_class_type_flags", params=[("int", "byte_size"), ("int", "dwarf2_addr_class")], predicate=True, - invalid=True, ) Method( @@ -1521,7 +1497,6 @@ Method( name="address_class_type_flags_to_name", params=[("type_instance_flags", "type_flags")], predicate=True, - invalid=True, ) Method( @@ -1546,7 +1521,6 @@ type_flags was set, false otherwise. name="address_class_name_to_type_flags", params=[("const char *", "name"), ("type_instance_flags *", "type_flags_ptr")], predicate=True, - invalid=True, ) Method( @@ -1572,7 +1546,6 @@ Fetch the pointer to the ith function argument. ("struct type *", "type"), ], predicate=True, - invalid=True, ) Method( @@ -1592,7 +1565,6 @@ sections. ("const struct regcache *", "regcache"), ], predicate=True, - invalid=True, ) Method( @@ -1603,7 +1575,6 @@ Create core file notes name="make_corefile_notes", params=[("bfd *", "obfd"), ("int *", "note_size")], predicate=True, - invalid=True, ) Method( @@ -1614,7 +1585,6 @@ Find core file memory regions name="find_memory_regions", params=[("find_memory_region_ftype", "func"), ("void *", "data")], predicate=True, - invalid=True, ) Method( @@ -1625,7 +1595,6 @@ Given a bfd OBFD, segment ADDRESS and SIZE, create a memory tag section to be du name="create_memtag_section", params=[("bfd *", "obfd"), ("CORE_ADDR", "address"), ("size_t", "size")], predicate=True, - invalid=True, ) Method( @@ -1636,7 +1605,6 @@ Given a memory tag section OSEC, fill OSEC's contents with the appropriate tag d name="fill_memtag_section", params=[("asection *", "osec")], predicate=True, - invalid=True, ) Method( @@ -1654,7 +1622,6 @@ If no tags were found, return an empty vector. ("size_t", "length"), ], predicate=True, - invalid=True, ) Method( @@ -1668,7 +1635,6 @@ failed, otherwise, return the red length of READBUF. name="core_xfer_shared_libraries", params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")], predicate=True, - invalid=True, ) Method( @@ -1681,7 +1647,6 @@ Return the number of bytes read (zero indicates failure). name="core_xfer_shared_libraries_aix", params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")], predicate=True, - invalid=True, ) Method( @@ -1692,7 +1657,6 @@ How the core target converts a PTID from a core file to a string. name="core_pid_to_str", params=[("ptid_t", "ptid")], predicate=True, - invalid=True, ) Method( @@ -1703,7 +1667,6 @@ How the core target extracts the name of a thread from a core file. name="core_thread_name", params=[("struct thread_info *", "thr")], predicate=True, - invalid=True, ) Method( @@ -1716,7 +1679,6 @@ of bytes read (zero indicates EOF, a negative value indicates failure). name="core_xfer_siginfo", params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")], predicate=True, - invalid=True, ) Value( @@ -1727,7 +1689,6 @@ BFD target to use when generating a core file. name="gcore_bfd_target", predicate=True, predefault="0", - invalid=True, printer="pstring (gdbarch->gcore_bfd_target)", ) @@ -1773,7 +1734,6 @@ The maximum length of an instruction on this architecture in bytes. name="max_insn_length", predicate=True, predefault="0", - invalid=True, ) Method( @@ -1806,7 +1766,6 @@ that case. name="displaced_step_copy_insn", params=[("CORE_ADDR", "from"), ("CORE_ADDR", "to"), ("struct regcache *", "regs")], predicate=True, - invalid=True, ) Method( @@ -1856,7 +1815,6 @@ see the comments in infrun.c. ], predicate=True, predefault="NULL", - invalid=True, ) Method( @@ -1869,7 +1827,6 @@ Throw an exception if any unexpected error happens. name="displaced_step_prepare", params=[("thread_info *", "thread"), ("CORE_ADDR &", "displaced_pc")], predicate=True, - invalid=True, ) Method( @@ -1891,7 +1848,6 @@ Return the closure associated to the displaced step buffer that is at ADDR. name="displaced_step_copy_insn_closure_by_addr", params=[("inferior *", "inf"), ("CORE_ADDR", "addr")], predicate=True, - invalid=True, ) Function( @@ -1924,7 +1880,6 @@ offset adjusted; etc. params=[("CORE_ADDR *", "to"), ("CORE_ADDR", "from")], predicate=True, predefault="NULL", - invalid=True, ) Function( @@ -1935,7 +1890,6 @@ Refresh overlay mapped state for section OSECT. name="overlay_update", params=[("struct obj_section *", "osect")], predicate=True, - invalid=True, ) Method( @@ -1943,7 +1897,6 @@ Method( name="core_read_description", params=[("struct target_ops *", "target"), ("bfd *", "abfd")], predicate=True, - invalid=True, ) Value( @@ -1967,7 +1920,6 @@ Return -1 if something goes wrong, 0 otherwise. name="process_record", params=[("struct regcache *", "regcache"), ("CORE_ADDR", "addr")], predicate=True, - invalid=True, ) Method( @@ -1979,7 +1931,6 @@ Return -1 if something goes wrong, 0 otherwise. name="process_record_signal", params=[("struct regcache *", "regcache"), ("enum gdb_signal", "signal")], predicate=True, - invalid=True, ) Method( @@ -1996,7 +1947,6 @@ headers. This is mainly used when cross-debugging core files --- name="gdb_signal_from_target", params=[("int", "signo")], predicate=True, - invalid=True, ) Method( @@ -2013,7 +1963,6 @@ signal number is invalid. name="gdb_signal_to_target", params=[("enum gdb_signal", "signal")], predicate=True, - invalid=True, ) Method( @@ -2026,7 +1975,6 @@ Return a type suitable to inspect extra signal information. name="get_siginfo_type", params=[], predicate=True, - invalid=True, ) Method( @@ -2037,7 +1985,6 @@ Record architecture-specific information from the symbol table. name="record_special_symbol", params=[("struct objfile *", "objfile"), ("asymbol *", "sym")], predicate=True, - invalid=True, ) Method( @@ -2049,7 +1996,6 @@ Get architecture-specific system calls information from registers. name="get_syscall_number", params=[("thread_info *", "thread")], predicate=True, - invalid=True, ) Value( @@ -2219,7 +2165,6 @@ something like `(%', do not match just the `('. name="stap_is_single_operand", params=[("const char *", "s")], predicate=True, - invalid=True, ) Method( @@ -2250,7 +2195,6 @@ parser), and should advance the buffer pointer (p->arg). name="stap_parse_special_token", params=[("struct stap_parse_info *", "p")], predicate=True, - invalid=True, ) Method( @@ -2287,7 +2231,6 @@ The rationale for this can be found at PR breakpoints/24541. ("int", "regnum"), ], predicate=True, - invalid=True, ) Method( @@ -2300,7 +2243,6 @@ NARG must be >= 0. name="dtrace_parse_probe_argument", params=[("int", "narg")], predicate=True, - invalid=True, ) Method( @@ -2312,7 +2254,6 @@ corresponding to a disabled DTrace is-enabled probe. name="dtrace_probe_is_enabled", params=[("CORE_ADDR", "addr")], predicate=True, - invalid=True, ) Method( @@ -2323,7 +2264,6 @@ Enable a DTrace is-enabled probe at ADDR. name="dtrace_enable_probe", params=[("CORE_ADDR", "addr")], predicate=True, - invalid=True, ) Method( @@ -2334,7 +2274,6 @@ Disable a DTrace is-enabled probe at ADDR. name="dtrace_disable_probe", params=[("CORE_ADDR", "addr")], predicate=True, - invalid=True, ) Value( @@ -2476,7 +2415,6 @@ Implement the "info proc" command. name="info_proc", params=[("const char *", "args"), ("enum info_proc_what", "what")], predicate=True, - invalid=True, ) Method( @@ -2489,7 +2427,6 @@ one for live targets. name="core_info_proc", params=[("const char *", "args"), ("enum info_proc_what", "what")], predicate=True, - invalid=True, ) Method( @@ -2585,7 +2522,6 @@ Return 1 if an entry was read into *TYPEP and *VALP. ("CORE_ADDR *", "valp"), ], predicate=True, - invalid=True, ) Method( From patchwork Mon Mar 6 15:31:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66035 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DE5738515CC for ; Mon, 6 Mar 2023 15:33:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DE5738515CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678116784; bh=DO+Jovu2taA68Uu10uUEx0vaUGsaenOjfl1pBBIuaI0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=iFaDauksSvTcY61Fy7fhzXrQ89+3bm5E/sXVhpG/+/wm3GsuEPp6PVVZEvLdZOzqb MF7G4SywrdPmOn+eDp29gS6YKWopFzHlxpOPRofzAvUDZEAogmbh86j5FY2GG4XZ5R guTXwyy6ytgpfT8lOZXYGjgBVGw94MBn9EBbPkg8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 143FC385AC29 for ; Mon, 6 Mar 2023 15:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 143FC385AC29 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-d5XW-_ibMV6f0Y4CxmMQJg-1; Mon, 06 Mar 2023 10:32:04 -0500 X-MC-Unique: d5XW-_ibMV6f0Y4CxmMQJg-1 Received: by mail-ed1-f71.google.com with SMTP id c1-20020a0564021f8100b004acbe232c03so14148228edc.9 for ; Mon, 06 Mar 2023 07:32:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DO+Jovu2taA68Uu10uUEx0vaUGsaenOjfl1pBBIuaI0=; b=w+29UFDQZVixCfldKenMlf6OKckNLOgdTYnFLico9zFuad3nukNrhr4LmeHQS9v5PW hGiZpA2xxH4D/wivku4w0On+J5psXEE1LDvBujnikht64vZ5Xis1As24FYCleGiPFahC Gt0jwLj5pQpizWsuUTMjko49KiSRwcxhTf8pbP1MPUbgK2DMpXykghIKBskZPT6Pye6C 3mXWX0+0MLZMbuoGFc35hOvnyaUuvxwVU2YLkNUJqdIRzyQFU0JWKjADPRr52VaqmmiM RzVbonmBHgpHJ4XbU9km/FfliaEVqMH/Cbwzzzg9J0CDlZOPDKT2jwD/8q6AMsF853U9 F8HA== X-Gm-Message-State: AO0yUKU5/swycZlXzIQzJi3bZTquAVpihZnCsV6Va40RDhZs+fUmpemb nLkgiLBovTrTQdeENYmQ/o2o9B5jidOJgiN/QiQapBKtU8N+c3xymJlnf1ZWFWX83A4vFiWYm9k NxSCmiCoPA4lxOhYdfVzZuqf1dMYWbR3mKFjGQZ6u69/CngbIhSGH+FVB0zk1sdC+7oSxH5Lbvc KQcnUapA== X-Received: by 2002:aa7:d90d:0:b0:4af:70a6:5b06 with SMTP id a13-20020aa7d90d000000b004af70a65b06mr10817914edr.27.1678116723370; Mon, 06 Mar 2023 07:32:03 -0800 (PST) X-Google-Smtp-Source: AK7set8eev84TB/FdYJbv4nZsJ1Vs2hp66KzOFKtoYtGIuwWPNrGZSjjaBKr1Ee90r+XmBaUNBrSgA== X-Received: by 2002:aa7:d90d:0:b0:4af:70a6:5b06 with SMTP id a13-20020aa7d90d000000b004af70a65b06mr10817893edr.27.1678116723042; Mon, 06 Mar 2023 07:32:03 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id k12-20020a50ce4c000000b004c0459c20f9sm5236559edj.66.2023.03.06.07.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:32:02 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 2/5] gdb/gdbarch: remove yet more 'invalid=True' from gdbarch_components.py Date: Mon, 6 Mar 2023 15:31:54 +0000 Message-Id: <2dc5238144357ac1885ae86b12ef6bd77daa01c5.1678116328.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Following on from the previous commit, this commit removes yet more 'invalid=True' lines from gdbarch_components.py where the invalid setting has no effect. Due to the algorithm used in gdbarch.py for generated verify_gdbarch, if a component has a postdefault value then no invalid check will ever be generated for the component, as such setting 'invalid=True' on the component is pointless. This commit removes the setting of invalid. There is no change in the generated code after this commit. --- gdb/gdbarch_components.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 656c6a9f905..d3dfcfc806f 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -206,7 +206,6 @@ Value( type="const struct floatformat **", name="bfloat16_format", postdefault="floatformats_bfloat16", - invalid=True, printer="pformat (gdbarch, gdbarch->bfloat16_format)", ) @@ -221,7 +220,6 @@ Value( type="const struct floatformat **", name="half_format", postdefault="floatformats_ieee_half", - invalid=True, printer="pformat (gdbarch, gdbarch->half_format)", ) @@ -236,7 +234,6 @@ Value( type="const struct floatformat **", name="float_format", postdefault="floatformats_ieee_single", - invalid=True, printer="pformat (gdbarch, gdbarch->float_format)", ) @@ -251,7 +248,6 @@ Value( type="const struct floatformat **", name="double_format", postdefault="floatformats_ieee_double", - invalid=True, printer="pformat (gdbarch, gdbarch->double_format)", ) @@ -266,7 +262,6 @@ Value( type="const struct floatformat **", name="long_double_format", postdefault="floatformats_ieee_double", - invalid=True, printer="pformat (gdbarch, gdbarch->long_double_format)", ) @@ -289,7 +284,6 @@ One if `wchar_t' is signed, zero if unsigned. name="wchar_signed", predefault="-1", postdefault="1", - invalid=True, ) Method( @@ -332,7 +326,6 @@ addr_bit is the size of a target address as represented in gdb name="addr_bit", predefault="0", postdefault="gdbarch_ptr_bit (gdbarch)", - invalid=True, ) Value( @@ -355,7 +348,6 @@ and if Dwarf versions < 4 need to be supported. name="dwarf2_addr_size", predefault="0", postdefault="gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT", - invalid=True, ) Value( @@ -366,7 +358,6 @@ One if `char' acts like `signed char', zero if `unsigned char'. name="char_signed", predefault="-1", postdefault="1", - invalid=True, ) Function( From patchwork Mon Mar 6 15:31:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66033 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 176813853567 for ; Mon, 6 Mar 2023 15:32:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 176813853567 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678116766; bh=6s+kgrU59Xm9Es1+bJ75lFLErd+KHsOQyJSxmH5nKcg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TJRER8wwgqfwkTohsL8BvjyiHghBd8LyPGw2LqqEQZ2NrkScYgbLfWAJ1a/eYFCyH 8Y4byvSCW4ea2MEMLqPFavgeNDPQzBm7KZtteLcQmG4TrTQw3vk3sSN2zaOqMCvcbg HE07Ngt8gTBp7imZ5ceuSr1P9knsDQ11fDpjdH7A= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 60E9238582A3 for ; Mon, 6 Mar 2023 15:32:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60E9238582A3 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-i_ldF0E7N8-nIrQUlDLpWg-1; Mon, 06 Mar 2023 10:32:06 -0500 X-MC-Unique: i_ldF0E7N8-nIrQUlDLpWg-1 Received: by mail-ed1-f71.google.com with SMTP id ec11-20020a0564020d4b00b004e2cb85c8bcso5305312edb.16 for ; Mon, 06 Mar 2023 07:32:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6s+kgrU59Xm9Es1+bJ75lFLErd+KHsOQyJSxmH5nKcg=; b=3q7juUOZZYspH+71R94CTKgPejGnXD/mObJowX4884BoqrtfGXjujhGnz2xbZ45F0Z 0I33ix3Wdfn6Tvaa24zdTcMiYr4RD3Cb5G/g7n71CqFVyH0PDn4Wvhg6qK7AuHpNQ8qL yoALyeJPCrXbEVABHfWtwlOWY/+/f+kW5adUD+DdRSZXMXbqHC2JIumkiCYPl8V6+2oQ AYhB0dEkcMtPE3D1g0CWZvlo0vS5ZCQ5soziqi4bfmdeYdSu4gGPg+chEUkETStVcXqy eDS8Lf+Xa7VURse32D6aGy6x9tvS4DgI04x+mNyM2aQ6JPoka9iz2vhXxUjdUVd9ynVV 74eg== X-Gm-Message-State: AO0yUKW+fFyMEE5nZZDZ9CAppSrSYzdYI7+sZc7PEXmq7CHbCdarFs4u cW1he8PVcrg7akHMDRudkPq834iGypprvNUwxWS/6Y0+3adQxP8Pxy7NMfAR4QbxHHrG/VVG1XX jDHOAJj2EM4JGKP5borKSaSb7e8urW5BEaLhmwoQnx3cwqiEZQL8CzVTCZxUDmVGlH8WNh4RXI0 wrGHpMbQ== X-Received: by 2002:a17:907:1045:b0:8a6:93a4:c892 with SMTP id oy5-20020a170907104500b008a693a4c892mr11089330ejb.44.1678116725060; Mon, 06 Mar 2023 07:32:05 -0800 (PST) X-Google-Smtp-Source: AK7set9fi4OvsoTzFLyfOwSpSc48ZmjzWvcEorU6pi17wo0802tE2Ek+zent5wFBOpubCHaPJ+DLew== X-Received: by 2002:a17:907:1045:b0:8a6:93a4:c892 with SMTP id oy5-20020a170907104500b008a693a4c892mr11089318ejb.44.1678116724689; Mon, 06 Mar 2023 07:32:04 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id u2-20020a50d502000000b004c0057b478bsm5339363edi.34.2023.03.06.07.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:32:04 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 3/5] gdb/gdbarch: split postdefault setup from invalid check in gdbarch.py Date: Mon, 6 Mar 2023 15:31:55 +0000 Message-Id: <06694cb90bbc2a7b8acc8ecc262d28ee3a565331.1678116328.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Restructure how gdbarch.py generates the verify_gdbarch function. Previously the postdefault handling was bundled together with the validation. This means that a field can't have both a postdefault, and set its invalid attribute to a string. This doesn't seem reasonable to me, I see no reason why a field can't have both a postdefault (used when the tdep doesn't set the field), and an invalid expression, which can be used to validate the value that a tdep might set. In this commit I restructure the verify_gdbarch generation code to allow the above, there is no change in the actual generated code in this commit, that will come in later commit. I did end up having to remove the "invalid" attribute (where the attribute was set to True) from a number of fields in this commit. This invalid attribute was never having an effect as these components all have a postdefault. Consider; the "postdefault" is applied if the field still has its initial value, while an "invalid" attribute set to True means error if the field still has its default value. But the field never will have its default value, it will always have its postdefault value. --- gdb/gdbarch.py | 38 ++++++++++++++++++++++--------------- gdb/gdbarch_components.py | 40 +++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py index 93b1e8bf84e..806aee26831 100755 --- a/gdb/gdbarch.py +++ b/gdb/gdbarch.py @@ -203,35 +203,43 @@ with open("gdbarch.c", "w") as f: file=f, ) for c in filter(not_info, components): + # An opportunity to write in the 'postdefault' value. We + # change field's value to the postdefault if its current value + # is not different to the initial value of the field. + if c.postdefault is not None: + init_value = c.predefault or "0" + print(f" if (gdbarch->{c.name} == {init_value})", file=f) + print(f" gdbarch->{c.name} = {c.postdefault};", file=f) + + # Now validate the value. if c.invalid is False: print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) elif c.predicate: print(f" /* Skip verify of {c.name}, has predicate. */", file=f) - elif isinstance(c.invalid, str) and c.postdefault is not None: - print(f" if ({c.invalid})", file=f) - print(f" gdbarch->{c.name} = {c.postdefault};", file=f) - elif c.predefault is not None and c.postdefault is not None: - print(f" if (gdbarch->{c.name} == {c.predefault})", file=f) - print(f" gdbarch->{c.name} = {c.postdefault};", file=f) - elif c.postdefault is not None: - print(f" if (gdbarch->{c.name} == 0)", file=f) - print(f" gdbarch->{c.name} = {c.postdefault};", file=f) + elif c.invalid is None: + # No validation has been requested for this component. + pass elif isinstance(c.invalid, str): print(f" if ({c.invalid})", file=f) print(f""" log.puts ("\\n\\t{c.name}");""", file=f) - elif c.predefault is not None: - print(f" if (gdbarch->{c.name} == {c.predefault})", file=f) - print(f""" log.puts ("\\n\\t{c.name}");""", file=f) elif c.invalid is True: - print(f" if (gdbarch->{c.name} == 0)", file=f) - print(f""" log.puts ("\\n\\t{c.name}");""", file=f) + if c.postdefault is not None: + # This component has its 'invalid' field set to True, but + # also has a postdefault. This makes no sense, the + # postdefault will have been applied above, so this field + # will not have a zero value. + raise Exception(f"component {c.name} has postdefault and invalid set to True") + else: + init_value = c.predefault or "0" + print(f" if (gdbarch->{c.name} == {init_value})", file=f) + print(f""" log.puts ("\\n\\t{c.name}");""", file=f) else: # We should not allow ourselves to simply do nothing here # because no other case applies. If we end up here then # either the input data needs adjusting so one of the # above cases matches, or we need additional cases adding # here. - raise Exception("unhandled case when generating gdbarch validation") + raise Exception(f"unhandled case when generating gdbarch validation: {c.name}") print(" if (!log.empty ())", file=f) print( """ internal_error (_("verify_gdbarch: the following are invalid ...%s"),""", diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index d3dfcfc806f..1f217123216 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -63,34 +63,28 @@ # * "predefault", "postdefault", and "invalid" - These are used for # the initialization and verification steps: # -# A gdbarch is zero-initialized. Then, if a field has a pre-default, -# the field is set to that value. After initialization is complete -# (that is, after the tdep code has a chance to change the settings), -# the post-initialization step is done. +# A gdbarch is zero-initialized. Then, if a field has a "predefault", +# the field is set to that value. This becomes the field's initial +# value. # -# There is a generic algorithm to generate a "validation function" for -# all fields. If the field has an "invalid" attribute with a string -# value, then this string is the expression (note that a string-valued -# "invalid" and "predicate" are mutually exclusive; and the case where -# invalid is True means to ignore this field and instead use the -# default checking that is about to be described). Otherwise, if -# there is a "predefault", then the field is valid if it differs from -# the predefault. Otherwise, the check is done against 0 (really NULL -# for function pointers, but same idea). -# -# In post-initialization / validation, there are several cases. +# After initialization is complete (that is, after the tdep code has a +# chance to change the settings), the post-initialization step is +# done. # -# * If "invalid" is False, or if the field specifies "predicate", -# validation is skipped. Otherwise, a validation step is emitted. +# If the field still has its initial value (see above), and the field +# has a "postdefault", then the field is set to this value. # -# * Otherwise, the validity is checked using the usual validation -# function (see above). If the field is considered valid, nothing is -# done. +# After the possible "postdefault" assignment, validation is +# performed for fields that don't have a "predicate". # -# * Otherwise, the field's value is invalid. If there is a -# "postdefault", then the field is assigned that value. +# If the field has an "invalid" attribute with a string value, then +# this string is the expression that should evaluate to true when the +# field is invalid. # -# * Otherwise, the gdbarch will fail validation and gdb will crash. +# Otherwise, if "invalid" is True, then the generic validation +# function is used: the field is considered invalid it still contains +# its default value. This validation is what is used within the _p +# predicate function if the field has "predicate" set to True. # # Function and Method share: # From patchwork Mon Mar 6 15:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66036 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D4BB385B50D for ; Mon, 6 Mar 2023 15:33:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D4BB385B50D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678116814; bh=lbbq+qpgU32tmPw47obw5bAhNo4+1fMp77S84L0yt+M=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=upvWkAit2KggV6ajk1Q5sPRs9kIDlYt57gIg3qINGldcJsmhzEfrge2eyYr0Q85K/ 7okd+WPFCXJvnek9mALuwo9QR/FP479Shi7amyeD0aC3GAGsgsVCarLeHYmUDBzEBh foMnUWqMp+NIvIjjEKGv3yIDfY5x9kHuVpdQqJZw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id AF7C8385B513 for ; Mon, 6 Mar 2023 15:32:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF7C8385B513 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-286-221LGJw1MRu0rUN-Of8__A-1; Mon, 06 Mar 2023 10:32:08 -0500 X-MC-Unique: 221LGJw1MRu0rUN-Of8__A-1 Received: by mail-ed1-f72.google.com with SMTP id ec11-20020a0564020d4b00b004e2cb85c8bcso5305457edb.16 for ; Mon, 06 Mar 2023 07:32:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116726; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lbbq+qpgU32tmPw47obw5bAhNo4+1fMp77S84L0yt+M=; b=pIUt/YHagR5nT0pvWAsWUln510qPldZChvBzAcg4NpSMCBDc2MZh8ilkj8bq+aB2IO EdvEszUMbtvdsy5BwMuWqLLnpxDlqhS5t08/o65y7DuPYF+f03K2KVwDIg0lnsQiG5hW D9hevBNR2EkhK457ZMNv+KeEMNG79SMvsL2VoYubA9XJqWfAMrJs9Vi2anlnseetbWxk nenH46+Man6dLI5lLpjijA6BWaPrI8gY+BwmA5tur0MCWNfOyWvwXFy1guyop/2Q5J3k 9viI2jIoyYO4qAJMCYfkPyuBvPP2pi+TPP9Uqw/qIFVa50RvZc2bsGFmeV5s4/LuV8GA JXng== X-Gm-Message-State: AO0yUKUHArRLOpV3hKSWhXQ7QAnGVr/DtSxOVlpfcDdBkaq3O8q9AOm2 GaTrhLZ7N23+gQn4++gBcuGdGKD1tl3NdtMk0MSmNQq4ljdOXNFS6h98E2lvAJkeRO+fxbzAt+q 4CKiko9mnzwpEXV1KFsTsQ0BpU8dS14GzDN979Qg3X1e1n59BB0my5lueFodn+sNcFiKB9Kw4qR OLzuk+0g== X-Received: by 2002:a17:906:af18:b0:8aa:c155:9233 with SMTP id lx24-20020a170906af1800b008aac1559233mr11008399ejb.26.1678116726567; Mon, 06 Mar 2023 07:32:06 -0800 (PST) X-Google-Smtp-Source: AK7set/bhJoex42FnNGUXwXaZ/BbPVmpEEqEQjwiyw7+Zm81jbSekiqwKZqBZBZmo9+IvYML6WEl3A== X-Received: by 2002:a17:906:af18:b0:8aa:c155:9233 with SMTP id lx24-20020a170906af1800b008aac1559233mr11008361ejb.26.1678116726053; Mon, 06 Mar 2023 07:32:06 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id f20-20020a1709064dd400b008ec43ae626csm4688299ejw.167.2023.03.06.07.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:32:05 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 4/5] gdb/gdbarch: remove the 'invalid=None' state from gdbarch_components.py Date: Mon, 6 Mar 2023 15:31:56 +0000 Message-Id: <7452e65c89feea14efa71eb0272e00c2e68f6afd.1678116328.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This commit ensures that the 'invalid' property of all components is either True, False, or a string. Additionally, this commit allows a component to have both a predicate and for the 'invalid' property to be a string. Removing the option for 'invalid' to be None allows us to simplify the algorithms in gdbarch.py a little. Allowing a component to have both a predicate and an 'invalid' string means that we can validate the value that a tdep sets into a field, but also allow a predicate to ensure that the field has changed from the default. This functionality isn't going to be used in this series, but I have tested it locally and believe that it would work, and this might make it easier for others to add new components in the future. In gdbarch_types.py, I've updated the type annotations to show that the 'invalid' field should not be None, and I've changed the default for this field from None to False. Additionally, in gdbarch_types.py I've removed an assert from Component.get_predicate. This assert ensured that we didn't have the predicate field set to True and the invalid field set to a string. However, no component currently uses this configuration, and after this commit, that combination is now supported, so the assert can be removed. As a consequence of the gdbarch_types.py changes we see some additional comments generated in gdbarch.c about verification being skipped due to the invalid field being False. In gdbarch_components.py I've had to add 'invalid=True' for two components: gcore_bfd_target and max_insn_length, without this the validation in the gdbarch getter would disappear. And in gdbarch.py I've reworked the logic for generating the verify_gdbarch function, and for generating the getter functions. The logic for generating the getter functions is still not ideal, I ended up having to add this additional logic block: elif c.postdefault is not None and c.predefault is not None: print(" /* Check variable changed from pre-default. */", file=f) print(f" gdb_assert (gdbarch->{c.name} != {c.predefault});", file=f) which was needed to ensure we continued to generate the same code as before, without this the fact that invalid is now False when it would previously have been None, meant that we dropped the gdb_assert in favour of a comment like: print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) which is clearly not a good change. We could potentially look at improving this in a later commit, but I don't plan to do that in this series. --- gdb/gdbarch.c | 16 ++++++++++++++++ gdb/gdbarch.py | 32 +++++++++++++------------------- gdb/gdbarch_components.py | 2 ++ gdb/gdbarch_types.py | 7 +++---- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 7e4e34d5aca..efd111eeabc 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -298,29 +298,38 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of bfloat16_bit, invalid_p == 0 */ if (gdbarch->bfloat16_format == 0) gdbarch->bfloat16_format = floatformats_bfloat16; + /* Skip verify of bfloat16_format, invalid_p == 0 */ /* Skip verify of half_bit, invalid_p == 0 */ if (gdbarch->half_format == 0) gdbarch->half_format = floatformats_ieee_half; + /* Skip verify of half_format, invalid_p == 0 */ /* Skip verify of float_bit, invalid_p == 0 */ if (gdbarch->float_format == 0) gdbarch->float_format = floatformats_ieee_single; + /* Skip verify of float_format, invalid_p == 0 */ /* Skip verify of double_bit, invalid_p == 0 */ if (gdbarch->double_format == 0) gdbarch->double_format = floatformats_ieee_double; + /* Skip verify of double_format, invalid_p == 0 */ /* Skip verify of long_double_bit, invalid_p == 0 */ if (gdbarch->long_double_format == 0) gdbarch->long_double_format = floatformats_ieee_double; + /* Skip verify of long_double_format, invalid_p == 0 */ /* Skip verify of wchar_bit, invalid_p == 0 */ if (gdbarch->wchar_signed == -1) gdbarch->wchar_signed = 1; + /* Skip verify of wchar_signed, invalid_p == 0 */ /* Skip verify of floatformat_for_type, invalid_p == 0 */ /* Skip verify of ptr_bit, invalid_p == 0 */ if (gdbarch->addr_bit == 0) gdbarch->addr_bit = gdbarch_ptr_bit (gdbarch); + /* Skip verify of addr_bit, invalid_p == 0 */ if (gdbarch->dwarf2_addr_size == 0) gdbarch->dwarf2_addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; + /* Skip verify of dwarf2_addr_size, invalid_p == 0 */ if (gdbarch->char_signed == -1) gdbarch->char_signed = 1; + /* Skip verify of char_signed, invalid_p == 0 */ /* Skip verify of read_pc, has predicate. */ /* Skip verify of write_pc, has predicate. */ /* Skip verify of virtual_frame_pointer, invalid_p == 0 */ @@ -412,6 +421,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of skip_trampoline_code, invalid_p == 0 */ if (gdbarch->so_ops == 0) gdbarch->so_ops = &solib_target_so_ops; + /* Skip verify of so_ops, invalid_p == 0 */ /* Skip verify of skip_solib_resolver, invalid_p == 0 */ /* Skip verify of in_solib_return_trampoline, invalid_p == 0 */ /* Skip verify of in_indirect_branch_thunk, invalid_p == 0 */ @@ -1490,6 +1500,7 @@ const struct floatformat ** gdbarch_bfloat16_format (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of bfloat16_format, invalid_p == 0 */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_bfloat16_format called\n"); return gdbarch->bfloat16_format; @@ -1523,6 +1534,7 @@ const struct floatformat ** gdbarch_half_format (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of half_format, invalid_p == 0 */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_half_format called\n"); return gdbarch->half_format; @@ -1556,6 +1568,7 @@ const struct floatformat ** gdbarch_float_format (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of float_format, invalid_p == 0 */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_float_format called\n"); return gdbarch->float_format; @@ -1589,6 +1602,7 @@ const struct floatformat ** gdbarch_double_format (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of double_format, invalid_p == 0 */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_double_format called\n"); return gdbarch->double_format; @@ -1622,6 +1636,7 @@ const struct floatformat ** gdbarch_long_double_format (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of long_double_format, invalid_p == 0 */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_long_double_format called\n"); return gdbarch->long_double_format; @@ -3304,6 +3319,7 @@ const struct target_so_ops * gdbarch_so_ops (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of so_ops, invalid_p == 0 */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_so_ops called\n"); return gdbarch->so_ops; diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py index 806aee26831..f296c160bbc 100755 --- a/gdb/gdbarch.py +++ b/gdb/gdbarch.py @@ -212,17 +212,12 @@ with open("gdbarch.c", "w") as f: print(f" gdbarch->{c.name} = {c.postdefault};", file=f) # Now validate the value. - if c.invalid is False: - print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) - elif c.predicate: - print(f" /* Skip verify of {c.name}, has predicate. */", file=f) - elif c.invalid is None: - # No validation has been requested for this component. - pass - elif isinstance(c.invalid, str): + if isinstance(c.invalid, str): print(f" if ({c.invalid})", file=f) print(f""" log.puts ("\\n\\t{c.name}");""", file=f) - elif c.invalid is True: + elif c.predicate: + print(f" /* Skip verify of {c.name}, has predicate. */", file=f) + elif c.invalid: if c.postdefault is not None: # This component has its 'invalid' field set to True, but # also has a postdefault. This makes no sense, the @@ -234,12 +229,7 @@ with open("gdbarch.c", "w") as f: print(f" if (gdbarch->{c.name} == {init_value})", file=f) print(f""" log.puts ("\\n\\t{c.name}");""", file=f) else: - # We should not allow ourselves to simply do nothing here - # because no other case applies. If we end up here then - # either the input data needs adjusting so one of the - # above cases matches, or we need additional cases adding - # here. - raise Exception(f"unhandled case when generating gdbarch validation: {c.name}") + print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) print(" if (!log.empty ())", file=f) print( """ internal_error (_("verify_gdbarch: the following are invalid ...%s"),""", @@ -356,14 +346,18 @@ with open("gdbarch.c", "w") as f: print(f"gdbarch_{c.name} (struct gdbarch *gdbarch)", file=f) print("{", file=f) print(" gdb_assert (gdbarch != NULL);", file=f) - if c.invalid is False: - print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) - elif isinstance(c.invalid, str): + if isinstance(c.invalid, str): print(" /* Check variable is valid. */", file=f) print(f" gdb_assert (!({c.invalid}));", file=f) - elif c.predefault: + elif c.postdefault is not None and c.predefault is not None: print(" /* Check variable changed from pre-default. */", file=f) print(f" gdb_assert (gdbarch->{c.name} != {c.predefault});", file=f) + elif c.invalid: + if c.predefault: + print(" /* Check variable changed from pre-default. */", file=f) + print(f" gdb_assert (gdbarch->{c.name} != {c.predefault});", file=f) + else: + print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) print(" if (gdbarch_debug >= 2)", file=f) print( f""" gdb_printf (gdb_stdlog, "gdbarch_{c.name} called\\n");""", diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 1f217123216..1eef2fb584e 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1675,6 +1675,7 @@ BFD target to use when generating a core file. predicate=True, predefault="0", printer="pstring (gdbarch->gcore_bfd_target)", + invalid=True ) Value( @@ -1719,6 +1720,7 @@ The maximum length of an instruction on this architecture in bytes. name="max_insn_length", predicate=True, predefault="0", + invalid=True, ) Method( diff --git a/gdb/gdbarch_types.py b/gdb/gdbarch_types.py index 988da80dd7c..d40851d127f 100755 --- a/gdb/gdbarch_types.py +++ b/gdb/gdbarch_types.py @@ -46,7 +46,7 @@ class Component: predicate: bool = False, predefault: Optional[str] = None, postdefault: Optional[str] = None, - invalid: Optional[Union[bool, str]] = None, + invalid: Union[bool, str] = False, params: Optional[List[Tuple[str, str]]] = None, param_checks: Optional[List[str]] = None, result_checks: Optional[List[str]] = None, @@ -74,7 +74,6 @@ class Component: def get_predicate(self): "Return the expression used for validity checking." - assert self.predicate and not isinstance(self.invalid, str) if self.predefault: predicate = f"gdbarch->{self.name} != {self.predefault}" else: @@ -98,7 +97,7 @@ class Value(Component): predicate: bool = False, predefault: Optional[str] = None, postdefault: Optional[str] = None, - invalid: Optional[Union[bool, str]] = None, + invalid: Union[bool, str] = False, printer: Optional[str] = None, ): super().__init__( @@ -126,7 +125,7 @@ class Function(Component): predicate: bool = False, predefault: Optional[str] = None, postdefault: Optional[str] = None, - invalid: Optional[Union[bool, str]] = None, + invalid: Union[bool, str] = False, printer: Optional[str] = None, param_checks: Optional[List[str]] = None, result_checks: Optional[List[str]] = None, From patchwork Mon Mar 6 15:31:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66034 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 028E438515F1 for ; Mon, 6 Mar 2023 15:33:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 028E438515F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678116780; bh=WPiRKQOYcxJ1o6Dfiu+HvAjM8+A+kd+k+X71grt8GpE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=VOww5KnIGzyX/yju8tq0/3RSZCCZrZ0/LeAf7RYV4mfQOgbZlvN94g6W63N9XCs7m BWlAipp9n/9DNsdR1jeQskaThJB4xmV/JCV44cLtbhWUFjzOeXVTC1rci39oDp6hlq yarYOWDTtXlxGG1Ypv24phQn2a9Nsr2oF2Vku4oQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6F21D385B526 for ; Mon, 6 Mar 2023 15:32:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F21D385B526 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-emdZRvDWN5KAflMhmehzqA-1; Mon, 06 Mar 2023 10:32:09 -0500 X-MC-Unique: emdZRvDWN5KAflMhmehzqA-1 Received: by mail-ed1-f70.google.com with SMTP id d35-20020a056402402300b004e37aed9832so5003092eda.18 for ; Mon, 06 Mar 2023 07:32:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678116728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WPiRKQOYcxJ1o6Dfiu+HvAjM8+A+kd+k+X71grt8GpE=; b=tqo2N/yeJsle2aOxkcJyJ6C3nf6STa5J/IR83Oko5UGLwz5mcUg45HrjVQBEQHQH6u L0PL6BxcWINsoXLVdsfk0kXeOpwkzJRQ7j7zmJromNMOTFfWbotloBltN/ZzNKDD+56G KeB2iWMNGEtLXys8Emp4KeN3fjoHOme75Fxzy/WQZojCz3FaZkmnEuepbuGB8+jrMkE7 FmHLzKEK6dks2PXg+00g1J+JFFaYUxpJ6yu+HoKzAI8p61dH2GMNkBQFK2ogekOOLNLP RK5Fg3Ov2BsxV6VRZEcKGyuPBEuNN9P46oT250bxOvazzObkXh1qG/Zv+BKlfcH5hc2n /75A== X-Gm-Message-State: AO0yUKXgvc9IkIrGPEaMd1C4pJBl+LjgdIZh4kgf55VNkTHOUPv8i2Li 4/FUgRBYbJBd5vVPccMsIrlPQEdmeN913Htwy5WkTa4DsA3LlK/H7p6Z2vfUcnNWb+cvC+lvQGN IQze+lTGRnkP6x4uRBt1kdedx/5hD8BXzskvCWacblz9bo5RlJTsR89FPWLFMllpF3HonXROppz 0KUFrFJw== X-Received: by 2002:a17:907:60d1:b0:907:68b9:e05c with SMTP id hv17-20020a17090760d100b0090768b9e05cmr14346605ejc.58.1678116727640; Mon, 06 Mar 2023 07:32:07 -0800 (PST) X-Google-Smtp-Source: AK7set+ErpuXXO6jlZR4tG+KRMFWR+nhz9fFkX9DPz8IGxrEnbiy2F/7c7czMR8oUBaIf05cZ93CBQ== X-Received: by 2002:a17:907:60d1:b0:907:68b9:e05c with SMTP id hv17-20020a17090760d100b0090768b9e05cmr14346572ejc.58.1678116727287; Mon, 06 Mar 2023 07:32:07 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id 23-20020a170906005700b008e3e2b6a9adsm4734112ejg.94.2023.03.06.07.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 07:32:06 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess , Simon Marchi Subject: [PATCHv2 5/5] gdb: add gdbarch::displaced_step_buffer_length Date: Mon, 6 Mar 2023 15:31:57 +0000 Message-Id: <4d9f698341b49f6f0c58537a46caf30b953d17ca.1678116328.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The gdbarch::max_insn_length field is used mostly to support displaced stepping; it controls the size of the buffers allocated for the displaced-step instruction, and is also used when first copying the instruction, and later, when fixing up the instruction, in order to read in and parse the instruction being stepped. However, it has started to be used in other places in GDB, for example, it's used in the Python disassembler API, and it is used on amd64 as part of branch-tracing instruction classification. The problem is that the value assigned to max_insn_length is not always the maximum instruction length, but sometimes is a multiple of that length, as required to support displaced stepping, see rs600, ARM, and AArch64 for examples of this. It seems to me that we are overloading the meaning of the max_insn_length field, and I think that could potentially lead to confusion. I propose that we add a new gdbarch field, gdbarch::displaced_step_buffer_length, this new field will do exactly what it says on the tin; represent the required displaced step buffer size. The max_insn_length field can then do exactly what it claims to do; represent the maximum length of a single instruction. As some architectures (e.g. i386, and amd64) only require their displaced step buffers to be a single instruction in size, I propose that the default for displaced_step_buffer_length will be the value of max_insn_length. Architectures than need more buffer space can then override this default as needed. I've updated all architectures to setup the new field if appropriate, and I've audited all calls to gdbarch_max_insn_length and switched to gdbarch_displaced_step_buffer_length where appropriate. There should be no user visible changes after this commit. Approved-By: Simon Marchi --- gdb/aarch64-linux-tdep.c | 4 +++- gdb/arm-tdep.c | 4 +++- gdb/displaced-stepping.c | 6 +++--- gdb/gdbarch-gen.h | 12 ++++++++++-- gdb/gdbarch.c | 26 ++++++++++++++++++++++++++ gdb/gdbarch_components.py | 18 ++++++++++++++++-- gdb/linux-tdep.c | 2 +- gdb/rs6000-tdep.c | 6 ++++-- 8 files changed, 66 insertions(+), 12 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 0000b498f89..3eaf4e1131f 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -2240,7 +2240,9 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_get_syscall_number (gdbarch, aarch64_linux_get_syscall_number); /* Displaced stepping. */ - set_gdbarch_max_insn_length (gdbarch, 4 * AARCH64_DISPLACED_MODIFIED_INSNS); + set_gdbarch_max_insn_length (gdbarch, 4); + set_gdbarch_displaced_step_max_buffer_length + (gdbarch, 4 * AARCH64_DISPLACED_MODIFIED_INSNS); set_gdbarch_displaced_step_copy_insn (gdbarch, aarch64_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, aarch64_displaced_step_fixup); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index b64c21ce68f..d1941992c77 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -10662,7 +10662,9 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Note: for displaced stepping, this includes the breakpoint, and one word of additional scratch space. This setting isn't used for anything beside displaced stepping at present. */ - set_gdbarch_max_insn_length (gdbarch, 4 * ARM_DISPLACED_MODIFIED_INSNS); + set_gdbarch_displaced_step_max_buffer_length + (gdbarch, 4 * ARM_DISPLACED_MODIFIED_INSNS); + set_gdbarch_max_insn_length (gdbarch, 4); /* This should be low enough for everything. */ tdep->lowest_pc = 0x20; diff --git a/gdb/displaced-stepping.c b/gdb/displaced-stepping.c index 06b32a80f6a..72b6366390f 100644 --- a/gdb/displaced-stepping.c +++ b/gdb/displaced-stepping.c @@ -55,7 +55,7 @@ displaced_step_buffers::prepare (thread_info *thread, CORE_ADDR &displaced_pc) regcache *regcache = get_thread_regcache (thread); const address_space *aspace = regcache->aspace (); gdbarch *arch = regcache->arch (); - ULONGEST len = gdbarch_max_insn_length (arch); + ULONGEST len = gdbarch_displaced_step_max_buffer_length (arch); /* Search for an unused buffer. */ displaced_step_buffer *buffer = nullptr; @@ -243,7 +243,7 @@ displaced_step_buffers::finish (gdbarch *arch, thread_info *thread, below. */ thread->inf->displaced_step_state.unavailable = false; - ULONGEST len = gdbarch_max_insn_length (arch); + ULONGEST len = gdbarch_displaced_step_max_buffer_length (arch); /* Restore memory of the buffer. */ write_memory_ptid (thread->ptid, buffer->addr, @@ -302,7 +302,7 @@ displaced_step_buffers::restore_in_ptid (ptid_t ptid) regcache *regcache = get_thread_regcache (buffer.current_thread); gdbarch *arch = regcache->arch (); - ULONGEST len = gdbarch_max_insn_length (arch); + ULONGEST len = gdbarch_displaced_step_max_buffer_length (arch); write_memory_ptid (ptid, buffer.addr, buffer.saved_copy.data (), len); diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index ddb97f60315..76d12a15317 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -1039,8 +1039,8 @@ extern void set_gdbarch_max_insn_length (struct gdbarch *gdbarch, ULONGEST max_i see the comments in infrun.c. The TO area is only guaranteed to have space for - gdbarch_max_insn_length (arch) bytes, so this function must not - write more bytes than that to that area. + gdbarch_displaced_step_buffer_length (arch) octets, so this + function must not write more octets than that to this area. If you do not provide this function, GDB assumes that the architecture does not support displaced stepping. @@ -1122,6 +1122,14 @@ typedef void (gdbarch_displaced_step_restore_all_in_ptid_ftype) (inferior *paren extern void gdbarch_displaced_step_restore_all_in_ptid (struct gdbarch *gdbarch, inferior *parent_inf, ptid_t child_ptid); extern void set_gdbarch_displaced_step_restore_all_in_ptid (struct gdbarch *gdbarch, gdbarch_displaced_step_restore_all_in_ptid_ftype *displaced_step_restore_all_in_ptid); +/* The maximum length in octets required for a displaced-step instruction + buffer. By default this will be the same as gdbarch::max_insn_length, + but should be overridden for architectures that might expand a + displaced-step instruction to multiple replacement instructions. */ + +extern ULONGEST gdbarch_displaced_step_buffer_length (struct gdbarch *gdbarch); +extern void set_gdbarch_displaced_step_buffer_length (struct gdbarch *gdbarch, ULONGEST displaced_step_buffer_length); + /* Relocate an instruction to execute at a different address. OLDLOC is the address in the inferior memory where the instruction to relocate is currently at. On input, TO points to the destination diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index efd111eeabc..8cb307d39c9 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -192,6 +192,7 @@ struct gdbarch gdbarch_displaced_step_finish_ftype *displaced_step_finish = NULL; gdbarch_displaced_step_copy_insn_closure_by_addr_ftype *displaced_step_copy_insn_closure_by_addr = nullptr; gdbarch_displaced_step_restore_all_in_ptid_ftype *displaced_step_restore_all_in_ptid = nullptr; + ULONGEST displaced_step_buffer_length = 0; gdbarch_relocate_instruction_ftype *relocate_instruction = NULL; gdbarch_overlay_update_ftype *overlay_update = nullptr; gdbarch_core_read_description_ftype *core_read_description = nullptr; @@ -463,6 +464,10 @@ verify_gdbarch (struct gdbarch *gdbarch) log.puts ("\n\tdisplaced_step_finish"); /* Skip verify of displaced_step_copy_insn_closure_by_addr, has predicate. */ /* Skip verify of displaced_step_restore_all_in_ptid, invalid_p == 0 */ + if (gdbarch->displaced_step_buffer_length == 0) + gdbarch->displaced_step_buffer_length = gdbarch->max_insn_length; + if (gdbarch->displaced_step_buffer_length < gdbarch->max_insn_length) + log.puts ("\n\tdisplaced_step_buffer_length"); /* Skip verify of relocate_instruction, has predicate. */ /* Skip verify of overlay_update, has predicate. */ /* Skip verify of core_read_description, has predicate. */ @@ -1121,6 +1126,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) gdb_printf (file, "gdbarch_dump: displaced_step_restore_all_in_ptid = <%s>\n", host_address_to_string (gdbarch->displaced_step_restore_all_in_ptid)); + gdb_printf (file, + "gdbarch_dump: displaced_step_buffer_length = %s\n", + plongest (gdbarch->displaced_step_buffer_length)); gdb_printf (file, "gdbarch_dump: gdbarch_relocate_instruction_p() = %d\n", gdbarch_relocate_instruction_p (gdbarch)); @@ -4169,6 +4177,24 @@ set_gdbarch_displaced_step_restore_all_in_ptid (struct gdbarch *gdbarch, gdbarch->displaced_step_restore_all_in_ptid = displaced_step_restore_all_in_ptid; } +ULONGEST +gdbarch_displaced_step_buffer_length (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Check variable is valid. */ + gdb_assert (!(gdbarch->displaced_step_buffer_length < gdbarch->max_insn_length)); + if (gdbarch_debug >= 2) + gdb_printf (gdb_stdlog, "gdbarch_displaced_step_buffer_length called\n"); + return gdbarch->displaced_step_buffer_length; +} + +void +set_gdbarch_displaced_step_buffer_length (struct gdbarch *gdbarch, + ULONGEST displaced_step_buffer_length) +{ + gdbarch->displaced_step_buffer_length = displaced_step_buffer_length; +} + bool gdbarch_relocate_instruction_p (struct gdbarch *gdbarch) { diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 1eef2fb584e..58fba1aea71 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1739,8 +1739,8 @@ For a general explanation of displaced stepping and how GDB uses it, see the comments in infrun.c. The TO area is only guaranteed to have space for -gdbarch_max_insn_length (arch) bytes, so this function must not -write more bytes than that to that area. +gdbarch_displaced_step_buffer_length (arch) octets, so this +function must not write more octets than that to this area. If you do not provide this function, GDB assumes that the architecture does not support displaced stepping. @@ -1848,6 +1848,20 @@ contents of all displaced step buffers in the child's address space. invalid=False, ) +Value( + comment=""" +The maximum length in octets required for a displaced-step instruction +buffer. By default this will be the same as gdbarch::max_insn_length, +but should be overridden for architectures that might expand a +displaced-step instruction to multiple replacement instructions. +""", + type="ULONGEST", + name="displaced_step_buffer_length", + predefault="0", + postdefault="gdbarch->max_insn_length", + invalid="gdbarch->displaced_step_buffer_length < gdbarch->max_insn_length", +) + Method( comment=""" Relocate an instruction to execute at a different address. OLDLOC diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index e6ce13a1c67..ce48515d8ca 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2603,7 +2603,7 @@ linux_displaced_step_prepare (gdbarch *arch, thread_info *thread, at DISP_STEP_BUF_ADDR. They are all of size BUF_LEN. */ CORE_ADDR disp_step_buf_addr = linux_displaced_step_location (thread->inf->gdbarch); - int buf_len = gdbarch_max_insn_length (arch); + int buf_len = gdbarch_displaced_step_max_buffer_length (arch); linux_gdbarch_data *gdbarch_data = get_linux_gdbarch_data (arch); gdb_assert (gdbarch_data->num_disp_step_buffers > 0); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 104515de030..9fc4574bb41 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -889,7 +889,8 @@ ppc_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) { - size_t len = gdbarch_max_insn_length (gdbarch); + size_t len = gdbarch_displaced_step_max_buffer_length (gdbarch); + gdb_assert (len > PPC_INSN_SIZE); std::unique_ptr closure (new ppc_displaced_step_copy_insn_closure (len)); gdb_byte *buf = closure->buf.data (); @@ -8363,8 +8364,9 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_displaced_step_finish (gdbarch, ppc_displaced_step_finish); set_gdbarch_displaced_step_restore_all_in_ptid (gdbarch, ppc_displaced_step_restore_all_in_ptid); + set_gdbarch_displaced_step_max_buffer_length (gdbarch, 2 * PPC_INSN_SIZE); - set_gdbarch_max_insn_length (gdbarch, 2 * PPC_INSN_SIZE); + set_gdbarch_max_insn_length (gdbarch, PPC_INSN_SIZE); /* Hook in ABI-specific overrides, if they have been registered. */ info.target_desc = tdesc;