2012-11-13 Giuseppe Montalto <giuseppe.montalto@st.com>
* mi/mi-main.c (mi_cmd_data_write_memory): Handle additional parameter COUNT, for pattern filling of memory regions. * NEWS: Mention it. doc * gdb.texinfo (GDB/MI Data Manipulation): Document new optional parameter "count" of -data-write-memory-bytes, and add an example. testsuite * gdb.mi/mi-fill-memory.exp: New test.
This commit is contained in:
parent
4cd2972117
commit
62747a60cb
@ -1,3 +1,9 @@
|
||||
2012-11-13 Giuseppe Montalto <giuseppe.montalto@st.com>
|
||||
|
||||
* mi/mi-main.c (mi_cmd_data_write_memory): Handle additional
|
||||
parameter COUNT, for pattern filling of memory regions.
|
||||
* NEWS: Mention it.
|
||||
|
||||
2012-11-13 Markus Metzger <markus.t.metzger@intel.com>
|
||||
|
||||
* disasm.h (DISASSEMBLY_FILENAME): New macro.
|
||||
|
2
gdb/NEWS
2
gdb/NEWS
@ -90,6 +90,8 @@ show print type typedefs
|
||||
** The data-disassemble command response will include a "fullname" field
|
||||
containing the absolute file name when GDB can determine it and source
|
||||
has been requested.
|
||||
** New optional parameter COUNT added to the "-data-write-memory-bytes"
|
||||
command, to allow pattern filling of memory areas.
|
||||
|
||||
*** Changes in GDB 7.5
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2012-11-13 Giuseppe Montalto <giuseppe.montalto@st.com>
|
||||
|
||||
* gdb.texinfo (GDB/MI Data Manipulation): Document new optional
|
||||
parameter "count" of -data-write-memory-bytes, and add an example.
|
||||
|
||||
2012-11-12 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* gdb.texinfo (Symbols): Document "info type-printers",
|
||||
|
@ -31443,6 +31443,7 @@ The corresponding @value{GDBN} command is @samp{x}.
|
||||
|
||||
@smallexample
|
||||
-data-write-memory-bytes @var{address} @var{contents}
|
||||
-data-write-memory-bytes @var{address} @var{contents} @r{[}@var{count}@r{]}
|
||||
@end smallexample
|
||||
|
||||
@noindent
|
||||
@ -31457,6 +31458,11 @@ quoted using the C convention.
|
||||
@item @var{contents}
|
||||
The hex-encoded bytes to write.
|
||||
|
||||
@item @var{count}
|
||||
Optional argument indicating the number of bytes to be written. If @var{count}
|
||||
is greater than @var{contents}' length, @value{GDBN} will repeatedly
|
||||
write @var{contents} until it fills @var{count} bytes.
|
||||
|
||||
@end table
|
||||
|
||||
@subsubheading @value{GDBN} Command
|
||||
@ -31472,6 +31478,12 @@ There's no corresponding @value{GDBN} command.
|
||||
(gdb)
|
||||
@end smallexample
|
||||
|
||||
@smallexample
|
||||
(gdb)
|
||||
-data-write-memory-bytes &a "aabbccdd" 16e
|
||||
^done
|
||||
(gdb)
|
||||
@end smallexample
|
||||
|
||||
@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@node GDB/MI Tracepoint Commands
|
||||
|
@ -1656,7 +1656,8 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
|
||||
/* Implementation of the -data-write-memory-bytes command.
|
||||
|
||||
ADDR: start address
|
||||
DATA: string of bytes to write at that address. */
|
||||
DATA: string of bytes to write at that address
|
||||
COUNT: number of bytes to be filled (decimal integer). */
|
||||
|
||||
void
|
||||
mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc)
|
||||
@ -1664,11 +1665,13 @@ mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc)
|
||||
CORE_ADDR addr;
|
||||
char *cdata;
|
||||
gdb_byte *data;
|
||||
int len, r, i;
|
||||
gdb_byte *databuf;
|
||||
size_t len, r, i, steps, remainder;
|
||||
long int count, j;
|
||||
struct cleanup *back_to;
|
||||
|
||||
if (argc != 2)
|
||||
error (_("Usage: ADDR DATA."));
|
||||
if (argc != 2 && argc != 3)
|
||||
error (_("Usage: ADDR DATA [COUNT]."));
|
||||
|
||||
addr = parse_and_eval_address (argv[0]);
|
||||
cdata = argv[1];
|
||||
@ -1677,18 +1680,45 @@ mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc)
|
||||
cdata);
|
||||
|
||||
len = strlen (cdata)/2;
|
||||
if (argc == 3)
|
||||
count = strtoul (argv[2], NULL, 10);
|
||||
else
|
||||
count = len;
|
||||
|
||||
data = xmalloc (len);
|
||||
back_to = make_cleanup (xfree, data);
|
||||
databuf = xmalloc (len * sizeof (gdb_byte));
|
||||
back_to = make_cleanup (xfree, databuf);
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
int x;
|
||||
sscanf (cdata + i * 2, "%02x", &x);
|
||||
data[i] = (gdb_byte) x;
|
||||
if (sscanf (cdata + i * 2, "%02x", &x) != 1)
|
||||
error (_("Invalid argument"));
|
||||
databuf[i] = (gdb_byte) x;
|
||||
}
|
||||
|
||||
write_memory_with_notification (addr, data, len);
|
||||
if (len < count)
|
||||
{
|
||||
/* Pattern is made of less bytes than count:
|
||||
repeat pattern to fill memory. */
|
||||
data = xmalloc (count);
|
||||
make_cleanup (xfree, data);
|
||||
|
||||
steps = count / len;
|
||||
remainder = count % len;
|
||||
for (j = 0; j < steps; j++)
|
||||
memcpy (data + j * len, databuf, len);
|
||||
|
||||
if (remainder > 0)
|
||||
memcpy (data + steps * len, databuf, remainder);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pattern is longer than or equal to count:
|
||||
just copy len bytes. */
|
||||
data = databuf;
|
||||
}
|
||||
|
||||
write_memory_with_notification (addr, data, count);
|
||||
|
||||
do_cleanups (back_to);
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
2012-11-13 Giuseppe Montalto <giuseppe.montalto@st.com>
|
||||
|
||||
* gdb.mi/mi-fill-memory.exp: New test.
|
||||
|
||||
2012-11-12 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* gdb.base/completion.exp: Update for "info type-printers".
|
||||
|
58
gdb/testsuite/gdb.mi/mi-fill-memory.exp
Normal file
58
gdb/testsuite/gdb.mi/mi-fill-memory.exp
Normal file
@ -0,0 +1,58 @@
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#
|
||||
# added for testing the -data-write-memory-bytes MI command enhancements
|
||||
#
|
||||
|
||||
load_lib mi-support.exp
|
||||
set MIFLAGS "-i=mi"
|
||||
|
||||
gdb_exit
|
||||
if [mi_gdb_start] {
|
||||
continue
|
||||
}
|
||||
|
||||
standard_testfile "mi-read-memory"
|
||||
|
||||
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}.c" "${binfile}" executable {debug}] != "" } {
|
||||
untested mi-fill-memory.exp
|
||||
return -1
|
||||
}
|
||||
|
||||
mi_run_to_main
|
||||
mi_next_to "main" "" "mi-read-memory.c" "20" "next at main"
|
||||
|
||||
mi_gdb_test "1-data-write-memory-bytes"\
|
||||
"1\\\^error,msg=\"Usage: ADDR DATA \\\[COUNT\\\]\.\""\
|
||||
"no arguments"
|
||||
|
||||
mi_gdb_test "2-data-write-memory-bytes 8"\
|
||||
"2\\\^error,msg=\"Usage: ADDR DATA \\\[COUNT\\\]\.\""\
|
||||
"one argument missing"
|
||||
|
||||
mi_gdb_test "3-data-write-memory-bytes \$pc ab"\
|
||||
"3\\\^done" \
|
||||
"memory successfully written"
|
||||
|
||||
mi_gdb_test "4-data-write-memory-bytes \$pc ab 8"\
|
||||
"4\\\^done" \
|
||||
"memory successfully filled (8 bytes)"
|
||||
|
||||
mi_gdb_test "5-interpreter-exec console \"x \$pc\"" \
|
||||
".*0xabababab.*" \
|
||||
"pattern correctly read from memory"
|
||||
|
||||
mi_gdb_exit
|
Loading…
Reference in New Issue
Block a user