aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/h8300-tdep.c6
-rw-r--r--gdb/mt-tdep.c8
-rw-r--r--gdb/tilegx-tdep.c8
-rw-r--r--gdb/xstormy16-tdep.c8
5 files changed, 31 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c4b9e07..84f410f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2012-08-24 Siddhesh Poyarekar <siddhesh@redhat.com>
+
+ * h8300-tdep.c (h8300_push_dummy_call): Replace unsafe alloca
+ with xmalloc/cleanup.
+ * mt-tdep.c (mt_push_dummy_call): Likewise.
+ * tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
+ * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.
+
2012-08-24 Yao Qi <yao@codesourcery.com>
* jv-exp.y (push_expression_name): Add "." at the end of error
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 237f4a3..7fc4daa 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -666,13 +666,15 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argument = 0; argument < nargs; argument++)
{
+ struct cleanup *back_to;
struct type *type = value_type (args[argument]);
int len = TYPE_LENGTH (type);
char *contents = (char *) value_contents (args[argument]);
/* Pad the argument appropriately. */
int padded_len = align_up (len, wordsize);
- gdb_byte *padded = alloca (padded_len);
+ gdb_byte *padded = xmalloc (padded_len);
+ back_to = make_cleanup (xfree, padded);
memset (padded, 0, padded_len);
memcpy (len < wordsize ? padded + padded_len - len : padded,
@@ -720,6 +722,8 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
subsequent arguments go on the stack. */
reg = E_ARGLAST_REGNUM + 1;
}
+
+ do_cleanups (back_to);
}
/* Store return address. */
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index ee4b6eb..0ae51b3 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -845,16 +845,20 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (j = nargs - 1; j >= i; j--)
{
gdb_byte *val;
+ struct cleanup *back_to;
+ const gdb_byte *contents = value_contents (args[j]);
/* Right-justify the value in an aligned-length buffer. */
typelen = TYPE_LENGTH (value_type (args[j]));
slacklen = (wordsize - (typelen % wordsize)) % wordsize;
- val = alloca (typelen + slacklen);
- memcpy (val, value_contents (args[j]), typelen);
+ val = xmalloc (typelen + slacklen);
+ back_to = make_cleanup (xfree, val);
+ memcpy (val, contents, typelen);
memset (val + typelen, 0, slacklen);
/* Now write this data to the stack. */
stack_dest -= typelen + slacklen;
write_memory (stack_dest, val, typelen + slacklen);
+ do_cleanups (back_to);
}
/* Finally, if a param needs to be split between registers and stack,
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index 9ec3aaa..627a470 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -343,16 +343,20 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
for (j = nargs - 1; j >= i; j--)
{
gdb_byte *val;
+ struct cleanup *back_to;
+ const gdb_byte *contents = value_contents (args[j]);
typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
slacklen = ((typelen + 3) & (~3)) - typelen;
- val = alloca (typelen + slacklen);
- memcpy (val, value_contents (args[j]), typelen);
+ val = xmalloc (typelen + slacklen);
+ back_to = make_cleanup (xfree, val);
+ memcpy (val, contents, typelen);
memset (val + typelen, 0, slacklen);
/* Now write data to the stack. The stack grows downwards. */
stack_dest -= typelen + slacklen;
write_memory (stack_dest, val, typelen + slacklen);
+ do_cleanups (back_to);
}
/* Add 2 words for linkage space to the stack. */
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 47fc86b..d5e315c 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -279,16 +279,20 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
for (j = nargs - 1; j >= i; j--)
{
char *val;
+ struct cleanup *back_to;
+ const gdb_byte *bytes = value_contents (args[j]);
typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
slacklen = typelen & 1;
- val = alloca (typelen + slacklen);
- memcpy (val, value_contents (args[j]), typelen);
+ val = xmalloc (typelen + slacklen);
+ back_to = make_cleanup (xfree, val);
+ memcpy (val, bytes, typelen);
memset (val + typelen, 0, slacklen);
/* Now write this data to the stack. The stack grows upwards. */
write_memory (stack_dest, val, typelen + slacklen);
stack_dest += typelen + slacklen;
+ do_cleanups (back_to);
}
store_unsigned_integer (buf, xstormy16_pc_size, byte_order, bp_addr);