Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* remote-sim.h
@ 2011-10-31 23:24 Mike Stump
  2011-11-01  3:55 ` remote-sim.h Mike Frysinger
  2011-11-06 17:35 ` remote-sim.h Mike Frysinger
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Stump @ 2011-10-31 23:24 UTC (permalink / raw)
  To: gdb-patches

So, gdb includes remote-sim.h, but CORE_ADDR_TYPE isn't defined by the time the header is included.  On my platform, CORE_ADDR_TYPE is defined in sim-main.h.  I checked and the BFD bits are defined, so, I just use them as a fallback, works for my purposes.  I don't think this is the cleanest solution, so I don't think this is the right patch for the tree.  So, I kinda want to include sim-basics.h before this point, as that file, the sim people decided, would ensure that CORE_ADDR_TYPE is defined.  So, we can include that file here?  The problem is, there is no -I for any of the sim things, and that header will want to include things like cconfig.h...  Ick.  I kinda want the api to just use a fixed type that is big enough for any of the bfd targets and be done with it.  Thoughts?

Index: include/gdb/remote-sim.h
===================================================================
--- include/gdb/remote-sim.h    (revision 1866)
+++ include/gdb/remote-sim.h    (working copy)
@@ -32,8 +32,12 @@ extern "C" {
    gdb does (unsigned int - from defs.h).  */
 
 #ifndef CORE_ADDR_TYPE
+#if BFD_ARCH_SIZE <= 32
 typedef unsigned int SIM_ADDR;
 #else
+typedef unsigned long SIM_ADDR;
+#endif
+#else
 typedef CORE_ADDR_TYPE SIM_ADDR;
 #endif
 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-10-31 23:24 remote-sim.h Mike Stump
@ 2011-11-01  3:55 ` Mike Frysinger
  2011-11-01  5:38   ` remote-sim.h Mike Stump
  2011-11-06 17:35 ` remote-sim.h Mike Frysinger
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2011-11-01  3:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Mike Stump

[-- Attachment #1: Type: Text/Plain, Size: 1552 bytes --]

On Monday 31 October 2011 14:11:08 Mike Stump wrote:
> So, gdb includes remote-sim.h, but CORE_ADDR_TYPE isn't defined by the time
> the header is included.  On my platform, CORE_ADDR_TYPE is defined in
> sim-main.h.  I checked and the BFD bits are defined, so, I just use them
> as a fallback, works for my purposes.  I don't think this is the cleanest
> solution, so I don't think this is the right patch for the tree.  So, I
> kinda want to include sim-basics.h before this point, as that file, the
> sim people decided, would ensure that CORE_ADDR_TYPE is defined.  So, we
> can include that file here?  The problem is, there is no -I for any of the
> sim things, and that header will want to include things like cconfig.h... 
> Ick.  I kinda want the api to just use a fixed type that is big enough for
> any of the bfd targets and be done with it.  Thoughts?
> 
> --- include/gdb/remote-sim.h    (revision 1866)
> +++ include/gdb/remote-sim.h    (working copy)
> @@ -32,8 +32,12 @@ extern "C" {
>     gdb does (unsigned int - from defs.h).  */
> 
>  #ifndef CORE_ADDR_TYPE
> +#if BFD_ARCH_SIZE <= 32
>  typedef unsigned int SIM_ADDR;
>  #else
> +typedef unsigned long SIM_ADDR;
> +#endif
> +#else
>  typedef CORE_ADDR_TYPE SIM_ADDR;
>  #endif

i'm guessing you're creating a 64bit simulator.  this setup won't work when 
building on a 32bit system as unsigned long will still be 32bit.  i wonder if 
bfd_vma would be appropriate as a default instead, but i'm not sure of the 
exact purpose of that type ...
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-11-01  3:55 ` remote-sim.h Mike Frysinger
@ 2011-11-01  5:38   ` Mike Stump
  2011-11-01 18:55     ` remote-sim.h Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Stump @ 2011-11-01  5:38 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Oct 31, 2011, at 8:54 PM, Mike Frysinger wrote:
>> +#if BFD_ARCH_SIZE <= 32
>> typedef unsigned int SIM_ADDR;
>> #else
>> +typedef unsigned long SIM_ADDR;
>> +#endif
>> +#else
>> typedef CORE_ADDR_TYPE SIM_ADDR;
>> #endif
> 
> i'm guessing you're creating a 64bit simulator.  this setup won't work when 
> building on a 32bit system as unsigned long will still be 32bit.  i wonder if 
> bfd_vma would be appropriate as a default instead, but i'm not sure of the 
> exact purpose of that type ...

Indeed, bfd_vma would work just fine for me.  (I only have 64-bit pointers, and only have one target).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-11-01  5:38   ` remote-sim.h Mike Stump
@ 2011-11-01 18:55     ` Tom Tromey
  2011-11-01 19:50       ` remote-sim.h Mike Stump
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2011-11-01 18:55 UTC (permalink / raw)
  To: Mike Stump; +Cc: Mike Frysinger, gdb-patches

>>>>> "Mike" == Mike Stump <mikestump@comcast.net> writes:

Mike> Indeed, bfd_vma would work just fine for me.  (I only have 64-bit
Mike> pointers, and only have one target).

I don't know this code, but the comment in remote-sim.h indicates it is
trying to use the same type as gdb, and the current gdb/defs.h says:

    typedef bfd_vma CORE_ADDR;

remote-sim.h is the only reference I see to CORE_ADDR_TYPE.
I don't know the history but replacing it with bfd_vma seems like the
right thing.

Tom


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-11-01 18:55     ` remote-sim.h Tom Tromey
@ 2011-11-01 19:50       ` Mike Stump
  2011-11-02 17:02         ` remote-sim.h Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Stump @ 2011-11-01 19:50 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Mike Frysinger, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]

