From patchwork Wed Aug 21 15:58:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 34228 Received: (qmail 115284 invoked by alias); 21 Aug 2019 15:58:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 115215 invoked by uid 89); 21 Aug 2019 15:58:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR04-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr70075.outbound.protection.outlook.com (HELO EUR04-HE1-obe.outbound.protection.outlook.com) (40.107.7.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Aug 2019 15:58:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T1Bv9YUWRP+GFOUImYOzk/wCL1pEFCWQmtSqyXtIGus=; b=gCDyl3eahJJqDevjlISjm7ZND2gIS90b7+pU5TDZ7gKCyX0sLM+2h/lZh+BtkFkiFoc9NdHICdqZ4SriJvsUgTtRlGdstw10b4qFc3IQbnrGzoJcZTE1G8fheChXVHThZMohARKVjbJ7aHGL30ma5HFbv9cj9C5JHOIRtquQPwQ= Received: from VI1PR08CA0225.eurprd08.prod.outlook.com (2603:10a6:802:15::34) by HE1PR0802MB2601.eurprd08.prod.outlook.com (2603:10a6:3:d8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Wed, 21 Aug 2019 15:58:30 +0000 Received: from VE1EUR03FT010.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by VI1PR08CA0225.outlook.office365.com (2603:10a6:802:15::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2199.14 via Frontend Transport; Wed, 21 Aug 2019 15:58:29 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT010.mail.protection.outlook.com (10.152.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2199.13 via Frontend Transport; Wed, 21 Aug 2019 15:58:28 +0000 Received: ("Tessian outbound 1e6e633a5b56:v26"); Wed, 21 Aug 2019 15:58:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a1ba26310d74b381 X-CR-MTA-TID: 64aa7808 Received: from 0e7a583c9ae6.3 (cr-mta-lb-1.cr-mta-net [104.47.4.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id A0EFF476-80B9-4BE3-84CA-4AAC8B291BEF.1; Wed, 21 Aug 2019 15:58:22 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2053.outbound.protection.outlook.com [104.47.4.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0e7a583c9ae6.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Wed, 21 Aug 2019 15:58:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7Fr3hrlPbfirc9LqjuCh+/mxyUaw9zCemPSzz4D3+RSiLpxGG1mfAXCuWEHcAbIp1YjDSI2mFLxVuGJG9O3vcUC6Q5XUwvTPYUXDtwTIX6TXjR/1Vm5SJe16sodbFalCDZr6Ajy1CDiUA3PiXeNyrQV06H/xVxduj9YejsZvukj8nLOFKaIByNlsZmThKMi68LvOC5c41+wv750oVzZPAcGCQKy+QvKYSc619OD067SdPTmJFBeR5cxNiJaIb3xX79pfpDvqR9Bw+i97vbXQmIggs3PzU62q3ST0UMoa8uuKJGtBKC1oyJFcwJ8GRiowms586wqH1v1GjJgBUUEKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T1Bv9YUWRP+GFOUImYOzk/wCL1pEFCWQmtSqyXtIGus=; b=WEnlbs1otnE4iwdQ5j+MNSpFT3rmi9iuwDay7lLWDN/D+Sm8B/IjFsiKmCLaIV8PaCvBfHIqmLPwFVgTddOQ3bS887J0ngWc9FeoDiXp4bUWRcWzg3dRGZlzZhlUP14ZaBJro3PbKg3oDJK4q//Y+E1J39yfigeuEyQceQgJkJsBfrLHgp3qy4fdjjYHJsZlkzAa71mVOUc8MgKzsFhckqTwSA6LXQ+Wj3xEKaqzsQEhbwH6MxE8cabWXQ4uhuHD1d+ckg/BbqPWCm1AnAP3jZtQxywyo2aiAky7P9jPfAIAuAzBChkqt53YTTooEVeYwAApHhav0s/B3E7Jqz4azw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T1Bv9YUWRP+GFOUImYOzk/wCL1pEFCWQmtSqyXtIGus=; b=gCDyl3eahJJqDevjlISjm7ZND2gIS90b7+pU5TDZ7gKCyX0sLM+2h/lZh+BtkFkiFoc9NdHICdqZ4SriJvsUgTtRlGdstw10b4qFc3IQbnrGzoJcZTE1G8fheChXVHThZMohARKVjbJ7aHGL30ma5HFbv9cj9C5JHOIRtquQPwQ= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2344.eurprd08.prod.outlook.com (10.172.228.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.19; Wed, 21 Aug 2019 15:58:21 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::8c83:15d:248f:3a]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::8c83:15d:248f:3a%10]) with mapi id 15.20.2178.020; Wed, 21 Aug 2019 15:58:21 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH v2 1/3] Refactor svr4_create_solib_event_breakpoints Date: Wed, 21 Aug 2019 15:58:21 +0000 Message-ID: <20190821155816.45504-2-alan.hayward@arm.com> References: <20190821155816.45504-1-alan.hayward@arm.com> In-Reply-To: <20190821155816.45504-1-alan.hayward@arm.com> Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DB6PR0802MB2344; x-ms-exchange-transport-forked: True x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3826;OLM:3826; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(376002)(346002)(396003)(136003)(39860400002)(189003)(199004)(54534003)(476003)(11346002)(486006)(2616005)(446003)(25786009)(478600001)(2501003)(86362001)(66066001)(1076003)(6486002)(14454004)(53936002)(5640700003)(81166006)(81156014)(8936002)(44832011)(8676002)(4326008)(5660300002)(50226002)(102836004)(36756003)(66946007)(76176011)(6512007)(6916009)(6436002)(386003)(6506007)(3846002)(2351001)(71190400001)(71200400001)(6116002)(52116002)(305945005)(186003)(14444005)(256004)(316002)(7736002)(26005)(66476007)(99286004)(2906002)(66446008)(64756008)(66556008)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2344; H:DB6PR0802MB2133.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: rQyOZDuyuZEcWgzqwaioZnrLpffE0NtysWKlZ0/a+nNFW8ddoRLFk2fcT/0hg2j4sS5fLoXqC7kKKr03dpXP5jFGLoawSeO0MF/p1xn7z1PSZYRjinEcmAau5HzJqE7SgOkiwXQftvSejmrXQZeSpa97+gFgQWn3gcwUX2wryOeqCRwo9/6T8p/BSa+0AJcP4YJe+yYfelgEDAeJNIyiBMV1Ne3XZcN3P/Rx4e1amayovf/8hF3DI0BHT5ruHAVagaPNX0DdsQFrAsWWrlAQgDrjgd0cbZVhUCT2Wu2Skwk9pj0DqOYZmA71rYeDXI5E3hls62Wz97qGbAZyuIjldJwwnXc//aHYjXDOBImpQ4nGLRnNOLxCKW5qjIPZkGtMGwmWKajBk59du94yvucwWpB00NLMzdP0DmH01OYRaIk= MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; Return-Path: Alan.Hayward@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 26590def-ace8-42ca-f1c9-08d7265063e4 X-IsSubscribed: yes Move the bulk of svr4_create_solib_event_breakpoints into a new function to simplify the logic. No functional changes. gdb/ChangeLog: 2019-08-21 Alan Hayward * solib-svr4.c (svr4_find_and_create_probe_breakpoints): Move code to here... (svr4_create_solib_event_breakpoints): ...from here. --- gdb/solib-svr4.c | 127 ++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 67 deletions(-) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index c0c505acaa..b21eacb68f 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -2061,6 +2061,61 @@ svr4_create_probe_breakpoints (svr4_info *info, struct gdbarch *gdbarch, svr4_update_solib_event_breakpoints (); } +/* Find all the glibc named probes. Only if all of the probes are found, then + create them and return true. Otherwise return false. If WITH_PREFIX is set + then add "rtld" to the front of the probe names. */ +static bool +svr4_find_and_create_probe_breakpoints (svr4_info *info, + struct gdbarch *gdbarch, + struct obj_section *os, + bool with_prefix) +{ + std::vector probes[NUM_PROBES]; + bool checked_can_use_probe_arguments = false; + + for (int i = 0; i < NUM_PROBES; i++) + { + const char *name = probe_info[i].name; + char buf[32]; + + /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4 shipped with an early + version of the probes code in which the probes' names were prefixed + with "rtld_" and the "map_failed" probe did not exist. The locations + of the probes are otherwise the same, so we check for probes with + prefixed names if probes with unprefixed names are not present. */ + if (with_prefix) + { + xsnprintf (buf, sizeof (buf), "rtld_%s", name); + name = buf; + } + + probes[i] = find_probes_in_objfile (os->objfile, "rtld", name); + + /* The "map_failed" probe did not exist in early + versions of the probes code in which the probes' + names were prefixed with "rtld_". */ + if (with_prefix && streq (name, "rtld_map_failed")) + continue; + + /* Ensure at least one probe for the current name was found. */ + if (probes[i].empty ()) + return false; + + /* Ensure probe arguments can be evaluated. */ + if (!checked_can_use_probe_arguments) + { + probe *p = probes[i][0]; + if (!p->can_evaluate_arguments ()) + return false; + checked_can_use_probe_arguments = true; + } + } + + /* All probes found. Now create them. */ + svr4_create_probe_breakpoints (info, gdbarch, probes, os->objfile); + return true; +} + /* Both the SunOS and the SVR4 dynamic linkers call a marker function before and after mapping and unmapping shared libraries. The sole purpose of this method is to allow debuggers to set a breakpoint so @@ -2077,74 +2132,12 @@ static void svr4_create_solib_event_breakpoints (svr4_info *info, struct gdbarch *gdbarch, CORE_ADDR address) { - struct obj_section *os; - - os = find_pc_section (address); - if (os != NULL) - { - int with_prefix; - - for (with_prefix = 0; with_prefix <= 1; with_prefix++) - { - std::vector probes[NUM_PROBES]; - int all_probes_found = 1; - int checked_can_use_probe_arguments = 0; - - for (int i = 0; i < NUM_PROBES; i++) - { - const char *name = probe_info[i].name; - probe *p; - char buf[32]; - - /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4 - shipped with an early version of the probes code in - which the probes' names were prefixed with "rtld_" - and the "map_failed" probe did not exist. The - locations of the probes are otherwise the same, so - we check for probes with prefixed names if probes - with unprefixed names are not present. */ - if (with_prefix) - { - xsnprintf (buf, sizeof (buf), "rtld_%s", name); - name = buf; - } - - probes[i] = find_probes_in_objfile (os->objfile, "rtld", name); - - /* The "map_failed" probe did not exist in early - versions of the probes code in which the probes' - names were prefixed with "rtld_". */ - if (strcmp (name, "rtld_map_failed") == 0) - continue; - - if (probes[i].empty ()) - { - all_probes_found = 0; - break; - } - - /* Ensure probe arguments can be evaluated. */ - if (!checked_can_use_probe_arguments) - { - p = probes[i][0]; - if (!p->can_evaluate_arguments ()) - { - all_probes_found = 0; - break; - } - checked_can_use_probe_arguments = 1; - } - } - - if (all_probes_found) - svr4_create_probe_breakpoints (info, gdbarch, probes, os->objfile); - - if (all_probes_found) - return; - } - } + struct obj_section *os = find_pc_section (address); - create_solib_event_breakpoint (gdbarch, address); + if (os == nullptr + || (!svr4_find_and_create_probe_breakpoints (info, gdbarch, os, false) + && !svr4_find_and_create_probe_breakpoints (info, gdbarch, os, true))) + create_solib_event_breakpoint (gdbarch, address); } /* Helper function for gdb_bfd_lookup_symbol. */