From: Andrew Cagney <ac131313@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [patch/rfc] Fix gdb/1426: osabi initialization race condition
Date: Fri, 24 Oct 2003 02:45:00 -0000 [thread overview]
Message-ID: <3F98921A.9040302@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 488 bytes --]
Hello,
ref: http://sources.redhat.com/gdb/bugs/1426 for details.
The attached implements the "hack" suggested in tdep/1426 to work around
a bogus error message:
A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB. Attempting to continue with the default
rs6000:6000 settingsGNU gdb 2003-10-23-cvs
Copyright 2003 Free Software Foundation, Inc.
...
that appears on some platforms during startup.
Baring comment, I'll commit this in a few days.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 3778 bytes --]
2003-10-23 Andrew Cagney <cagney@redhat.com>
* osabi.c (GDB_OSABI_DEFAULT): Delete macro definition.
(user_osabi_default): New static variable.
(_initialize_gdb_osabi): Initialize "user_osabi_default" to
GDB_OSABI_DEFAULT if defined, GDB_OSABI_UNKNOWN otherwize.
(gdbarch_lookup_osabi): Replace GDB_OSABI_DEFAULT with
"user_osabi_default".
(set_osabi, show_osabi): Ditto.
Work around GDB PR tdep/1426.
Index: osabi.c
===================================================================
RCS file: /cvs/src/src/gdb/osabi.c,v
retrieving revision 1.17
diff -u -r1.17 osabi.c
--- osabi.c 24 Aug 2003 11:47:18 -0000 1.17
+++ osabi.c 24 Oct 2003 02:30:08 -0000
@@ -30,10 +30,6 @@
#include "elf-bfd.h"
-#ifndef GDB_OSABI_DEFAULT
-#define GDB_OSABI_DEFAULT GDB_OSABI_UNKNOWN
-#endif
-
/* State for the "set osabi" command. */
static enum { osabi_auto, osabi_default, osabi_user } user_osabi_state;
static enum gdb_osabi user_selected_osabi;
@@ -45,6 +41,23 @@
};
static const char *set_osabi_string;
+/* Value for the "default" osabi.
+
+ It is initialized, during per-file initialization, by the function
+ _initialize_osabi below, to the build-time macro GDB_OSABI_DEFAULT.
+ Due to a race condition with the code trying to create the initial
+ "static" architecture, it is not statically initialized to
+ GDB_OSABI_DEFAULT.
+
+ The problem with static initialization is that the code creating
+ that initial "static" architecture calls gdbarch_osabi_init
+ (requesting the "default" OSABI) before any per-file initialization
+ has occured, but it is only during that per-file initialization
+ that the OSABI target code gets to register that said "default"
+ OSABI. Starting the user_osabi_default out as "uninitialized", and
+ then initializing it at per-file time works around the problem. */
+static int user_osabi_default = GDB_OSABI_UNINITIALIZED;
+
/* This table matches the indices assigned to enum gdb_osabi. Keep
them in sync. */
static const char * const gdb_osabi_names[] =
@@ -210,8 +223,8 @@
an inconclusive result (otherwise). */
if (abfd == NULL)
{
- if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN)
- return GDB_OSABI_DEFAULT;
+ if (user_osabi_default != GDB_OSABI_UNKNOWN)
+ return user_osabi_default;
else
return GDB_OSABI_UNINITIALIZED;
}
@@ -277,8 +290,8 @@
/* If we didn't find a match, but a default was specified at configure
time, return the default. */
- if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN && match == GDB_OSABI_UNKNOWN)
- return GDB_OSABI_DEFAULT;
+ if (user_osabi_default != GDB_OSABI_UNKNOWN && match == GDB_OSABI_UNKNOWN)
+ return user_osabi_default;
else
return match;
}
@@ -504,7 +517,7 @@
user_osabi_state = osabi_auto;
else if (strcmp (set_osabi_string, "default") == 0)
{
- user_selected_osabi = GDB_OSABI_DEFAULT;
+ user_selected_osabi = user_osabi_default;
user_osabi_state = osabi_user;
}
else if (strcmp (set_osabi_string, "none") == 0)
@@ -545,9 +558,9 @@
printf_filtered ("The current OS ABI is \"%s\".\n",
gdbarch_osabi_name (user_selected_osabi));
- if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN)
+ if (user_osabi_default != GDB_OSABI_UNKNOWN)
printf_filtered ("The default OS ABI is \"%s\".\n",
- gdbarch_osabi_name (GDB_OSABI_DEFAULT));
+ gdbarch_osabi_name (user_osabi_default));
}
\f
extern initialize_file_ftype _initialize_gdb_osabi; /* -Wmissing-prototype */
@@ -577,4 +590,9 @@
add_cmd ("osabi", class_support, show_osabi, "Show OS/ABI of target.",
&showlist);
user_osabi_state = osabi_auto;
+#ifdef GDB_OSABI_DEFAULT
+ user_osabi_default = GDB_OSABI_DEFAULT;
+#else
+ user_osabi_default = GDB_OSABI_UNKNOWN;
+#endif
}
next reply other threads:[~2003-10-24 2:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-24 2:45 Andrew Cagney [this message]
2003-10-24 4:12 ` Daniel Jacobowitz
2003-10-24 13:55 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F98921A.9040302@redhat.com \
--to=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox