From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OCHNGoGq0WczVw0AWB0awg (envelope-from ) for ; Wed, 12 Mar 2025 11:38:41 -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=MjMcCNRp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 69A8F1E105; Wed, 12 Mar 2025 11:38:41 -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 D0FE81E08E for ; Wed, 12 Mar 2025 11:38:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7660B3858430 for ; Wed, 12 Mar 2025 15:38:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7660B3858430 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=MjMcCNRp Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id B53723858402 for ; Wed, 12 Mar 2025 15:37:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B53723858402 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 B53723858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741793840; cv=none; b=PS+3/JE1EXJzAPVUc05Twc4/jP41XDVjtXk66J5Re/OKOKZnBrnKpapZOZviF+jPJ+lLsEx/ply3qq80INf+mLeehK84RmriTixnWzzWd0+9P29hML5rDmODhQaqEg4c/kbsoo/I2UPkhW1Du9W8t/ozPABuDhMwpho5YPISQ74= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741793840; c=relaxed/simple; bh=1Qky8UHlVkfG94X3ApRXl2xk4iQViTL2uj2oM5RhPyU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=v1ekq4LzokImuSPHKxN/RvKzFbyF/FZqrUpkYDLngi4IqBjFICHUkYShKSPw88mpNH6M7bPLX4VdJpbPVJ0IitzyWwca4qNkcDx0bshzzu4KWDVkOOlgqXAei0KTd+TwON7ebDPNiqHeogHtoGzVaeJsCgKkoYKpFxhmfBeAY3A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B53723858402 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5e66407963fso7507615a12.2 for ; Wed, 12 Mar 2025 08:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741793838; x=1742398638; 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=MjMcCNRpVx0UbCAPOQkjat7gNWcjaocXb3vN4QTwYPsJNjtSPMcdV5zrwQApkPl2gm SNDwKX+vmTnccygwtAeNcQl814dCNgxvE1HXZK5270ZCaZPZ8F9tdHfHQ64rPnxPO6af 72u4ozSjYKdh5l6jcDycewnFut236PTWnAKfN2iV2MHebHko6fF3byH/TB0Nwr2Y5aY8 nScGHnctpi8wu94o9/WuBYTCxEQQXs80zTA13VFC/N5IMdZN+67CZ7XsbkuGQsrkkWoY ocBNDShdYkVkwuntFcMltceoAEwPBXarxTHDCJd0apYKUC9VqZZjWGAZ+8OThTaq/aYX EaiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741793838; x=1742398638; 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=hZ729Xd81LUZMRX9Pypp1cRoG0TbtAxgGYcnexl56Lb26ebp3OPMAPgahpljzTzI5B qwNO1TcTLrwHq3iwrGhGoPCArMN1kN0eNJG6L71oRa8LUY7bgkfB1BpxqmTuOo5TUfdG LWXgglwg1b3mLjhfquMyLTXYA38nX3txXPreBwOk0aVSRWA5rzWo6KNsubtpgGTeooPl KzTkRj/41K7ZPit9qA/QfzzIZbekGiATEqdzybtvpu13PJsHI9FdFVBy/QGU2InuR5c4 jVaKKLLpITznSatio9/1WYKhkpA22Ra7gTbOTy5nswxbXG8zF3I9GwbkTpHp9wfA/sKR tqCA== X-Gm-Message-State: AOJu0Yy0+7vHrISL2HHBa9+AUiih+/5zLgLNbuPd5m8Yz+CVXwG680Gn cf09+UYYvMK09ycau7xGxlaKfMLKsnGzAAo9EtG0886jjY+UaAlLlSiT5w7xqX4= X-Gm-Gg: ASbGncuKC2QLYIrZgdQ5Fl1P+zWpPHhjXU3OdszbQE5J0OKCcQVjtumCNx7KGKoxSs6 YTXJgGzv8ai6DPM8KnjYkU1+0GCW6mG17iSN4BacrnfSW4W8u7UwSxxXmtLcL67S9fwnt836Jse hafWKJ2iZ+deYbO/yp9ba5KJLjHLR44JPHyu1K8vjTg4IahWZK9biLPuREEOt70Mb1Poq5MqxWz ci/7AmH4H9kKDyz2aspw9VeXZRhC9NpB8/XFfXz4xFOhsZXXbrD2ro1iSxWv0MA+Ce5j4sphsg7 xZyLCqGBp9JfNcmFeifMeLEb+yyQ3wU6lTAnhcxJAokcFGN3LvrxqxeRFYY5Jt18hJOA X-Google-Smtp-Source: AGHT+IEqKB2oBbs1Ed8YwroabcxUt2FKosUmZ5+YklFePZcXgUP3U0cRRDGlDE056UyLOw2pjPIR8w== X-Received: by 2002:a05:6402:5387:b0:5e0:9254:c10e with SMTP id 4fb4d7f45d1cf-5e5e22dbbf6mr27629615a12.11.1741793837811; Wed, 12 Mar 2025 08:37:17 -0700 (PDT) Received: from pop-os.ssw.jku.at ([140.78.145.202]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e5c74a6af7sm9888800a12.33.2025.03.12.08.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Mar 2025 08:37:16 -0700 (PDT) From: dominikmascherbauer X-Google-Original-From: dominikmascherbauer To: gdb-patches@sourceware.org Cc: dominikmascherbauer Subject: [PATCH v2 3/3] Add testing for type signature fallback. Date: Wed, 12 Mar 2025 16:37:08 +0100 Message-Id: <86d6c18c10e7d42a687048182dba5982fb59a77c.1741792976.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