aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2001-07-09 16:53:03 +0000
committerKevin Buettner <kevinb@redhat.com>2001-07-09 16:53:03 +0000
commitd8bf3afa188f522f9251cb372627881729c2d382 (patch)
tree522c7f4b010484e9b15ece4646a38b0133cf142c /gdb/mi
parent96052a95b19f3acefb057415cc63d71c0c62ed6b (diff)
downloadgdb-d8bf3afa188f522f9251cb372627881729c2d382.zip
gdb-d8bf3afa188f522f9251cb372627881729c2d382.tar.gz
gdb-d8bf3afa188f522f9251cb372627881729c2d382.tar.bz2
Fix memory leak and compilation problems using AIX 5 native compiler.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/ChangeLog9
-rw-r--r--gdb/mi/mi-main.c24
2 files changed, 25 insertions, 8 deletions
diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog
index 5bf43f7..9784216 100644
--- a/gdb/mi/ChangeLog
+++ b/gdb/mi/ChangeLog
@@ -1,3 +1,12 @@
+2001-07-09 Kevin Buettner <kevinb@redhat.com>
+
+ * mi-main.c (register_changed_p, get_register): Use alloca()
+ to allocate space previously allocated via gcc's
+ variable-length array extension.
+ (mi_cmd_data_write_register_values, mi_cmd_data_write_memory):
+ Change type of ``buffer'' to ``void *''. Don't cast return value
+ from xmalloc(). Add a cleanup to free the xmalloc'd buffer.
+
2001-07-07 Andrew Cagney <ac131313@redhat.com>
* mi-main.c (mi_cmd_data_evaluate_expression): Replace value_ptr
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 78b7f7c..2ac2dd1 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -378,7 +378,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
static int
register_changed_p (int regnum)
{
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
+ char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
if (read_relative_register_raw_bytes (regnum, raw_buffer))
return -1;
@@ -483,8 +483,8 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
static int
get_register (int regnum, int format)
{
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
- char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
+ char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
+ char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
int optim;
static struct ui_stream *stb = NULL;
@@ -551,7 +551,6 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc)
int regnum;
int i;
int numregs;
- char *buffer;
LONGEST value;
char format;
@@ -602,14 +601,19 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc)
&& REGISTER_NAME (regnum) != NULL
&& *REGISTER_NAME (regnum) != '\000')
{
+ void *buffer;
+ struct cleanup *old_chain;
+
/* Get the value as a number */
value = parse_and_eval_address (argv[i + 1]);
/* Get the value into an array */
- buffer = (unsigned char *) xmalloc (REGISTER_SIZE);
+ buffer = xmalloc (REGISTER_SIZE);
+ old_chain = make_cleanup (xfree, buffer);
store_signed_integer (buffer, REGISTER_SIZE, value);
/* Write it down */
write_register_bytes (REGISTER_BYTE (regnum), buffer, REGISTER_RAW_SIZE (regnum));
- /* write_register_bytes (REGISTER_BYTE (regnum), buffer, REGISTER_SIZE); */
+ /* Free the buffer. */
+ do_cleanups (old_chain);
}
else
{
@@ -973,7 +977,8 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
/* FIXME: ezannoni 2000-02-17 LONGEST could possibly not be big
enough when using a compiler other than GCC. */
LONGEST value;
- unsigned char *buffer;
+ void *buffer;
+ struct cleanup *old_chain;
long offset = 0;
int optind = 0;
char *optarg;
@@ -1025,10 +1030,13 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
/* Get the value as a number */
value = parse_and_eval_address (argv[3]);
/* Get the value into an array */
- buffer = (unsigned char *) xmalloc (word_size);
+ buffer = xmalloc (word_size);
+ old_chain = make_cleanup (xfree, buffer);
store_signed_integer (buffer, word_size, value);
/* Write it down to memory */
write_memory (addr, buffer, word_size);
+ /* Free the buffer. */
+ do_cleanups (old_chain);
return MI_CMD_DONE;
}