Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Memory reads and writes should have size_t length
@ 2012-05-31  8:08 Siddhesh Poyarekar
  2012-06-01 18:10 ` Jan Kratochvil
  0 siblings, 1 reply; 7+ messages in thread
From: Siddhesh Poyarekar @ 2012-05-31  8:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil, Tom Tromey

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

Hi,

Following the patch to bfd to accept size_t when reading objects from
memory:

http://sourceware.org/ml/gdb-patches/2012-05/msg00988.html

here's a patch makes memory reading and writing code consistent with
the above change and hence accept size_t for length. This change is not
comprehensive, i.e. there are a number of other places (to_xfer_partial
and friends) where a similar change should occur, but they're not
included in this change since those places already use LONGEST for
length and hence won't really be *fixing* anything. These changes on
the other hand, are supporting changes for the bitpos and type.length
changes:

http://sourceware.org/ml/gdb-patches/2012-05/msg00128.html

Regards,
Siddhesh

gdb/ChangeLog:

2012-05-31  Siddhesh Poyarekar  <siddhesh@redhat.com>

	* corefile.c (read_memory): Accept LEN argument as size_t.
	(read_stack): Likewise.
	(write_memory): Likewise.
	* gdbcore.h (read_memory): Likewise.
	(read_stack): Likewise.
	(write_memory): Likewise.
	* remote.c (remote_write_bytes_aux): Likewise.
	(remote_write_bytes): Likewise.
	* target.c (target_read_stack): Likewise.
	(target_write_memory): Likewise.
	(target_write_raw_memory): Likewise.
	* target.h (target_read_stack): Likewise.
	(target_write_memory): Likewise.
	(target_write_raw_memory): Likewise.

[-- Attachment #2: gdb-memory-sizet.patch --]
[-- Type: text/x-patch, Size: 5185 bytes --]

diff --git a/gdb/corefile.c b/gdb/corefile.c
index 986e4f5..89fcf49 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -213,7 +213,7 @@ memory_error (int status, CORE_ADDR memaddr)
 /* Same as target_read_memory, but report an error if can't read.  */
 
 void
-read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
 {
   int status;
 
@@ -225,7 +225,7 @@ read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
 /* Same as target_read_stack, but report an error if can't read.  */
 
 void
-read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
 {
   int status;
 
@@ -352,7 +352,7 @@ read_memory_typed_address (CORE_ADDR addr, struct type *type)
    write.  */
 void
 write_memory (CORE_ADDR memaddr, 
-	      const bfd_byte *myaddr, int len)
+	      const bfd_byte *myaddr, size_t len)
 {
   int status;
 
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index 776ce9f..9843b1e 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -45,11 +45,11 @@ extern void memory_error (int status, CORE_ADDR memaddr);
 
 /* Like target_read_memory, but report an error if can't read.  */
 
-extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
+extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len);
 
 /* Like target_read_stack, but report an error if can't read.  */
 
-extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
+extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len);
 
 /* Read an integer from debugged memory, given address and number of
    bytes.  */
@@ -83,7 +83,8 @@ CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
    byteswapping, alignment, different sizes for host vs. target types,
    etc.  */
 
-extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len);
+extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
+			  size_t len);
 
 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
 extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
diff --git a/gdb/remote.c b/gdb/remote.c
index 565de19..80e889f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6450,7 +6450,7 @@ check_binary_download (CORE_ADDR addr)
 
 static int
 remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
-			const gdb_byte *myaddr, int len,
+			const gdb_byte *myaddr, size_t len,
 			char packet_format, int use_length)
 {
   struct remote_state *rs = get_remote_state ();
@@ -6611,7 +6611,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
    error.  Only transfer a single packet.  */
 
 static int
-remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, size_t len)
 {
   char *packet_format = 0;
 
diff --git a/gdb/target.c b/gdb/target.c
index 91b4b47..a074188 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1772,7 +1772,7 @@ target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
    the target's stack.  This may trigger different cache behavior.  */
 
 int
-target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
@@ -1791,7 +1791,7 @@ target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
    Callers that can deal with partial writes should call target_write.  */
 
 int
-target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, size_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
@@ -1810,7 +1810,7 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
    should call target_write.  */
 
 int
-target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, size_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
diff --git a/gdb/target.h b/gdb/target.h
index f3ef33a..99ce3b7 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -999,13 +999,13 @@ extern int target_read_string (CORE_ADDR, char **, int, int *);
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
 			       size_t len);
 
-extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
+extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len);
 
 extern int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
-				int len);
+				size_t len);
 
 extern int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
-				    int len);
+				    size_t len);
 
 /* Fetches the target's memory map.  If one is found it is sorted
    and returned, after some consistency checking.  Otherwise, NULL
-- 
1.7.7.6


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

* Re: [PATCH] Memory reads and writes should have size_t length
  2012-05-31  8:08 [PATCH] Memory reads and writes should have size_t length Siddhesh Poyarekar
@ 2012-06-01 18:10 ` Jan Kratochvil
  2012-06-01 19:59   ` Siddhesh Poyarekar
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2012-06-01 18:10 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: gdb-patches, Tom Tromey

On Thu, 31 May 2012 09:23:20 +0200, Siddhesh Poyarekar wrote:
> --- a/gdb/corefile.c
> +++ b/gdb/corefile.c
> @@ -213,7 +213,7 @@ memory_error (int status, CORE_ADDR memaddr)
>  /* Same as target_read_memory, but report an error if can't read.  */
>  
>  void
> -read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
> +read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)

This patch goes again more far than what is needed, couldn't this be ssize_t?
Making it unsigned could be some other cleanup.

The bfd/ change could also use ssize_t but I find the bfd-gdb interface could
be more final.


Thanks,
Jan


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

* Re: [PATCH] Memory reads and writes should have size_t length
  2012-06-01 18:10 ` Jan Kratochvil