On Nov 1, 2011, at 10:18 AM, Tom Tromey wrote:
> I don't know this code, but the comment in remote-sim.h indicates it is
> trying to use the same type as gdb, and the current gdb/defs.h says:
> 
>    typedef bfd_vma CORE_ADDR;
> 
> remote-sim.h is the only reference I see to CORE_ADDR_TYPE.
> I don't know the history but replacing it with bfd_vma seems like the
> right thing.

Ah, yes, I agree.

Another patch to get the overlay code to work is below.  It just replaces unsigned int (32-bits for me) with CORE_ADDR, as otherwise int doesn't have enough bits to actually hold a long (64-bits for me).

Index: gdb/symfile.c
===================================================================
--- gdb/symfile.c	(revision 1878)
+++ gdb/symfile.c	(working copy)
@@ -122,7 +122,7 @@ static void overlay_command (char *, int
 
 static void simple_free_overlay_table (void);
 
-static void read_target_long_array (CORE_ADDR, unsigned int *, int, int,
+static void read_target_long_array (CORE_ADDR, CORE_ADDR *, int, int,
 				    enum bfd_endian);
 
 static int simple_read_overlay_table (void);
@@ -3307,8 +3307,8 @@ overlay_command (char *args, int from_tt
    the target (whenever possible).  */
 
 /* Cached, dynamically allocated copies of the target data structures: */
-static unsigned (*cache_ovly_table)[4] = 0;
-static unsigned cache_novlys = 0;
+static CORE_ADDR (*cache_ovly_table)[4] = 0;
+static CORE_ADDR cache_novlys = 0;
 static CORE_ADDR cache_ovly_table_base = 0;
 enum ovly_index
   {
@@ -3329,7 +3329,7 @@ simple_free_overlay_table (void)
 /* Read an array of ints of size SIZE from the target into a local buffer.
    Convert to host order.  int LEN is number of ints.  */
 static void
-read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
+read_target_long_array (CORE_ADDR memaddr, CORE_ADDR *myaddr,
 			int len, int size, enum bfd_endian byte_order)
 {
   /* FIXME (alloca): Not safe if array is very large.  */
@@ -3380,7 +3380,7 @@ simple_read_overlay_table (void)
     = (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
   cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym);
   read_target_long_array (cache_ovly_table_base,
-                          (unsigned int *) cache_ovly_table,
+                          (CORE_ADDR *) cache_ovly_table,
                           cache_novlys * 4, word_size, byte_order);
 
   return 1;			/* SUCCESS */
@@ -3411,7 +3411,7 @@ simple_overlay_update_1 (struct obj_sect
 	/* && cache_ovly_table[i][SIZE] == size */ )
       {
 	read_target_long_array (cache_ovly_table_base + i * word_size,
-				(unsigned int *) cache_ovly_table[i],
+				(CORE_ADDR *) cache_ovly_table[i],
 				4, word_size, byte_order);
 	if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
 	    && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)



[-- Attachment #2: symfile.patch.txt --]
[-- Type: text/plain, Size: 2234 bytes --]

Index: gdb/symfile.c
===================================================================
--- gdb/symfile.c	(revision 1878)
+++ gdb/symfile.c	(working copy)
@@ -122,7 +122,7 @@ static void overlay_command (char *, int
 
 static void simple_free_overlay_table (void);
 
-static void read_target_long_array (CORE_ADDR, unsigned int *, int, int,
+static void read_target_long_array (CORE_ADDR, CORE_ADDR *, int, int,
 				    enum bfd_endian);
 
 static int simple_read_overlay_table (void);
@@ -3307,8 +3307,8 @@ overlay_command (char *args, int from_tt
    the target (whenever possible).  */
 
 /* Cached, dynamically allocated copies of the target data structures: */
-static unsigned (*cache_ovly_table)[4] = 0;
-static unsigned cache_novlys = 0;
+static CORE_ADDR (*cache_ovly_table)[4] = 0;
+static CORE_ADDR cache_novlys = 0;
 static CORE_ADDR cache_ovly_table_base = 0;
 enum ovly_index
   {
@@ -3329,7 +3329,7 @@ simple_free_overlay_table (void)
 /* Read an array of ints of size SIZE from the target into a local buffer.
    Convert to host order.  int LEN is number of ints.  */
 static void
-read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
+read_target_long_array (CORE_ADDR memaddr, CORE_ADDR *myaddr,
 			int len, int size, enum bfd_endian byte_order)
 {
   /* FIXME (alloca): Not safe if array is very large.  */
@@ -3380,7 +3380,7 @@ simple_read_overlay_table (void)
     = (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
   cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym);
   read_target_long_array (cache_ovly_table_base,
-                          (unsigned int *) cache_ovly_table,
+                          (CORE_ADDR *) cache_ovly_table,
                           cache_novlys * 4, word_size, byte_order);
 
   return 1;			/* SUCCESS */
@@ -3411,7 +3411,7 @@ simple_overlay_update_1 (struct obj_sect
 	/* && cache_ovly_table[i][SIZE] == size */ )
       {
 	read_target_long_array (cache_ovly_table_base + i * word_size,
-				(unsigned int *) cache_ovly_table[i],
+				(CORE_ADDR *) cache_ovly_table[i],
 				4, word_size, byte_order);
 	if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
 	    && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-11-01 19:50       ` remote-sim.h Mike Stump
@ 2011-11-02 17:02         ` Tom Tromey
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2011-11-02 17:02 UTC (permalink / raw)
  To: Mike Stump; +Cc: Mike Frysinger, gdb-patches

>>>>> "Mike" == Mike Stump <mikestump@comcast.net> writes:

Tom> remote-sim.h is the only reference I see to CORE_ADDR_TYPE.
Tom> I don't know the history but replacing it with bfd_vma seems like the
Tom> right thing.

Mike> Ah, yes, I agree.

The patch to do that is preapproved, with a ChangeLog entry of course.

Mike> Another patch to get the overlay code to work is below.  It just
Mike> replaces unsigned int (32-bits for me) with CORE_ADDR, as
Mike> otherwise int doesn't have enough bits to actually hold a long
Mike> (64-bits for me).

Needs a ChangeLog but is otherwise ok.

Tom


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-10-31 23:24 remote-sim.h Mike Stump
  2011-11-01  3:55 ` remote-sim.h Mike Frysinger
@ 2011-11-06 17:35 ` Mike Frysinger
  2011-11-06 18:31   ` remote-sim.h Mike Stump
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2011-11-06 17:35 UTC (permalink / raw)
  To: gdb-patches; +Cc: Mike Stump

[-- Attachment #1: Type: Text/Plain, Size: 90 bytes --]

looks like this really old bug:
http://sourceware.org/bugzilla/show_bug.cgi?id=7504
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: remote-sim.h
  2011-11-06 17:35 ` remote-sim.h Mike Frysinger
@ 2011-11-06 18:31   ` Mike Stump
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Stump @ 2011-11-06 18:31 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Nov 5, 2011, at 11:58 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> looks like this really old bug:
> http://sourceware.org/bugzilla/show_bug.cgi?id=7504

Look at the bright side, at least it handles 32 bit code.  :-). It isn't like anyone actually has 64 bit CPUs yet.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-11-06 18:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-31 23:24 remote-sim.h Mike Stump
2011-11-01  3:55 ` remote-sim.h Mike Frysinger
2011-11-01  5:38   ` remote-sim.h Mike Stump
2011-11-01 18:55     ` remote-sim.h Tom Tromey
2011-11-01 19:50       ` remote-sim.h Mike Stump
2011-11-02 17:02         ` remote-sim.h Tom Tromey
2011-11-06 17:35 ` remote-sim.h Mike Frysinger
2011-11-06 18:31   ` remote-sim.h Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox