projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gdb/copyright.py: Exit if run from the wrong directory
[deliverable/binutils-gdb.git]
/
gdb
/
coffread.c
diff --git
a/gdb/coffread.c
b/gdb/coffread.c
index ae0d05bddf33f96204432abc198a71f8a0d2d38c..3e5ade80a4985156e03a2bf74b3f3cb74c8c7d38 100644
(file)
--- a/
gdb/coffread.c
+++ b/
gdb/coffread.c
@@
-18,34
+18,29
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "symtab.h"
+#include "gdbtypes.h"
+#include "demangle.h"
+#include "breakpoint.h"
-/* Standard C includes. */
-#include <ctype.h>
-
-/* Local non-gdb includes. */
#include "bfd.h"
#include "bfd.h"
-#include "block.h"
-#include "breakpoint.h"
-#include "build-id.h"
-#include "buildsym-legacy.h"
-#include "coff-pe-read.h"
-#include "coff/internal.h"
-#include "complaints.h"
-#include "demangle.h"
-#include "dictionary.h"
-#include "gdb-stabs.h"
#include "gdb_obstack.h"
#include "gdb_obstack.h"
-#include "gdbtypes.h"
-#include "libcoff.h"
+#include <ctype.h>
+
+#include "coff/internal.h" /* Internal format of COFF symbols in BFD */
+#include "libcoff.h" /* FIXME secret internal data from BFD */
#include "objfiles.h"
#include "objfiles.h"
-#include "
psymtab
.h"
+#include "
buildsym-legacy
.h"
#include "stabsread.h"
#include "stabsread.h"
-#include "
symtab
.h"
+#include "
complaints
.h"
#include "target.h"
#include "target.h"
+#include "block.h"
+#include "dictionary.h"
-/* Key for COFF-associated data. */
+#include "coff-pe-read.h"
-static const struct objfile_data *coff_objfile_data_key;
+#include "psymtab.h"
+#include "build-id.h"
/* The objfile we are currently reading. */
/* The objfile we are currently reading. */
@@
-53,16
+48,20
@@
static struct objfile *coffread_objfile;
struct coff_symfile_info
{
struct coff_symfile_info
{
- file_ptr min_lineno_offset
;
/* Where in file lowest line#s are. */
- file_ptr max_lineno_offset
;
/* 1+last byte of line#s in file. */
+ file_ptr min_lineno_offset
= 0;
/* Where in file lowest line#s are. */
+ file_ptr max_lineno_offset
= 0;
/* 1+last byte of line#s in file. */
- CORE_ADDR textaddr
;
/* Addr of .text section. */
- unsigned int textsize
;
/* Size of .text section. */
+ CORE_ADDR textaddr
= 0;
/* Addr of .text section. */
+ unsigned int textsize
= 0;
/* Size of .text section. */
std::vector<asection *> *stabsects; /* .stab sections. */
std::vector<asection *> *stabsects; /* .stab sections. */
- asection *stabstrsect
;
/* Section pointer for .stab section. */
- char *stabstrdata;
+ asection *stabstrsect
= nullptr;
/* Section pointer for .stab section. */
+ char *stabstrdata
= nullptr
;
};
};
+/* Key for COFF-associated data. */
+
+static const struct objfile_key<coff_symfile_info> coff_objfile_data_key;
+
/* Translate an external name string into a user-visible name. */
#define EXTERNAL_NAME(string, abfd) \
(string[0] == bfd_get_symbol_leading_char (abfd) \
/* Translate an external name string into a user-visible name. */
#define EXTERNAL_NAME(string, abfd) \
(string[0] == bfd_get_symbol_leading_char (abfd) \
@@
-223,15
+222,15
@@
coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
const char *name;
csi = (struct coff_symfile_info *) csip;
const char *name;
csi = (struct coff_symfile_info *) csip;
- name = bfd_
get_section_name (abfd,
sectp);
+ name = bfd_
section_name (
sectp);
if (strcmp (name, ".text") == 0)
{
if (strcmp (name, ".text") == 0)
{
- csi->textaddr = bfd_section_vma (
abfd,
sectp);
- csi->textsize += bfd_section_size (
abfd,
sectp);
+ csi->textaddr = bfd_section_vma (sectp);
+ csi->textsize += bfd_section_size (sectp);
}
else if (startswith (name, ".text"))
{
}
else if (startswith (name, ".text"))
{
- csi->textsize += bfd_section_size (
abfd,
sectp);
+ csi->textsize += bfd_section_size (sectp);
}
else if (strcmp (name, ".stabstr") == 0)
{
}
else if (strcmp (name, ".stabstr") == 0)
{
@@
-308,7
+307,7
@@
cs_section_address (struct coff_symbol *cs, bfd *abfd)
args.resultp = §
bfd_map_over_sections (abfd, find_targ_sec, &args);
if (sect != NULL)
args.resultp = §
bfd_map_over_sections (abfd, find_targ_sec, &args);
if (sect != NULL)
- addr = bfd_
get_section_vma (abfd,
sect);
+ addr = bfd_
section_vma (
sect);
return addr;
}
return addr;
}
@@
-418,7
+417,7
@@
static int
is_import_fixup_symbol (struct coff_symbol *cs,
enum minimal_symbol_type type)
{
is_import_fixup_symbol (struct coff_symbol *cs,
enum minimal_symbol_type type)
{
- /* The following is a bit of a heuristic using the characteri
c
tics
+ /* The following is a bit of a heuristic using the characteri
s
tics
of these fixup symbols, but should work well in practice... */
int i;
of these fixup symbols, but should work well in practice... */
int i;
@@
-457,14
+456,13
@@
record_minimal_symbol (minimal_symbol_reader &reader,
{
/* Because the value of these symbols is within a function code
range, these symbols interfere with the symbol-from-address
{
/* Because the value of these symbols is within a function code
range, these symbols interfere with the symbol-from-address
- reverse lookup; this manifests itself
s
in backtraces, or any
+ reverse lookup; this manifests itself in backtraces, or any
other commands that prints symbolic addresses. Just pretend
these symbols do not exist. */
return NULL;
}
other commands that prints symbolic addresses. Just pretend
these symbols do not exist. */
return NULL;
}
- return reader.record_full (cs->c_name, strlen (cs->c_name), true, address,
- type, section);
+ return reader.record_full (cs->c_name, true, address, type, section);
}
\f
/* coff_symfile_init ()
}
\f
/* coff_symfile_init ()
@@
-484,16
+482,8
@@
record_minimal_symbol (minimal_symbol_reader &reader,
static void
coff_symfile_init (struct objfile *objfile)
{
static void
coff_symfile_init (struct objfile *objfile)
{
- struct dbx_symfile_info *dbx;
- struct coff_symfile_info *coff;
-
- /* Allocate struct to keep track of stab reading. */
- dbx = XCNEW (struct dbx_symfile_info);
- set_objfile_data (objfile, dbx_objfile_data_key, dbx);
-
/* Allocate struct to keep track of the symfile. */
/* Allocate struct to keep track of the symfile. */
- coff = XCNEW (struct coff_symfile_info);
- set_objfile_data (objfile, coff_objfile_data_key, coff);
+ coff_objfile_data_key.emplace (objfile);
/* COFF objects may be reordered, so set OBJF_REORDERED. If we
find this causes a significant slowdown in gdb then we could
/* COFF objects may be reordered, so set OBJF_REORDERED. If we
find this causes a significant slowdown in gdb then we could
@@
-547,15
+537,14
@@
coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
struct coff_symfile_info *info;
bfd *abfd = objfile->obfd;
coff_data_type *cdata = coff_data (abfd);
struct coff_symfile_info *info;
bfd *abfd = objfile->obfd;
coff_data_type *cdata = coff_data (abfd);
- char *filename = bfd_get_filename (abfd);
+ c
onst c
har *filename = bfd_get_filename (abfd);
int val;
unsigned int num_symbols;
int symtab_offset;
int stringtab_offset;
int stabstrsize;
int val;
unsigned int num_symbols;
int symtab_offset;
int stringtab_offset;
int stabstrsize;
- info = (struct coff_symfile_info *) objfile_data (objfile,
- coff_objfile_data_key);
+ info = coff_objfile_data_key.get (objfile);
symfile_bfd = abfd; /* Kludge for swap routines. */
std::vector<asection *> stabsects;
symfile_bfd = abfd; /* Kludge for swap routines. */
std::vector<asection *> stabsects;
@@
-651,7
+640,7
@@
coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
for (minimal_symbol *msym : objfile->msymbols ())
{
{
for (minimal_symbol *msym : objfile->msymbols ())
{
- const char *name =
MSYMBOL_LINKAGE_NAME (msym
);
+ const char *name =
msym->linkage_name (
);
/* If the minimal symbols whose name are prefixed by "__imp_"
or "_imp_", get rid of the prefix, and search the minimal
/* If the minimal symbols whose name are prefixed by "__imp_"
or "_imp_", get rid of the prefix, and search the minimal
@@
-702,7
+691,7
@@
coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
bfd_get_section_contents? */
bfd_seek (abfd, abfd->where, 0);
bfd_get_section_contents? */
bfd_seek (abfd, abfd->where, 0);
- stabstrsize = bfd_section_size (
abfd,
info->stabstrsect);
+ stabstrsize = bfd_section_size (info->stabstrsect);
coffstab_build_psymtabs (objfile,
info->textaddr, info->textsize,
coffstab_build_psymtabs (objfile,
info->textaddr, info->textsize,
@@
-1513,15
+1502,15
@@
patch_opaque_types (struct symtab *s)
&& TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
&& TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
- const char *name =
SYMBOL_LINKAGE_NAME (real_sym
);
+ const char *name =
real_sym->linkage_name (
);
int hash = hashname (name);
struct symbol *sym, *prev;
prev = 0;
for (sym = opaque_type_chain[hash]; sym;)
{
int hash = hashname (name);
struct symbol *sym, *prev;
prev = 0;
for (sym = opaque_type_chain[hash]; sym;)
{
- if (name[0] ==
SYMBOL_LINKAGE_NAME (sym
)[0]
- && strcmp (name + 1,
SYMBOL_LINKAGE_NAME (sym
) + 1) == 0)
+ if (name[0] ==
sym->linkage_name (
)[0]
+ && strcmp (name + 1,
sym->linkage_name (
) + 1) == 0)
{
if (prev)
{
{
if (prev)
{
@@
-1577,9
+1566,9
@@
process_coff_symbol (struct coff_symbol *cs,
name = cs->c_name;
name = EXTERNAL_NAME (name, objfile->obfd);
name = cs->c_name;
name = EXTERNAL_NAME (name, objfile->obfd);
-
SYMBOL_SET_LANGUAGE (sym,
get_current_subfile ()->language,
-
&objfile->objfile_obstack);
-
SYMBOL_SET_NAMES (sym, name, strlen (name), 1, objfile
);
+
sym->set_language (
get_current_subfile ()->language,
+ &objfile->objfile_obstack);
+
sym->compute_and_set_names (name, true, objfile->per_bfd
);
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
@@
-1619,9
+1608,10
@@
process_coff_symbol (struct coff_symbol *cs,
case C_THUMBEXTFUNC:
case C_EXT:
SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
case C_THUMBEXTFUNC:
case C_EXT:
SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
- SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
- SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
+ SET_SYMBOL_VALUE_ADDRESS (sym,
+ (CORE_ADDR) cs->c_value
+ + ANOFFSET (objfile->section_offsets,
+ SECT_OFF_TEXT (objfile)));
add_symbol_to_list (sym, get_global_symbols ());
break;
add_symbol_to_list (sym, get_global_symbols ());
break;
@@
-1629,9
+1619,10
@@
process_coff_symbol (struct coff_symbol *cs,
case C_THUMBSTATFUNC:
case C_STAT:
SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
case C_THUMBSTATFUNC:
case C_STAT:
SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
- SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
- SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
+ SET_SYMBOL_VALUE_ADDRESS (sym,
+ (CORE_ADDR) cs->c_value
+ + ANOFFSET (objfile->section_offsets,
+ SECT_OFF_TEXT (objfile)));
if (within_function)
{
/* Static symbol of local scope. */
if (within_function)
{
/* Static symbol of local scope. */
@@
-1702,7
+1693,7
@@
process_coff_symbol (struct coff_symbol *cs,
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
- xstrdup (
SYMBOL_LINKAGE_NAME (sym
));
+ xstrdup (
sym->linkage_name (
));
}
/* Keep track of any type which points to empty structured
}
/* Keep track of any type which points to empty structured
@@
-1716,7
+1707,7
@@
process_coff_symbol (struct coff_symbol *cs,
&& TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym)))
!= TYPE_CODE_UNDEF)
{
&& TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym)))
!= TYPE_CODE_UNDEF)
{
- int i = hashname (
SYMBOL_LINKAGE_NAME (sym
));
+ int i = hashname (
sym->linkage_name (
));
SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i];
opaque_type_chain[i] = sym;
SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i];
opaque_type_chain[i] = sym;
@@
-1734,11
+1725,10
@@
process_coff_symbol (struct coff_symbol *cs,
names for anonymous enums, structures, and unions, like
"~0fake" or ".0fake". Thanks, but no thanks... */
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
names for anonymous enums, structures, and unions, like
"~0fake" or ".0fake". Thanks, but no thanks... */
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
- if (SYMBOL_LINKAGE_NAME (sym) != NULL
- && *SYMBOL_LINKAGE_NAME (sym) != '~'
- && *SYMBOL_LINKAGE_NAME (sym) != '.')
- TYPE_NAME (SYMBOL_TYPE (sym)) =
- concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL);
+ if (sym->linkage_name () != NULL
+ && *sym->linkage_name () != '~'
+ && *sym->linkage_name () != '.')
+ TYPE_NAME (SYMBOL_TYPE (sym)) = xstrdup (sym->linkage_name ());
add_symbol_to_list (sym, get_file_symbols ());
break;
add_symbol_to_list (sym, get_file_symbols ());
break;
@@
-1794,11
+1784,9
@@
decode_type (struct coff_symbol *cs, unsigned int c_type,
base_type = decode_type (cs, new_c_type, aux, objfile);
index_type = objfile_type (objfile)->builtin_int;
range_type
base_type = decode_type (cs, new_c_type, aux, objfile);
index_type = objfile_type (objfile)->builtin_int;
range_type
- = create_static_range_type ((struct type *) NULL,
- index_type, 0, n - 1);
+ = create_static_range_type (NULL, index_type, 0, n - 1);
type =
type =
- create_array_type ((struct type *) NULL,
- base_type, range_type);
+ create_array_type (NULL, base_type, range_type);
}
return type;
}
}
return type;
}
@@
-2031,9
+2019,7
@@
coff_read_struct_type (int index, int length, int lastsym,
list = newobj;
/* Save the data. */
list = newobj;
/* Save the data. */
- list->field.name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- name, strlen (name));
+ list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
&sub_aux, objfile);
SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
&sub_aux, objfile);
SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
@@
-2049,9
+2035,7
@@
coff_read_struct_type (int index, int length, int lastsym,
list = newobj;
/* Save the data. */
list = newobj;
/* Save the data. */
- list->field.name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- name, strlen (name));
+ list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
&sub_aux, objfile);
SET_FIELD_BITPOS (list->field, ms->c_value);
FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
&sub_aux, objfile);
SET_FIELD_BITPOS (list->field, ms->c_value);
@@
-2121,9
+2105,8
@@
coff_read_enum_type (int index, int length, int lastsym,
case C_MOE:
sym = allocate_symbol (objfile);
case C_MOE:
sym = allocate_symbol (objfile);
- name = (char *) obstack_copy0 (&objfile->objfile_obstack, name,
- strlen (name));
- SYMBOL_SET_LINKAGE_NAME (sym, name);
+ name = obstack_strdup (&objfile->objfile_obstack, name);
+ sym->set_linkage_name (name);
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE (sym) = ms->c_value;
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE (sym) = ms->c_value;
@@
-2170,7
+2153,7
@@
coff_read_enum_type (int index, int length, int lastsym,
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
- TYPE_FIELD_NAME (type, n) =
SYMBOL_LINKAGE_NAME (xsym
);
+ TYPE_FIELD_NAME (type, n) =
xsym->linkage_name (
);
SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
@@
-2211,22
+2194,11
@@
static const struct sym_fns coff_sym_fns =
&psym_functions
};
&psym_functions
};
-/* Free the per-objfile COFF data. */
-
-static void
-coff_free_info (struct objfile *objfile, void *arg)
-{
- xfree (arg);
-}
-
void
_initialize_coffread (void)
{
add_symtab_fns (bfd_target_coff_flavour, &coff_sym_fns);
void
_initialize_coffread (void)
{
add_symtab_fns (bfd_target_coff_flavour, &coff_sym_fns);
- coff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
- coff_free_info);
-
coff_register_index
= register_symbol_register_impl (LOC_REGISTER, &coff_register_funcs);
}
coff_register_index
= register_symbol_register_impl (LOC_REGISTER, &coff_register_funcs);
}
This page took
0.029421 seconds
and
4
git commands to generate.