/* Auxiliary vector support for GDB, the GNU debugger.
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This file is part of GDB.
#include "inferior.h"
#include "valprint.h"
#include "gdbcore.h"
-#include "observer.h"
+#include "observable.h"
#include "filestuff.h"
#include "objfiles.h"
overhead of transfering data from a remote target to the local host. */
struct auxv_info
{
- LONGEST length;
- gdb_byte *data;
+ gdb::optional<gdb::byte_vector> data;
};
/* Handles the cleanup of the auxv cache for inferior INF. ARG is ignored.
info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
if (info != NULL)
{
- xfree (info->data);
- xfree (info);
+ delete info;
set_inferior_data (inf, auxv_inferior_data, NULL);
}
}
info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
if (info == NULL)
{
- info = XCNEW (struct auxv_info);
- info->length = target_read_alloc (ops, TARGET_OBJECT_AUXV,
- NULL, &info->data);
+ info = new auxv_info;
+ info->data = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);
set_inferior_data (inf, auxv_inferior_data, info);
}
target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
{
CORE_ADDR type, val;
- gdb_byte *data;
- gdb_byte *ptr;
- struct auxv_info *info;
-
- info = get_auxv_inferior_data (ops);
+ auxv_info *info = get_auxv_inferior_data (ops);
- data = info->data;
- ptr = data;
+ if (!info->data)
+ return -1;
- if (info->length <= 0)
- return info->length;
+ gdb_byte *data = info->data->data ();
+ gdb_byte *ptr = data;
+ size_t len = info->data->size ();
while (1)
- switch (target_auxv_parse (ops, &ptr, data + info->length, &type, &val))
+ switch (target_auxv_parse (ops, &ptr, data + len, &type, &val))
{
case 1: /* Here's an entry, check it. */
if (type == match)
{
struct gdbarch *gdbarch = target_gdbarch ();
CORE_ADDR type, val;
- gdb_byte *data;
- gdb_byte *ptr;
- struct auxv_info *info;
int ents = 0;
+ auxv_info *info = get_auxv_inferior_data (ops);
- info = get_auxv_inferior_data (ops);
+ if (!info->data)
+ return -1;
- data = info->data;
- ptr = data;
- if (info->length <= 0)
- return info->length;
+ gdb_byte *data = info->data->data ();
+ gdb_byte *ptr = data;
+ size_t len = info->data->size ();
- while (target_auxv_parse (ops, &ptr, data + info->length, &type, &val) > 0)
+ while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
{
gdbarch_print_auxv_entry (gdbarch, file, type, val);
++ents;
}
static void
-info_auxv_command (char *cmd, int from_tty)
+info_auxv_command (const char *cmd, int from_tty)
{
if (! target_has_stack)
error (_("The program has no auxiliary information now."));
}
}
-
-extern initialize_file_ftype _initialize_auxv; /* -Wmissing-prototypes; */
-
void
_initialize_auxv (void)
{
= register_inferior_data_with_cleanup (NULL, auxv_inferior_data_cleanup);
/* Observers used to invalidate the auxv cache when needed. */
- observer_attach_inferior_exit (invalidate_auxv_cache_inf);
- observer_attach_inferior_appeared (invalidate_auxv_cache_inf);
- observer_attach_executable_changed (invalidate_auxv_cache);
+ gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf);
+ gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf);
+ gdb::observers::executable_changed.attach (invalidate_auxv_cache);
}