@ 2012-06-01 19:59   ` Siddhesh Poyarekar
  2012-06-04 21:54     ` Jan Kratochvil
  0 siblings, 1 reply; 7+ messages in thread
From: Siddhesh Poyarekar @ 2012-06-01 19:59 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Tom Tromey

On Fri, 1 Jun 2012 19:48:09 +0200, Jan wrote:

> On Thu, 31 May 2012 09:23:20 +0200, Siddhesh Poyarekar wrote:
> > --- a/gdb/corefile.c
> > +++ b/gdb/corefile.c
> > @@ -213,7 +213,7 @@ memory_error (int status, CORE_ADDR memaddr)
> >  /* Same as target_read_memory, but report an error if can't read.
> > */ 
> >  void
> > -read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
> > +read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
> 
> This patch goes again more far than what is needed, couldn't this be
> ssize_t? Making it unsigned could be some other cleanup.
> 

I took the liberty of changing signs here because this patch in itself
is small enough (and independent) and if it does cause a regression, it
should be pretty easy to isolate even with a simple bisect, unlike the
last patch where we'd have to hunt through 6k lines of a patch to
figure out what went wrong.

This patch can be tested independently, so I figured this was OK. What
do you think?

Regards,
Siddhesh


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

* Re: [PATCH] Memory reads and writes should have size_t length
  2012-06-01 19:59   ` Siddhesh Poyarekar
@ 2012-06-04 21:54     ` Jan Kratochvil
  2012-06-05  3:16       ` Siddhesh Poyarekar
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2012-06-04 21:54 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: gdb-patches, Tom Tromey

On Fri, 01 Jun 2012 21:59:58 +0200, Siddhesh Poyarekar wrote:
> On Fri, 1 Jun 2012 19:48:09 +0200, Jan wrote:
> > This patch goes again more far than what is needed, couldn't this be
> > ssize_t? Making it unsigned could be some other cleanup.
> > 
> 
> I took the liberty of changing signs here because this patch in itself
> is small enough (and independent)

But read_memory has 120 callers to check, other functions have hundreds of
other callers to check.  I have found at least the patch below to catch some
of these cases but it is far from complete.

Currently negative values were harmless on 32-bit hosts but now they will
overwrite GDB address space:

#include <stdio.h>
void target_read(long long x) {
  printf("%llx, 0<x==%d\n",x,0<x);
}
void target_read_memory_old(int    x) { target_read(x); }
void target_read_memory_new(size_t x) { target_read(x); }
int main (void) {
  target_read_memory_old(-1LL);
  target_read_memory_new(-1LL);
  return 0;
}

gcc -o 54   54.c -Wall -g     ;./54
ffffffffffffffff, 0<x==0
ffffffffffffffff, 0<x==0
gcc -o 5432 54.c -Wall -g -m32;./5432
ffffffffffffffff, 0<x==0
ffffffff, 0<x==1


> and if it does cause a regression, it
> should be pretty easy to isolate even with a simple bisect,

I do not think we need to cause regressions here, ssize_t has no practical
disadvantages compared to size_t, just it is not so clean/nice.


> This patch can be tested independently, so I figured this was OK. What
> do you think?

Unless someone else is going to protect all the hundreds/thousands of callers I
do not think it is worth it and ssize_t is good enough.


Thanks,
Jan


diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 0e441fb..1636216 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -427,6 +427,8 @@ read_fat_string_value (char *dest, struct value *val, int max_len)
      The lower bound is always 1, so we only need to read the upper bound.  */
   bounds_val = value_ind (value_field (val, bounds_fieldno));
   len = value_as_long (value_field (bounds_val, upper_bound_fieldno));
+  if (len < 0)
+    error (_("Invalid task format.  Aborting."));
 
   /* Make sure that we do not read more than max_len characters...  */
   if (len > max_len)
diff --git a/gdb/valops.c b/gdb/valops.c
index feb47f5..ca4ee26 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1282,7 +1282,7 @@ value_assign (struct value *toval, struct value *fromval)
 		&& ((LONGEST) changed_addr % TYPE_LENGTH (type)) == 0)
 	      changed_len = TYPE_LENGTH (type);
 
-	    if (changed_len > (int) sizeof (LONGEST))
+	    if (changed_len > (int) sizeof (LONGEST) || changed_len < 0)
 	      error (_("Can't handle bitfields which "
 		       "don't fit in a %d bit word."),
 		     (int) sizeof (LONGEST) * HOST_CHAR_BIT);


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

* Re: [PATCH] Memory reads and writes should have size_t length
  2012-06-04 21:54     ` Jan Kratochvil
