Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org, Tom Tromey <tromey@redhat.com>
Subject: Re: [PATCH] Memory reads and writes should have size_t length
Date: Tue, 05 Jun 2012 03:16:00 -0000	[thread overview]
Message-ID: <20120605084605.186d537a@spoyarek> (raw)
In-Reply-To: <20120604215419.GA27980@host2.jankratochvil.net>

[-- 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

  reply	other threads:[~2012-06-05  3:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-31  8:08 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 [this message]
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

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=20120605084605.186d537a@spoyarek \
    --to=siddhesh@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=tromey@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