};
-/* target_read_string -- read a null terminated string, up to LEN bytes,
- from MEMADDR in target. Set *ERRNOP to the errno code, or 0 if successful.
- Set *STRING to a pointer to malloc'd memory containing the data; the caller
- is responsible for freeing it. Return the number of bytes successfully
- read. */
+/* See target.h. */
-int
-target_read_string (CORE_ADDR memaddr, gdb::unique_xmalloc_ptr<char> *string,
- int len, int *errnop)
+gdb::unique_xmalloc_ptr<char>
+target_read_string (CORE_ADDR memaddr, int len, int *bytes_read)
{
- int bytes_read;
gdb::unique_xmalloc_ptr<gdb_byte> buffer;
+ int ignore;
+ if (bytes_read == nullptr)
+ bytes_read = &ignore;
+
/* Note that the endian-ness does not matter here. */
int errcode = read_string (memaddr, -1, 1, len, BFD_ENDIAN_LITTLE,
- &buffer, &bytes_read);
-
- if (errnop != nullptr)
- *errnop = errcode;
+ &buffer, bytes_read);
+ if (errcode != 0)
+ return {};
- string->reset ((char *) buffer.release ());
- return bytes_read;
+ return gdb::unique_xmalloc_ptr<char> ((char *) buffer.release ());
}
struct target_section_table *
if (res == TARGET_XFER_UNAVAILABLE)
break;
- /* We want to continue past core files to executables, but not
- past a running target's memory. */
+ /* Don't continue past targets which have all the memory.
+ At one time, this code was necessary to read data from
+ executables / shared libraries when data for the requested
+ addresses weren't available in the core file. But now the
+ core target handles this case itself. */
if (ops->has_all_memory ())
break;
const char *section_name = section->the_bfd_section->name;
memaddr = overlay_mapped_address (memaddr, section);
+
+ 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->sections,
table->sections_end,
- section_name);
+ match_cb);
}
}
return section_table_xfer_memory_partial (readbuf, writebuf,
memaddr, len, xfered_len,
table->sections,
- table->sections_end,
- NULL);
+ table->sections_end);
}
}
/* See target/target.h. */
ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+ target_wait_flags options)
{
return current_top_target ()->wait (ptid, status, options);
}
ptid_t
default_target_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status,
- int options)
+ target_wait_flags options)
{
status->kind = TARGET_WAITKIND_IGNORE;
return minus_one_ptid;
{
inferior *inf = current_inferior ();
- inferior_ptid = null_ptid;
+ switch_to_no_thread ();
/* Mark breakpoints uninserted in case something tries to delete a
breakpoint while we delete the inferior's threads (which would
if (proc_target == NULL)
continue;
- for (thread_info *thr : inf->threads ())
+ for (thread_info *thr : inf->non_exited_threads ())
{
/* A thread can be THREAD_STOPPED and executing, while
running an infcall. */
OPT is removed from TARGET_OPTIONS. */
static void
-do_option (int *target_options, std::string *ret,
- int opt, const char *opt_str)
+do_option (target_wait_flags *target_options, std::string *ret,
+ target_wait_flag opt, const char *opt_str)
{
if ((*target_options & opt) != 0)
{
/* See target.h. */
std::string
-target_options_to_string (int target_options)
+target_options_to_string (target_wait_flags target_options)
{
std::string ret;