From patchwork Tue Oct 8 17:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 98551 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 CA6EC386183D for ; Tue, 8 Oct 2024 17:13:46 +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.129.124]) by sourceware.org (Postfix) with ESMTP id B2D56385DDDD for ; Tue, 8 Oct 2024 17:12:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2D56385DDDD 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 B2D56385DDDD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728407527; cv=none; b=pCSKWGAIR5JxvdaIMDID4nht5sXUo8faGGwGf17g6zK8JU1yne1b5GZ+UTEtkn7IDHAU2uVUtGKkHDJ+DC+xuG0KD9Md9jwl17sV0FY/zSp6d/1v07iNHnwUrPn19/pm6kQ7xfBvIugGHecg3AiMItiZFrIYwS9NoesVPC73C6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728407527; c=relaxed/simple; bh=tUcNKxfe+KnPgYvPe+2ijszWSFJAxV+3vg+mCXTfMHU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JVjRcowhoCSE/RweTcxZDBqjNU5WuJzsaS5mOwRY8XLu1n0TJDVg6TEC/2aKTANEDIa5EvhTh6Ynj68J4lI7rhjXaEFtjxAdZ+6Yfcxe2zZfnSX2jPa9DyEG4K0mPqH622W/BtSyTfOXbMXLAN5F236pMAIHQKzbP09afjGs6co= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728407520; 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: in-reply-to:in-reply-to:references:references; bh=gjdjKpuLjuAtydjhOfFD6awEjJ1eLXw+nsEl8qgmQI0=; b=C9kRNHA9mMOCaoKvdRZwp7U72oshQ6HR/Ny2tD3XJWlNUO1KO6yFJS3PaFtPpGUPHzuT8v mPLa4wKhcgctRylw4kjg7xmBhPc28rdgO0jZtt7OznrJeI7Autxc9FDkDvE8Q9fALsf/qZ kPvPAylYjdYP7o/vEVggAtVYXX8bcRE= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-mu5KIGlyOaKWd3Y31V-6Og-1; Tue, 08 Oct 2024 13:11:59 -0400 X-MC-Unique: mu5KIGlyOaKWd3Y31V-6Og-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5398b8cb3cdso4376900e87.1 for ; Tue, 08 Oct 2024 10:11:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728407517; x=1729012317; 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=gjdjKpuLjuAtydjhOfFD6awEjJ1eLXw+nsEl8qgmQI0=; b=VbX4VgsJ2t+lg/El/brrVg9IaCvOgJvpkP64MAt2ZKkCyxOF5gYz5Kh5Rif9bsszZc /nYou34G2qbDH5q52bK4mwIB6DE/1MaFNAQ1UC6cP7gOjKvV9FFptDNtDCeiDwL08PZL AFxa6ujgvdVuZd8TWLzOlI0m0PMSZHTv8Gdo4ggkvvuc4cDy+pBznVqg+tyblblxOyXV lcL9bRGB4PSTQh1b+6MYrQ9y9/94Rrjy5oj45vHVUeJiYXwnr2OFQTOS2o4LWhkjofq2 Y8bDIQ4zG9er6Uih/lx1nl7aVjQ057neJCtEkUQnK41JdQARNziKzP/Zj7UQsefnrTS6 AUqg== X-Gm-Message-State: AOJu0Yy5mj4ANhgeqiyDYWaafv6T/pVjjLbzXfjrXyW9ax8up9I3cL9U /iAWUjoDQS1qcPkzwTXe9P+JSw0TB83M+NXqOzeHTbP3h09WJSSjAU/e85gfc71tXI5po3sdEb4 RxcjxXijJsJ9trddEFRx+cu73RvxH+j4+P2fCACMk3LjvMgwP7MbYeMHpV2NtVonF4YP1+euaqR nQ9AO7mjtRWzFluKaGV0ECiJXpm0y7rKUIRfVojZX7jnw= X-Received: by 2002:a05:6512:3190:b0:52e:be84:225c with SMTP id 2adb3069b0e04-539ab88af0fmr7560009e87.33.1728407516831; Tue, 08 Oct 2024 10:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgdWksUHx9OZhIW7hMDsZPJ21VB00/1kNo5oWjwJ9xAP+WM60m6plgKpQFBoQ5KArfIY3fOA== X-Received: by 2002:a05:6512:3190:b0:52e:be84:225c with SMTP id 2adb3069b0e04-539ab88af0fmr7559976e87.33.1728407516094; Tue, 08 Oct 2024 10:11:56 -0700 (PDT) Received: from localhost ([195.213.152.26]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a996274deeesm175885866b.103.2024.10.08.10.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 10:11:55 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Luis Machado Subject: [PATCH 3/5] gdb: split osabi support between gdb/ and gdbsupport/ directories Date: Tue, 8 Oct 2024 18:11:48 +0100 Message-Id: <63b58681b3abc4ef52c2b17c10bcb26a1a5033ea.1728407374.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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 In future commits I want to call set_tdesc_osabi from gdbserver/ code. Currently the only version of set_tdesc_osabi available to gdbserver takes a string representing the osabi. The problem with this is that, having lots of calls to set_tdesc_osabi which all take a string is an invite for a typo to slip in. This typo could potentially go unnoticed until someone tries to debug the wrong combination of GDB and gdbserver, at which point GDB will fail to find the correct gdbarch because it doesn't understand the osabi string. It would be better if the set_tdesc_osabi calls in gdbserver could take an 'enum gdb_osabi' value and then convert this to the "correct" string internally. In this was we are guaranteed to always have a valid, known, osabi string. This commit splits the osabi related code, which currently lives entirely on the GDB wide, between gdb/ and gdbsupport/. I've moved the enum definition along with the array of osabi names into gdbsupport/. Then all the functions that access the names list, and which convert between names and enum values are also moved. I've taken the opportunity of this move to add a '.def' file which contains all the enum names along with the name strings. This '.def' file is then used to create 'enum gdb_osabi' as well as the array of osabi name strings. By using a '.def' file we know that the enum order will always match the name string array. This commit is just a refactor, there are no user visible changes after this commit. This commit doesn't change how gdbserver sets the target description osabi string, that will come in the next commit. --- gdb/osabi.c | 91 ---------------------------------- gdb/osabi.h | 41 +--------------- gdbsupport/Makefile.am | 1 + gdbsupport/Makefile.in | 15 +++--- gdbsupport/osabi-common.cc | 98 +++++++++++++++++++++++++++++++++++++ gdbsupport/osabi-common.def | 57 +++++++++++++++++++++ gdbsupport/osabi-common.h | 54 ++++++++++++++++++++ 7 files changed, 220 insertions(+), 137 deletions(-) create mode 100644 gdbsupport/osabi-common.cc create mode 100644 gdbsupport/osabi-common.def create mode 100644 gdbsupport/osabi-common.h diff --git a/gdb/osabi.c b/gdb/osabi.c index 8a1efce4599..6c00228fb4a 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -42,93 +42,6 @@ static const char *gdb_osabi_available_names[GDB_OSABI_INVALID + 3] = { }; static const char *set_osabi_string; -/* Names associated with each osabi. */ - -struct osabi_names -{ - /* The "pretty" name. */ - - const char *pretty; - - /* The triplet regexp, or NULL if not known. */ - - const char *regexp; -}; - -/* This table matches the indices assigned to enum gdb_osabi. Keep - them in sync. */ -static const struct osabi_names gdb_osabi_names[] = -{ - { "unknown", NULL }, - { "none", NULL }, - - { "SVR4", NULL }, - { "GNU/Hurd", NULL }, - { "Solaris", NULL }, - { "GNU/Linux", "linux(-gnu[^-]*)?" }, - { "FreeBSD", NULL }, - { "NetBSD", NULL }, - { "OpenBSD", NULL }, - { "WindowsCE", NULL }, - { "DJGPP", NULL }, - { "Cygwin", NULL }, - { "Windows", NULL }, - { "AIX", NULL }, - { "DICOS", NULL }, - { "Darwin", NULL }, - { "OpenVMS", NULL }, - { "LynxOS178", NULL }, - { "Newlib", NULL }, - { "SDE", NULL }, - { "PikeOS", NULL }, - - { "", NULL } -}; - -const char * -gdbarch_osabi_name (enum gdb_osabi osabi) -{ - if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID) - return gdb_osabi_names[osabi].pretty; - - return gdb_osabi_names[GDB_OSABI_INVALID].pretty; -} - -/* See osabi.h. */ - -const char * -osabi_triplet_regexp (enum gdb_osabi osabi) -{ - if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID) - return gdb_osabi_names[osabi].regexp; - - return gdb_osabi_names[GDB_OSABI_INVALID].regexp; -} - -/* Lookup the OS ABI corresponding to the specified target description - string. */ - -enum gdb_osabi -osabi_from_tdesc_string (const char *name) -{ - int i; - - for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++) - if (strcmp (name, gdb_osabi_names[i].pretty) == 0) - { - /* See note above: the name table matches the indices assigned - to enum gdb_osabi. */ - enum gdb_osabi osabi = (enum gdb_osabi) i; - - if (osabi == GDB_OSABI_INVALID) - return GDB_OSABI_UNKNOWN; - else - return osabi; - } - - return GDB_OSABI_UNKNOWN; -} - /* Handler for a given architecture/OS ABI pair. There should be only one handler for a given OS ABI each architecture family. */ struct gdb_osabi_handler @@ -671,10 +584,6 @@ void _initialize_gdb_osabi (); void _initialize_gdb_osabi () { - if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID].pretty, "") != 0) - internal_error - (_("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent")); - /* Register a generic sniffer for ELF flavoured files. */ gdbarch_register_osabi_sniffer (bfd_arch_unknown, bfd_target_elf_flavour, diff --git a/gdb/osabi.h b/gdb/osabi.h index d2b1a359098..984bdd4e5dc 100644 --- a/gdb/osabi.h +++ b/gdb/osabi.h @@ -19,35 +19,7 @@ #ifndef OSABI_H #define OSABI_H -/* * List of known OS ABIs. If you change this, make sure to update the - table in osabi.c. */ -enum gdb_osabi -{ - GDB_OSABI_UNKNOWN = 0, /* keep this zero */ - GDB_OSABI_NONE, - - GDB_OSABI_SVR4, - GDB_OSABI_HURD, - GDB_OSABI_SOLARIS, - GDB_OSABI_LINUX, - GDB_OSABI_FREEBSD, - GDB_OSABI_NETBSD, - GDB_OSABI_OPENBSD, - GDB_OSABI_WINCE, - GDB_OSABI_GO32, - GDB_OSABI_CYGWIN, - GDB_OSABI_WINDOWS, - GDB_OSABI_AIX, - GDB_OSABI_DICOS, - GDB_OSABI_DARWIN, - GDB_OSABI_OPENVMS, - GDB_OSABI_LYNXOS178, - GDB_OSABI_NEWLIB, - GDB_OSABI_SDE, - GDB_OSABI_PIKEOS, - - GDB_OSABI_INVALID /* keep this last */ -}; +#include "gdbsupport/osabi-common.h" /* Register an OS ABI sniffer. Each arch/flavour may have more than one sniffer. This is used to e.g. differentiate one OS's a.out from @@ -69,23 +41,12 @@ void gdbarch_register_osabi (enum bfd_architecture, unsigned long, /* Lookup the OS ABI corresponding to the specified BFD. */ enum gdb_osabi gdbarch_lookup_osabi (bfd *); -/* Lookup the OS ABI corresponding to the specified target description - string. */ -enum gdb_osabi osabi_from_tdesc_string (const char *text); - /* Return true if there's an OS ABI handler for INFO. */ bool has_gdb_osabi_handler (struct gdbarch_info info); /* Initialize the gdbarch for the specified OS ABI variant. */ void gdbarch_init_osabi (struct gdbarch_info, struct gdbarch *); -/* Return the name of the specified OS ABI. */ -const char *gdbarch_osabi_name (enum gdb_osabi); - -/* Return a regular expression that matches the OS part of a GNU - configury triplet for the given OSABI. */ -const char *osabi_triplet_regexp (enum gdb_osabi osabi); - /* Helper routine for ELF file sniffers. This looks at ABI tag note sections to determine the OS ABI from the note. */ void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *, diff --git a/gdbsupport/Makefile.am b/gdbsupport/Makefile.am index 36e561e015d..d2e2299cc3f 100644 --- a/gdbsupport/Makefile.am +++ b/gdbsupport/Makefile.am @@ -76,6 +76,7 @@ libgdbsupport_a_SOURCES = \ job-control.cc \ netstuff.cc \ new-op.cc \ + osabi-common.cc \ pathstuff.cc \ print-utils.cc \ ptid.cc \ diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in index 9cff86bd987..c0d406c3a35 100644 --- a/gdbsupport/Makefile.in +++ b/gdbsupport/Makefile.in @@ -162,12 +162,13 @@ am_libgdbsupport_a_OBJECTS = agent.$(OBJEXT) btrace-common.$(OBJEXT) \ gdb-dlfcn.$(OBJEXT) gdb_obstack.$(OBJEXT) gdb_regex.$(OBJEXT) \ gdb_tilde_expand.$(OBJEXT) gdb_wait.$(OBJEXT) \ gdb_vecs.$(OBJEXT) job-control.$(OBJEXT) netstuff.$(OBJEXT) \ - new-op.$(OBJEXT) pathstuff.$(OBJEXT) print-utils.$(OBJEXT) \ - ptid.$(OBJEXT) rsp-low.$(OBJEXT) run-time-clock.$(OBJEXT) \ - safe-strerror.$(OBJEXT) scoped_mmap.$(OBJEXT) search.$(OBJEXT) \ - signals.$(OBJEXT) signals-state-save-restore.$(OBJEXT) \ - task-group.$(OBJEXT) tdesc.$(OBJEXT) thread-pool.$(OBJEXT) \ - xml-utils.$(OBJEXT) $(am__objects_1) $(am__objects_2) + new-op.$(OBJEXT) osabi-common.$(OBJEXT) pathstuff.$(OBJEXT) \ + print-utils.$(OBJEXT) ptid.$(OBJEXT) rsp-low.$(OBJEXT) \ + run-time-clock.$(OBJEXT) safe-strerror.$(OBJEXT) \ + scoped_mmap.$(OBJEXT) search.$(OBJEXT) signals.$(OBJEXT) \ + signals-state-save-restore.$(OBJEXT) task-group.$(OBJEXT) \ + tdesc.$(OBJEXT) thread-pool.$(OBJEXT) xml-utils.$(OBJEXT) \ + $(am__objects_1) $(am__objects_2) libgdbsupport_a_OBJECTS = $(am_libgdbsupport_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -433,6 +434,7 @@ libgdbsupport_a_SOURCES = \ job-control.cc \ netstuff.cc \ new-op.cc \ + osabi-common.cc \ pathstuff.cc \ print-utils.cc \ ptid.cc \ @@ -542,6 +544,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/job-control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netstuff.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/new-op.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osabi-common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pathstuff.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print-utils.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptid.Po@am__quote@ diff --git a/gdbsupport/osabi-common.cc b/gdbsupport/osabi-common.cc new file mode 100644 index 00000000000..785eb478664 --- /dev/null +++ b/gdbsupport/osabi-common.cc @@ -0,0 +1,98 @@ +/* OS ABI variant handling for GDB and gdbserver. + + Copyright (C) 2001-2024 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 "gdbsupport/osabi-common.h" + +/* Names associated with each osabi. */ + +struct osabi_names +{ + /* The "pretty" name. */ + + const char *pretty; + + /* The triplet regexp, or NULL if not known. */ + + const char *regexp; +}; + +/* This table matches the indices assigned to enum gdb_osabi. Keep + them in sync. */ +static const struct osabi_names gdb_osabi_names[] = +{ +#define GDB_OSABI_DEF_FIRST(Enum, Name, Regex) \ + { Name, Regex }, + +#define GDB_OSABI_DEF(Enum, Name, Regex) \ + { Name, Regex }, + +#define GDB_OSABI_DEF_LAST(Enum, Name, Regex) \ + { Name, Regex } + +#include "gdbsupport/osabi-common.def" + +#undef GDB_OSABI_DEF_LAST +#undef GDB_OSABI_DEF +#undef GDB_OSABI_DEF_FIRST +}; + +/* See gdbsupport/osabi-common.h. */ + +const char * +gdbarch_osabi_name (enum gdb_osabi osabi) +{ + if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID) + return gdb_osabi_names[osabi].pretty; + + return gdb_osabi_names[GDB_OSABI_INVALID].pretty; +} + +/* See gdbsupport/osabi-commomn.h. */ + +enum gdb_osabi +osabi_from_tdesc_string (const char *name) +{ + int i; + + for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++) + if (strcmp (name, gdb_osabi_names[i].pretty) == 0) + { + /* See note above: the name table matches the indices assigned + to enum gdb_osabi. */ + enum gdb_osabi osabi = (enum gdb_osabi) i; + + if (osabi == GDB_OSABI_INVALID) + return GDB_OSABI_UNKNOWN; + else + return osabi; + } + + return GDB_OSABI_UNKNOWN; +} + +/* See gdbsupport/osabi-common.h. */ + +const char * +osabi_triplet_regexp (enum gdb_osabi osabi) +{ + if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID) + return gdb_osabi_names[osabi].regexp; + + return gdb_osabi_names[GDB_OSABI_INVALID].regexp; +} diff --git a/gdbsupport/osabi-common.def b/gdbsupport/osabi-common.def new file mode 100644 index 00000000000..637da26a050 --- /dev/null +++ b/gdbsupport/osabi-common.def @@ -0,0 +1,57 @@ +/* OS ABI variant definitions for GDB and gdbserver. + + Copyright (C) 2001-2024 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +/* Each definition in this file is an osabi known to GDB. + + The first argument is used to create the enum name and is appended + to 'GDB_OSABI_'. + + The second argument is the osabi name. These strings can't be + changed _ever_ as gdbserver will emit these. Changing these + strings would break compatibility with already released versions of + GDB and/or gdbserver. + + The third argument is a regexp which matches against a target + triplet. */ + +GDB_OSABI_DEF_FIRST (UNKNOWN, "unknown", nullptr) + +GDB_OSABI_DEF (NONE, "none", nullptr) + +GDB_OSABI_DEF (SVR4, "SVR4", nullptr) +GDB_OSABI_DEF (HURD, "GNU/Hurd", nullptr) +GDB_OSABI_DEF (SOLARIS, "Solaris", nullptr) +GDB_OSABI_DEF (LINUX, "GNU/Linux", "linux(-gnu[^-]*)?") +GDB_OSABI_DEF (FREEBSD, "FreeBSD", nullptr) +GDB_OSABI_DEF (NETBSD, "NetBSD", nullptr) +GDB_OSABI_DEF (OPENBSD, "OpenBSD", nullptr) +GDB_OSABI_DEF (WINCE, "WindowsCE", nullptr) +GDB_OSABI_DEF (GO32, "DJGPP", nullptr) +GDB_OSABI_DEF (CYGWIN, "Cygwin", nullptr) +GDB_OSABI_DEF (WINDOWS, "Windows", nullptr) +GDB_OSABI_DEF (AIX, "AIX", nullptr) +GDB_OSABI_DEF (DICOS, "DICOS", nullptr) +GDB_OSABI_DEF (DARWIN, "Darwin", nullptr) +GDB_OSABI_DEF (OPENVMS, "OpenVMS", nullptr) +GDB_OSABI_DEF (LYNXOS178, "LynxOS178", nullptr) +GDB_OSABI_DEF (NEWLIB, "Newlib", nullptr) +GDB_OSABI_DEF (SDE, "SDE", nullptr) +GDB_OSABI_DEF (PIKEOS, "PikeOS", nullptr) + +GDB_OSABI_DEF_LAST (INVALID, "", nullptr) diff --git a/gdbsupport/osabi-common.h b/gdbsupport/osabi-common.h new file mode 100644 index 00000000000..99318eb0ca7 --- /dev/null +++ b/gdbsupport/osabi-common.h @@ -0,0 +1,54 @@ +/* OS ABI variant handling for GDB and gdbserver. + + Copyright (C) 2001-2024 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +#ifndef OSABI_COMMON_H +#define OSABI_COMMON_H + +/* List of known OS ABIs. If you change this, make sure to update the + table in osabi-common.cc. */ +enum gdb_osabi +{ +#define GDB_OSABI_DEF_FIRST(Enum, Name, Regex) \ + GDB_OSABI_ ## Enum = 0, + +#define GDB_OSABI_DEF(Enum, Name, Regex) \ + GDB_OSABI_ ## Enum, + +#define GDB_OSABI_DEF_LAST(Enum, Name, Regex) \ + GDB_OSABI_ ## Enum + +#include "gdbsupport/osabi-common.def" + +#undef GDB_OSABI_DEF_LAST +#undef GDB_OSABI_DEF +#undef GDB_OSABI_DEF_FIRST +}; + +/* Lookup the OS ABI corresponding to the specified target description + string. */ +enum gdb_osabi osabi_from_tdesc_string (const char *text); + +/* Return the name of the specified OS ABI. */ +const char *gdbarch_osabi_name (enum gdb_osabi); + +/* Return a regular expression that matches the OS part of a GNU + configury triplet for the given OSABI. */ +const char *osabi_triplet_regexp (enum gdb_osabi osabi); + +#endif /* OSABI_COMMON_H */