binutils-gdb/gdb/minsyms.h

305 lines
10 KiB
C
Raw Normal View History

/* Minimal symbol table definitions for GDB.
Copyright (C) 2011-2018 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef MINSYMS_H
#define MINSYMS_H
Introduce OP_VAR_MSYM_VALUE The previous patch left GDB with an inconsistency. While with normal expression evaluation the "unknown return type" error shows the name of the function that misses debug info: (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type ^^^^^^ which can by handy in more complicated expressions, "ptype" does not: (gdb) ptype getenv ("PATH") function has unknown return type; cast the call to its declared return type ^^^^^^^^ This commit is a step toward fixing it. The problem is that while evaluating the expression above, we have no reference to the minimal symbol where we could extract the name from. This is because the resulting expression tree has no reference to the minsym at all. During parsing, the type and address of the minsym are extracted and an UNOP_MEMVAL / UNOP_MEMVAL_TLS operator is generated (see write_exp_elt_msym). With "set debug expression", here's what you see: 0 OP_FUNCALL Number of args: 0 3 UNOP_MEMVAL Type @0x565334a51930 (<text variable, no debug info>) 6 OP_LONG Type @0x565334a51c60 (__CORE_ADDR), value 140737345035648 (0x7ffff7751d80) The "print" case finds the function name, because call_function_by_hand looks up the function by address again. However, for "ptype", we don't reach that code, because obviously we don't really call the function. Unlike minsym references, references to variables with debug info have a pointer to the variable's symbol in the expression tree, with OP_VAR_VALUE: (gdb) ptype main() ... 0 OP_FUNCALL Number of args: 0 3 OP_VAR_VALUE Block @0x0, symbol @0x559bbbd9b358 (main(int, char**)) ... so I don't see why do minsyms need to be different. So to prepare for fixing the missing function name issue, this commit adds a new OP_VAR_MSYM_VALUE operator that mimics OP_VAR_VALUE, except that it's for minsyms instead of debug symbols. For infcalls, we now get expressions like these: 0 OP_FUNCALL Number of args: 0 3 OP_VAR_MSYM_VALUE Objfile @0x1e41bf0, msymbol @0x7fffe599b000 (getenv) In the following patch, we'll make OP_FUNCALL extract the function name from the symbol stored in OP_VAR_VALUE/OP_VAR_MSYM_VALUE. OP_VAR_MSYM_VALUE will be used more in a later patch in the series too. gdb/ChangeLog: 2017-09-04 Pedro Alves <palves@redhat.com> * ada-lang.c (resolve_subexp): Handle OP_VAR_MSYM_VALUE. * ax-gdb.c (gen_msym_var_ref): New function. (gen_expr): Handle OP_VAR_MSYM_VALUE. * eval.c (evaluate_var_msym_value): New function. * eval.c (evaluate_subexp_standard): Handle OP_VAR_MSYM_VALUE. <OP_FUNCALL>: Extract function name from symbol/minsym and pass it to call_function_by_hand. * expprint.c (print_subexp_standard, dump_subexp_body_standard): Handle OP_VAR_MSYM_VALUE. (union exp_element) <msymbol>: New field. * minsyms.h (struct type): Forward declare. (find_minsym_type_and_address): Declare. * parse.c (write_exp_elt_msym): New function. (write_exp_msymbol): Delete, refactored as ... (find_minsym_type_and_address): ... this new function. (write_exp_msymbol): Reimplement using OP_VAR_MSYM_VALUE. (operator_length_standard, operator_check_standard): Handle OP_VAR_MSYM_VALUE. * std-operator.def (OP_VAR_MSYM_VALUE): New.
2017-09-04 21:21:13 +02:00
struct type;
/* Several lookup functions return both a minimal symbol and the
objfile in which it is found. This structure is used in these
cases. */
struct bound_minimal_symbol
{
/* The minimal symbol that was found, or NULL if no minimal symbol
was found. */
struct minimal_symbol *minsym;
/* If MINSYM is not NULL, then this is the objfile in which the
symbol is defined. */
struct objfile *objfile;
};
/* This header declares most of the API for dealing with minimal
symbols and minimal symbol tables. A few things are declared
elsewhere; see below.
A minimal symbol is a symbol for which there is no direct debug
information. For example, for an ELF binary, minimal symbols are
created from the ELF symbol table.
For the definition of the minimal symbol structure, see struct
minimal_symbol in symtab.h.
Minimal symbols are stored in tables attached to an objfile; see
objfiles.h for details. Code should generally treat these tables
as opaque and use functions provided by minsyms.c to inspect them.
*/
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
struct msym_bunch;
/* An RAII-based object that is used to record minimal symbols while
they are being read. */
class minimal_symbol_reader
{
public:
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
/* Prepare to start collecting minimal symbols. This should be
called by a symbol reader to initialize the minimal symbol
module. */
explicit minimal_symbol_reader (struct objfile *);
~minimal_symbol_reader ();
/* Install the minimal symbols that have been collected into the
given objfile. */
void install ();
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
/* Record a new minimal symbol. This is the "full" entry point;
simpler convenience entry points are also provided below.
This returns a new minimal symbol. It is ok to modify the returned
minimal symbol (though generally not necessary). It is not ok,
though, to stash the pointer anywhere; as minimal symbols may be
moved after creation. The memory for the returned minimal symbol
is still owned by the minsyms.c code, and should not be freed.
Arguments are:
NAME - the symbol's name
NAME_LEN - the length of the name
COPY_NAME - if true, the minsym code must make a copy of NAME. If
false, then NAME must be NUL-terminated, and must have a lifetime
that is at least as long as OBJFILE's lifetime.
ADDRESS - the address of the symbol
MS_TYPE - the type of the symbol
SECTION - the symbol's section
*/
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
struct minimal_symbol *record_full (const char *name,
int name_len,
bool copy_name,
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
CORE_ADDR address,
enum minimal_symbol_type ms_type,
int section);
/* Like record_full, but:
- uses strlen to compute NAME_LEN,
- passes COPY_NAME = true,
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
- and passes a default SECTION, depending on the type
This variant does not return the new symbol. */
void record (const char *name, CORE_ADDR address,
enum minimal_symbol_type ms_type);
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
/* Like record_full, but:
- uses strlen to compute NAME_LEN,
- passes COPY_NAME = true. */
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
struct minimal_symbol *record_with_info (const char *name,
CORE_ADDR address,
enum minimal_symbol_type ms_type,
int section)
{
return record_full (name, strlen (name), true, address, ms_type, section);
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
}
private:
/* No need for these. They are intentionally not defined anywhere. */
minimal_symbol_reader &operator=
(const minimal_symbol_reader &);
minimal_symbol_reader (const minimal_symbol_reader &);
struct objfile *m_objfile;
Record minimal symbols directly in reader. This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
2016-09-22 22:25:08 +02:00
/* Bunch currently being filled up.
The next field points to chain of filled bunches. */
struct msym_bunch *m_msym_bunch;
/* Number of slots filled in current bunch. */
int m_msym_bunch_index;
/* Total number of minimal symbols recorded so far for the
objfile. */
int m_msym_count;
};
/* Create the terminating entry of OBJFILE's minimal symbol table.
If OBJFILE->msymbols is zero, allocate a single entry from
OBJFILE->objfile_obstack; otherwise, just initialize
OBJFILE->msymbols[OBJFILE->minimal_symbol_count]. */
void terminate_minimal_symbol_table (struct objfile *objfile);
Fix setting-breakpoints regression on PPC64 (function descriptors) The recent-ish commit e5f25bc5d6db ('Fix "list ambiguous_variable"') caused a serious regression on PPC64. See <https://sourceware.org/ml/gdb-patches/2017-11/msg00666.html>. Basically, after that patch, GDB sets breakpoints in function descriptors instead of where the descriptors point to, which is incorrect. The problem is that GDB now only runs a minsym's address through gdbarch_convert_from_func_ptr_addr if msymbol_is_text returns true. However, if the symbol points to a function descriptor, msymbol_is_text is false since function descriptors are in fact outside the text section. The fix is to also run a non-text address through gdbarch_convert_from_func_ptr_addr, and if that detects that it was indeed a function descriptor, treat the resulting address as a function. While implementing that directly in linespec.c:minsym_found (where the bad msymbol_is_text check is) fixes the issue, I noticed that linespec.c:add_minsym has some code that also basically needs to do the same checks, however it's implemented differently. Also, add_minsym is calling find_pc_sect_line on non-function symbols, which also doesn't look right. So I introduced msymbol_is_function, so that we have a simple place to consider minsyms and function descriptors. And then, the only other use of msymbol_is_text is in find_function_alias_target, which turns out to also be incorrect. Changing that one to use msymbol_is_function, i.e., to consider function descriptors too fixes (on PPC64): -FAIL: gdb.base/symbol-alias.exp: p func_alias -FAIL: gdb.base/symbol-alias.exp: p *func_alias() +PASS: gdb.base/symbol-alias.exp: p func_alias +PASS: gdb.base/symbol-alias.exp: p *func_alias() And then after that, msymbol_is_text is no longer used anywhere, so it can be removed. Tested on x86_64 GNU/Linux, no regressions. Tested on PPC64 GNU/Linux and results compared to a testrun of e5f25bc5d6db^ (before the offending commit), also no regressions. (there's a couple new FAILs and some new symbol name matching unit tests are crashing, but that looks unrelated). gdb/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * linespec.c (minsym_found, add_minsym): Use msymbol_is_function. * minsyms.c (msymbol_is_text): Delete. (msymbol_is_function): New function. * minsyms.h (msymbol_is_text): Delete. (msymbol_is_function): New declaration. * symtab.c (find_function_alias_target): Use msymbol_is_function.
2017-11-29 20:25:58 +01:00
/* Return whether MSYMBOL is a function/method. If FUNC_ADDRESS_P is
non-NULL, and the MSYMBOL is a function, then *FUNC_ADDRESS_P is
set to the function's address, already resolved if MINSYM points to
a function descriptor. */
bool msymbol_is_function (struct objfile *objfile,
minimal_symbol *minsym,
CORE_ADDR *func_address_p = NULL);
Handle function aliases better (PR gdb/19487, errno printing) (Ref: https://sourceware.org/ml/gdb/2017-06/msg00048.html) This patch improves GDB support for function aliases defined with __attribute__ alias. For example, in the test added by this commit, there is no reference to "func_alias" in the debug info at all, only to "func"'s definition: $ nm ./testsuite/outputs/gdb.base/symbol-alias/symbol-alias | grep " func" 00000000004005ae t func 00000000004005ae T func_alias $ readelf -w ./testsuite/outputs/gdb.base/symbol-alias/symbol-alias | grep func -B 1 -A 8 <1><db>: Abbrev Number: 5 (DW_TAG_subprogram) <dc> DW_AT_name : (indirect string, offset: 0x111): func <e0> DW_AT_decl_file : 1 <e1> DW_AT_decl_line : 27 <e2> DW_AT_prototyped : 1 <e2> DW_AT_type : <0xf8> <e6> DW_AT_low_pc : 0x4005ae <ee> DW_AT_high_pc : 0xb <f6> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f8> DW_AT_GNU_all_call_sites: 1 So all GDB knows about "func_alias" is from the minsym (elf symbol): (gdb) p func_alias $1 = {<text variable, no debug info>} 0x4005ae <func> (gdb) ptype func_alias type = int () (gdb) p func $2 = {struct S *(void)} 0x4005ae <func> (gdb) ptype func type = struct S { int field1; int field2; } *(void) The result is that calling func_alias from the command line produces incorrect results. This is similar (though not exactly the same) to the glibc errno/__errno_location/__GI___errno_location situation. On glibc, errno is defined like this: extern int *__errno_location (void); #define errno (*__errno_location ()) with __GI___errno_location being an internal alias for __errno_location. On my system's libc (F23), I do see debug info for __errno_location, in the form of name vs linkage name: <1><95a5>: Abbrev Number: 18 (DW_TAG_subprogram) <95a6> DW_AT_external : 1 <95a6> DW_AT_name : (indirect string, offset: 0x2c26): __errno_location <95aa> DW_AT_decl_file : 1 <95ab> DW_AT_decl_line : 24 <95ac> DW_AT_linkage_name: (indirect string, offset: 0x2c21): __GI___errno_location <95b0> DW_AT_prototyped : 1 <95b0> DW_AT_type : <0x9206> <95b4> DW_AT_low_pc : 0x20f40 <95bc> DW_AT_high_pc : 0x11 <95c4> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <95c6> DW_AT_GNU_all_call_sites: 1 however that doesn't matter in practice, because GDB doesn't record demangled names anyway, and so we end up with the exact same situation covered by the testcase. So the fix is to make the expression parser find a debug symbol for the same address as the just-found minsym, when a lookup by name didn't find a debug symbol by name. We now get: (gdb) p func_alias $1 = {struct S *(void)} 0x4005ae <func> (gdb) p __errno_location $2 = {int *(void)} 0x7ffff6e92830 <__errno_location> I've made the test exercise variable aliases too, for completeness. Those already work correctly, because unlike for function aliases, GCC emits debug information for variable aliases. Tested on GNU/Linux. gdb/ChangeLog: 2017-08-21 Pedro Alves <palves@redhat.com> PR gdb/19487 * c-exp.y (variable production): Handle function aliases. * minsyms.c (msymbol_is_text): New function. * minsyms.h (msymbol_is_text): Declare. * symtab.c (find_function_alias_target): New function. * symtab.h (find_function_alias_target): Declare. gdb/testsuite/ChangeLog: 2017-08-21 Pedro Alves <palves@redhat.com> PR gdb/19487 * gdb.base/symbol-alias.c: New. * gdb.base/symbol-alias2.c: New. * gdb.base/symbol-alias.exp: New.
2017-08-21 12:34:32 +02:00
/* Compute a hash code for the string argument. */
unsigned int msymbol_hash (const char *);
/* Like msymbol_hash, but compute a hash code that is compatible with
strcmp_iw. */
unsigned int msymbol_hash_iw (const char *);
/* Compute the next hash value from previous HASH and the character C. This
is only a GDB in-memory computed value with no external files compatibility
requirements. */
#define SYMBOL_HASH_NEXT(hash, c) \
((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113)
/* Look through all the current minimal symbol tables and find the
first minimal symbol that matches NAME. If OBJF is non-NULL, limit
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
the search to that objfile. If SFILE is non-NULL, the only
file-scope symbols considered will be from that source file (global
symbols are still preferred). Returns a bound minimal symbol that
matches, or an empty bound minimal symbol if no match is found. */
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol lookup_minimal_symbol (const char *,
const char *,
struct objfile *);
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
/* Like lookup_minimal_symbol, but searches all files and
objfiles. */
remove msymbol_objfile This is another patch in my ongoing series to "split" objfile to share more read-only data across inferiors. See http://sourceware.org/gdb/wiki/ObjfileSplitting When symbols are finally shared, there will be no back-link from the symbol to its containing objfile, because there may be more than one such objfile. So, all such back-links must be removed. One hidden back-link is the msymbol_objfile function. Since (eventually) a symbol may appear in more than one objfile, trying to look up the objfile given just a symbol cannot work. This patch removes msymbol_objfile in favor of using a bound minimal symbol. It introduces a new function to make this conversion simpler in some spots. The bonus of this patch is that using msymbol_objfile is slower than simply looking up the owning objfile in the first place. Built and regtested on x86-64 Fedora 18. * ada-exp.y (write_var_or_type): Use bound_minimal_symbol. * ada-lang.c (ada_lookup_simple_minsym): Return bound_minimal_symbol. * ada-lang.h (ada_lookup_simple_minsym): Update. * c-exp.y (variable): Use lookup_bound_minimal_symbol. * f-exp.y (variable): Use lookup_bound_minimal_symbol. * go-exp.y (variable): Use lookup_bound_minimal_symbol. * jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol. * m2-exp.y (variable): Use lookup_bound_minimal_symbol. * minsyms.c (msymbol_objfile): Remove. (lookup_minimal_symbol_internal): New function, from lookup_minimal_symbol. (lookup_minimal_symbol): Rewrite using lookup_minimal_symbol_internal. (lookup_bound_minimal_symbol): New function. * minsyms.h (msymbol_objfile): Remove. (lookup_bound_minimal_symbol): Declare. * p-exp.y (variable): Use lookup_bound_minimal_symbol. * parse.c (write_exp_msymbol): Change parameter to a bound_minimal_symbol. (write_dollar_variable): Use lookup_bound_minimal_symbol. * parser-defs.h (write_exp_msymbol): Update. * printcmd.c (address_info): Use lookup_bound_minimal_symbol. * symfile.c (simple_read_overlay_table): Use lookup_bound_minimal_symbol. * symtab.c (skip_prologue_sal): Don't use msymbol_objfile. (search_symbols): Likewise. (print_msymbol_info): Take a bound_minimal_symbol argument. (symtab_symbol_info, rbreak_command): Update. * symtab.h (struct symbol_search) <msymbol>: Change type to bound_minimal_symbol. * valops.c (find_function_in_inferior): Use lookup_bound_minimal_symbol. * value.c (value_fn_field): Use lookup_bound_minimal_symbol.
2013-08-05 17:51:02 +02:00
struct bound_minimal_symbol lookup_bound_minimal_symbol (const char *);
/* Look through all the current minimal symbol tables and find the
first minimal symbol that matches NAME and has text type. If OBJF
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
is non-NULL, limit the search to that objfile. Returns a bound
minimal symbol that matches, or an "empty" bound minimal symbol
otherwise.
This function only searches the mangled (linkage) names. */
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol lookup_minimal_symbol_text (const char *,
struct objfile *);
/* Look through all the current minimal symbol tables and find the
first minimal symbol that matches NAME and is a solib trampoline.
If OBJF is non-NULL, limit the search to that objfile. Returns a
pointer to the minimal symbol that matches, or NULL if no match is
found.
This function only searches the mangled (linkage) names. */
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol lookup_minimal_symbol_solib_trampoline
(const char *,
struct objfile *);
/* Look through all the current minimal symbol tables and find the
first minimal symbol that matches NAME and PC. If OBJF is non-NULL,
limit the search to that objfile. Returns a pointer to the minimal
symbol that matches, or NULL if no match is found. */
struct minimal_symbol *lookup_minimal_symbol_by_pc_name
(CORE_ADDR, const char *, struct objfile *);
Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer) When we're stepping (with "step"), we want to skip trampoline-like functions automatically, including GNU ifunc resolvers. That is done by infrun.c calling into: in_solib_dynsym_resolve_code -> svr4_in_dynsym_resolve_code -> in_gnu_ifunc_stub A problem here is that if there's a regular text symbol at the same address as the ifunc symbol, the minimal symbol lookup in in_gnu_ifunc_stub may miss the GNU ifunc symbol: (...) 41: 000000000000071a 53 FUNC GLOBAL DEFAULT 11 gnu_ifunc_resolver (...) 50: 000000000000071a 53 IFUNC GLOBAL DEFAULT 11 gnu_ifunc (...) This causes this FAIL in the tests added later in the series: (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: resolver received HWCAP set step-mode on (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: set step-mode on step 0x00007ffff7bd371a in gnu_ifunc_resolver () from build/gdb/testsuite/outputs/gdb.base/gnu-ifunc/gnu-ifunc-lib-1-0-0.so (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: step Above, GDB simply thought that it stepped into a regular function, so it stopped stepping, while it should have continued stepping past the resolver. The fix is to teach minimal symbol lookup to prefer GNU ifunc symbols if desired. gdb/ChangeLog: 2018-04-26 Pedro Alves <palves@redhat.com> * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Rename to ... (lookup_minimal_symbol_by_pc_section): ... this. Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter. Handle it. (lookup_minimal_symbol_by_pc_section): Delete old implementation. (lookup_minimal_symbol_by_pc): Adjust. (in_gnu_ifunc_stub): Prefer GNU ifunc symbols. (lookup_solib_trampoline_symbol_by_pc): Adjust. * minsyms.h (lookup_msym_prefer): New enum. (lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter.
2018-04-26 14:01:27 +02:00
enum class lookup_msym_prefer
{
/* Prefer mst_text symbols. */
TEXT,
/* Prefer mst_solib_trampoline symbols when there are text and
trampoline symbols at the same address. Otherwise prefer
mst_text symbols. */
TRAMPOLINE,
/* Prefer mst_text_gnu_ifunc symbols when there are text and ifunc
symbols at the same address. Otherwise prefer mst_text
symbols. */
GNU_IFUNC,
};
/* Search through the minimal symbol table for each objfile and find
the symbol whose address is the largest address that is still less
than or equal to PC, and which matches SECTION.
If SECTION is NULL, this uses the result of find_pc_section
instead.
The result has a non-NULL 'minsym' member if such a symbol is
Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer) When we're stepping (with "step"), we want to skip trampoline-like functions automatically, including GNU ifunc resolvers. That is done by infrun.c calling into: in_solib_dynsym_resolve_code -> svr4_in_dynsym_resolve_code -> in_gnu_ifunc_stub A problem here is that if there's a regular text symbol at the same address as the ifunc symbol, the minimal symbol lookup in in_gnu_ifunc_stub may miss the GNU ifunc symbol: (...) 41: 000000000000071a 53 FUNC GLOBAL DEFAULT 11 gnu_ifunc_resolver (...) 50: 000000000000071a 53 IFUNC GLOBAL DEFAULT 11 gnu_ifunc (...) This causes this FAIL in the tests added later in the series: (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: resolver received HWCAP set step-mode on (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: set step-mode on step 0x00007ffff7bd371a in gnu_ifunc_resolver () from build/gdb/testsuite/outputs/gdb.base/gnu-ifunc/gnu-ifunc-lib-1-0-0.so (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: step Above, GDB simply thought that it stepped into a regular function, so it stopped stepping, while it should have continued stepping past the resolver. The fix is to teach minimal symbol lookup to prefer GNU ifunc symbols if desired. gdb/ChangeLog: 2018-04-26 Pedro Alves <palves@redhat.com> * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Rename to ... (lookup_minimal_symbol_by_pc_section): ... this. Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter. Handle it. (lookup_minimal_symbol_by_pc_section): Delete old implementation. (lookup_minimal_symbol_by_pc): Adjust. (in_gnu_ifunc_stub): Prefer GNU ifunc symbols. (lookup_solib_trampoline_symbol_by_pc): Adjust. * minsyms.h (lookup_msym_prefer): New enum. (lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter.
2018-04-26 14:01:27 +02:00
found, or NULL if PC is not in a suitable range.
See definition of lookup_msym_prefer for description of PREFER. By
default mst_text symbols are preferred. */
struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section
Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer) When we're stepping (with "step"), we want to skip trampoline-like functions automatically, including GNU ifunc resolvers. That is done by infrun.c calling into: in_solib_dynsym_resolve_code -> svr4_in_dynsym_resolve_code -> in_gnu_ifunc_stub A problem here is that if there's a regular text symbol at the same address as the ifunc symbol, the minimal symbol lookup in in_gnu_ifunc_stub may miss the GNU ifunc symbol: (...) 41: 000000000000071a 53 FUNC GLOBAL DEFAULT 11 gnu_ifunc_resolver (...) 50: 000000000000071a 53 IFUNC GLOBAL DEFAULT 11 gnu_ifunc (...) This causes this FAIL in the tests added later in the series: (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: resolver received HWCAP set step-mode on (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: set step-mode on step 0x00007ffff7bd371a in gnu_ifunc_resolver () from build/gdb/testsuite/outputs/gdb.base/gnu-ifunc/gnu-ifunc-lib-1-0-0.so (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: step Above, GDB simply thought that it stepped into a regular function, so it stopped stepping, while it should have continued stepping past the resolver. The fix is to teach minimal symbol lookup to prefer GNU ifunc symbols if desired. gdb/ChangeLog: 2018-04-26 Pedro Alves <palves@redhat.com> * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Rename to ... (lookup_minimal_symbol_by_pc_section): ... this. Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter. Handle it. (lookup_minimal_symbol_by_pc_section): Delete old implementation. (lookup_minimal_symbol_by_pc): Adjust. (in_gnu_ifunc_stub): Prefer GNU ifunc symbols. (lookup_solib_trampoline_symbol_by_pc): Adjust. * minsyms.h (lookup_msym_prefer): New enum. (lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter.
2018-04-26 14:01:27 +02:00
(CORE_ADDR,
struct obj_section *,
lookup_msym_prefer prefer = lookup_msym_prefer::TEXT);
/* Backward compatibility: search through the minimal symbol table
for a matching PC (no section given).
This is a wrapper that calls lookup_minimal_symbol_by_pc_section
with a NULL section argument. */
struct bound_minimal_symbol lookup_minimal_symbol_by_pc (CORE_ADDR);
/* Iterate over all the minimal symbols in the objfile OBJF which
match NAME. Both the ordinary and demangled names of each symbol
are considered. The caller is responsible for canonicalizing NAME,
should that need to be done.
For each matching symbol, CALLBACK is called with the symbol. */
void iterate_over_minimal_symbols
(struct objfile *objf, const lookup_name_info &name,
Calling ifunc functions when resolver has debug info, user symbol same name If the GNU ifunc resolver has the same name as the user visible symbol, and the resolver has debug info, then the DWARF info for the resolver masks the ifunc minsym. In that scenario, if you try calling the ifunc from GDB, you call the resolver instead. With the gnu-ifunc.exp testcase added in a following patch, you'd see: (gdb) p gnu_ifunc (3) $1 = (int (*)(int)) 0x400753 <final> (gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=1: resolved_debug=0: p gnu_ifunc (3) ^^^^^^^^^^^^^^^^ That is, we called the ifunc resolver manually, which returned a pointer to the ifunc target function ("final"). The "final" symbol is the function that GDB should have called automatically, ~~~~~~~~~~~~ int final (int arg) { return arg + 1; } ~~~~~~~~~ which is what happens if you don't have debug info for the resolver: (gdb) p gnu_ifunc (3) $1 = 4 (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=0: resolver_debug=0: resolved_debug=1: p gnu_ifunc (3) ^^^^^^^^^^^^^^^^ or if the resolver's symbol has a different name from the ifunc (as is the case with modern uses of ifunc via __attribute__ ifunc, such as glibc uses): (gdb) p gnu_ifunc (3) $1 = 4 (gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=1: resolved_debug=0: p gnu_ifunc (3) ^^^^^^^^^^^^^^^ in which case after this patch, you can still call the resolver directly if you want: (gdb) p gnu_ifunc_resolver (3) $1 = (int (*)(int)) 0x400753 <final> gdb/ChangeLog: 2018-04-26 Pedro Alves <palves@redhat.com> * c-exp.y (variable production): Prefer ifunc minsyms over regular function symbols. * symtab.c (find_gnu_ifunc): New function. * minsyms.h (lookup_msym_prefer): New enum. (lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline' parameter by a lookup_msym_prefer parameter. * symtab.h (find_gnu_ifunc): New declaration.
2018-04-26 14:01:26 +02:00
gdb::function_view<bool (struct minimal_symbol *)> callback);
/* Compute the upper bound of MINSYM. The upper bound is the last
address thought to be part of the symbol. If the symbol has a
size, it is used. Otherwise use the lesser of the next minimal
symbol in the same section, or the end of the section, as the end
of the function. */
CORE_ADDR minimal_symbol_upper_bound (struct bound_minimal_symbol minsym);
Introduce OP_VAR_MSYM_VALUE The previous patch left GDB with an inconsistency. While with normal expression evaluation the "unknown return type" error shows the name of the function that misses debug info: (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type ^^^^^^ which can by handy in more complicated expressions, "ptype" does not: (gdb) ptype getenv ("PATH") function has unknown return type; cast the call to its declared return type ^^^^^^^^ This commit is a step toward fixing it. The problem is that while evaluating the expression above, we have no reference to the minimal symbol where we could extract the name from. This is because the resulting expression tree has no reference to the minsym at all. During parsing, the type and address of the minsym are extracted and an UNOP_MEMVAL / UNOP_MEMVAL_TLS operator is generated (see write_exp_elt_msym). With "set debug expression", here's what you see: 0 OP_FUNCALL Number of args: 0 3 UNOP_MEMVAL Type @0x565334a51930 (<text variable, no debug info>) 6 OP_LONG Type @0x565334a51c60 (__CORE_ADDR), value 140737345035648 (0x7ffff7751d80) The "print" case finds the function name, because call_function_by_hand looks up the function by address again. However, for "ptype", we don't reach that code, because obviously we don't really call the function. Unlike minsym references, references to variables with debug info have a pointer to the variable's symbol in the expression tree, with OP_VAR_VALUE: (gdb) ptype main() ... 0 OP_FUNCALL Number of args: 0 3 OP_VAR_VALUE Block @0x0, symbol @0x559bbbd9b358 (main(int, char**)) ... so I don't see why do minsyms need to be different. So to prepare for fixing the missing function name issue, this commit adds a new OP_VAR_MSYM_VALUE operator that mimics OP_VAR_VALUE, except that it's for minsyms instead of debug symbols. For infcalls, we now get expressions like these: 0 OP_FUNCALL Number of args: 0 3 OP_VAR_MSYM_VALUE Objfile @0x1e41bf0, msymbol @0x7fffe599b000 (getenv) In the following patch, we'll make OP_FUNCALL extract the function name from the symbol stored in OP_VAR_VALUE/OP_VAR_MSYM_VALUE. OP_VAR_MSYM_VALUE will be used more in a later patch in the series too. gdb/ChangeLog: 2017-09-04 Pedro Alves <palves@redhat.com> * ada-lang.c (resolve_subexp): Handle OP_VAR_MSYM_VALUE. * ax-gdb.c (gen_msym_var_ref): New function. (gen_expr): Handle OP_VAR_MSYM_VALUE. * eval.c (evaluate_var_msym_value): New function. * eval.c (evaluate_subexp_standard): Handle OP_VAR_MSYM_VALUE. <OP_FUNCALL>: Extract function name from symbol/minsym and pass it to call_function_by_hand. * expprint.c (print_subexp_standard, dump_subexp_body_standard): Handle OP_VAR_MSYM_VALUE. (union exp_element) <msymbol>: New field. * minsyms.h (struct type): Forward declare. (find_minsym_type_and_address): Declare. * parse.c (write_exp_elt_msym): New function. (write_exp_msymbol): Delete, refactored as ... (find_minsym_type_and_address): ... this new function. (write_exp_msymbol): Reimplement using OP_VAR_MSYM_VALUE. (operator_length_standard, operator_check_standard): Handle OP_VAR_MSYM_VALUE. * std-operator.def (OP_VAR_MSYM_VALUE): New.
2017-09-04 21:21:13 +02:00
/* Return the type of MSYMBOL, a minimal symbol of OBJFILE. If
ADDRESS_P is not NULL, set it to the MSYMBOL's resolved
address. */
type *find_minsym_type_and_address (minimal_symbol *msymbol, objfile *objf,
CORE_ADDR *address_p);
#endif /* MINSYMS_H */