<http://www.openinventionnetwork.com>. */
#include "addr-record.hh"
-#include "misc.hh"
size_t
addr_record_find_addr (struct addr_record *ar, uint64_t addr)
{
size_t a = 0;
- size_t b = ar->size;
+ size_t b = ar->size ();
while (a < b)
{
size_t i = (a + b) / 2;
- uint64_t v = ar->addrs[i];
+ uint64_t v = (*ar)[i];
if (v > addr)
b = i;
bool
addr_record_has_addr (struct addr_record *ar, uint64_t addr)
{
- if (ar->size == 0
- || addr < ar->addrs[0]
- || addr > ar->addrs[ar->size - 1])
+ if (ar->size () == 0
+ || addr < (*ar)[0]
+ || addr > (*ar)[ar->size () - 1])
return false;
size_t a = addr_record_find_addr (ar, addr);
- return a < ar->size && ar->addrs[a] == addr;
+ return a < ar->size () && (*ar)[a] == addr;
}
void
addr_record_add (struct addr_record *ar, uint64_t addr)
{
size_t a = addr_record_find_addr (ar, addr);
- if (a >= ar->size || ar->addrs[a] != addr)
- {
- REALLOC (ar, addrs);
- size_t len = ar->size - a;
- memmove (ar->addrs + a + 1, ar->addrs + a, len * sizeof (*ar->addrs));
-
- ar->addrs[a] = addr;
- ar->size++;
- }
-}
-
-void
-addr_record_free (struct addr_record *ar)
-{
- if (ar != NULL)
- free (ar->addrs);
+ if (a >= ar->size () || (*ar)[a] != addr)
+ ar->insert (ar->begin () + a, addr);
}
interpretable as a DIE. */
struct addr_record
+ : std::vector<uint64_t>
{
- size_t size;
- size_t alloc;
- uint64_t *addrs;
+ typedef std::vector<uint64_t> _super_t;
+public:
+ using _super_t::const_iterator;
+ using _super_t::begin;
+ using _super_t::end;
+ using _super_t::push_back;
+ using _super_t::operator[];
+ using _super_t::size;
+ using _super_t::insert;
};
size_t addr_record_find_addr (struct addr_record *ar, uint64_t addr);
bool addr_record_has_addr (struct addr_record *ar, uint64_t addr);
void addr_record_add (struct addr_record *ar, uint64_t addr);
-void addr_record_free (struct addr_record *ar);
/* Functions and data structures for reference handling. Just like
the above, we use this to check validity of DIE references.
if (section == NULL)
{
abbrev_table t;
- WIPE (t);
section = &abbrevs.insert (std::make_pair (abbr_off, t)).first->second;
section->offset = abbr_off;
bool used; /* There are CUs using this table. */
abbrev *find_abbrev (uint64_t abbrev_code) const;
+
+ abbrev_table ()
+ : next (NULL)
+ , abbr (NULL)
+ , offset (0)
+ , size (0)
+ , alloc (0)
+ , used (false)
+ {}
};
class check_debug_abbrev
#include "check_debug_info.hh"
#include "check_debug_line.hh"
#include "check_debug_aranges.hh"
-#include "misc.hh"
checkdescriptor const *
read_cu_headers::descriptor ()
else
{
if (symbolp != NULL)
- WIPE (*symbolp);
+ memset (*symbolp, 0, sizeof (**symbolp));
if (type_is_rel
&& (relocate == rel_require
|| (relocate == rel_nonzero
check_debug_info::~check_debug_info ()
{
- for (std::vector<cu>::iterator it = cus.begin ();
- it != cus.end (); ++it)
- addr_record_free (&it->die_addrs);
}
cu *
bool has_arange; // Whether we saw arange section pointing at this CU.
bool has_pubnames; // Likewise for pubnames.
bool has_pubtypes; // Likewise for pubtypes.
+
+ cu ()
+ : next (NULL)
+ , head (NULL)
+ , cudie_offset (0)
+ , low_pc (0)
+ , has_arange (false)
+ , has_pubnames (false)
+ , has_pubtypes (false)
+ {}
};
/** The pass for reading basic .debug_info data -- the layout of
}
ref_record oprefs;
-
- struct addr_record opaddrs;
- WIPE (opaddrs);
+ addr_record opaddrs;
while (!read_ctx_eof (&ctx))
{
out:
for (ref_record::const_iterator it = oprefs.begin ();
it != oprefs.end (); ++it)
- {
- if (!addr_record_has_addr (&opaddrs, it->addr))
- wr_error (it->who) << "unresolved reference to opcode at "
- << pri::hex (it->addr) << ".\n";
- }
-
- addr_record_free (&opaddrs);
+ if (!addr_record_has_addr (&opaddrs, it->addr))
+ wr_error (it->who) << "unresolved reference to opcode at "
+ << pri::hex (it->addr) << ".\n";
return true;
}
#include "coverage.hh"
#include "pri.hh"
#include "check_debug_loc_range.hh"
-#include "misc.hh"
using elfutils::dwarf;
#endif
#include "coverage.hh"
-#include "misc.hh"
#include "pri.hh"
#include <stdbool.h>
/* Pedantic checking of DWARF files.
- Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
Elf_Data *data; /* May be NULL if data in this section are
missing or not substantial. */
enum section_id id;
+
+ sec ()
+ : scn (NULL)
+ , name (NULL)
+ , data (NULL)
+ , id (sec_invalid)
+ {}
};
struct elf_file
<http://www.openinventionnetwork.com>. */
#include "messages.hh"
-#include "misc.hh"
#include "coverage.hh"
#include "option.hh"
void
message_criteria::operator *= (message_criteria const &rhs)
{
- struct message_criteria ret;
- WIPE (ret);
-
+ message_criteria ret;
for (size_t i = 0; i < size (); ++i)
for (size_t j = 0; j < rhs.size (); ++j)
{
} \
} while (0)
-#define WIPE(OBJ) memset (&OBJ, 0, sizeof (OBJ))
-
bool address_aligned (uint64_t addr, uint64_t align);
bool necessary_alignment (uint64_t start, uint64_t length,
uint64_t align);
REALLOC (&sec->rel, rel);
struct relocation *cur = sec->rel.rel + sec->rel.size++;
- WIPE (*cur);
+ new (cur) relocation ();
GElf_Rela rela_mem, *rela
= get_rel_or_rela (reldata, i, &rela_mem, sec->rel.type);
/* Pedantic checking of DWARF files.
- Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
bool invalid; /* Whether this one relocation should be
ignored. Necessary so that we don't report
invalid & missing relocation twice. */
+
+ relocation ()
+ : offset (0)
+ , addend (0)
+ , symndx (0)
+ , type (0)
+ , invalid (false)
+ {}
};
struct relocation_data
size_t size;
size_t alloc;
size_t index; /* Current index. */
+
+ relocation_data ()
+ : symdata (NULL)
+ , type (SHT_NULL)
+ , rel (NULL)
+ , size (0)
+ , alloc (0)
+ , index (0)
+ {}
};
enum skip_type
/* Section 0 is special, skip it. */
REALLOC (file, sec);
- file->sec[file->size++].id = sec_invalid;
+ new (file->sec + file->size++) sec ();
if (false)
{
REALLOC (file, sec);
size_t curndx = file->size++;
struct sec *cursec = file->sec + curndx;
+ new (cursec) sec ();
GElf_Shdr *shdr = gelf_getshdr (scn, &cursec->shdr);
if (shdr == NULL)
secentry *entry = secinfo.get (scnname);
cursec->scn = scn;
- cursec->id = entry != NULL ? entry->id : sec_invalid;
+ if (entry != NULL)
+ cursec->id = entry->id;
cursec->name = scnname;
- cursec->rel = (struct relocation_data){NULL, SHT_NULL, NULL, 0, 0, 0};
/* Dwarf section. */
if (entry != NULL)