aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:36:23 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:46:02 -0500
commitc583a2520616c2736cffc389c89a48b159366e6c (patch)
treeb4925f26506fcee96c16119431c01760f05db95d /gdb/target.c
parentca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff)
downloadgdb-users/simark/clang-format.zip
gdb-users/simark/clang-format.tar.gz
gdb-users/simark/clang-format.tar.bz2
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c763
1 files changed, 357 insertions, 406 deletions
diff --git a/gdb/target.c b/gdb/target.c
index d0aa8f5..038dd36 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -62,26 +62,25 @@ static void default_terminal_info (struct target_ops *, const char *, int);
static int default_watchpoint_addr_within_range (struct target_ops *,
CORE_ADDR, CORE_ADDR, int);
-static int default_region_ok_for_hw_watchpoint (struct target_ops *,
- CORE_ADDR, int);
+static int default_region_ok_for_hw_watchpoint (struct target_ops *, CORE_ADDR,
+ int);
static void default_rcmd (struct target_ops *, const char *, struct ui_file *);
-static ptid_t default_get_ada_task_ptid (struct target_ops *self,
- long lwp, ULONGEST tid);
+static ptid_t default_get_ada_task_ptid (struct target_ops *self, long lwp,
+ ULONGEST tid);
static void default_mourn_inferior (struct target_ops *self);
-static int default_search_memory (struct target_ops *ops,
- CORE_ADDR start_addr,
+static int default_search_memory (struct target_ops *ops, CORE_ADDR start_addr,
ULONGEST search_space_len,
const gdb_byte *pattern,
ULONGEST pattern_len,
CORE_ADDR *found_addrp);
static int default_verify_memory (struct target_ops *self,
- const gdb_byte *data,
- CORE_ADDR memaddr, ULONGEST size);
+ const gdb_byte *data, CORE_ADDR memaddr,
+ ULONGEST size);
static void tcomplain (void) ATTRIBUTE_NORETURN;
@@ -91,13 +90,14 @@ static int dummy_find_memory_regions (struct target_ops *self,
find_memory_region_ftype ignore1,
void *ignore2);
-static gdb::unique_xmalloc_ptr<char> dummy_make_corefile_notes
- (struct target_ops *self, bfd *ignore1, int *ignore2);
+static gdb::unique_xmalloc_ptr<char>
+dummy_make_corefile_notes (struct target_ops *self, bfd *ignore1,
+ int *ignore2);
static std::string default_pid_to_str (struct target_ops *ops, ptid_t ptid);
-static enum exec_direction_kind default_execution_direction
- (struct target_ops *self);
+static enum exec_direction_kind
+default_execution_direction (struct target_ops *self);
/* Mapping between target_info objects (which have address identity)
and corresponding open/factory function/callback. Each add_target
@@ -147,7 +147,7 @@ bool may_stop = true;
static unsigned int targetdebug = 0;
static void
-set_targetdebug (const char *args, int from_tty, struct cmd_list_element *c)
+set_targetdebug (const char *args, int from_tty, struct cmd_list_element *c)
{
if (targetdebug)
current_inferior ()->push_target (the_debug_target);
@@ -159,14 +159,13 @@ static void
show_targetdebug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Target debugging is %s.\n"), value);
+ gdb_printf (file, _ ("Target debugging is %s.\n"), value);
}
int
target_has_memory ()
{
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
if (t->has_memory ())
return 1;
@@ -177,8 +176,7 @@ target_has_memory ()
int
target_has_stack ()
{
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
if (t->has_stack ())
return 1;
@@ -189,8 +187,7 @@ target_has_stack ()
int
target_has_registers ()
{
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
if (t->has_registers ())
return 1;
@@ -204,8 +201,7 @@ target_has_execution (inferior *inf)
if (inf == nullptr)
inf = current_inferior ();
- for (target_ops *t = inf->top_target ();
- t != nullptr;
+ for (target_ops *t = inf->top_target (); t != nullptr;
t = inf->find_target_beneath (t))
if (t->has_execution (inf))
return true;
@@ -376,7 +372,7 @@ target_can_lock_scheduler ()
{
target_ops *target = current_inferior ()->top_target ();
- return (target->get_thread_control_capabilities ()& tc_schedlock) != 0;
+ return (target->get_thread_control_capabilities () & tc_schedlock) != 0;
}
/* See target.h. */
@@ -531,7 +527,6 @@ target_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
return target->region_ok_for_hw_watchpoint (addr, len);
}
-
int
target_can_do_single_step ()
{
@@ -680,8 +675,8 @@ target_trace_stop ()
}
int
-target_trace_find (trace_find_type type, int num,
- CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
+target_trace_find (trace_find_type type, int num, CORE_ADDR addr1,
+ CORE_ADDR addr2, int *tpp)
{
target_ops *target = current_inferior ()->top_target ();
@@ -822,14 +817,16 @@ bool
target_fetch_memtags (CORE_ADDR address, size_t len, gdb::byte_vector &tags,
int type)
{
- return current_inferior ()->top_target ()->fetch_memtags (address, len, tags, type);
+ return current_inferior ()->top_target ()->fetch_memtags (address, len, tags,
+ type);
}
bool
target_store_memtags (CORE_ADDR address, size_t len,
const gdb::byte_vector &tags, int type)
{
- return current_inferior ()->top_target ()->store_memtags (address, len, tags, type);
+ return current_inferior ()->top_target ()->store_memtags (address, len, tags,
+ type);
}
void
@@ -847,14 +844,13 @@ open_target (const char *args, int from_tty, struct cmd_list_element *command)
target_open_ftype *func = target_factories[ti];
if (targetdebug)
- gdb_printf (gdb_stdlog, "-> %s->open (...)\n",
- ti->shortname);
+ gdb_printf (gdb_stdlog, "-> %s->open (...)\n", ti->shortname);
func (args, from_tty);
if (targetdebug)
- gdb_printf (gdb_stdlog, "<- %s->open (%s, %d)\n",
- ti->shortname, args, from_tty);
+ gdb_printf (gdb_stdlog, "<- %s->open (%s, %d)\n", ti->shortname, args,
+ from_tty);
}
/* See target.h. */
@@ -867,11 +863,11 @@ add_target (const target_info &t, target_open_ftype *func,
auto &func_slot = target_factories[&t];
if (func_slot != nullptr)
- internal_error (_("target already added (\"%s\")."), t.shortname);
+ internal_error (_ ("target already added (\"%s\")."), t.shortname);
func_slot = func;
if (targetlist == NULL)
- add_basic_prefix_cmd ("target", class_run, _("\
+ add_basic_prefix_cmd ("target", class_run, _ ("\
Connect to a target machine or process.\n\
The first argument is the type or protocol of the target machine.\n\
Remaining arguments are interpreted by the target protocol. For more\n\
@@ -907,7 +903,6 @@ add_deprecated_target_alias (const target_info &tinfo, const char *alias)
void
target_kill (void)
{
-
/* If the commit_resume_state of the to-be-killed-inferior's process stratum
is true, and this inferior is the last live inferior with resumed threads
of that target, then we want to leave commit_resume_state to false, as the
@@ -1092,7 +1087,8 @@ target_terminal::ours_for_output ()
return;
target_terminal_is_ours_kind (target_terminal_state::is_ours_for_output);
- target_terminal::m_terminal_state = target_terminal_state::is_ours_for_output;
+ target_terminal::m_terminal_state
+ = target_terminal_state::is_ours_for_output;
}
/* See target/target.h. */
@@ -1123,20 +1119,20 @@ target_supports_terminal_ours (void)
static void
tcomplain (void)
{
- error (_("You can't do that when your target is `%s'"),
+ error (_ ("You can't do that when your target is `%s'"),
current_inferior ()->top_target ()->shortname ());
}
void
noprocess (void)
{
- error (_("You can't do that without a process to debug."));
+ error (_ ("You can't do that without a process to debug."));
}
static void
default_terminal_info (struct target_ops *self, const char *args, int from_tty)
{
- gdb_printf (_("No saved terminal information.\n"));
+ gdb_printf (_ ("No saved terminal information.\n"));
}
/* A default implementation for the to_get_ada_task_ptid target method.
@@ -1216,7 +1212,7 @@ target_stack::unpush (target_ops *t)
strata stratum = t->stratum ();
if (stratum == dummy_stratum)
- internal_error (_("Attempt to unpush the dummy target"));
+ internal_error (_ ("Attempt to unpush the dummy target"));
/* Look for the specified target. Note that a target can only occur
once in the target stack. */
@@ -1257,7 +1253,7 @@ static void
generic_tls_error (void)
{
throw_error (TLS_GENERIC_ERROR,
- _("Cannot find thread-local variables on this target"));
+ _ ("Cannot find thread-local variables on this target"));
}
/* Using the objfile specified in OBJFILE, find the address for the
@@ -1281,10 +1277,9 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
try
{
CORE_ADDR lm_addr;
-
+
/* Fetch the load module address for this objfile. */
- lm_addr = gdbarch_fetch_tls_load_module_address (gdbarch,
- objfile);
+ lm_addr = gdbarch_fetch_tls_load_module_address (gdbarch, objfile);
if (gdbarch_get_thread_local_address_p (gdbarch))
addr = gdbarch_get_thread_local_address (gdbarch, ptid, lm_addr,
@@ -1301,42 +1296,44 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
switch (ex.error)
{
case TLS_NO_LIBRARY_SUPPORT_ERROR:
- error (_("Cannot find thread-local variables "
- "in this thread library."));
+ error (_ ("Cannot find thread-local variables "
+ "in this thread library."));
break;
case TLS_LOAD_MODULE_NOT_FOUND_ERROR:
if (objfile_is_library)
- error (_("Cannot find shared library `%s' in dynamic"
- " linker's load module list"), objfile_name (objfile));
+ error (_ ("Cannot find shared library `%s' in dynamic"
+ " linker's load module list"),
+ objfile_name (objfile));
else
- error (_("Cannot find executable file `%s' in dynamic"
- " linker's load module list"), objfile_name (objfile));
+ error (_ ("Cannot find executable file `%s' in dynamic"
+ " linker's load module list"),
+ objfile_name (objfile));
break;
case TLS_NOT_ALLOCATED_YET_ERROR:
if (objfile_is_library)
- error (_("The inferior has not yet allocated storage for"
- " thread-local variables in\n"
- "the shared library `%s'\n"
- "for %s"),
+ error (_ ("The inferior has not yet allocated storage for"
+ " thread-local variables in\n"
+ "the shared library `%s'\n"
+ "for %s"),
objfile_name (objfile),
target_pid_to_str (ptid).c_str ());
else
- error (_("The inferior has not yet allocated storage for"
- " thread-local variables in\n"
- "the executable `%s'\n"
- "for %s"),
+ error (_ ("The inferior has not yet allocated storage for"
+ " thread-local variables in\n"
+ "the executable `%s'\n"
+ "for %s"),
objfile_name (objfile),
target_pid_to_str (ptid).c_str ());
break;
case TLS_GENERIC_ERROR:
if (objfile_is_library)
- error (_("Cannot find thread-local storage for %s, "
- "shared library %s:\n%s"),
+ error (_ ("Cannot find thread-local storage for %s, "
+ "shared library %s:\n%s"),
target_pid_to_str (ptid).c_str (),
objfile_name (objfile), ex.what ());
else
- error (_("Cannot find thread-local storage for %s, "
- "executable file %s:\n%s"),
+ error (_ ("Cannot find thread-local storage for %s, "
+ "executable file %s:\n%s"),
target_pid_to_str (ptid).c_str (),
objfile_name (objfile), ex.what ());
break;
@@ -1347,7 +1344,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
}
}
else
- error (_("Cannot find thread-local variables on this target"));
+ error (_ ("Cannot find thread-local variables on this target"));
return addr;
}
@@ -1355,18 +1352,19 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
const char *
target_xfer_status_to_string (enum target_xfer_status status)
{
-#define CASE(X) case X: return #X
+#define CASE(X) \
+ case X: \
+ return #X
switch (status)
{
- CASE(TARGET_XFER_E_IO);
- CASE(TARGET_XFER_UNAVAILABLE);
+ CASE (TARGET_XFER_E_IO);
+ CASE (TARGET_XFER_UNAVAILABLE);
default:
return "<unknown>";
}
#undef CASE
};
-
const target_section_table *
target_get_section_table (struct target_ops *target)
{
@@ -1435,7 +1433,7 @@ memory_xfer_check_region (gdb_byte *readbuf, const gdb_byte *writebuf,
case MEM_FLASH:
/* We only support writing to flash during "load" for now. */
if (writebuf != NULL)
- error (_("Writing to flash memory forbidden in this context"));
+ error (_ ("Writing to flash memory forbidden in this context"));
break;
case MEM_NONE:
@@ -1457,16 +1455,15 @@ memory_xfer_check_region (gdb_byte *readbuf, const gdb_byte *writebuf,
enum target_xfer_status
raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST memaddr, LONGEST len,
- ULONGEST *xfered_len)
+ const gdb_byte *writebuf, ULONGEST memaddr,
+ LONGEST len, ULONGEST *xfered_len)
{
enum target_xfer_status res;
do
{
- res = ops->xfer_partial (TARGET_OBJECT_MEMORY, NULL,
- readbuf, writebuf, memaddr, len,
- xfered_len);
+ res = ops->xfer_partial (TARGET_OBJECT_MEMORY, NULL, readbuf, writebuf,
+ memaddr, len, xfered_len);
if (res == TARGET_XFER_OK)
break;
@@ -1491,9 +1488,7 @@ raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
object was originally being written. Note we do write-through
first, so that if it fails, we don't write to the cache contents
that never made it to the target. */
- if (writebuf != NULL
- && inferior_ptid != null_ptid
- && target_dcache_init_p ()
+ if (writebuf != NULL && inferior_ptid != null_ptid && target_dcache_init_p ()
&& (stack_cache_enabled_p () || code_cache_enabled_p ()))
{
DCACHE *dcache = target_dcache_get ();
@@ -1511,8 +1506,8 @@ raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
static enum target_xfer_status
memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
- gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr,
- ULONGEST len, ULONGEST *xfered_len)
+ gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
enum target_xfer_status res;
ULONGEST reg_len;
@@ -1532,14 +1527,13 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
memaddr = overlay_mapped_address (memaddr, section);
- auto match_cb = [=] (const struct target_section *s)
- {
- return (strcmp (section_name, s->the_bfd_section->name) == 0);
- };
+ auto match_cb = [=] (const struct target_section *s) {
+ return (strcmp (section_name, s->the_bfd_section->name) == 0);
+ };
- return section_table_xfer_memory_partial (readbuf, writebuf,
- memaddr, len, xfered_len,
- *table, match_cb);
+ return section_table_xfer_memory_partial (readbuf, writebuf, memaddr,
+ len, xfered_len, *table,
+ match_cb);
}
}
@@ -1552,9 +1546,8 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
&& (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY))
{
const target_section_table *table = target_get_section_table (ops);
- return section_table_xfer_memory_partial (readbuf, writebuf,
- memaddr, len, xfered_len,
- *table);
+ return section_table_xfer_memory_partial (readbuf, writebuf, memaddr,
+ len, xfered_len, *table);
}
}
@@ -1642,8 +1635,8 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object,
gdb::byte_vector buf (writebuf, writebuf + len);
breakpoint_xfer_memory (NULL, buf.data (), writebuf, memaddr, len);
- res = memory_xfer_partial_1 (ops, object, NULL, buf.data (), memaddr, len,
- xfered_len);
+ res = memory_xfer_partial_1 (ops, object, NULL, buf.data (), memaddr,
+ len, xfered_len);
}
return res;
@@ -1658,10 +1651,9 @@ make_scoped_restore_show_memory_breakpoints (int show)
/* For docs see target.h, to_xfer_partial. */
enum target_xfer_status
-target_xfer_partial (struct target_ops *ops,
- enum target_object object, const char *annex,
- gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, ULONGEST len,
+target_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
{
enum target_xfer_status retval;
@@ -1671,7 +1663,7 @@ target_xfer_partial (struct target_ops *ops,
return TARGET_XFER_EOF;
if (writebuf && !may_write_memory)
- error (_("Writing to memory is not allowed (addr %s, len %s)"),
+ error (_ ("Writing to memory is not allowed (addr %s, len %s)"),
core_addr_to_string_nz (offset), plongest (len));
*xfered_len = 0;
@@ -1681,8 +1673,8 @@ target_xfer_partial (struct target_ops *ops,
complicated. */
if (object == TARGET_OBJECT_MEMORY || object == TARGET_OBJECT_STACK_MEMORY
|| object == TARGET_OBJECT_CODE_MEMORY)
- retval = memory_xfer_partial (ops, object, readbuf,
- writebuf, offset, len, xfered_len);
+ retval = memory_xfer_partial (ops, object, readbuf, writebuf, offset, len,
+ xfered_len);
else if (object == TARGET_OBJECT_RAW_MEMORY)
{
/* Skip/avoid accessing the target if the memory region
@@ -1700,8 +1692,8 @@ target_xfer_partial (struct target_ops *ops,
xfered_len);
}
else
- retval = ops->xfer_partial (object, annex, readbuf,
- writebuf, offset, len, xfered_len);
+ retval = ops->xfer_partial (object, annex, readbuf, writebuf, offset, len,
+ xfered_len);
if (targetdebug)
{
@@ -1710,13 +1702,10 @@ target_xfer_partial (struct target_ops *ops,
gdb_printf (gdb_stdlog,
"%s:target_xfer_partial "
"(%d, %s, %s, %s, %s, %s) = %d, %s",
- ops->shortname (),
- (int) object,
- (annex ? annex : "(null)"),
+ ops->shortname (), (int) object, (annex ? annex : "(null)"),
host_address_to_string (readbuf),
host_address_to_string (writebuf),
- core_addr_to_string_nz (offset),
- pulongest (len), retval,
+ core_addr_to_string_nz (offset), pulongest (len), retval,
pulongest (*xfered_len));
if (readbuf)
@@ -1730,7 +1719,7 @@ target_xfer_partial (struct target_ops *ops,
gdb_puts (", bytes =", gdb_stdlog);
for (i = 0; i < *xfered_len; i++)
{
- if ((((intptr_t) &(myaddr[i])) & 0xf) == 0)
+ if ((((intptr_t) & (myaddr[i])) & 0xf) == 0)
{
if (targetdebug < 2 && i > 0)
{
@@ -1770,9 +1759,9 @@ target_xfer_partial (struct target_ops *ops,
int
target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- if (target_read (current_inferior ()->top_target (),
- TARGET_OBJECT_MEMORY, NULL,
- myaddr, memaddr, len) == len)
+ if (target_read (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY,
+ NULL, myaddr, memaddr, len)
+ == len)
return 0;
else
return -1;
@@ -1802,8 +1791,8 @@ int
target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
if (target_read (current_inferior ()->top_target (),
- TARGET_OBJECT_RAW_MEMORY, NULL,
- myaddr, memaddr, len) == len)
+ TARGET_OBJECT_RAW_MEMORY, NULL, myaddr, memaddr, len)
+ == len)
return 0;
else
return -1;
@@ -1816,8 +1805,8 @@ int
target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
if (target_read (current_inferior ()->top_target (),
- TARGET_OBJECT_STACK_MEMORY, NULL,
- myaddr, memaddr, len) == len)
+ TARGET_OBJECT_STACK_MEMORY, NULL, myaddr, memaddr, len)
+ == len)
return 0;
else
return -1;
@@ -1830,8 +1819,8 @@ int
target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
if (target_read (current_inferior ()->top_target (),
- TARGET_OBJECT_CODE_MEMORY, NULL,
- myaddr, memaddr, len) == len)
+ TARGET_OBJECT_CODE_MEMORY, NULL, myaddr, memaddr, len)
+ == len)
return 0;
else
return -1;
@@ -1846,9 +1835,9 @@ target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
int
target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
{
- if (target_write (current_inferior ()->top_target (),
- TARGET_OBJECT_MEMORY, NULL,
- myaddr, memaddr, len) == len)
+ if (target_write (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY,
+ NULL, myaddr, memaddr, len)
+ == len)
return 0;
else
return -1;
@@ -1861,11 +1850,12 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
target_write. */
int
-target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
+target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
+ ssize_t len)
{
if (target_write (current_inferior ()->top_target (),
- TARGET_OBJECT_RAW_MEMORY, NULL,
- myaddr, memaddr, len) == len)
+ TARGET_OBJECT_RAW_MEMORY, NULL, myaddr, memaddr, len)
+ == len)
return 0;
else
return -1;
@@ -1894,7 +1884,7 @@ target_memory_map (void)
if (last_one != NULL && last_one->hi > this_one->lo)
{
- warning (_("Overlapping regions in memory map: ignoring"));
+ warning (_ ("Overlapping regions in memory map: ignoring"));
return std::vector<mem_region> ();
}
@@ -1920,29 +1910,25 @@ static void
show_trust_readonly (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file,
- _("Mode for reading from readonly sections is %s.\n"),
+ gdb_printf (file, _ ("Mode for reading from readonly sections is %s.\n"),
value);
}
/* Target vector read/write partial wrapper functions. */
static enum target_xfer_status
-target_read_partial (struct target_ops *ops,
- enum target_object object,
- const char *annex, gdb_byte *buf,
- ULONGEST offset, ULONGEST len,
- ULONGEST *xfered_len)
+target_read_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *buf, ULONGEST offset,
+ ULONGEST len, ULONGEST *xfered_len)
{
return target_xfer_partial (ops, object, annex, buf, NULL, offset, len,
xfered_len);
}
static enum target_xfer_status
-target_write_partial (struct target_ops *ops,
- enum target_object object,
- const char *annex, const gdb_byte *buf,
- ULONGEST offset, LONGEST len, ULONGEST *xfered_len)
+target_write_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, const gdb_byte *buf, ULONGEST offset,
+ LONGEST len, ULONGEST *xfered_len)
{
return target_xfer_partial (ops, object, annex, NULL, buf, offset, len,
xfered_len);
@@ -1953,18 +1939,15 @@ target_write_partial (struct target_ops *ops,
/* For docs on target_read see target.h. */
LONGEST
-target_read (struct target_ops *ops,
- enum target_object object,
- const char *annex, gdb_byte *buf,
- ULONGEST offset, LONGEST len)
+target_read (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *buf, ULONGEST offset, LONGEST len)
{
LONGEST xfered_total = 0;
int unit_size = 1;
/* If we are reading from a memory object, find the length of an addressable
unit for that architecture. */
- if (object == TARGET_OBJECT_MEMORY
- || object == TARGET_OBJECT_STACK_MEMORY
+ if (object == TARGET_OBJECT_MEMORY || object == TARGET_OBJECT_STACK_MEMORY
|| object == TARGET_OBJECT_CODE_MEMORY
|| object == TARGET_OBJECT_RAW_MEMORY)
unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ());
@@ -1989,7 +1972,6 @@ target_read (struct target_ops *ops,
}
else
return TARGET_XFER_E_IO;
-
}
return len;
}
@@ -2016,9 +1998,8 @@ target_read (struct target_ops *ops,
take care of reading multiple ranges then. */
static void
-read_whatever_is_readable (struct target_ops *ops,
- const ULONGEST begin, const ULONGEST end,
- int unit_size,
+read_whatever_is_readable (struct target_ops *ops, const ULONGEST begin,
+ const ULONGEST end, int unit_size,
std::vector<memory_read_result> *result)
{
ULONGEST current_begin = begin;
@@ -2035,15 +2016,17 @@ read_whatever_is_readable (struct target_ops *ops,
/* Check that either first or the last byte is readable, and give up
if not. This heuristic is meant to permit reading accessible memory
at the boundary of accessible region. */
- if (target_read_partial (ops, TARGET_OBJECT_MEMORY, NULL,
- buf.get (), begin, 1, &xfered_len) == TARGET_XFER_OK)
+ if (target_read_partial (ops, TARGET_OBJECT_MEMORY, NULL, buf.get (), begin,
+ 1, &xfered_len)
+ == TARGET_XFER_OK)
{
forward = 1;
++current_begin;
}
else if (target_read_partial (ops, TARGET_OBJECT_MEMORY, NULL,
buf.get () + (end - begin) - 1, end - 1, 1,
- &xfered_len) == TARGET_XFER_OK)
+ &xfered_len)
+ == TARGET_XFER_OK)
{
forward = 0;
--current_end;
@@ -2080,8 +2063,7 @@ read_whatever_is_readable (struct target_ops *ops,
xfer = target_read (ops, TARGET_OBJECT_MEMORY, NULL,
buf.get () + (first_half_begin - begin) * unit_size,
- first_half_begin,
- first_half_end - first_half_begin);
+ first_half_begin, first_half_end - first_half_begin);
if (xfer == first_half_end - first_half_begin)
{
@@ -2113,8 +2095,8 @@ read_whatever_is_readable (struct target_ops *ops,
/* The [current_end, end) range has been read. */
LONGEST region_len = end - current_end;
- gdb::unique_xmalloc_ptr<gdb_byte> data
- ((gdb_byte *) xmalloc (region_len * unit_size));
+ gdb::unique_xmalloc_ptr<gdb_byte> data (
+ (gdb_byte *) xmalloc (region_len * unit_size));
memcpy (data.get (), buf.get () + (current_end - begin) * unit_size,
region_len * unit_size);
result->emplace_back (current_end, end, std::move (data));
@@ -2122,8 +2104,8 @@ read_whatever_is_readable (struct target_ops *ops,
}
std::vector<memory_read_result>
-read_memory_robust (struct target_ops *ops,
- const ULONGEST offset, const LONGEST len)
+read_memory_robust (struct target_ops *ops, const ULONGEST offset,
+ const LONGEST len)
{
std::vector<memory_read_result> result;
int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ());
@@ -2152,11 +2134,11 @@ read_memory_robust (struct target_ops *ops,
else
{
LONGEST to_read = std::min (len - xfered_total, region_len);
- gdb::unique_xmalloc_ptr<gdb_byte> buffer
- ((gdb_byte *) xmalloc (to_read * unit_size));
+ gdb::unique_xmalloc_ptr<gdb_byte> buffer (
+ (gdb_byte *) xmalloc (to_read * unit_size));
- LONGEST xfered_partial =
- target_read (ops, TARGET_OBJECT_MEMORY, NULL, buffer.get (),
+ LONGEST xfered_partial
+ = target_read (ops, TARGET_OBJECT_MEMORY, NULL, buffer.get (),
offset + xfered_total, to_read);
/* Call an observer, notifying them of the xfer progress? */
if (xfered_partial <= 0)
@@ -2182,12 +2164,10 @@ read_memory_robust (struct target_ops *ops,
return result;
}
-
/* An alternative to target_write with progress callbacks. */
LONGEST
-target_write_with_progress (struct target_ops *ops,
- enum target_object object,
+target_write_with_progress (struct target_ops *ops, enum target_object object,
const char *annex, const gdb_byte *buf,
ULONGEST offset, LONGEST len,
void (*progress) (ULONGEST, void *), void *baton)
@@ -2197,8 +2177,7 @@ target_write_with_progress (struct target_ops *ops,
/* If we are writing to a memory object, find the length of an addressable
unit for that architecture. */
- if (object == TARGET_OBJECT_MEMORY
- || object == TARGET_OBJECT_STACK_MEMORY
+ if (object == TARGET_OBJECT_MEMORY || object == TARGET_OBJECT_STACK_MEMORY
|| object == TARGET_OBJECT_CODE_MEMORY
|| object == TARGET_OBJECT_RAW_MEMORY)
unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ());
@@ -2232,10 +2211,9 @@ target_write_with_progress (struct target_ops *ops,
/* For docs on target_write see target.h. */
LONGEST
-target_write (struct target_ops *ops,
- enum target_object object,
- const char *annex, const gdb_byte *buf,
- ULONGEST offset, LONGEST len)
+target_write (struct target_ops *ops, enum target_object object,
+ const char *annex, const gdb_byte *buf, ULONGEST offset,
+ LONGEST len)
{
return target_write_with_progress (ops, object, annex, buf, offset, len,
NULL, NULL);
@@ -2244,7 +2222,7 @@ target_write (struct target_ops *ops,
/* Help for target_read_alloc and target_read_stralloc. See their comments
for details. */
-template <typename T>
+template<typename T>
gdb::optional<gdb::def_vector<T>>
target_read_alloc_1 (struct target_ops *ops, enum target_object object,
const char *annex)
@@ -2269,10 +2247,9 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object,
buf.resize (buf_pos + chunk);
- status = target_read_partial (ops, object, annex,
- (gdb_byte *) &buf[buf_pos],
- buf_pos, chunk,
- &xfered_len);
+ status
+ = target_read_partial (ops, object, annex, (gdb_byte *) &buf[buf_pos],
+ buf_pos, chunk, &xfered_len);
if (status == TARGET_XFER_EOF)
{
@@ -2321,8 +2298,8 @@ target_read_stralloc (struct target_ops *ops, enum target_object object,
it != buf->end (); it++)
if (*it != '\0')
{
- warning (_("target object %d, annex %s, "
- "contained unexpected null characters"),
+ warning (_ ("target object %d, annex %s, "
+ "contained unexpected null characters"),
(int) object, annex ? annex : "(none)");
break;
}
@@ -2340,14 +2317,13 @@ get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf,
target. This read must bypass the overlay support (as symbols
don't match this target), and GDB's internal cache (wrong cache
for this target). */
- if (target_read (ops, TARGET_OBJECT_RAW_MEMORY, NULL, buf, addr, len)
- != len)
+ if (target_read (ops, TARGET_OBJECT_RAW_MEMORY, NULL, buf, addr, len) != len)
memory_error (TARGET_XFER_E_IO, addr);
}
ULONGEST
-get_target_memory_unsigned (struct target_ops *ops, CORE_ADDR addr,
- int len, enum bfd_endian byte_order)
+get_target_memory_unsigned (struct target_ops *ops, CORE_ADDR addr, int len,
+ enum bfd_endian byte_order)
{
gdb_byte buf[sizeof (ULONGEST)];
@@ -2364,7 +2340,7 @@ target_insert_breakpoint (struct gdbarch *gdbarch,
{
if (!may_insert_breakpoints)
{
- warning (_("May not insert breakpoints"));
+ warning (_ ("May not insert breakpoints"));
return 1;
}
@@ -2386,7 +2362,7 @@ target_remove_breakpoint (struct gdbarch *gdbarch,
breakpoints should be left in place. */
if (!may_insert_breakpoints)
{
- warning (_("May not remove breakpoints"));
+ warning (_ ("May not remove breakpoints"));
return 1;
}
@@ -2403,12 +2379,10 @@ info_target_command (const char *args, int from_tty)
if (current_program_space->symfile_object_file != NULL)
{
objfile *objf = current_program_space->symfile_object_file;
- gdb_printf (_("Symbols from \"%s\".\n"),
- objfile_name (objf));
+ gdb_printf (_ ("Symbols from \"%s\".\n"), objfile_name (objf));
}
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
{
if (!t->has_memory ())
@@ -2417,8 +2391,8 @@ info_target_command (const char *args, int from_tty)
if ((int) (t->stratum ()) <= (int) dummy_stratum)
continue;
if (has_all_mem)
- gdb_printf (_("\tWhile running this, "
- "GDB does not access memory from...\n"));
+ gdb_printf (_ ("\tWhile running this, "
+ "GDB does not access memory from...\n"));
gdb_printf ("%s:\n", t->longname ());
t->files_info ();
has_all_mem = t->has_all_memory ();
@@ -2482,9 +2456,8 @@ target_preopen (int from_tty)
if (current_inferior ()->pid != 0)
{
- if (!from_tty
- || !target_has_execution ()
- || query (_("A program is being debugged already. Kill it? ")))
+ if (!from_tty || !target_has_execution ()
+ || query (_ ("A program is being debugged already. Kill it? ")))
{
/* Core inferiors actually should be detached, not
killed. */
@@ -2494,7 +2467,7 @@ target_preopen (int from_tty)
target_detach (current_inferior (), 0);
}
else
- error (_("Program not killed."));
+ error (_ ("Program not killed."));
}
/* Calling target_kill may remove the target from the stack. But if
@@ -2532,7 +2505,8 @@ target_detach (inferior *inf, int from_tty)
/* Hold a strong reference because detaching may unpush the
target. */
- auto proc_target_ref = target_ops_ref::new_reference (inf->process_target ());
+ auto proc_target_ref
+ = target_ops_ref::new_reference (inf->process_target ());
current_inferior ()->top_target ()->detach (inf, from_tty);
@@ -2592,8 +2566,8 @@ target_wait (ptid_t ptid, struct target_waitstatus *status,
/* See target.h. */
ptid_t
-default_target_wait (struct target_ops *ops,
- ptid_t ptid, struct target_waitstatus *status,
+default_target_wait (struct target_ops *ops, ptid_t ptid,
+ struct target_waitstatus *status,
target_wait_flags options)
{
status->set_ignore ();
@@ -2616,8 +2590,7 @@ target_thread_name (struct thread_info *info)
struct thread_info *
target_thread_handle_to_thread_info (const gdb_byte *thread_handle,
- int handle_len,
- struct inferior *inf)
+ int handle_len, struct inferior *inf)
{
target_ops *target = current_inferior ()->top_target ();
@@ -2693,7 +2666,7 @@ default_follow_fork (struct target_ops *self, inferior *child_inf,
bool follow_child, bool detach_fork)
{
/* Some target returned a fork event, but did not know how to follow it. */
- internal_error (_("could not find a target to follow fork"));
+ internal_error (_ ("could not find a target to follow fork"));
}
/* See target.h. */
@@ -2732,7 +2705,7 @@ target_follow_exec (inferior *follow_inf, ptid_t ptid,
static void
default_mourn_inferior (struct target_ops *self)
{
- internal_error (_("could not find a target to follow mourn inferior"));
+ internal_error (_ ("could not find a target to follow mourn inferior"));
}
void
@@ -2756,21 +2729,18 @@ target_read_description (struct target_ops *target)
return target->read_description ();
}
-
/* Default implementation of memory-searching. */
static int
-default_search_memory (struct target_ops *self,
- CORE_ADDR start_addr, ULONGEST search_space_len,
- const gdb_byte *pattern, ULONGEST pattern_len,
- CORE_ADDR *found_addrp)
+default_search_memory (struct target_ops *self, CORE_ADDR start_addr,
+ ULONGEST search_space_len, const gdb_byte *pattern,
+ ULONGEST pattern_len, CORE_ADDR *found_addrp)
{
- auto read_memory = [=] (CORE_ADDR addr, gdb_byte *result, size_t len)
- {
- return target_read (current_inferior ()->top_target (),
- TARGET_OBJECT_MEMORY, NULL,
- result, addr, len) == len;
- };
+ auto read_memory = [=] (CORE_ADDR addr, gdb_byte *result, size_t len) {
+ return target_read (current_inferior ()->top_target (),
+ TARGET_OBJECT_MEMORY, NULL, result, addr, len)
+ == len;
+ };
/* Start over from the top of the target stack. */
return simple_search_memory (read_memory, start_addr, search_space_len,
@@ -2802,8 +2772,7 @@ target_search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
void
target_require_runnable (void)
{
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
{
/* If this target knows how to create a new program, then
@@ -2819,15 +2788,15 @@ target_require_runnable (void)
if (t->stratum () > process_stratum)
continue;
- error (_("The \"%s\" target does not support \"run\". "
- "Try \"help target\" or \"continue\"."),
+ error (_ ("The \"%s\" target does not support \"run\". "
+ "Try \"help target\" or \"continue\"."),
t->shortname ());
}
/* This function is only called if the target is running. In that
case there should have been a process_stratum target and it
should either know how to create inferiors, or not... */
- internal_error (_("No targets found"));
+ internal_error (_ ("No targets found"));
}
/* Whether GDB is allowed to fall back to the default run target for
@@ -2839,8 +2808,8 @@ show_auto_connect_native_target (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
gdb_printf (file,
- _("Whether GDB may automatically connect to the "
- "native target is %s.\n"),
+ _ ("Whether GDB may automatically connect to the "
+ "native target is %s.\n"),
value);
}
@@ -2855,7 +2824,7 @@ void
set_native_target (target_ops *target)
{
if (the_native_target != NULL)
- internal_error (_("native target already set (\"%s\")."),
+ internal_error (_ ("native target already set (\"%s\")."),
the_native_target->longname ());
the_native_target = target;
@@ -2883,7 +2852,7 @@ find_default_run_target (const char *do_mesg)
return the_native_target;
if (do_mesg != NULL)
- error (_("Don't know how to %s. Try \"help target\"."), do_mesg);
+ error (_ ("Don't know how to %s. Try \"help target\"."), do_mesg);
return NULL;
}
@@ -2893,8 +2862,7 @@ struct target_ops *
find_attach_target (void)
{
/* If a target on the current stack can attach, use it. */
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
{
if (t->can_attach ())
@@ -2911,8 +2879,7 @@ struct target_ops *
find_run_target (void)
{
/* If a target on the current stack can run, use it. */
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
{
if (t->can_create_inferior ())
@@ -2948,8 +2915,8 @@ target_info_proc (const char *args, enum info_proc_what what)
if (t->info_proc (args, what))
{
if (targetdebug)
- gdb_printf (gdb_stdlog,
- "target_info_proc (\"%s\", %d)\n", args, what);
+ gdb_printf (gdb_stdlog, "target_info_proc (\"%s\", %d)\n", args,
+ what);
return 1;
}
@@ -3048,8 +3015,7 @@ target_ops::can_create_inferior ()
}
void
-target_ops::create_inferior (const char *, const std::string &,
- char **, int)
+target_ops::create_inferior (const char *, const std::string &, char **, int)
{
gdb_assert_not_reached ("target_ops::create_inferior called");
}
@@ -3063,8 +3029,7 @@ target_ops::can_run ()
int
target_can_run ()
{
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
{
if (t->can_run ())
@@ -3101,10 +3066,7 @@ struct fileio_fh_t
int target_fd;
/* Check whether this fileio_fh_t represents a closed file. */
- bool is_closed ()
- {
- return target_fd < 0;
- }
+ bool is_closed () { return target_fd < 0; }
};
/* Vector of currently open file handles. The value returned by
@@ -3145,9 +3107,9 @@ acquire_fileio_fd (target_ops *target, int target_fd)
/* Push a new handle if no closed handles were found. */
if (lowest_closed_fd == fileio_fhandles.size ())
- fileio_fhandles.push_back (fileio_fh_t {target, target_fd});
+ fileio_fhandles.push_back (fileio_fh_t { target, target_fd });
else
- fileio_fhandles[lowest_closed_fd] = {target, target_fd};
+ fileio_fhandles[lowest_closed_fd] = { target, target_fd };
/* Should no longer be marked closed. */
gdb_assert (!fileio_fhandles[lowest_closed_fd].is_closed ());
@@ -3174,15 +3136,14 @@ fileio_fd_to_fh (int fd)
return &fileio_fhandles[fd];
}
-
/* Default implementations of file i/o methods. We don't want these
to delegate automatically, because we need to know which target
supported the method, in order to call it directly from within
pread/pwrite, etc. */
int
-target_ops::fileio_open (struct inferior *inf, const char *filename,
- int flags, int mode, int warn_if_slow,
+target_ops::fileio_open (struct inferior *inf, const char *filename, int flags,
+ int mode, int warn_if_slow,
fileio_error *target_errno)
{
*target_errno = FILEIO_ENOSYS;
@@ -3198,8 +3159,8 @@ target_ops::fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
}
int
-target_ops::fileio_pread (int fd, gdb_byte *read_buf, int len,
- ULONGEST offset, fileio_error *target_errno)
+target_ops::fileio_pread (int fd, gdb_byte *read_buf, int len, ULONGEST offset,
+ fileio_error *target_errno)
{
*target_errno = FILEIO_ENOSYS;
return -1;
@@ -3238,13 +3199,13 @@ target_ops::fileio_readlink (struct inferior *inf, const char *filename,
/* See target.h. */
int
-target_fileio_open (struct inferior *inf, const char *filename,
- int flags, int mode, bool warn_if_slow, fileio_error *target_errno)
+target_fileio_open (struct inferior *inf, const char *filename, int flags,
+ int mode, bool warn_if_slow, fileio_error *target_errno)
{
for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ())
{
- int fd = t->fileio_open (inf, filename, flags, mode,
- warn_if_slow, target_errno);
+ int fd = t->fileio_open (inf, filename, flags, mode, warn_if_slow,
+ target_errno);
if (fd == -1 && *target_errno == FILEIO_ENOSYS)
continue;
@@ -3258,10 +3219,8 @@ target_fileio_open (struct inferior *inf, const char *filename,
gdb_printf (gdb_stdlog,
"target_fileio_open (%d,%s,0x%x,0%o,%d)"
" = %d (%d)\n",
- inf == NULL ? 0 : inf->num,
- filename, flags, mode,
- warn_if_slow, fd,
- fd != -1 ? 0 : *target_errno);
+ inf == NULL ? 0 : inf->num, filename, flags, mode,
+ warn_if_slow, fd, fd != -1 ? 0 : *target_errno);
return fd;
}
@@ -3283,23 +3242,23 @@ target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
else if (fh->target == NULL)
*target_errno = FILEIO_EIO;
else
- ret = fh->target->fileio_pwrite (fh->target_fd, write_buf,
- len, offset, target_errno);
+ ret = fh->target->fileio_pwrite (fh->target_fd, write_buf, len, offset,
+ target_errno);
if (targetdebug)
gdb_printf (gdb_stdlog,
"target_fileio_pwrite (%d,...,%d,%s) "
"= %d (%d)\n",
- fd, len, pulongest (offset),
- ret, ret != -1 ? 0 : *target_errno);
+ fd, len, pulongest (offset), ret,
+ ret != -1 ? 0 : *target_errno);
return ret;
}
/* See target.h. */
int
-target_fileio_pread (int fd, gdb_byte *read_buf, int len,
- ULONGEST offset, fileio_error *target_errno)
+target_fileio_pread (int fd, gdb_byte *read_buf, int len, ULONGEST offset,
+ fileio_error *target_errno)
{
fileio_fh_t *fh = fileio_fd_to_fh (fd);
int ret = -1;
@@ -3309,15 +3268,15 @@ target_fileio_pread (int fd, gdb_byte *read_buf, int len,
else if (fh->target == NULL)
*target_errno = FILEIO_EIO;
else
- ret = fh->target->fileio_pread (fh->target_fd, read_buf,
- len, offset, target_errno);
+ ret = fh->target->fileio_pread (fh->target_fd, read_buf, len, offset,
+ target_errno);
if (targetdebug)
gdb_printf (gdb_stdlog,
"target_fileio_pread (%d,...,%d,%s) "
"= %d (%d)\n",
- fd, len, pulongest (offset),
- ret, ret != -1 ? 0 : *target_errno);
+ fd, len, pulongest (offset), ret,
+ ret != -1 ? 0 : *target_errno);
return ret;
}
@@ -3337,9 +3296,8 @@ target_fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
ret = fh->target->fileio_fstat (fh->target_fd, sb, target_errno);
if (targetdebug)
- gdb_printf (gdb_stdlog,
- "target_fileio_fstat (%d) = %d (%d)\n",
- fd, ret, ret != -1 ? 0 : *target_errno);
+ gdb_printf (gdb_stdlog, "target_fileio_fstat (%d) = %d (%d)\n", fd, ret,
+ ret != -1 ? 0 : *target_errno);
return ret;
}
@@ -3356,17 +3314,15 @@ target_fileio_close (int fd, fileio_error *target_errno)
else
{
if (fh->target != NULL)
- ret = fh->target->fileio_close (fh->target_fd,
- target_errno);
+ ret = fh->target->fileio_close (fh->target_fd, target_errno);
else
ret = 0;
release_fileio_fd (fd, fh);
}
if (targetdebug)
- gdb_printf (gdb_stdlog,
- "target_fileio_close (%d) = %d (%d)\n",
- fd, ret, ret != -1 ? 0 : *target_errno);
+ gdb_printf (gdb_stdlog, "target_fileio_close (%d) = %d (%d)\n", fd, ret,
+ ret != -1 ? 0 : *target_errno);
return ret;
}
@@ -3387,8 +3343,8 @@ target_fileio_unlink (struct inferior *inf, const char *filename,
gdb_printf (gdb_stdlog,
"target_fileio_unlink (%d,%s)"
" = %d (%d)\n",
- inf == NULL ? 0 : inf->num, filename,
- ret, ret != -1 ? 0 : *target_errno);
+ inf == NULL ? 0 : inf->num, filename, ret,
+ ret != -1 ? 0 : *target_errno);
return ret;
}
@@ -3414,9 +3370,8 @@ target_fileio_readlink (struct inferior *inf, const char *filename,
gdb_printf (gdb_stdlog,
"target_fileio_readlink (%d,%s)"
" = %s (%d)\n",
- inf == NULL ? 0 : inf->num,
- filename, ret ? ret->c_str () : "(nil)",
- ret ? 0 : *target_errno);
+ inf == NULL ? 0 : inf->num, filename,
+ ret ? ret->c_str () : "(nil)", ret ? 0 : *target_errno);
return ret;
}
@@ -3429,6 +3384,7 @@ target_fileio_readlink (struct inferior *inf, const char *filename,
class scoped_target_fd
{
public:
+
explicit scoped_target_fd (int fd) noexcept
: m_fd (fd)
{
@@ -3446,12 +3402,10 @@ public:
DISABLE_COPY_AND_ASSIGN (scoped_target_fd);
- int get () const noexcept
- {
- return m_fd;
- }
+ int get () const noexcept { return m_fd; }
private:
+
int m_fd;
};
@@ -3527,7 +3481,7 @@ target_fileio_read_alloc (struct inferior *inf, const char *filename,
/* See target.h. */
-gdb::unique_xmalloc_ptr<char>
+gdb::unique_xmalloc_ptr<char>
target_fileio_read_stralloc (struct inferior *inf, const char *filename)
{
gdb_byte *buffer;
@@ -3549,8 +3503,8 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename)
for (i = strlen (bufstr); i < transferred; i++)
if (bufstr[i] != 0)
{
- warning (_("target file %s "
- "contained unexpected null characters"),
+ warning (_ ("target file %s "
+ "contained unexpected null characters"),
filename);
break;
}
@@ -3558,18 +3512,17 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename)
return gdb::unique_xmalloc_ptr<char> (bufstr);
}
-
static int
-default_region_ok_for_hw_watchpoint (struct target_ops *self,
- CORE_ADDR addr, int len)
+default_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR addr,
+ int len)
{
return (len <= gdbarch_ptr_bit (target_gdbarch ()) / TARGET_CHAR_BIT);
}
static int
default_watchpoint_addr_within_range (struct target_ops *target,
- CORE_ADDR addr,
- CORE_ADDR start, int length)
+ CORE_ADDR addr, CORE_ADDR start,
+ int length)
{
return addr >= start && addr < start + length;
}
@@ -3595,8 +3548,6 @@ find_target_at (enum strata stratum)
return current_inferior ()->target_at (stratum);
}
-
-
/* See target.h */
void
@@ -3614,7 +3565,7 @@ target_announce_detach (int from_tty)
gdb_printf ("Detaching from pid %s\n",
target_pid_to_str (ptid_t (pid)).c_str ());
else
- gdb_printf (_("Detaching from program: %s, %s\n"), exec_file,
+ gdb_printf (_ ("Detaching from program: %s, %s\n"), exec_file,
target_pid_to_str (ptid_t (pid)).c_str ());
}
@@ -3666,7 +3617,7 @@ generic_mourn_inferior (void)
if (deprecated_detach_hook)
deprecated_detach_hook ();
}
-
+
/* Convert a normal process ID to a string. Returns the string in a
static buffer. */
@@ -3687,16 +3638,15 @@ static int
dummy_find_memory_regions (struct target_ops *self,
find_memory_region_ftype ignore1, void *ignore2)
{
- error (_("Command not implemented for this target."));
+ error (_ ("Command not implemented for this target."));
return 0;
}
/* Error-catcher for target_make_corefile_notes. */
static gdb::unique_xmalloc_ptr<char>
-dummy_make_corefile_notes (struct target_ops *self,
- bfd *ignore1, int *ignore2)
+dummy_make_corefile_notes (struct target_ops *self, bfd *ignore1, int *ignore2)
{
- error (_("Command not implemented for this target."));
+ error (_ ("Command not implemented for this target."));
return NULL;
}
@@ -3715,11 +3665,7 @@ get_dummy_target ()
return &the_dummy_target;
}
-static const target_info dummy_target_info = {
- "None",
- N_("None"),
- ""
-};
+static const target_info dummy_target_info = { "None", N_ ("None"), "" };
strata
dummy_target::stratum () const
@@ -3745,8 +3691,6 @@ debug_target::info () const
return beneath ()->info ();
}
-
-
void
target_close (struct target_ops *targ)
{
@@ -3782,7 +3726,7 @@ target_stop (ptid_t ptid)
if (!may_stop)
{
- warning (_("May not interrupt or stop the target, ignoring attempt"));
+ warning (_ ("May not interrupt or stop the target, ignoring attempt"));
return;
}
@@ -3794,7 +3738,7 @@ target_interrupt ()
{
if (!may_stop)
{
- warning (_("May not interrupt or stop the target, ignoring attempt"));
+ warning (_ ("May not interrupt or stop the target, ignoring attempt"));
return;
}
@@ -3908,8 +3852,7 @@ target_options_to_string (target_wait_flags target_options)
{
std::string ret;
-#define DO_TARG_OPTION(OPT) \
- do_option (&target_options, &ret, OPT, #OPT)
+#define DO_TARG_OPTION(OPT) do_option (&target_options, &ret, OPT, #OPT)
DO_TARG_OPTION (TARGET_WNOHANG);
@@ -3931,7 +3874,7 @@ void
target_store_registers (struct regcache *regcache, int regno)
{
if (!may_write_registers)
- error (_("Writing to registers is not allowed (regno %d)"), regno);
+ error (_ ("Writing to registers is not allowed (regno %d)"), regno);
current_inferior ()->top_target ()->store_registers (regcache, regno);
if (targetdebug)
@@ -3947,8 +3890,8 @@ target_core_of_thread (ptid_t ptid)
}
int
-simple_verify_memory (struct target_ops *ops,
- const gdb_byte *data, CORE_ADDR lma, ULONGEST size)
+simple_verify_memory (struct target_ops *ops, const gdb_byte *data,
+ CORE_ADDR lma, ULONGEST size)
{
LONGEST total_xfered = 0;
@@ -3957,11 +3900,11 @@ simple_verify_memory (struct target_ops *ops,
ULONGEST xfered_len;
enum target_xfer_status status;
gdb_byte buf[1024];
- ULONGEST howmuch = std::min<ULONGEST> (sizeof (buf), size - total_xfered);
+ ULONGEST howmuch
+ = std::min<ULONGEST> (sizeof (buf), size - total_xfered);
- status = target_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL,
- buf, NULL, lma + total_xfered, howmuch,
- &xfered_len);
+ status = target_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL, buf, NULL,
+ lma + total_xfered, howmuch, &xfered_len);
if (status == TARGET_XFER_OK
&& memcmp (data + total_xfered, buf, xfered_len) == 0)
{
@@ -3977,12 +3920,12 @@ simple_verify_memory (struct target_ops *ops,
/* Default implementation of memory verification. */
static int
-default_verify_memory (struct target_ops *self,
- const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
+default_verify_memory (struct target_ops *self, const gdb_byte *data,
+ CORE_ADDR memaddr, ULONGEST size)
{
/* Start over from the top of the target stack. */
- return simple_verify_memory (current_inferior ()->top_target (),
- data, memaddr, size);
+ return simple_verify_memory (current_inferior ()->top_target (), data,
+ memaddr, size);
}
int
@@ -4180,8 +4123,7 @@ target_insn_history (int size, gdb_disassembly_flags flags)
/* See target.h. */
void
-target_insn_history_from (ULONGEST from, int size,
- gdb_disassembly_flags flags)
+target_insn_history_from (ULONGEST from, int size, gdb_disassembly_flags flags)
{
current_inferior ()->top_target ()->insn_history_from (from, size, flags);
}
@@ -4214,7 +4156,8 @@ target_call_history_from (ULONGEST begin, int size, record_print_flags flags)
/* See target.h. */
void
-target_call_history_range (ULONGEST begin, ULONGEST end, record_print_flags flags)
+target_call_history_range (ULONGEST begin, ULONGEST end,
+ record_print_flags flags)
{
current_inferior ()->top_target ()->call_history_range (begin, end, flags);
}
@@ -4251,10 +4194,8 @@ target_done_generating_core (void)
current_inferior ()->top_target ()->done_generating_core ();
}
-
-
-static char targ_desc[] =
-"Names of targets and files being debugged.\nShows the entire \
+static char targ_desc[]
+ = "Names of targets and files being debugged.\nShows the entire \
stack of targets currently in use (including the exec-file,\n\
core-file, and process, if any), as well as the symbol file name.";
@@ -4262,7 +4203,7 @@ static void
default_rcmd (struct target_ops *self, const char *command,
struct ui_file *output)
{
- error (_("\"monitor\" command not supported by this target."));
+ error (_ ("\"monitor\" command not supported by this target."));
}
static void
@@ -4294,7 +4235,8 @@ flash_erase_command (const char *cmd, int from_tty)
ui_out_emit_tuple tuple_emitter (current_uiout, "erased-regions");
- current_uiout->message (_("Erasing flash memory region at address "));
+ current_uiout->message (
+ _ ("Erasing flash memory region at address "));
current_uiout->field_core_addr ("address", gdbarch, m.lo);
current_uiout->message (", size = ");
current_uiout->field_string ("size", hex_string (m.hi - m.lo));
@@ -4306,7 +4248,7 @@ flash_erase_command (const char *cmd, int from_tty)
if (found_flash_region)
target_flash_done ();
else
- current_uiout->message (_("No flash memory regions found.\n"));
+ current_uiout->message (_ ("No flash memory regions found.\n"));
}
/* Print the name of each layers of our target stack. */
@@ -4314,10 +4256,9 @@ flash_erase_command (const char *cmd, int from_tty)
static void
maintenance_print_target_stack (const char *cmd, int from_tty)
{
- gdb_printf (_("The current target stack is:\n"));
+ gdb_printf (_ ("The current target stack is:\n"));
- for (target_ops *t = current_inferior ()->top_target ();
- t != NULL;
+ for (target_ops *t = current_inferior ()->top_target (); t != NULL;
t = t->beneath ())
{
if (t->stratum () == debug_stratum)
@@ -4354,7 +4295,7 @@ static void
set_maint_target_async (bool permitted)
{
if (have_live_inferiors ())
- error (_("Cannot change this setting while the inferior is running."));
+ error (_ ("Cannot change this setting while the inferior is running."));
target_async_permitted = permitted;
}
@@ -4366,12 +4307,13 @@ get_maint_target_async ()
}
static void
-show_maint_target_async (ui_file *file, int from_tty,
- cmd_list_element *c, const char *value)
+show_maint_target_async (ui_file *file, int from_tty, cmd_list_element *c,
+ const char *value)
{
gdb_printf (file,
- _("Controlling the inferior in "
- "asynchronous mode is %s.\n"), value);
+ _ ("Controlling the inferior in "
+ "asynchronous mode is %s.\n"),
+ value);
}
/* Return true if the target operates in non-stop mode even with "set
@@ -4388,8 +4330,7 @@ target_always_non_stop_p (void)
bool
target_is_non_stop_p ()
{
- return ((non_stop
- || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
+ return ((non_stop || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
|| (target_non_stop_enabled == AUTO_BOOLEAN_AUTO
&& target_always_non_stop_p ()))
&& target_can_async_p ());
@@ -4425,7 +4366,7 @@ static void
set_maint_target_non_stop (auto_boolean enabled)
{
if (have_live_inferiors ())
- error (_("Cannot change this setting while the inferior is running."));
+ error (_ ("Cannot change this setting while the inferior is running."));
target_non_stop_enabled = enabled;
}
@@ -4439,18 +4380,19 @@ get_maint_target_non_stop ()
}
static void
-show_maint_target_non_stop (ui_file *file, int from_tty,
- cmd_list_element *c, const char *value)
+show_maint_target_non_stop (ui_file *file, int from_tty, cmd_list_element *c,
+ const char *value)
{
if (target_non_stop_enabled == AUTO_BOOLEAN_AUTO)
gdb_printf (file,
- _("Whether the target is always in non-stop mode "
- "is %s (currently %s).\n"), value,
- target_always_non_stop_p () ? "on" : "off");
+ _ ("Whether the target is always in non-stop mode "
+ "is %s (currently %s).\n"),
+ value, target_always_non_stop_p () ? "on" : "off");
else
gdb_printf (file,
- _("Whether the target is always in non-stop mode "
- "is %s.\n"), value);
+ _ ("Whether the target is always in non-stop mode "
+ "is %s.\n"),
+ value);
}
/* Temporary copies of permission settings. */
@@ -4485,7 +4427,7 @@ set_target_permissions (const char *args, int from_tty,
if (target_has_execution ())
{
update_target_permissions ();
- error (_("Cannot change this setting while the inferior is running."));
+ error (_ ("Cannot change this setting while the inferior is running."));
}
/* Make the real values match the user-changed values. */
@@ -4501,7 +4443,7 @@ set_target_permissions (const char *args, int from_tty,
static void
set_write_memory_permission (const char *args, int from_tty,
- struct cmd_list_element *c)
+ struct cmd_list_element *c)
{
/* Make the real values match the user-changed values. */
may_write_memory = may_write_memory_1;
@@ -4518,118 +4460,127 @@ _initialize_target ()
add_info ("target", info_target_command, targ_desc);
add_info ("files", info_target_command, targ_desc);
- add_setshow_zuinteger_cmd ("target", class_maintenance, &targetdebug, _("\
-Set target debugging."), _("\
-Show target debugging."), _("\
+ add_setshow_zuinteger_cmd ("target", class_maintenance, &targetdebug, _ ("\
+Set target debugging."),
+ _ ("\
+Show target debugging."),
+ _ ("\
When non-zero, target debugging is enabled. Higher numbers are more\n\
verbose."),
- set_targetdebug,
- show_targetdebug,
- &setdebuglist, &showdebuglist);
+ set_targetdebug, show_targetdebug, &setdebuglist,
+ &showdebuglist);
add_setshow_boolean_cmd ("trust-readonly-sections", class_support,
- &trust_readonly, _("\
-Set mode for reading from readonly sections."), _("\
-Show mode for reading from readonly sections."), _("\
+ &trust_readonly, _ ("\
+Set mode for reading from readonly sections."),
+ _ ("\
+Show mode for reading from readonly sections."),
+ _ ("\
When this mode is on, memory reads from readonly sections (such as .text)\n\
will be read from the object file instead of from the target. This will\n\
result in significant performance improvement for remote targets."),
- NULL,
- show_trust_readonly,
- &setlist, &showlist);
+ NULL, show_trust_readonly, &setlist, &showlist);
add_com ("monitor", class_obscure, do_monitor_command,
- _("Send a command to the remote monitor (remote targets only)."));
+ _ ("Send a command to the remote monitor (remote targets only)."));
add_cmd ("target-stack", class_maintenance, maintenance_print_target_stack,
- _("Print the name of each layer of the internal target stack."),
+ _ ("Print the name of each layer of the internal target stack."),
&maintenanceprintlist);
- add_setshow_boolean_cmd ("target-async", no_class,
- _("\
-Set whether gdb controls the inferior in asynchronous mode."), _("\
-Show whether gdb controls the inferior in asynchronous mode."), _("\
+ add_setshow_boolean_cmd ("target-async", no_class, _ ("\
+Set whether gdb controls the inferior in asynchronous mode."),
+ _ ("\
+Show whether gdb controls the inferior in asynchronous mode."),
+ _ ("\
Tells gdb whether to control the inferior in asynchronous mode."),
- set_maint_target_async,
- get_maint_target_async,
- show_maint_target_async,
- &maintenance_set_cmdlist,
+ set_maint_target_async, get_maint_target_async,
+ show_maint_target_async, &maintenance_set_cmdlist,
&maintenance_show_cmdlist);
- add_setshow_auto_boolean_cmd ("target-non-stop", no_class,
- _("\
-Set whether gdb always controls the inferior in non-stop mode."), _("\
-Show whether gdb always controls the inferior in non-stop mode."), _("\
+ add_setshow_auto_boolean_cmd ("target-non-stop", no_class, _ ("\
+Set whether gdb always controls the inferior in non-stop mode."),
+ _ ("\
+Show whether gdb always controls the inferior in non-stop mode."),
+ _ ("\
Tells gdb whether to control the inferior in non-stop mode."),
- set_maint_target_non_stop,
- get_maint_target_non_stop,
- show_maint_target_non_stop,
- &maintenance_set_cmdlist,
- &maintenance_show_cmdlist);
+ set_maint_target_non_stop,
+ get_maint_target_non_stop,
+ show_maint_target_non_stop,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
add_setshow_boolean_cmd ("may-write-registers", class_support,
- &may_write_registers_1, _("\
-Set permission to write into registers."), _("\
-Show permission to write into registers."), _("\
+ &may_write_registers_1, _ ("\
+Set permission to write into registers."),
+ _ ("\
+Show permission to write into registers."),
+ _ ("\
When this permission is on, GDB may write into the target's registers.\n\
Otherwise, any sort of write attempt will result in an error."),
- set_target_permissions, NULL,
- &setlist, &showlist);
+ set_target_permissions, NULL, &setlist, &showlist);
add_setshow_boolean_cmd ("may-write-memory", class_support,
- &may_write_memory_1, _("\
-Set permission to write into target memory."), _("\
-Show permission to write into target memory."), _("\
+ &may_write_memory_1, _ ("\
+Set permission to write into target memory."),
+ _ ("\
+Show permission to write into target memory."),
+ _ ("\
When this permission is on, GDB may write into the target's memory.\n\
Otherwise, any sort of write attempt will result in an error."),
- set_write_memory_permission, NULL,
- &setlist, &showlist);
+ set_write_memory_permission, NULL, &setlist,
+ &showlist);
add_setshow_boolean_cmd ("may-insert-breakpoints", class_support,
- &may_insert_breakpoints_1, _("\
-Set permission to insert breakpoints in the target."), _("\
-Show permission to insert breakpoints in the target."), _("\
+ &may_insert_breakpoints_1, _ ("\
+Set permission to insert breakpoints in the target."),
+ _ ("\
+Show permission to insert breakpoints in the target."),
+ _ ("\
When this permission is on, GDB may insert breakpoints in the program.\n\
Otherwise, any sort of insertion attempt will result in an error."),
- set_target_permissions, NULL,
- &setlist, &showlist);
+ set_target_permissions, NULL, &setlist, &showlist);
add_setshow_boolean_cmd ("may-insert-tracepoints", class_support,
- &may_insert_tracepoints_1, _("\
-Set permission to insert tracepoints in the target."), _("\
-Show permission to insert tracepoints in the target."), _("\
+ &may_insert_tracepoints_1, _ ("\
+Set permission to insert tracepoints in the target."),
+ _ ("\
+Show permission to insert tracepoints in the target."),
+ _ ("\
When this permission is on, GDB may insert tracepoints in the program.\n\
Otherwise, any sort of insertion attempt will result in an error."),
- set_target_permissions, NULL,
- &setlist, &showlist);
+ set_target_permissions, NULL, &setlist, &showlist);
add_setshow_boolean_cmd ("may-insert-fast-tracepoints", class_support,
- &may_insert_fast_tracepoints_1, _("\
-Set permission to insert fast tracepoints in the target."), _("\
-Show permission to insert fast tracepoints in the target."), _("\
+ &may_insert_fast_tracepoints_1, _ ("\
+Set permission to insert fast tracepoints in the target."),
+ _ ("\
+Show permission to insert fast tracepoints in the target."),
+ _ ("\
When this permission is on, GDB may insert fast tracepoints.\n\
Otherwise, any sort of insertion attempt will result in an error."),
- set_target_permissions, NULL,
- &setlist, &showlist);
+ set_target_permissions, NULL, &setlist, &showlist);
- add_setshow_boolean_cmd ("may-interrupt", class_support,
- &may_stop_1, _("\
-Set permission to interrupt or signal the target."), _("\
-Show permission to interrupt or signal the target."), _("\
+ add_setshow_boolean_cmd ("may-interrupt", class_support, &may_stop_1, _ ("\
+Set permission to interrupt or signal the target."),
+ _ ("\
+Show permission to interrupt or signal the target."),
+ _ ("\
When this permission is on, GDB may interrupt/stop the target's execution.\n\
Otherwise, any attempt to interrupt or stop will be ignored."),
- set_target_permissions, NULL,
- &setlist, &showlist);
+ set_target_permissions, NULL, &setlist, &showlist);
add_com ("flash-erase", no_class, flash_erase_command,
- _("Erase all flash memory regions."));
+ _ ("Erase all flash memory regions."));
add_setshow_boolean_cmd ("auto-connect-native-target", class_support,
- &auto_connect_native_target, _("\
-Set whether GDB may automatically connect to the native target."), _("\
-Show whether GDB may automatically connect to the native target."), _("\
+ &auto_connect_native_target, _ ("\
+Set whether GDB may automatically connect to the native target."),
+ _ ("\
+Show whether GDB may automatically connect to the native target."),
+ _ ("\
When on, and GDB is not connected to a target yet, GDB\n\
attempts \"run\" and other commands with the native target."),
- NULL, show_auto_connect_native_target,
- &setlist, &showlist);
+ NULL, show_auto_connect_native_target, &setlist,
+ &showlist);
}