#include "stack.h"
#include "gdb_bfd.h"
#include "cli/cli-utils.h"
+#include "common/byte-vector.h"
#include <sys/types.h>
#include <fcntl.h>
static void overlay_invalidate_all (void);
-static void overlay_command (char *, int);
-
static void simple_free_overlay_table (void);
static void read_target_long_array (CORE_ADDR, unsigned int *, int, int,
calls add_symtab_fns() to register information on each format it is
prepared to read. */
-typedef struct
+struct registered_sym_fns
{
+ registered_sym_fns (bfd_flavour sym_flavour_, const struct sym_fns *sym_fns_)
+ : sym_flavour (sym_flavour_), sym_fns (sym_fns_)
+ {}
+
/* BFD flavour that we handle. */
enum bfd_flavour sym_flavour;
/* The "vtable" of symbol functions. */
const struct sym_fns *sym_fns;
-} registered_sym_fns;
-
-DEF_VEC_O (registered_sym_fns);
+};
-static VEC (registered_sym_fns) *symtab_fns = NULL;
+static std::vector<registered_sym_fns> symtab_fns;
/* Values for "set print symbol-loading". */
if (symfile_objfile != NULL)
{
- free_objfile (symfile_objfile);
+ delete symfile_objfile;
gdb_assert (symfile_objfile == NULL);
}
ABFD is a BFD already open on the file, as from symfile_bfd_open.
A new reference is acquired by this function.
- For NAME description see allocate_objfile's definition.
+ For NAME description see the objfile constructor.
ADD_FLAGS encodes verbosity, whether this is main symbol file or
extra, such as dynamically loaded code, and what to do with breakpoins.
if (mainline)
flags |= OBJF_MAINLINE;
- objfile = allocate_objfile (abfd, name, flags);
+ objfile = new struct objfile (abfd, name, flags);
if (parent)
add_separate_debug_objfile (objfile, parent);
}
/* Add BFD as a separate debug file for OBJFILE. For NAME description
- see allocate_objfile's definition. */
+ see the objfile constructor. */
void
symbol_file_add_separate (bfd *bfd, const char *name,
void
add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *sf)
{
- registered_sym_fns fns = { flavour, sf };
-
- VEC_safe_push (registered_sym_fns, symtab_fns, &fns);
+ symtab_fns.emplace_back (flavour, sf);
}
/* Initialize OBJFILE to read symbols from its associated BFD. It
static const struct sym_fns *
find_sym_fns (bfd *abfd)
{
- registered_sym_fns *rsf;
enum bfd_flavour our_flavour = bfd_get_flavour (abfd);
- int i;
if (our_flavour == bfd_target_srec_flavour
|| our_flavour == bfd_target_ihex_flavour
|| our_flavour == bfd_target_tekhex_flavour)
return NULL; /* No symbols. */
- for (i = 0; VEC_iterate (registered_sym_fns, symtab_fns, i, rsf); ++i)
- if (our_flavour == rsf->sym_flavour)
- return rsf->sym_fns;
+ for (const registered_sym_fns &rsf : symtab_fns)
+ if (our_flavour == rsf.sym_flavour)
+ return rsf.sym_fns;
error (_("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown."),
bfd_get_target (abfd));
might add a verify_memory() method to the target vector and
then use that. remote.c could implement that method using
the ``qCRC'' packet. */
- gdb_byte *check = (gdb_byte *) xmalloc (bytes);
- struct cleanup *verify_cleanups = make_cleanup (xfree, check);
+ gdb::byte_vector check (bytes);
- if (target_read_memory (args->lma, check, bytes) != 0)
+ if (target_read_memory (args->lma, check.data (), bytes) != 0)
error (_("Download verify read failed at %s"),
paddress (target_gdbarch (), args->lma));
- if (memcmp (args->buffer, check, bytes) != 0)
+ if (memcmp (args->buffer, check.data (), bytes) != 0)
error (_("Download verify compare failed at %s"),
paddress (target_gdbarch (), args->lma));
- do_cleanups (verify_cleanups);
}
totals->data_count += bytes;
args->lma += bytes;
objfile_name (objf)))
error (_("Not confirmed."));
- free_objfile (objf);
+ delete objf;
clear_symtab_users (0);
}
/* FIXME: Do we have to free a whole linked list, or is this
enough? */
- if (objfile->global_psymbols.list)
- xfree (objfile->global_psymbols.list);
- memset (&objfile->global_psymbols, 0,
- sizeof (objfile->global_psymbols));
- if (objfile->static_psymbols.list)
- xfree (objfile->static_psymbols.list);
- memset (&objfile->static_psymbols, 0,
- sizeof (objfile->static_psymbols));
+ objfile->global_psymbols.clear ();
+ objfile->static_psymbols.clear ();
/* Free the obstacks for non-reusable objfiles. */
psymbol_bcache_free (objfile->psymbol_cache);
static struct cmd_list_element *overlaylist;
static void
-overlay_command (char *args, int from_tty)
+overlay_command (const char *args, int from_tty)
{
printf_unfiltered
("\"overlay\" must be followed by the name of an overlay command.\n");