This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: Add functions for storing integers
- To: gdb-patches at sources dot redhat dot com
- Subject: RFA: Add functions for storing integers
- From: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Date: Fri, 9 Nov 2001 13:53:55 -0500 (EST)
I could have sworn we had functions that did this already.
2001-11-09 Jim Blandy <jimb@redhat.com>
* corefile.c (write_memory_unsigned_integer,
write_memory_signed_integer): New functions.
(write_memory): Move to be with other write_memory_* functions.
* gdbcore.h (write_memory_unsigned_integer,
write_memory_signed_integer): New declarations.
Index: gdb/corefile.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/corefile.c,v
retrieving revision 2.28
diff -c -r2.28 corefile.c
*** gdb/corefile.c 2001/07/27 23:52:58 2.28
--- gdb/corefile.c 2001/11/09 18:48:41
***************
*** 260,276 ****
print_address (addr, info->stream);
}
- /* Same as target_write_memory, but report an error if can't write. */
- void
- write_memory (CORE_ADDR memaddr, char *myaddr, int len)
- {
- int status;
-
- status = target_write_memory (memaddr, myaddr, len);
- if (status != 0)
- memory_error (status, memaddr);
- }
-
/* Read an integer from debugged memory, given address and number of bytes. */
LONGEST
--- 260,265 ----
***************
*** 317,322 ****
--- 306,341 ----
break;
}
}
+
+ /* Same as target_write_memory, but report an error if can't write. */
+ void
+ write_memory (CORE_ADDR memaddr, char *myaddr, int len)
+ {
+ int status;
+
+ status = target_write_memory (memaddr, myaddr, len);
+ if (status != 0)
+ memory_error (status, memaddr);
+ }
+
+ /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
+ void
+ write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
+ {
+ char *buf = alloca (len);
+ store_unsigned_integer (buf, len, value);
+ write_memory (addr, buf, len);
+ }
+
+ /* Store VALUE at ADDR in the inferior as a LEN-byte signed integer. */
+ void
+ write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
+ {
+ char *buf = alloca (len);
+ store_signed_integer (buf, len, value);
+ write_memory (addr, buf, len);
+ }
+
#if 0
Index: gdb/gdbcore.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbcore.h,v
retrieving revision 1.30
diff -c -r1.30 gdbcore.h
*** gdb/gdbcore.h 2001/03/26 19:54:04 1.30
--- gdb/gdbcore.h 2001/11/09 18:48:41
***************
*** 72,77 ****
--- 72,85 ----
extern void write_memory (CORE_ADDR memaddr, char *myaddr, int 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,
+ ULONGEST value);
+
+ /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
+ extern void write_memory_signed_integer (CORE_ADDR addr, int len,
+ LONGEST value);
+
extern void generic_search (int len, char *data, char *mask,
CORE_ADDR startaddr, int increment,
CORE_ADDR lorange, CORE_ADDR hirange,