forked from Imagelibrary/binutils-gdb
Remove read_memory_string
read_memory_string is redundant and only called in a couple of spots. This patch removes it in favor of target_read_string. gdb/ChangeLog 2020-06-15 Tom Tromey <tromey@adacore.com> * corefile.c (read_memory_string): Remove. * ada-valprint.c (ada_value_print_ptr): Update. * ada-lang.h (ada_tag_name): Change return type. * ada-lang.c (type_from_tag): Update. (ada_tag_name_from_tsd): Change return type. Use target_read_string. (ada_tag_name): Likewise. * gdbcore.h (read_memory_string): Don't declare.
This commit is contained in:
@@ -1,3 +1,14 @@
|
|||||||
|
2020-06-15 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* corefile.c (read_memory_string): Remove.
|
||||||
|
* ada-valprint.c (ada_value_print_ptr): Update.
|
||||||
|
* ada-lang.h (ada_tag_name): Change return type.
|
||||||
|
* ada-lang.c (type_from_tag): Update.
|
||||||
|
(ada_tag_name_from_tsd): Change return type. Use
|
||||||
|
target_read_string.
|
||||||
|
(ada_tag_name): Likewise.
|
||||||
|
* gdbcore.h (read_memory_string): Don't declare.
|
||||||
|
|
||||||
2020-06-14 Hannes Domani <ssbssa@yahoo.de>
|
2020-06-14 Hannes Domani <ssbssa@yahoo.de>
|
||||||
|
|
||||||
* symtab.c (rbreak_command): Ignore Windows drive colon.
|
* symtab.c (rbreak_command): Ignore Windows drive colon.
|
||||||
|
|||||||
@@ -6567,10 +6567,10 @@ value_tag_from_contents_and_address (struct type *type,
|
|||||||
static struct type *
|
static struct type *
|
||||||
type_from_tag (struct value *tag)
|
type_from_tag (struct value *tag)
|
||||||
{
|
{
|
||||||
const char *type_name = ada_tag_name (tag);
|
gdb::unique_xmalloc_ptr<char> type_name = ada_tag_name (tag);
|
||||||
|
|
||||||
if (type_name != NULL)
|
if (type_name != NULL)
|
||||||
return ada_find_any_type (ada_encode (type_name));
|
return ada_find_any_type (ada_encode (type_name.get ()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6718,37 +6718,42 @@ ada_get_tsd_from_tag (struct value *tag)
|
|||||||
/* Given the TSD of a tag (type-specific data), return a string
|
/* Given the TSD of a tag (type-specific data), return a string
|
||||||
containing the name of the associated type.
|
containing the name of the associated type.
|
||||||
|
|
||||||
The returned value is good until the next call. May return NULL
|
May return NULL if we are unable to determine the tag name. */
|
||||||
if we are unable to determine the tag name. */
|
|
||||||
|
|
||||||
static char *
|
static gdb::unique_xmalloc_ptr<char>
|
||||||
ada_tag_name_from_tsd (struct value *tsd)
|
ada_tag_name_from_tsd (struct value *tsd)
|
||||||
{
|
{
|
||||||
static char name[1024];
|
|
||||||
char *p;
|
char *p;
|
||||||
struct value *val;
|
struct value *val;
|
||||||
|
|
||||||
val = ada_value_struct_elt (tsd, "expanded_name", 1);
|
val = ada_value_struct_elt (tsd, "expanded_name", 1);
|
||||||
if (val == NULL)
|
if (val == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
read_memory_string (value_as_address (val), name, sizeof (name) - 1);
|
gdb::unique_xmalloc_ptr<char> buffer;
|
||||||
for (p = name; *p != '\0'; p += 1)
|
int err;
|
||||||
|
if (target_read_string (value_as_address (val), &buffer, INT_MAX, &err) == 0
|
||||||
|
|| err != 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
for (p = buffer.get (); *p != '\0'; ++p)
|
||||||
|
{
|
||||||
if (isalpha (*p))
|
if (isalpha (*p))
|
||||||
*p = tolower (*p);
|
*p = tolower (*p);
|
||||||
return name;
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The type name of the dynamic type denoted by the 'tag value TAG, as
|
/* The type name of the dynamic type denoted by the 'tag value TAG, as
|
||||||
a C string.
|
a C string.
|
||||||
|
|
||||||
Return NULL if the TAG is not an Ada tag, or if we were unable to
|
Return NULL if the TAG is not an Ada tag, or if we were unable to
|
||||||
determine the name of that tag. The result is good until the next
|
determine the name of that tag. */
|
||||||
call. */
|
|
||||||
|
|
||||||
const char *
|
gdb::unique_xmalloc_ptr<char>
|
||||||
ada_tag_name (struct value *tag)
|
ada_tag_name (struct value *tag)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
gdb::unique_xmalloc_ptr<char> name;
|
||||||
|
|
||||||
if (!ada_is_tag_type (value_type (tag)))
|
if (!ada_is_tag_type (value_type (tag)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -12104,9 +12109,11 @@ ada_exception_message_1 (void)
|
|||||||
if (e_msg_len <= 0)
|
if (e_msg_len <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
gdb::unique_xmalloc_ptr<char> e_msg ((char *) xmalloc (e_msg_len + 1));
|
gdb::unique_xmalloc_ptr<char> e_msg;
|
||||||
read_memory_string (value_address (e_msg_val), e_msg.get (), e_msg_len + 1);
|
int err;
|
||||||
e_msg.get ()[e_msg_len] = '\0';
|
if (target_read_string (value_address (e_msg_val), &e_msg, INT_MAX, &err) == 0
|
||||||
|
|| err != 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return e_msg;
|
return e_msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ extern int ada_is_tagged_type (struct type *, int);
|
|||||||
|
|
||||||
extern int ada_is_tag_type (struct type *);
|
extern int ada_is_tag_type (struct type *);
|
||||||
|
|
||||||
extern const char *ada_tag_name (struct value *);
|
extern gdb::unique_xmalloc_ptr<char> ada_tag_name (struct value *);
|
||||||
|
|
||||||
extern struct value *ada_tag_value_at_base_address (struct value *obj);
|
extern struct value *ada_tag_value_at_base_address (struct value *obj);
|
||||||
|
|
||||||
|
|||||||
@@ -754,10 +754,10 @@ ada_value_print_ptr (struct value *val,
|
|||||||
struct type *type = ada_check_typedef (value_type (val));
|
struct type *type = ada_check_typedef (value_type (val));
|
||||||
if (ada_is_tag_type (type))
|
if (ada_is_tag_type (type))
|
||||||
{
|
{
|
||||||
const char *name = ada_tag_name (val);
|
gdb::unique_xmalloc_ptr<char> name = ada_tag_name (val);
|
||||||
|
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
fprintf_filtered (stream, " (%s)", name);
|
fprintf_filtered (stream, " (%s)", name.get ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -328,33 +328,6 @@ read_code_unsigned_integer (CORE_ADDR memaddr, int len,
|
|||||||
return extract_unsigned_integer (buf, len, byte_order);
|
return extract_unsigned_integer (buf, len, byte_order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
read_memory_string (CORE_ADDR memaddr, char *buffer, int max_len)
|
|
||||||
{
|
|
||||||
char *cp;
|
|
||||||
int i;
|
|
||||||
int cnt;
|
|
||||||
|
|
||||||
cp = buffer;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (cp - buffer >= max_len)
|
|
||||||
{
|
|
||||||
buffer[max_len - 1] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cnt = max_len - (cp - buffer);
|
|
||||||
if (cnt > 8)
|
|
||||||
cnt = 8;
|
|
||||||
read_memory (memaddr + (int) (cp - buffer), (gdb_byte *) cp, cnt);
|
|
||||||
for (i = 0; i < cnt && *cp; i++, cp++)
|
|
||||||
; /* null body */
|
|
||||||
|
|
||||||
if (i < cnt && !*cp)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
read_memory_typed_address (CORE_ADDR addr, struct type *type)
|
read_memory_typed_address (CORE_ADDR addr, struct type *type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,12 +87,6 @@ extern ULONGEST read_code_unsigned_integer (CORE_ADDR memaddr,
|
|||||||
int len,
|
int len,
|
||||||
enum bfd_endian byte_order);
|
enum bfd_endian byte_order);
|
||||||
|
|
||||||
/* Read a null-terminated string from the debuggee's memory, given
|
|
||||||
address, a buffer into which to place the string, and the maximum
|
|
||||||
available space. */
|
|
||||||
|
|
||||||
extern void read_memory_string (CORE_ADDR, char *, int);
|
|
||||||
|
|
||||||
/* Read the pointer of type TYPE at ADDR, and return the address it
|
/* Read the pointer of type TYPE at ADDR, and return the address it
|
||||||
represents. */
|
represents. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user