* [commit] New function gdbarch_infi_fill
@ 2003-11-09 23:52 Andrew Cagney
2003-11-10 0:48 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-11-09 23:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
Hello,
The attached adds the new function gdbarch_info_fill. This new function
fills in un-initialized fields of the "info" structure using global
"set" variables and the "gdbarch" parameter.
committed,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 7250 bytes --]
2003-11-09 Andrew Cagney <cagney@redhat.com>
* Makefile.in (arch-utils.o): Update dependencies.
* arch-utils.c: Include "osabi.h".
(gdbarch_info_fill): New function.
* arch-utils.h (gdbarch_info_fill): Declare.
* gdbarch.sh (gdbarch_update_p): Call "gdbarch_info_fill".
* gdbarch.c: Re-generate.
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.102
diff -u -r1.102 arch-utils.c
--- arch-utils.c 9 Nov 2003 12:07:16 -0000 1.102
+++ arch-utils.c 9 Nov 2003 23:42:45 -0000
@@ -31,6 +31,8 @@
#include "gdb_assert.h"
#include "sim-regno.h"
+#include "osabi.h"
+
#include "version.h"
#include "floatformat.h"
@@ -678,6 +680,54 @@
memset (info, 0, sizeof (struct gdbarch_info));
info->byte_order = BFD_ENDIAN_UNKNOWN;
info->osabi = GDB_OSABI_UNINITIALIZED;
+}
+
+/* Similar it init, but this time fill in the blanks. Information is
+ obtained from the specified architecture, global "set ..." options,
+ and explicitly initialized INFO fields. */
+
+void
+gdbarch_info_fill (struct gdbarch *gdbarch, struct gdbarch_info *info)
+{
+ /* "(gdb) set architecture ...". */
+ if (info->bfd_arch_info == NULL
+ && !target_architecture_auto
+ && gdbarch != NULL)
+ info->bfd_arch_info = gdbarch_bfd_arch_info (gdbarch);
+ if (info->bfd_arch_info == NULL
+ && info->abfd != NULL
+ && bfd_get_arch (info->abfd) != bfd_arch_unknown
+ && bfd_get_arch (info->abfd) != bfd_arch_obscure)
+ info->bfd_arch_info = bfd_get_arch_info (info->abfd);
+ if (info->bfd_arch_info == NULL
+ && gdbarch != NULL)
+ info->bfd_arch_info = gdbarch_bfd_arch_info (gdbarch);
+
+ /* "(gdb) set byte-order ...". */
+ if (info->byte_order == BFD_ENDIAN_UNKNOWN
+ && !target_byte_order_auto
+ && gdbarch != NULL)
+ info->byte_order = gdbarch_byte_order (gdbarch);
+ /* From the INFO struct. */
+ if (info->byte_order == BFD_ENDIAN_UNKNOWN
+ && info->abfd != NULL)
+ info->byte_order = (bfd_big_endian (info->abfd) ? BFD_ENDIAN_BIG
+ : bfd_little_endian (info->abfd) ? BFD_ENDIAN_LITTLE
+ : BFD_ENDIAN_UNKNOWN);
+ /* From the current target. */
+ if (info->byte_order == BFD_ENDIAN_UNKNOWN
+ && gdbarch != NULL)
+ info->byte_order = gdbarch_byte_order (gdbarch);
+
+ /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */
+ if (info->osabi == GDB_OSABI_UNINITIALIZED)
+ info->osabi = gdbarch_lookup_osabi (info->abfd);
+ if (info->osabi == GDB_OSABI_UNINITIALIZED
+ && gdbarch != NULL)
+ info->osabi = gdbarch_osabi (gdbarch);
+
+ /* Must have at least filled in the architecture. */
+ gdb_assert (info->bfd_arch_info != NULL);
}
/* */
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.60
diff -u -r1.60 arch-utils.h
--- arch-utils.h 9 Nov 2003 12:07:16 -0000 1.60
+++ arch-utils.h 9 Nov 2003 23:42:45 -0000
@@ -153,6 +153,12 @@
default values are not zero. */
extern void gdbarch_info_init (struct gdbarch_info *info);
+/* Similar it init, but this time fill in the blanks. Information is
+ obtained from the specified architecture, global "set ..." options,
+ and explicitly initialized INFO fields. */
+extern void gdbarch_info_fill (struct gdbarch *gdbarch,
+ struct gdbarch_info *info);
+
/* Return the architecture for ABFD. If no suitable architecture
could be find, return NULL. */
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.256
diff -u -r1.256 gdbarch.c
--- gdbarch.c 9 Nov 2003 12:07:16 -0000 1.256
+++ gdbarch.c 9 Nov 2003 23:43:07 -0000
@@ -5922,38 +5922,7 @@
/* Fill in missing parts of the INFO struct using a number of
sources: ``set ...''; INFOabfd supplied; existing target. */
-
- /* ``(gdb) set architecture ...'' */
- if (info.bfd_arch_info == NULL
- && !TARGET_ARCHITECTURE_AUTO)
- info.bfd_arch_info = TARGET_ARCHITECTURE;
- if (info.bfd_arch_info == NULL
- && info.abfd != NULL
- && bfd_get_arch (info.abfd) != bfd_arch_unknown
- && bfd_get_arch (info.abfd) != bfd_arch_obscure)
- info.bfd_arch_info = bfd_get_arch_info (info.abfd);
- if (info.bfd_arch_info == NULL)
- info.bfd_arch_info = TARGET_ARCHITECTURE;
-
- /* ``(gdb) set byte-order ...'' */
- if (info.byte_order == BFD_ENDIAN_UNKNOWN
- && !TARGET_BYTE_ORDER_AUTO)
- info.byte_order = TARGET_BYTE_ORDER;
- /* From the INFO struct. */
- if (info.byte_order == BFD_ENDIAN_UNKNOWN
- && info.abfd != NULL)
- info.byte_order = (bfd_big_endian (info.abfd) ? BFD_ENDIAN_BIG
- : bfd_little_endian (info.abfd) ? BFD_ENDIAN_LITTLE
- : BFD_ENDIAN_UNKNOWN);
- /* From the current target. */
- if (info.byte_order == BFD_ENDIAN_UNKNOWN)
- info.byte_order = TARGET_BYTE_ORDER;
-
- /* ``(gdb) set osabi ...'' is handled by gdbarch_lookup_osabi. */
- if (info.osabi == GDB_OSABI_UNINITIALIZED)
- info.osabi = gdbarch_lookup_osabi (info.abfd);
- if (info.osabi == GDB_OSABI_UNINITIALIZED)
- info.osabi = current_gdbarch->osabi;
+ gdbarch_info_fill (current_gdbarch, &info);
/* Must have found some sort of architecture. */
gdb_assert (info.bfd_arch_info != NULL);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.281
diff -u -r1.281 gdbarch.sh
--- gdbarch.sh 9 Nov 2003 12:07:16 -0000 1.281
+++ gdbarch.sh 9 Nov 2003 23:43:30 -0000
@@ -2138,38 +2138,7 @@
/* Fill in missing parts of the INFO struct using a number of
sources: \`\`set ...''; INFOabfd supplied; existing target. */
-
- /* \`\`(gdb) set architecture ...'' */
- if (info.bfd_arch_info == NULL
- && !TARGET_ARCHITECTURE_AUTO)
- info.bfd_arch_info = TARGET_ARCHITECTURE;
- if (info.bfd_arch_info == NULL
- && info.abfd != NULL
- && bfd_get_arch (info.abfd) != bfd_arch_unknown
- && bfd_get_arch (info.abfd) != bfd_arch_obscure)
- info.bfd_arch_info = bfd_get_arch_info (info.abfd);
- if (info.bfd_arch_info == NULL)
- info.bfd_arch_info = TARGET_ARCHITECTURE;
-
- /* \`\`(gdb) set byte-order ...'' */
- if (info.byte_order == BFD_ENDIAN_UNKNOWN
- && !TARGET_BYTE_ORDER_AUTO)
- info.byte_order = TARGET_BYTE_ORDER;
- /* From the INFO struct. */
- if (info.byte_order == BFD_ENDIAN_UNKNOWN
- && info.abfd != NULL)
- info.byte_order = (bfd_big_endian (info.abfd) ? BFD_ENDIAN_BIG
- : bfd_little_endian (info.abfd) ? BFD_ENDIAN_LITTLE
- : BFD_ENDIAN_UNKNOWN);
- /* From the current target. */
- if (info.byte_order == BFD_ENDIAN_UNKNOWN)
- info.byte_order = TARGET_BYTE_ORDER;
-
- /* \`\`(gdb) set osabi ...'' is handled by gdbarch_lookup_osabi. */
- if (info.osabi == GDB_OSABI_UNINITIALIZED)
- info.osabi = gdbarch_lookup_osabi (info.abfd);
- if (info.osabi == GDB_OSABI_UNINITIALIZED)
- info.osabi = current_gdbarch->osabi;
+ gdbarch_info_fill (current_gdbarch, &info);
/* Must have found some sort of architecture. */
gdb_assert (info.bfd_arch_info != NULL);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [commit] New function gdbarch_infi_fill
2003-11-09 23:52 [commit] New function gdbarch_infi_fill Andrew Cagney
@ 2003-11-10 0:48 ` Daniel Jacobowitz
2003-11-10 16:19 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-11-10 0:48 UTC (permalink / raw)
To: gdb-patches
On Sun, Nov 09, 2003 at 06:50:54PM -0500, Andrew Cagney wrote:
> Hello,
>
> The attached adds the new function gdbarch_info_fill. This new function
> fills in un-initialized fields of the "info" structure using global
> "set" variables and the "gdbarch" parameter.
>
> committed,
> Andrew
Yeah! I've wanted this before. Though now I can't remember why.
> +/* Similar it init, but this time fill in the blanks. Information is
"Similar to".
> +/* Similar it init, but this time fill in the blanks. Information is
Ditto.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [commit] New function gdbarch_infi_fill
2003-11-10 0:48 ` Daniel Jacobowitz
@ 2003-11-10 16:19 ` Andrew Cagney
2003-11-10 16:26 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-11-10 16:19 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 728 bytes --]
> On Sun, Nov 09, 2003 at 06:50:54PM -0500, Andrew Cagney wrote:
>
>> Hello,
>>
>> The attached adds the new function gdbarch_info_fill. This new function
>> fills in un-initialized fields of the "info" structure using global
>> "set" variables and the "gdbarch" parameter.
>>
>> committed,
>> Andrew
>
>
> Yeah! I've wanted this before. Though now I can't remember why.
This all begs two questions.
Should gdbarch_info be filled in first?
Should the assertion:
gdbarch_find_by_info (gdbarch_info (gdbarch)) == gdbarch
always hold? At present architectures like the MIPS make this very hard
- keying off information found in the BFD and not the corresponding
info struct.
> "Similar to".
Fixed.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 1424 bytes --]
2003-11-10 Andrew Cagney <cagney@redhat.com>
* arch-utils.h, arch-utils.c: Fix typo in comment.
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.105
diff -u -r1.105 arch-utils.c
--- arch-utils.c 10 Nov 2003 16:03:26 -0000 1.105
+++ arch-utils.c 10 Nov 2003 16:16:22 -0000
@@ -686,7 +686,7 @@
info->osabi = GDB_OSABI_UNINITIALIZED;
}
-/* Similar it init, but this time fill in the blanks. Information is
+/* Similar to init, but this time fill in the blanks. Information is
obtained from the specified architecture, global "set ..." options,
and explicitly initialized INFO fields. */
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.61
diff -u -r1.61 arch-utils.h
--- arch-utils.h 9 Nov 2003 23:52:28 -0000 1.61
+++ arch-utils.h 10 Nov 2003 16:16:22 -0000
@@ -153,7 +153,7 @@
default values are not zero. */
extern void gdbarch_info_init (struct gdbarch_info *info);
-/* Similar it init, but this time fill in the blanks. Information is
+/* Similar to init, but this time fill in the blanks. Information is
obtained from the specified architecture, global "set ..." options,
and explicitly initialized INFO fields. */
extern void gdbarch_info_fill (struct gdbarch *gdbarch,
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [commit] New function gdbarch_infi_fill
2003-11-10 16:19 ` Andrew Cagney
@ 2003-11-10 16:26 ` Daniel Jacobowitz
2003-11-11 18:42 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-11-10 16:26 UTC (permalink / raw)
To: gdb-patches
On Mon, Nov 10, 2003 at 11:19:05AM -0500, Andrew Cagney wrote:
> >On Sun, Nov 09, 2003 at 06:50:54PM -0500, Andrew Cagney wrote:
> >
> >>Hello,
> >>
> >>The attached adds the new function gdbarch_info_fill. This new function
> >>fills in un-initialized fields of the "info" structure using global
> >>"set" variables and the "gdbarch" parameter.
> >>
> >>committed,
> >>Andrew
> >
> >
> >Yeah! I've wanted this before. Though now I can't remember why.
>
> This all begs two questions.
>
> Should gdbarch_info be filled in first?
Not sure.
> Should the assertion:
>
> gdbarch_find_by_info (gdbarch_info (gdbarch)) == gdbarch
>
> always hold? At present architectures like the MIPS make this very hard
> - keying off information found in the BFD and not the corresponding
> info struct.
This, however, I'd really like. I remember why I wanted it now. Take
a look at the end of osabi.c:set_osabi - I am not especially confident
that that code works. It seems to me that the above assertion makes it
much more likely to work.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [commit] New function gdbarch_infi_fill
2003-11-10 16:26 ` Daniel Jacobowitz
@ 2003-11-11 18:42 ` Andrew Cagney
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-11-11 18:42 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> Should the assertion:
>>
>> gdbarch_find_by_info (gdbarch_info (gdbarch)) == gdbarch
>>
>> always hold? At present architectures like the MIPS make this very hard
>> - keying off information found in the BFD and not the corresponding
>> info struct.
>
>
> This, however, I'd really like. I remember why I wanted it now. Take
> a look at the end of osabi.c:set_osabi - I am not especially confident
> that that code works. It seems to me that the above assertion makes it
> much more likely to work.
Like with "frame_id", it would mean adding some sort of "special" field.
That way the MIPS could record that its debugging "o64" but with
variation #28: sizeof(long) == 8, FPU :-/
It would also make architecture creation more robust vis:
- fill in "gdbarch_info"
Setting osabi et.al. based on the bfd et.al.
- create the architecture from "gdbarch_info"
but with _no_ bfd.
harder to get right, but probably more correct.
Adding to wish list ...
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-11-11 18:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-09 23:52 [commit] New function gdbarch_infi_fill Andrew Cagney
2003-11-10 0:48 ` Daniel Jacobowitz
2003-11-10 16:19 ` Andrew Cagney
2003-11-10 16:26 ` Daniel Jacobowitz
2003-11-11 18:42 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox