mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
Change target_read_string API
This simplifies the target_read_string API a bit. Note that some code was using safe_strerror on the error codes returned by target_read_string. It seems to me that this is incorrect (if it was ever correct, it must have been quite a long time ago). gdb/ChangeLog 2020-06-15 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat::handle_output_debug_string): Update. (windows_nat::handle_ms_vc_exception): Update. * target.h (target_read_string): Change API. * target.c (target_read_string): Change API. * solib-svr4.c (open_symbol_file_object, svr4_read_so_list): Update. * solib-frv.c (frv_current_sos): Update. * solib-dsbt.c (dsbt_current_sos): Update. * solib-darwin.c (darwin_current_sos): Update. * linux-thread-db.c (inferior_has_bug): Update. * expprint.c (print_subexp_standard): Update. * ada-lang.c (ada_main_name, ada_tag_name_from_tsd) (ada_exception_message_1): Update.
This commit is contained in:
26
gdb/target.c
26
gdb/target.c
@ -804,28 +804,24 @@ target_xfer_status_to_string (enum target_xfer_status status)
|
||||
};
|
||||
|
||||
|
||||
/* 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);
|
||||
&buffer, bytes_read);
|
||||
if (errcode != 0)
|
||||
return {};
|
||||
|
||||
if (errnop != nullptr)
|
||||
*errnop = errcode;
|
||||
|
||||
string->reset ((char *) buffer.release ());
|
||||
return bytes_read;
|
||||
return gdb::unique_xmalloc_ptr<char> ((char *) buffer.release ());
|
||||
}
|
||||
|
||||
struct target_section_table *
|
||||
|
Reference in New Issue
Block a user