From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WHIGBz9Q0GefMAwAWB0awg (envelope-from ) for ; Tue, 11 Mar 2025 11:01:19 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=NTfpf+hl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 18EEA1E105; Tue, 11 Mar 2025 11:01:19 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 50A311E08E for ; Tue, 11 Mar 2025 11:01:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0337C385780F for ; Tue, 11 Mar 2025 15:01:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0337C385780F Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=NTfpf+hl Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id CC2F03858294 for ; Tue, 11 Mar 2025 14:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC2F03858294 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CC2F03858294 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741705055; cv=none; b=v34UyEcZOZP8158qTSWP2/fFL6wVzibmOwCTMemAcmpPvNkVbPWVwz3coQGUXA+v/ePPGm5CYDLPKU9A/X22CTjJ4ee9w33KzCbO1YZ5fFwSUd4QfOaVL3fZoMiFZnY3wcj2Yl1uUnNduXADZPPpnaCE3ZPH4vsWMnfobBY0VmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741705055; c=relaxed/simple; bh=1Qky8UHlVkfG94X3ApRXl2xk4iQViTL2uj2oM5RhPyU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tm26FDua0+yieLfyb7sTRu7lTN/bjvszcKy8jVMSLkwBxJ8Y3e3QvEoeAUXQUKKWKuoPBvdTIfSIDpUqwNus06rLlZH1e6ufaAZs24GjOiONoJrJ2UHQ3yUYzD8InppRpcpBy+GionX0vUomteMSMm2LccyhoduL5Oo+hPrxqjo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-390fdaf2897so5401855f8f.0 for ; Tue, 11 Mar 2025 07:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741705053; x=1742309853; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RE3i5sWYOv8n4BAWEnW0gLBro5CA0lNgpSz88RSMC3Q=; b=NTfpf+hlO0RHtd17Tcyhxvk3XezcBBzY8usbnwWgmTlRPvnq615bApQ5uBejCdXJJT 8NfDDIoIFWVF50sDmgu+MRtCz+3VLfsnCsqOEJP7KyaAsh1kaknzRZVMRzpaYcNp6mhg UCdqJS5WHAujXbGsCki6BffEJXapMn8ZOooJsYtoOxLMuJ1NG7rf2w3pUTB70AEvI2OZ BUtK/UNGnWHNGVAiAeMeRc8opLbNqDkOcz+awA2vnep3WPeUhslGr8Jw3E2llJNsUb+Y qiVvNYuLB7DYEnEesrkQN8LVaCNHQd4MQVSzlHJ31Te2OLJAUtZC8zbutigWTdsoP0aW LDgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741705053; x=1742309853; 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=RE3i5sWYOv8n4BAWEnW0gLBro5CA0lNgpSz88RSMC3Q=; b=MO7un1T9Y0HAyYgXEKhhOHAgPsc2hhB/QJ5HXRT2yLbhea8u5Rya3AcPpeDzsmI6Jy EbL6Lwy0aUbLnNXSnBxgpOvDVB7bBMM5TEZ+zQdSV9ZcWhZmqY5JNKKf7POxA8V7M8fR x8xewCTpjwaBBoWV5RYi1FeC2K0CFgtpT1XT3nJFjgy7aFIRsm0NEz0Rt8SY1m96qi1z JSSSwVVhrzdJCAl50rXm6gFUfrZoide2/aIVRpbjiHyOwttuCV2u5MQk3H/2cgGZzH00 7baqP3FRLvSAnwQMSct3mNy+IioqXcuJmXJQT8UpYtdwLQ0vZEdMTOm6jDzyyvSZrPwa lFYg== X-Gm-Message-State: AOJu0YyANtpCYOrdlCkgNe0Ck9vpHNteGsyjVNN4lWVxdkOKTAN9IB9P ZJSuUhkKinWOL0J28S3uV2axI3th2Bc7FbkOET3Euw9XJAdlHHfAOCfobA== X-Gm-Gg: ASbGncuU4PVI99QxmXpboBJHlIIz8sfm05QDL69YTzPUkeIcs3fsk7F2lF/4ZZEguKS iUXP0aUUV6zGV278DZFrlqiOetvIFPxjU1R6uIVO4uvRajBhmsnRBqE7Ztv2Uo0Vt+j5UL2wTqd LSEOFNeYx5coXjbd8EZgqzo6XHAuf0ETo+IasIfYcjC3idcbvNCEI0kjk0lJrzT7wQY2G5Z7BIc Vsw68RSg6ulQAr5Wk8d8aamkh08//aI87YvY56i52H5afBKaD1SiCrNVDbkJn2cnjpteoNrIEkt w3V+AiYOXHRd/xG7QNudFYycOx5R5cpaHSPvxP+R5v+4AeHU1r1dfPKNj+MaGBI4pRjY X-Google-Smtp-Source: AGHT+IHe7nwV3Oi156ddV87WHJkw2/IJwyH/dadp1eOgErPkC101iyju2o2q/0nD3CL8amkYHW1CIw== X-Received: by 2002:a5d:64c7:0:b0:390:e2a3:cb7b with SMTP id ffacd0b85a97d-39132da28a0mr18225276f8f.34.1741705052643; Tue, 11 Mar 2025 07:57:32 -0700 (PDT) Received: from pop-os.ssw.jku.at ([140.78.145.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac239439074sm945195866b.10.2025.03.11.07.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 07:57:32 -0700 (PDT) From: dominikmascherbauer X-Google-Original-From: dominikmascherbauer To: gdb-patches@sourceware.org Cc: dominikmascherbauer Subject: [PATCH 3/3] Add testing for type signature fallback. Date: Tue, 11 Mar 2025 15:57:20 +0100 Message-Id: <486562227f9adc935db44ab048eecf7e9f10de2f.1741701275.git.dominik.mascherbauer@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Create an executable with a type unit that loads a JIT objfile with a reference its type unit. Then in the context of the JIT objfile the type is checked. This causes a type signature lookup with a fallback to the main objfile. --- .../gdb.dwarf2/sig-type-fallback-jit.c | 62 +++++++++++++++ .../gdb.dwarf2/sig-type-fallback-jit.exp | 75 +++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.c create mode 100644 gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.exp diff --git a/gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.c b/gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.c new file mode 100644 index 00000000000..da83e27ad64 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.c @@ -0,0 +1,62 @@ +/* This test program is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Simulate loading of JIT code. */ + +#include "../gdb.base/jit-elf-util.h" +#include "../gdb.base/jit-protocol.h" + +/* Must be defined by .exp file when compiling to know + what address to map the ELF binary to. */ +#ifndef LIB_ADDRESS +#error "Must define LOAD_ADDRESS" +#endif +#ifndef LIB_NAME_STRING +#error "Must define LIB_NAME_STRING" +#endif + +int +main () +{ + size_t obj_size; + void *load_addr = (void *) (size_t) (LIB_ADDRESS); + void *addr = load_elf (LIB_NAME_STRING, &obj_size, load_addr); + + /* Link entry at the end of the list. */ + struct jit_code_entry *const entry = calloc (1, sizeof (*entry)); + entry->symfile_addr = (const char *) addr; + entry->symfile_size = obj_size; + __jit_debug_descriptor.relevant_entry = entry; + __jit_debug_descriptor.first_entry = entry; + + /* Notify GDB. */ + __jit_debug_descriptor.action_flag = JIT_REGISTER; + __jit_debug_register_code (); + + // breakpoint 1 + + /* Now unregister entry. */ + /* Notify GDB. */ + __jit_debug_descriptor.action_flag = JIT_UNREGISTER; + __jit_debug_register_code (); + + __jit_debug_descriptor.first_entry = NULL; + __jit_debug_descriptor.relevant_entry = NULL; + free (entry); + + return 0; +} diff --git a/gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.exp b/gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.exp new file mode 100644 index 00000000000..91465118c5f --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.exp @@ -0,0 +1,75 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +load_lib dwarf.exp + +require dwarf2_support allow_shlib_tests + +set lib_address 0x7000000 +set lib_name libfoo.so + +standard_testfile .c .S -lib.S + +# Create fake DWARF TU for the main objfile. +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble ${asm_file} { + tu {version 5} 0x1122334455667788 the_type { + type_unit {} { + the_type: base_type { + {name myType} + {encoding @DW_ATE_signed} + {byte_size 4 sdata} + } + } + } +} + +# Create fake DWARF CU with type reference for the jit object file. +set asm_file_lib [standard_output_file $srcfile3] +Dwarf::assemble ${asm_file_lib} { + cu {} { + compile_unit {} { + declare_labels typedef_label + + typedef_label: typedef { + {name bar} + {type 0x1122334455667788 ref_sig8 } + } + } + } +} + + +set libobj [standard_output_file $lib_name] +if {[build_executable "build shared library" $libobj $asm_file_lib \ + [list debug text_segment=$lib_address shlib]] != 0} { + return -1 +} + +if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $asm_file] \ + [list debug additional_flags=-DLIB_ADDRESS=$lib_address \ + additional_flags=-DLIB_NAME_STRING=\"$libobj\" ]]} { + return -1 +} + +if {![runto_main]} { + return -1 +} + +gdb_test_no_output "set dwarf-type-signature-fallback main" +gdb_breakpoint [gdb_get_line_number "breakpoint 1"] +gdb_continue_to_breakpoint "first breakpoint" +gdb_test "ptype bar" "type = myType" \ No newline at end of file -- 2.34.1