@ 2012-06-05  3:16       ` Siddhesh Poyarekar
  2012-06-05 21:21         ` [commit] Change target_read_memory size_t->ssize_t [Re: [PATCH] Memory reads and writes should have size_t length] Jan Kratochvil
  2012-06-05 21:23         ` [commit] [PATCH] Memory reads and writes should have size_t length Jan Kratochvil
  0 siblings, 2 replies; 7+ messages in thread
From: Siddhesh Poyarekar @ 2012-06-05  3:16 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Tom Tromey

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

On Mon, 4 Jun 2012 23:54:19 +0200, Jan wrote:
> 
> Unless someone else is going to protect all the hundreds/thousands of
> callers I do not think it is worth it and ssize_t is good enough.
> 

OK, thanks for the explanation. Updated patch attached.

Regards,
Siddhesh

gdb/ChangeLog:

2012-06-05  Siddhesh Poyarekar  <siddhesh@redhat.com>

	* corefile.c (read_memory): Accept LEN argument as ssize_t.
	(read_stack): Likewise.
	(write_memory): Likewise.
	* gdbcore.h (read_memory): Likewise.
	(read_stack): Likewise.
	(write_memory): Likewise.
	* remote.c (remote_write_bytes_aux): Likewise.
	(remote_write_bytes): Likewise.
	* target.c (target_read_stack): Likewise.
	(target_write_memory): Likewise.
	(target_write_raw_memory): Likewise.
	* target.h (target_read_stack): Likewise.
	(target_write_memory): Likewise.
	(target_write_raw_memory): Likewise.

[-- Attachment #2: gdb-memory-ssizet.patch --]
[-- Type: text/x-patch, Size: 5186 bytes --]

diff --git a/gdb/corefile.c b/gdb/corefile.c
index 986e4f5..611cd62 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -213,7 +213,7 @@ memory_error (int status, CORE_ADDR memaddr)
 /* Same as target_read_memory, but report an error if can't read.  */
 
 void
-read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
 {
   int status;
 
@@ -225,7 +225,7 @@ read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
 /* Same as target_read_stack, but report an error if can't read.  */
 
 void
-read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
 {
   int status;
 
@@ -352,7 +352,7 @@ read_memory_typed_address (CORE_ADDR addr, struct type *type)
    write.  */
 void
 write_memory (CORE_ADDR memaddr, 
-	      const bfd_byte *myaddr, int len)
+	      const bfd_byte *myaddr, ssize_t len)
 {
   int status;
 
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index 776ce9f..1081f3f 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -45,11 +45,11 @@ extern void memory_error (int status, CORE_ADDR memaddr);
 
 /* Like target_read_memory, but report an error if can't read.  */
 
-extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
+extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
 
 /* Like target_read_stack, but report an error if can't read.  */
 
-extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
+extern void read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
 
 /* Read an integer from debugged memory, given address and number of
    bytes.  */
@@ -83,7 +83,8 @@ CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type);
    byteswapping, alignment, different sizes for host vs. target types,
    etc.  */
 
-extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len);
+extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
+			  ssize_t len);
 
 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
 extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
diff --git a/gdb/remote.c b/gdb/remote.c
index 54e7a67..322ff01 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6450,7 +6450,7 @@ check_binary_download (CORE_ADDR addr)
 
 static int
 remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
-			const gdb_byte *myaddr, int len,
+			const gdb_byte *myaddr, ssize_t len,
 			char packet_format, int use_length)
 {
   struct remote_state *rs = get_remote_state ();
@@ -6611,7 +6611,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
    error.  Only transfer a single packet.  */
 
 static int
-remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
 {
   char *packet_format = 0;
 
diff --git a/gdb/target.c b/gdb/target.c
index a2b2098..f7a78bb 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1772,7 +1772,7 @@ target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
    the target's stack.  This may trigger different cache behavior.  */
 
 int
-target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
@@ -1791,7 +1791,7 @@ target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
    Callers that can deal with partial writes should call target_write.  */
 
 int
-target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
@@ -1810,7 +1810,7 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
    should call target_write.  */
 
 int
-target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
diff --git a/gdb/target.h b/gdb/target.h
index a615e47..1057a02 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -999,13 +999,13 @@ extern int target_read_string (CORE_ADDR, char **, int, int *);
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
 			       size_t len);
 
-extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
+extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
 
 extern int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
-				int len);
+				ssize_t len);
 
 extern int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
-				    int len);
+				    ssize_t len);
 
 /* Fetches the target's memory map.  If one is found it is sorted
    and returned, after some consistency checking.  Otherwise, NULL

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

* [commit] Change target_read_memory size_t->ssize_t  [Re: [PATCH] Memory reads and writes should have size_t length]
  2012-06-05  3:16       ` Siddhesh Poyarekar
