/* MI Command Set.
- Copyright (C) 2000-2014 Free Software Foundation, Inc.
+ Copyright (C) 2000-2015 Free Software Foundation, Inc.
Contributed by Cygnus Solutions (a Red Hat company).
#include "gdbcmd.h"
#include <ctype.h>
-#include <sys/time.h>
+#include "gdb_sys_time.h"
#if defined HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
switch_to_thread (thread->ptid);
clear_proceed_status (0);
- proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT, 0);
+ proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
}
static int
/* Create a buffer and read it in. */
total_bytes = word_size * nr_rows * nr_cols;
- mbuf = xcalloc (total_bytes, 1);
+ mbuf = XCNEWVEC (gdb_byte, total_bytes);
make_cleanup (xfree, mbuf);
/* Dispatch memory reads to the topmost target, not the flattened
int ix;
VEC(memory_read_result_s) *result;
long offset = 0;
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
int oind = 0;
char *oarg;
enum opt
struct cleanup *t = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
char *data, *p;
int i;
+ int alloc_len;
ui_out_field_core_addr (uiout, "begin", gdbarch, read_result->begin);
ui_out_field_core_addr (uiout, "offset", gdbarch, read_result->begin
- addr);
ui_out_field_core_addr (uiout, "end", gdbarch, read_result->end);
- data = xmalloc ((read_result->end - read_result->begin) * 2 + 1);
+ alloc_len = (read_result->end - read_result->begin) * 2 * unit_size + 1;
+ data = (char *) xmalloc (alloc_len);
for (i = 0, p = data;
- i < (read_result->end - read_result->begin);
+ i < ((read_result->end - read_result->begin) * unit_size);
++i, p += 2)
{
sprintf (p, "%02x", read_result->data[i]);
char *cdata;
gdb_byte *data;
gdb_byte *databuf;
- size_t len, i, steps, remainder;
- long int count, j;
+ size_t len_hex, len_bytes, len_units, i, steps, remaining_units;
+ long int count_units;
struct cleanup *back_to;
+ int unit_size;
if (argc != 2 && argc != 3)
error (_("Usage: ADDR DATA [COUNT]."));
addr = parse_and_eval_address (argv[0]);
cdata = argv[1];
- if (strlen (cdata) % 2)
- error (_("Hex-encoded '%s' must have an even number of characters."),
+ len_hex = strlen (cdata);
+ unit_size = gdbarch_addressable_memory_unit_size (get_current_arch ());
+
+ if (len_hex % (unit_size * 2) != 0)
+ error (_("Hex-encoded '%s' must represent an integral number of "
+ "addressable memory units."),
cdata);
- len = strlen (cdata)/2;
+ len_bytes = len_hex / 2;
+ len_units = len_bytes / unit_size;
+
if (argc == 3)
- count = strtoul (argv[2], NULL, 10);
+ count_units = strtoul (argv[2], NULL, 10);
else
- count = len;
+ count_units = len_units;
- databuf = xmalloc (len * sizeof (gdb_byte));
+ databuf = XNEWVEC (gdb_byte, len_bytes);
back_to = make_cleanup (xfree, databuf);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len_bytes; ++i)
{
int x;
if (sscanf (cdata + i * 2, "%02x", &x) != 1)
databuf[i] = (gdb_byte) x;
}
- if (len < count)
+ if (len_units < count_units)
{
- /* Pattern is made of less bytes than count:
+ /* Pattern is made of less units than count:
repeat pattern to fill memory. */
- data = xmalloc (count);
+ data = (gdb_byte *) xmalloc (count_units * unit_size);
make_cleanup (xfree, data);
- steps = count / len;
- remainder = count % len;
- for (j = 0; j < steps; j++)
- memcpy (data + j * len, databuf, len);
+ /* Number of times the pattern is entirely repeated. */
+ steps = count_units / len_units;
+ /* Number of remaining addressable memory units. */
+ remaining_units = count_units % len_units;
+ for (i = 0; i < steps; i++)
+ memcpy (data + i * len_bytes, databuf, len_bytes);
- if (remainder > 0)
- memcpy (data + steps * len, databuf, remainder);
+ if (remaining_units > 0)
+ memcpy (data + steps * len_bytes, databuf,
+ remaining_units * unit_size);
}
else
{
/* Pattern is longer than or equal to count:
- just copy count bytes. */
+ just copy count addressable memory units. */
data = databuf;
}
- write_memory_with_notification (addr, data, count);
+ write_memory_with_notification (addr, data, count_units);
do_cleanups (back_to);
}
set_current_program_space (new_inferior->pspace);
}
- delete_inferior_1 (inf, 1 /* silent */);
+ delete_inferior (inf);
}
\f
{
char *token;
struct mi_parse *command = NULL;
- volatile struct gdb_exception exception;
/* This is to handle EOF (^D). We just quit gdb. */
/* FIXME: we should call some API function here. */
target_log_command (cmd);
- TRY_CATCH (exception, RETURN_MASK_ALL)
+ TRY
{
command = mi_parse (cmd, &token);
}
- if (exception.reason < 0)
+ CATCH (exception, RETURN_MASK_ALL)
{
mi_print_exception (token, exception);
xfree (token);
}
- else
+ END_CATCH
+
+ if (command != NULL)
{
- volatile struct gdb_exception result;
ptid_t previous_ptid = inferior_ptid;
command->token = token;
if (do_timings)
{
- command->cmd_start = (struct mi_timestamp *)
- xmalloc (sizeof (struct mi_timestamp));
+ command->cmd_start = XNEW (struct mi_timestamp);
timestamp (command->cmd_start);
}
- TRY_CATCH (result, RETURN_MASK_ALL)
+ TRY
{
captured_mi_execute_command (current_uiout, command);
}
- if (result.reason < 0)
+ CATCH (result, RETURN_MASK_ALL)
{
/* The command execution failed and error() was called
somewhere. */
mi_print_exception (command->token, result);
mi_out_rewind (current_uiout);
}
+ END_CATCH
bpstat_do_actions ();
struct collection_list tracepoint_list, stepping_list;
struct traceframe_info *tinfo;
int oind = 0;
- int var_print_values = PRINT_ALL_VALUES;
- int comp_print_values = PRINT_ALL_VALUES;
+ enum print_values var_print_values = PRINT_ALL_VALUES;
+ enum print_values comp_print_values = PRINT_ALL_VALUES;
int registers_format = 'x';
int memory_contents = 0;
struct ui_out *uiout = current_uiout;
if (tsv != NULL)
{
- tsvname = xrealloc (tsvname, strlen (tsv->name) + 2);
+ tsvname = (char *) xrealloc (tsvname, strlen (tsv->name) + 2);
tsvname[0] = '$';
strcpy (tsvname + 1, tsv->name);
ui_out_field_string (uiout, "name", tsvname);
ui_out_field_core_addr (uiout, "address", gdbarch, r->start);
ui_out_field_int (uiout, "length", r->length);
- data = xmalloc (r->length);
+ data = (gdb_byte *) xmalloc (r->length);
make_cleanup (xfree, data);
if (memory_contents)
int m;
char *data_str, *p;
- data_str = xmalloc (r->length * 2 + 1);
+ data_str = (char *) xmalloc (r->length * 2 + 1);
make_cleanup (xfree, data_str);
for (m = 0, p = data_str; m < r->length; ++m, p += 2)