From patchwork Thu Mar 22 04:11:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 26414 Received: (qmail 122299 invoked by alias); 22 Mar 2018 04:11:32 -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 122281 invoked by uid 89); 22 Mar 2018 04:11:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS autolearn=ham version=3.3.2 spammy=7729, filled X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 04:11:29 +0000 Received: from ESESSHC010.ericsson.se (Unknown_Domain [153.88.183.48]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 64.BA.13895.FEC23BA5; Thu, 22 Mar 2018 05:11:27 +0100 (CET) Received: from ESESBMR506.ericsson.se (153.88.183.202) by ESESSHC010.ericsson.se (153.88.183.48) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 22 Mar 2018 05:11:26 +0100 Received: from ESESSMB502.ericsson.se (153.88.183.163) by ESESBMR506.ericsson.se (153.88.183.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Thu, 22 Mar 2018 05:11:26 +0100 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26 via Frontend Transport; Thu, 22 Mar 2018 05:11:25 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.lan (192.222.164.54) by BL0PR1501MB2003.namprd15.prod.outlook.com (2603:10b6:207:31::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Thu, 22 Mar 2018 04:11:23 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH 1/2] Make "set osabi none" really work Date: Thu, 22 Mar 2018 00:11:12 -0400 Message-ID: <1521691873-25338-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: YTXPR0101CA0050.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::27) To BL0PR1501MB2003.namprd15.prod.outlook.com (2603:10b6:207:31::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6f1c34ea-38ad-42f6-1938-08d58faaf992 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BL0PR1501MB2003; X-Microsoft-Exchange-Diagnostics: 1; BL0PR1501MB2003; 3:Klgr7tqk9s3AZGViMmMAAazKuG0VcE8vO4Ye1E88olFFG5ebqvyfIT01kpU9bX2NuvMDhj+CvMAN1NU3xlk/XYJd8shHH7zDmGol8p5w3kQQ0e3Pp6HLbbZCgiqTZSkc8NFwwOIrfWVo/fmnpIHDSJ54XqTub7+PXcj3E9DuPU3TTKOGBbJDOlQ6NwcJByp4XPN0i0FNeRfUfOkNw9O49PKGUSIYNkJe9Nc+xjfN8KHUjBWRZAQqIdRmTcO7ppu/; 25:1xCZQIFonKD0j6Yj7vgqf/az4KMosmKBC+/LWQGLmr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AX1OA3QLkcugMD8keRPLZ+wD2eHOCulHJjV+8EUP6MXeDeh5cq; 4:+wWcfV2wPNXF0oSSV8QdX27qAfADWThkm1CCG0unM82MSp3SuPnZBvXZaQVH0o3Hw0EOvYN9E+OlRDzLvdgOCCM3x6Lpy0KWg4Vonu00o23gJVfvQtDDiMHa5kVv/D4gbaqnGYM14ls1LhzpYJTM+r0481AQYKJPoBIanSgBU1JbwCBnyvgGQSxUiu7SOpFuorUkkomKLcX1d/il+yrw9WaX8ta2IfWQykPDsbofVzZaFrECwCB6SmtLbQ7XGiSDRiPsGXuKFwGr3dxBYBlkqVrrK9zoNoXdfFupvvn/3IcTgQiH932EZ/7zeb4zwHDPErUdcSdS0r5uEMinWeu1LODnONBztyQx0gBDAUqdx5Q= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(10201501046)(3002001)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:BL0PR1501MB2003; BCL:0; PCL:0; RULEID:; SRVR:BL0PR1501MB2003; X-Forefront-PRVS: 0619D53754 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(39860400002)(396003)(39380400002)(376002)(54534003)(199004)(189003)(50466002)(6916009)(81166006)(97736004)(575784001)(86362001)(16526019)(3846002)(107886003)(7736002)(6116002)(6306002)(186003)(6512007)(6486002)(26005)(2361001)(59450400001)(6666003)(316002)(53936002)(51416003)(52116002)(6506007)(69596002)(48376002)(386003)(2351001)(8676002)(305945005)(66066001)(50226002)(47776003)(106356001)(16586007)(105586002)(36756003)(4326008)(8936002)(25786009)(21086003)(68736007)(81156014)(478600001)(5660300001)(2906002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR1501MB2003; H:elxacz23q12.lan; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR1501MB2003; 23:+d3mmtWVJOfBjagtSGiymnM1R061ef2uh+LaLIa?= =?us-ascii?Q?pHdW4loRoGBcutU3tyjItn1VmtYZsPx9BBvfFQir+19ITuZS+pesPvaKfHq4?= =?us-ascii?Q?xIpOKGAMmW4qFf8kqzxKS2NywzNgOjzX7kGHIQNLEF+vIKYahah8fq8HBZ8h?= =?us-ascii?Q?oU+LOo2n1KRdYI6weEt052/2hAOEoefdMGX4XsXfU03uCWlucN6VI+uzX/ds?= =?us-ascii?Q?rUP7sDTyC9y+VwM917HFvsMSDjfEpUlAe77817icgFcQKv4ee3GwIdOCjZgK?= =?us-ascii?Q?u6x9ALsnV7kMkTr7XUllqtYgrkzN46BulugNR2oJGwPXo3blmlypyPGVKtbG?= =?us-ascii?Q?6/px6s2i5ejFhwt248+tOmEHZcDvdmTXezn9bu9mvtdvdwa7vMwFP5KXITaK?= =?us-ascii?Q?vyIynXKbBYehTB0rlXDHae4tSDraaJoYGQFlzpSakDyJB1w/OAQnCelRgO74?= =?us-ascii?Q?XUwVvmQzkIMf5lWHPxmxATx/d1a5FyZSchkDlMAiIqVD28BFJB3UopCoIwLi?= =?us-ascii?Q?DIs7J2DteMRagd05dazcqs9TSTctOUu/xS8zQMGVtcBPf+I2LnILEzMh8PKw?= =?us-ascii?Q?QyWTeoDTA/O5tx6kUP+WP+1aYmCLE4tmwZb+RhyuaZKJV0sDwJ8kJl0Gcwn9?= =?us-ascii?Q?/bB48ZVqztiayZ4dx2EpBt00VbxR8u/71ezEq8SpuNh4N+gwV3SR2EiZyq/O?= =?us-ascii?Q?OdzIJderUiC3IXjbKPenLfSiy64Zqe8vi5/E85gtEXEHGSwedGp/EPjae0tC?= =?us-ascii?Q?3+8cEwd2xr3H4zaMpCiozp2ostUHYRimJLRaxQJQiEd5gVaR87HrMnuFF6pb?= =?us-ascii?Q?yDu3VZ5t4ElbJXCRsNjCQBjqE3ft9XTlYIQ06COY0tglAFWx4uQ0yVz0JXlX?= =?us-ascii?Q?snSNNZsqxBj14SmP65YxOti+92lxH8BcqNSHzKmSGRs1hzhOoMbrN01y0Rlk?= =?us-ascii?Q?c4yHGe7EPbddN2Wr3nKuvMOT6sswbsWt9LxrBRmQ6Bco/t+H3xON8h60lITc?= =?us-ascii?Q?pLqH+hqjXITFXZy7q1Z6rziGzg0ETRXKnXJB6DQY2G/UZgn4oGFxw7qh9/hf?= =?us-ascii?Q?VgLXzryTHUkNC4HW0J6iKKQtvetAkCJCRBavm2nntF0avy5O0r/9PE2JAlkX?= =?us-ascii?Q?5wwbkTSJGQrm7+CYjB1TgcDQOqfXhicKAspOz8lrCcMIFh5l90YPCcHnOWIb?= =?us-ascii?Q?sCnSG9ZcJcdmVIJuYxUkbTmd5tFICEmYijRXaP7L+6HVlCTVZmMvdgSd3WFc?= =?us-ascii?Q?zqqFl6U8TvQ+gZxeavNtL8dOv0QmHLfPR43zgknQC?= X-Microsoft-Antispam-Message-Info: Vx9J9ETAI57v0r9DVz2cQZZScufR4kEq7ljKTDBaKP5II9FON8SELEmEMhs5Iq+ChB/y9T8v4OnnHXKFEABUntIcmKUR9Kle9qpXPDLJVj/aUZezy0mlmozzBnYLRlwYtwcYpfW96SnxEPen7SciX6UeaML+Lf2rhxZBEeMijzu6O//LykRKKLTvkSXgAV9Z X-Microsoft-Exchange-Diagnostics: 1; BL0PR1501MB2003; 6:pHdxGl8qjPJj3kpe45UNfq1+xlPvaoxKvBFnE1GCPF7cxXu4SHZnrVm18SSfdWFeHfO8ykj77HZdLkSMkk9cS6La5nqe8cLxL284nKkpmu3zlzPSHQ29CYBfZAVpuoUimpv1agnublaGLCXLr+OQnR6mQPSUX5uOu9/z920srB0z/i/p1zXN+PN6inNIWVLoqyQksZFWIFUiFKQszqlFaHHwA93//WuBk4PAQjU30X9GdkMPvTKfHuPDj0W4gFfeBQdTGULs9rBDIU/Z9pd7Z8Ph3dKwXl24/PJ+XCaDpisD+qqiTgRuZUMgWiP2Em/4qeqeyLpikG5RNGHr5iGj+yZAYik2tdmkQ1rpSqLw5OPfNICRWKB4OqrVmfADs8MVaogEVSrM90vk3LteOIBEp1jjMV9Le3YtolkpYqyX61KxOrEIqm7+EVyjx7OkgTlDYFutAoe+QRxKH7hSo1biPg==; 5:sD6p3MyZliku++okj9VScz4DsqTgDxzXGv1hYqFkNyCwcjNfDHyrGcv6DM7cU4llrC6nfrOr3ILe0/lhvJwWjKGOsLsjqsJw5YtmReMTj3UNTKcqsGuvPcNCJTEZwUeoLix7mvZG4HfnYPyjEa+8txXq8sK7FbYWpeHYf6XbE0Q=; 24:jO2uSQeFuDKWHHcLFdTa6SYx2L4R+yrq5GjkHKP1mJiK1h6JCse/9Ue+w8BnmzQcVKcnOPZB5uUFWsc7v4ymY5mFGWlLabP21uQR5qprOiM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL0PR1501MB2003; 7:hLi3RPjHGFgv6YqaLNBUrJoIL33DH6gBrLCnUKnB37lxfukwkTTRvWTYi2tq2coy93GdYcQrZQ5z0PAMluWbo8tRJnzliAYnZFCZgS2MpzFGo7F8OKYGEoF8NYCWYsPdeh1aIgbQ3VTXbInEucPQ3hMmD+WBdCHQtyvmJBpxu0YEBhe8EwvuUa+OOK+1AyuAn4y5hAxcg3wRPa2EDOl5CA8bPh91khzWi75jYfSZVYVkdFFkyADXybaWvEMWFMwA X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2018 04:11:23.5231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f1c34ea-38ad-42f6-1938-08d58faaf992 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR1501MB2003 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes I was looking for a way to reproduce easily PR 22979 by doing this: (gdb) set architecture i386:x86-64 (gdb) set osabi none However, I noticed that even though I did "set osabi none", the gdbarch gdb created was for Linux: (gdb) set debug arch 1 (gdb) set architecture i386:x86-64 ... (gdb) set osabi none gdbarch_find_by_info: info.bfd_arch_info i386:x86-64 gdbarch_find_by_info: info.byte_order 1 (little) gdbarch_find_by_info: info.osabi 4 (GNU/Linux) <--- Wrong? gdbarch_find_by_info: info.abfd 0x0 gdbarch_find_by_info: info.tdep_info 0x0 gdbarch_find_by_info: Previous architecture 0x1e6fd30 (i386:x86-64) selected gdbarch_update_p: Architecture 0x1e6fd30 (i386:x86-64) unchanged This is because the value GDB_OSABI_UNKNOWN has an unclear role, sometimes meaning "no osabi" and sometimes "please selected automatically". Doing "set osabi none" sets the requested osabi to GDB_OSABI_UNKNOWN, in which case gdbarch_info_fill overrides it with a value from the target description, or the built-in default osabi. This means that it's impossible to force GDB not to use an osabi with "set osabi". Since my GDB's built-in default osabi is Linux, it always falls back to GDB_OSABI_LINUX. To fix it, I introduced GDB_OSABI_NONE, which really means "I don't want any osabi". GDB_OSABI_UNKNOWN can then be used only for "not set yet, please auto-detect". GDB_OSABI_UNINITIALIZED now seems unnecessary since it overlaps with GDB_OSABI_UNKNOWN, so I think it can be removed and gdbarch_info::osabi can be initialized to GDB_OSABI_UNKNOWN. gdb/ChangeLog: * defs.h (enum gdb_osabi): Remove GDB_OSABI_UNINITIALIZED, add GDB_OSABI_NONE. * arch-utils.c (gdbarch_info_init): Don't set info->osabi. * osabi.c (gdb_osabi_names): Add "unknown" entry. gdb/testsuite/ChangeLog: * gdb.base/osabi.exp: New file. --- gdb/arch-utils.c | 7 +++++-- gdb/defs.h | 3 +-- gdb/osabi.c | 12 +++++------- gdb/testsuite/gdb.base/osabi.exp | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 gdb/testsuite/gdb.base/osabi.exp diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 2ff0f4d..5986ed6 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -727,7 +727,6 @@ gdbarch_info_init (struct gdbarch_info *info) memset (info, 0, sizeof (struct gdbarch_info)); info->byte_order = BFD_ENDIAN_UNKNOWN; info->byte_order_for_code = info->byte_order; - info->osabi = GDB_OSABI_UNINITIALIZED; } /* Similar to init, but this time fill in the blanks. Information is @@ -772,9 +771,10 @@ gdbarch_info_fill (struct gdbarch_info *info) /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */ /* From the manual override, or from file. */ - if (info->osabi == GDB_OSABI_UNINITIALIZED) + if (info->osabi == GDB_OSABI_UNKNOWN) info->osabi = gdbarch_lookup_osabi (info->abfd); /* From the target. */ + if (info->osabi == GDB_OSABI_UNKNOWN && info->target_desc != NULL) info->osabi = tdesc_osabi (info->target_desc); /* From the configured default. */ @@ -782,6 +782,9 @@ gdbarch_info_fill (struct gdbarch_info *info) if (info->osabi == GDB_OSABI_UNKNOWN) info->osabi = GDB_OSABI_DEFAULT; #endif + /* If we still don't know which osabi to pick, pick none. */ + if (info->osabi == GDB_OSABI_UNKNOWN) + info->osabi = GDB_OSABI_NONE; /* Must have at least filled in the architecture. */ gdb_assert (info->bfd_arch_info != NULL); diff --git a/gdb/defs.h b/gdb/defs.h index ff3599d..dc38a28 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -482,9 +482,8 @@ extern int longest_to_int (LONGEST); table in osabi.c. */ enum gdb_osabi { - GDB_OSABI_UNINITIALIZED = -1, /* For struct gdbarch_info. */ - GDB_OSABI_UNKNOWN = 0, /* keep this zero */ + GDB_OSABI_NONE, GDB_OSABI_SVR4, GDB_OSABI_HURD, diff --git a/gdb/osabi.c b/gdb/osabi.c index fd44deb..ef1d993 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -58,6 +58,7 @@ struct osabi_names them in sync. */ static const struct osabi_names gdb_osabi_names[] = { + { "unknown", NULL }, { "none", NULL }, { "SVR4", NULL }, @@ -335,9 +336,11 @@ gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdb_osabi_handler *handler; - if (info.osabi == GDB_OSABI_UNKNOWN) + gdb_assert (info.osabi != GDB_OSABI_UNKNOWN); + + if (info.osabi == GDB_OSABI_NONE) { - /* Don't complain about an unknown OSABI. Assume the user knows + /* Don't complain about no OSABI. Assume the user knows what they are doing. */ return; } @@ -603,11 +606,6 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) user_selected_osabi = GDB_OSABI_DEFAULT; user_osabi_state = osabi_user; } - else if (strcmp (set_osabi_string, "none") == 0) - { - user_selected_osabi = GDB_OSABI_UNKNOWN; - user_osabi_state = osabi_user; - } else { int i; diff --git a/gdb/testsuite/gdb.base/osabi.exp b/gdb/testsuite/gdb.base/osabi.exp new file mode 100644 index 0000000..8d1ab5b --- /dev/null +++ b/gdb/testsuite/gdb.base/osabi.exp @@ -0,0 +1,26 @@ +# Copyright (C) 2018 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 . + +# This file is part of the gdb testsuite. + +# Test that choosing "set osabi none" really requests a gdbarch with no osabi. + +proc test_set_osabi_none { } { + clean_restart + gdb_test_no_output "set debug arch 1" + gdb_test "set osabi none" ".*gdbarch_find_by_info: info.osabi 1 \\(none\\).*" +} + +test_set_osabi_none