@ 2012-06-05 21:21         ` Jan Kratochvil
  2012-06-05 21:23         ` [commit] [PATCH] Memory reads and writes should have size_t length Jan Kratochvil
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2012-06-05 21:21 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: gdb-patches, Tom Tromey

On Tue, 05 Jun 2012 05:16:05 +0200, Siddhesh Poyarekar wrote:
> OK, thanks for the explanation. Updated patch attached.

To align the previous change:

commit a29f40b662a2626f877d7e9ca485af6c56959c35
2012-06-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
        * symfile-mem.c: 3 new gdb_static_assert for target_read_memory_bfd
        parameters.
        (target_read_memory_bfd): New function.
        (symbol_file_add_from_memory): Use it.

which used size_t with the ssize_t style parameters checked in this patch.

As there is now the target_read_memory_bfd stub the prototype no longer has to
be exactly the same bfd/<->gdb/.

tested on {x86_64,x86_64-m32}-fedora18pre-linux-gnu.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2012-06/msg00037.html

--- src/gdb/ChangeLog	2012/06/05 19:50:48	1.14327
+++ src/gdb/ChangeLog	2012/06/05 21:18:04	1.14328
@@ -1,3 +1,10 @@
+2012-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* symfile-mem.c: Change gdb_static_assert to ssize_t.
+	(target_read_memory_bfd): Cast gdb_assert LEN to ssize_t.
+	* target.c (target_read_memory): Change LEN to ssize_t.
+	* target.h (target_read_memory): Change LEN to ssize_t.
+
 2012-06-05  Pedro Alves  <palves@redhat.com>
 
 	PR backtrace/13866
