* [PATCH] set osabi command
@ 2002-08-15 14:19 Simon Posnjak
2002-08-19 15:31 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Simon Posnjak @ 2002-08-15 14:19 UTC (permalink / raw)
To: gdb-patches
Hi,
This patch adds a set osabi <which> command that it used to override the
automatic osabi detection. This is needed for some libary that don't
provide the .note.ABI-tag and the auto detection fails.
Regards Simon
--- /tmp/gdb+dejagnu-20020813/gdb/osabi.c Sat Jul 27 03:28:43 2002
+++ osabi.c Thu Aug 15 16:21:23 2002
@@ -20,6 +20,9 @@
#include "defs.h"
#include "osabi.h"
+#include "command.h"
+#include "gdbcmd.h"
+#include "completer.h"
#include "elf-bfd.h"
@@ -52,6 +55,48 @@
"<invalid>"
};
+static char *osabi_set_val = NULL;
+
+enum gdb_osabi
+gdbarch_osabi_var_set ()
+{
+ if (strcmp(osabi_set_val, "SVR4") == 0)
+ return GDB_OSABI_SVR4;
+ if (strcmp(osabi_set_val, "hurd") == 0)
+ return GDB_OSABI_HURD;
+ if (strcmp(osabi_set_val, "solaris") == 0)
+ return GDB_OSABI_SOLARIS;
+ if (strcmp(osabi_set_val, "OSF1") == 0)
+ return GDB_OSABI_OSF1;
+ if (strcmp(osabi_set_val, "linux") == 0)
+ return GDB_OSABI_LINUX;
+ if (strcmp(osabi_set_val, "freebsd_aout") == 0)
+ return GDB_OSABI_FREEBSD_AOUT;
+ if (strcmp(osabi_set_val, "freebsd_elf") == 0)
+ return GDB_OSABI_FREEBSD_ELF;
+ if (strcmp(osabi_set_val, "netbsd_aout") == 0)
+ return GDB_OSABI_NETBSD_AOUT;
+ if (strcmp(osabi_set_val, "netbsd_elf") == 0)
+ return GDB_OSABI_NETBSD_ELF;
+ if (strcmp(osabi_set_val, "wince") == 0)
+ return GDB_OSABI_WINCE;
+ if (strcmp(osabi_set_val, "go32") == 0)
+ return GDB_OSABI_GO32;
+ if (strcmp(osabi_set_val, "netware") == 0)
+ return GDB_OSABI_NETWARE;
+ if (strcmp(osabi_set_val, "irix") == 0)
+ return GDB_OSABI_IRIX;
+ if (strcmp(osabi_set_val, "lynxos") == 0)
+ return GDB_OSABI_LYNXOS;
+ if (strcmp(osabi_set_val, "arm_eabi_v1") == 0)
+ return GDB_OSABI_ARM_EABI_V1;
+ if (strcmp(osabi_set_val, "arm_eabi_v2") == 0)
+ return GDB_OSABI_ARM_EABI_V2;
+ if (strcmp(osabi_set_val, "arm_apcs") == 0)
+ return GDB_OSABI_ARM_APCS;
+ return GDB_OSABI_UNKNOWN;
+}
+
const char *
gdbarch_osabi_name (enum gdb_osabi osabi)
{
@@ -162,7 +207,13 @@
match = GDB_OSABI_UNKNOWN;
match_specific = 0;
-
+
+ if (osabi_set_val != NULL) {
+ match = gdbarch_osabi_var_set();
+ if (match != GDB_OSABI_UNKNOWN)
+ return match;
+ }
+
for (sniffer = gdb_osabi_sniffer_list; sniffer != NULL;
sniffer = sniffer->next)
{
@@ -373,7 +424,13 @@
{
unsigned int elfosabi;
enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
-
+
+ if (osabi_set_val != NULL) {
+ osabi = gdbarch_osabi_var_set();
+ if (osabi != GDB_OSABI_UNKNOWN)
+ return osabi;
+ }
+
elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
switch (elfosabi)
@@ -425,13 +482,24 @@
void
_initialize_gdb_osabi (void)
{
+ struct cmd_list_element *c;
+
if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID], "<invalid>") != 0)
internal_error
(__FILE__, __LINE__,
"_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent");
+ c = add_set_cmd ("osabi", class_support, var_string,
+ (char *) &osabi_set_val, "Set the osabi. Posible targets are: linux,
+ hurd, irix, freebsd_aout, freebsd_elf, netbsd_aout, netbsd_aout,
+ netbsd_elf, OSF1, SVR4, solaris, wince, netware, go32, arm_apcs,
+ arm_eabi_v1, arm_eabi_v2, lynxos", &setlist);
+ add_show_from_set (c, &showlist);
+ set_cmd_completer (c, filename_completer);
+
/* Register a generic sniffer for ELF flavoured files. */
gdbarch_register_osabi_sniffer (bfd_arch_unknown,
bfd_target_elf_flavour,
generic_elf_osabi_sniffer);
+
}
--
Simon Posnjak
http://klada.dyndns.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] set osabi command
2002-08-15 14:19 [PATCH] set osabi command Simon Posnjak
@ 2002-08-19 15:31 ` Andrew Cagney
2002-08-19 15:40 ` Jason R Thorpe
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-08-19 15:31 UTC (permalink / raw)
To: Simon Posnjak; +Cc: gdb-patches
> Hi,
>
> This patch adds a set osabi <which> command that it used to override the
> automatic osabi detection. This is needed for some libary that don't
> provide the .note.ABI-tag and the auto detection fails.
Thanks! While the command works, I think it can be improved upon.
Have a look at the existing ``set architecture'' command. For instance:
(gdb) set debug architecture 1
(gdb) set architecture <tab>
... a list of architectures ...
(gdb) set architecture <choose-one>
... gdb will immediatly change architecture updating everthing ...
(gdb) set architecture <rubbish>
... and error message should appear and the architecture doesn't change ...
(gdb) set architecture auto
... gdb's architecture is determined by the target ...
I think a ``set osabi'' command should be similar in that it always and
immediatly has an effect.
It gets complex though because the user could enter a sequence like:
(gdb) set architecture arm
... architecture forced to arm ...
(gdb) set osabi arm_eabi_v1
... osabi forced to arm_eabi_v1
(gdb) set architecture mips
... architecture forced to mips, what should happen to the OSABI? It
can't remain arm_eabi_v1 ...
Idea's?
> +static char *osabi_set_val = NULL;
> +
> +enum gdb_osabi
> +gdbarch_osabi_var_set ()
> +{
FYI, it is important that the OSABI not be hardwired in this way.
> + if (strcmp(osabi_set_val, "SVR4") == 0)
> + return GDB_OSABI_SVR4;
> + c = add_set_cmd ("osabi", class_support, var_string,
> + (char *) &osabi_set_val, "Set the osabi. Posible targets are: linux,
> + hurd, irix, freebsd_aout, freebsd_elf, netbsd_aout, netbsd_aout,
> + netbsd_elf, OSF1, SVR4, solaris, wince, netware, go32, arm_apcs,
> + arm_eabi_v1, arm_eabi_v2, lynxos", &setlist);
> + add_show_from_set (c, &showlist);
> + set_cmd_completer (c, filename_completer);
> +
Have a look at the add_set_enum() command.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] set osabi command
2002-08-19 15:31 ` Andrew Cagney
@ 2002-08-19 15:40 ` Jason R Thorpe
2002-08-19 16:09 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Jason R Thorpe @ 2002-08-19 15:40 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Simon Posnjak, gdb-patches
On Mon, Aug 19, 2002 at 06:31:54PM -0400, Andrew Cagney wrote:
> It gets complex though because the user could enter a sequence like:
>
> (gdb) set architecture arm
> ... architecture forced to arm ...
> (gdb) set osabi arm_eabi_v1
> ... osabi forced to arm_eabi_v1
> (gdb) set architecture mips
> ... architecture forced to mips, what should happen to the OSABI? It
> can't remain arm_eabi_v1 ...
>
> Idea's?
* If it's e.g. "NetBSD/ELF", it's perfectly valid for ARM and MIPS,
so it should stay the same.
* Failing that, if the target triplet has a default OSABI, then
that should be selected.
* Failing that, the "unknown" OSABI.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] set osabi command
2002-08-19 15:40 ` Jason R Thorpe
@ 2002-08-19 16:09 ` Andrew Cagney
2002-08-19 16:19 ` Jason R Thorpe
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-08-19 16:09 UTC (permalink / raw)
To: Jason R Thorpe; +Cc: Simon Posnjak, gdb-patches
> On Mon, Aug 19, 2002 at 06:31:54PM -0400, Andrew Cagney wrote:
>
> > It gets complex though because the user could enter a sequence like:
> >
> > (gdb) set architecture arm
> > ... architecture forced to arm ...
> > (gdb) set osabi arm_eabi_v1
> > ... osabi forced to arm_eabi_v1
> > (gdb) set architecture mips
> > ... architecture forced to mips, what should happen to the OSABI? It
> > can't remain arm_eabi_v1 ...
> >
> > Idea's?
>
> * If it's e.g. "NetBSD/ELF", it's perfectly valid for ARM and MIPS,
> so it should stay the same.
>
> * Failing that, if the target triplet has a default OSABI, then
> that should be selected.
>
> * Failing that, the "unknown" OSABI.
Are you suggesting that a ``set architecture'' command affect the ``set
osabi'' setting, possibly forcing it to some other value?
Another option is:
...
(gdb) set architecture mips
OSABI arm_eabi_v1 invalid for mips architecture
and possibly even:
Force OSABI to ``auto''? (y or n)
even figuring out that there is a clash is hairy.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] set osabi command
2002-08-19 16:09 ` Andrew Cagney
@ 2002-08-19 16:19 ` Jason R Thorpe
0 siblings, 0 replies; 5+ messages in thread
From: Jason R Thorpe @ 2002-08-19 16:19 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Simon Posnjak, gdb-patches
On Mon, Aug 19, 2002 at 07:09:18PM -0400, Andrew Cagney wrote:
> Are you suggesting that a ``set architecture'' command affect the ``set
> osabi'' setting, possibly forcing it to some other value?
Yes.
> Another option is:
>
> ...
> (gdb) set architecture mips
> OSABI arm_eabi_v1 invalid for mips architecture
Yah, that's probably good.
> and possibly even:
>
> Force OSABI to ``auto''? (y or n)
>
> even figuring out that there is a clash is hairy.
Actually, figuring out if there is a clash should be easy. Traverse the
list of registered OSABIs... each one will have an arch/osabi tuple. If
you don't find one that matches the current arch/osabi setting, then you
have found a clash, and go into recovery mode. Otherwise, there is no
clash, and you can safely use the current osabi setting with the new arch
setting.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-08-19 23:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-15 14:19 [PATCH] set osabi command Simon Posnjak
2002-08-19 15:31 ` Andrew Cagney
2002-08-19 15:40 ` Jason R Thorpe
2002-08-19 16:09 ` Andrew Cagney
2002-08-19 16:19 ` Jason R Thorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox