From patchwork Fri Mar 15 12:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 87237 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 A3AA03858416 for ; Fri, 15 Mar 2024 12:14:03 +0000 (GMT) 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 0738C3858C5E for ; Fri, 15 Mar 2024 12:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0738C3858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0738C3858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710504821; cv=none; b=iY/CGUTyjZ+yIidRzuYxwsLKJKih8itiESbZAOU87uhWdZ8kR559UD+oTv/SKef52CVwXUmYNABtMssbj5QtzNTkQ/6DMXCt4c/17zxgBBw03ZKwvmhc+bWtrvirRwpkoKioi5qJK09USGYrUQ11fpU+2ts74wRBfJeO6lR4pE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710504821; c=relaxed/simple; bh=G9JZYbV4aPWXMMQv9HG8Nzl0t++5K9muG8aVnOXGMRg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=lUdPtMsyTr2s7ZHB1ziVmyeDZUWxru2U62tlhh51J7tZQYTsyUHO/02eNgwE8D2poJQ1xIQ+1TioqNS6vukqaDxx51s59HDZ3kxQiF90iz6NQxtD4pqlfxR0AoOzJZbG7HKf0HwryG24bD9NrRwpgk7dVBZPaoydLB5L3GrUyPE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710504818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Toj0ZgnrYOLDju2Ycjp+iDhS0I5SqXNvdHyPNahCDWo=; b=fNTgrkcJP8hlK1uD1pHy98xQomTO04O+qDj3MD0BRPoJXHIMX2os/4JvohJOAgOCQy0/O4 qRkW4QJEcS1hG9YTTsOZsGOYulZUAtn3VAtDlfeKB/4V4L8Z6333ZK7egcItpSqQ+3APFD eT3PBmFMRPvTSFRDQGwiUockBeAzFWk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-jtGHjRveMCaXOikG-M5_yw-1; Fri, 15 Mar 2024 08:13:37 -0400 X-MC-Unique: jtGHjRveMCaXOikG-M5_yw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-412eeb789d9so9293435e9.3 for ; Fri, 15 Mar 2024 05:13:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710504815; x=1711109615; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Toj0ZgnrYOLDju2Ycjp+iDhS0I5SqXNvdHyPNahCDWo=; b=g2EWbtnqiZ8+EfelBdBcHejlIm2ixNKhU/XeG0TzNeaz9z2mQWJNHezix0CyjR0dUU 4rdULxjYgfng/6v4rvi4lCKyjll/c+5P++PcuBAJIvQ/aHfGSS28JOSEdDBIozsHBGbC 5THwzVR5krDtw4vl1cWPN0HFBjwl6xxNgdEK1Gx49YaWywzobqWWRhSod/D2FsDr/yzV FdwtzW1fKdsPhqJsSL5tiS/yhyV4T0BVoiPnrR+RcVb/8nRl7BxvDF595J6L018JqRvm n3yIud0FSfRg6fWp1AbbbdiYv4SK4metxEOI7N/GWAVO9/EFhwRW6DyO5zJwhDRxr6FB BjLA== X-Gm-Message-State: AOJu0YxhJYx4moae5Y1g15+I1UT1yrvmo+DMN8P9zFwbz/S5npcCUfke x/X9PdoDBFT0u8iTqrmu2r0NjREXlLOmTWPYPPVeMyjJfoJLoetgX2AS3c5g55SV2aC7RxxDXOJ UF5RgAmraQEzDuWOTExRrnS6pNFCja5T7odQFZC15ZbWZIcj1jymnOggBH1qHU2lNwbJGysXhVB D6M/6ULryp0PdhPgZHyEeWRTmgYwr7l9mISVgZp72dkOA= X-Received: by 2002:a05:600c:4686:b0:414:c5:8503 with SMTP id p6-20020a05600c468600b0041400c58503mr1194808wmo.38.1710504815361; Fri, 15 Mar 2024 05:13:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXFMi5QTbIiRQg0fTojpYd20Yw3QZahCMRxAek+MD3srZwN55EudBBsdjCv6M/uRjmPzPy5w== X-Received: by 2002:a05:600c:4686:b0:414:c5:8503 with SMTP id p6-20020a05600c468600b0041400c58503mr1194776wmo.38.1710504814624; Fri, 15 Mar 2024 05:13:34 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id s9-20020a05600c45c900b00413e79344b7sm5668020wmo.19.2024.03.15.05.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 05:13:34 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/testsuite: attach to i386 process stopped in vDSO Date: Fri, 15 Mar 2024 12:13:32 +0000 Message-Id: <6fea18ab451ed9e04ee7716635e7f0be91058122.1710504782.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Fedora GDB has carried around a patch for a while which tested attaching to an i386 process which is stopped within the vDSO library region. Apparently, at some point in the distant past there was an issue finding symbol information for this region in this situation. I'm struggling to track down the precise details of what the original bug was, however, acquiring symbol information for the vDSO region is different than for "normal" shared libraries -- the vDSO information is synthesised within GDB during the attach / inferior creation process -- so it's not unreasonable to imagine that there could be a bug specifically in this area of GDB which wouldn't impact "normal" shared libraries. I looked for references to vDSO in our testsuite and couldn't find any tests that looked like they did the same sort of thing, so I'd like to propose adding this test to our testsuite. It's a pretty simple test, and doesn't take long to run, so the cost of adding this is not huge. --- gdb/testsuite/gdb.arch/i386-attach-see-vdso.c | 25 +++++++++ .../gdb.arch/i386-attach-see-vdso.exp | 55 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/i386-attach-see-vdso.c create mode 100644 gdb/testsuite/gdb.arch/i386-attach-see-vdso.exp base-commit: 9fe07b7f95fbfdaf34d5b69e6d73cae000b43eea diff --git a/gdb/testsuite/gdb.arch/i386-attach-see-vdso.c b/gdb/testsuite/gdb.arch/i386-attach-see-vdso.c new file mode 100644 index 00000000000..2eee4c4995c --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-attach-see-vdso.c @@ -0,0 +1,25 @@ +/* This testcase 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 . */ + +#include + +int +main (void) +{ + pause (); + return 1; +} diff --git a/gdb/testsuite/gdb.arch/i386-attach-see-vdso.exp b/gdb/testsuite/gdb.arch/i386-attach-see-vdso.exp new file mode 100644 index 00000000000..dc757748332 --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-attach-see-vdso.exp @@ -0,0 +1,55 @@ +# 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 . + +# Ensure that when we attach to an i386 process, which is stopped in +# the vDSO, we are able to get symbols for the vDSO region. + +require {is_any_target "i?86-*-linux*" "x86_64-*-linux*"} +require can_spawn_for_attach + +standard_testfile + +set options {debug} +if {![istarget "i386-*-*"]} { + lappend options "additional_flags=-m32" +} + +# The kernel VDSO is used for the syscalls returns only on i386 (not x86_64). +if { [build_executable "failed to prepare" $testfile $srcfile $options] } { + return -1 +} + +# Don't tell GDB which executable we're debugging. +clean_restart + +# Start the test program ready for GDB to attach to it. +set test_spawn_id [spawn_wait_for_attach $binfile] +set testpid [spawn_id_get_pid $test_spawn_id] + +# Attach GDB to the process. +gdb_test_multiple "attach $testpid" "attach to test process" { + -re -wrap "Attaching to process $testpid.*" { + pass $gdb_test_name + } +} + +# The inferior will be stopped within the vDSO, check we get symbols +# for this address. +gdb_test "bt" "#0 *0x\[0-9a-f\]* in \[^?\]+\r\n#1\\s+.*" \ + "backtrace decodes VDSO" + +# Exit GDB and the spawned process. +gdb_exit +kill_wait_spawned_process $test_spawn_id