--- src/gdb/symfile-mem.c	2012/06/04 14:35:25	1.27
+++ src/gdb/symfile-mem.c	2012/06/05 21:18:05	1.28
@@ -60,7 +60,7 @@
 
 gdb_static_assert (sizeof (CORE_ADDR) == sizeof (bfd_vma));
 gdb_static_assert (sizeof (gdb_byte) == sizeof (bfd_byte));
-gdb_static_assert (sizeof (size_t) <= sizeof (bfd_size_type));
+gdb_static_assert (sizeof (ssize_t) <= sizeof (bfd_size_type));
 
 /* Provide bfd/ compatible prototype for target_read_memory.  Casting would not
    be enough as LEN width may differ.  */
@@ -69,8 +69,8 @@
 target_read_memory_bfd (bfd_vma memaddr, bfd_byte *myaddr, bfd_size_type len)
 {
   /* MYADDR must be already allocated for the LEN size so it has to fit in
-     size_t.  */
-  gdb_assert ((size_t) len == len);
+     ssize_t.  */
+  gdb_assert ((ssize_t) len == len);
 
   return target_read_memory (memaddr, myaddr, len);
 }
--- src/gdb/target.c	2012/06/01 16:37:59	1.308
+++ src/gdb/target.c	2012/06/05 21:18:05	1.309
@@ -1756,7 +1756,7 @@
    it makes no progress, and then return how much was transferred).  */
 
 int
-target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, size_t len)
+target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
 {
   /* Dispatch to the topmost target, not the flattened current_target.
      Memory accesses check target->to_has_(all_)memory, and the
--- src/gdb/target.h	2012/06/01 16:37:59	1.236
+++ src/gdb/target.h	2012/06/05 21:18:05	1.237
@@ -997,7 +997,7 @@
 extern int target_read_string (CORE_ADDR, char **, int, int *);
 
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
-			       size_t len);
+			       ssize_t len);
 
 extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
 


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

* [commit] [PATCH] Memory reads and writes should have size_t length
  2012-06-05  3:16       ` Siddhesh Poyarekar
  2012-06-05 21:21         ` [commit] Change target_read_memory size_t->ssize_t [Re: [PATCH] Memory reads and writes should have size_t length] Jan Kratochvil
@ 2012-06-05 21:23         ` Jan Kratochvil
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2012-06-05 21:23 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: gdb-patches, Tom Tromey

On Tue, 05 Jun 2012 05:16:05 +0200, Siddhesh Poyarekar wrote:
> OK, thanks for the explanation. Updated patch attached.

Checked in.  (simplified ChangeLog)

tested on {x86_64,x86_64-m32}-fedora18pre-linux-gnu.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2012-06/msg00038.html

--- src/gdb/ChangeLog	2012/06/05 21:18:04	1.14328
+++ src/gdb/ChangeLog	2012/06/05 21:22:30	1.14329
@@ -1,3 +1,14 @@
+2012-06-05  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	* corefile.c (read_memory, read_stack, write_memory): Accept LEN
+	argument as ssize_t.
+	* gdbcore.h (read_memory, read_stack, write_memory): Likewise.
+	* remote.c (remote_write_bytes_aux, remote_write_bytes): Likewise.
+	* target.c (target_read_stack, target_write_memory)
+	(target_write_raw_memory): Likewise.
+	* target.h (target_read_stack, target_write_memory)
+	(target_write_raw_memory): Likewise.
+
 2012-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* symfile-mem.c: Change gdb_static_assert to ssize_t.

[patch is the same]


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

end of thread, other threads:[~2012-06-05 21:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-31  8:08 [PATCH] Memory reads and writes should have size_t length Siddhesh Poyarekar
2012-06-01 18:10 ` Jan Kratochvil
2012-06-01 19:59   ` Siddhesh Poyarekar
2012-06-04 21:54     ` Jan Kratochvil
2012-06-05  3:16       ` Siddhesh Poyarekar
2012-06-05 21:21         ` [commit] Change target_read_memory size_t->ssize_t [Re: [PATCH] Memory reads and writes should have size_t length] Jan Kratochvil
2012-06-05 21:23         ` [commit] [PATCH] Memory reads and writes should have size_t length Jan Kratochvil

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