/* Symbol table definitions for GDB.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
section_offsets for this objfile. Negative means that the symbol
does not get relocated relative to a section. */
- short section;
+ short m_section;
+
+ /* Set the index into the obj_section list (within the containing
+ objfile) for the section that contains this symbol. See M_SECTION
+ for more details. */
+
+ void set_section_index (short idx)
+ { m_section = idx; }
+
+ /* Return the index into the obj_section list (within the containing
+ objfile) for the section that contains this symbol. See M_SECTION
+ for more details. */
+
+ short section_index () const
+ { return m_section; }
+
+ /* Return the obj_section from OBJFILE for this symbol. The symbol
+ returned is based on the SECTION member variable, and can be nullptr
+ if SECTION is negative. */
+
+ struct obj_section *obj_section (const struct objfile *objfile) const;
};
extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
#define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
-#define SYMBOL_SECTION(symbol) (symbol)->section
-#define SYMBOL_OBJ_SECTION(objfile, symbol) \
- (((symbol)->section >= 0) \
- ? (&(((objfile)->sections)[(symbol)->section])) \
- : NULL)
/* Try to determine the demangled name for a symbol, based on the
language of that symbol. If the language is set to language_auto,
#define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \
(((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol) \
: ((symbol)->value.address \
- + (objfile)->section_offsets[(symbol)->section]))
+ + (objfile)->section_offsets[(symbol)->section_index ()]))
/* For a bound minsym, we can easily compute the address directly. */
#define BMSYMBOL_VALUE_ADDRESS(symbol) \
MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
#define MSYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes
#define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
#define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
-#define MSYMBOL_SECTION(symbol) (symbol)->section
-#define MSYMBOL_OBJ_SECTION(objfile, symbol) \
- (((symbol)->section >= 0) \
- ? (&(((objfile)->sections)[(symbol)->section])) \
- : NULL)
#include "minsyms.h"
void (*generate_c_location) (struct symbol *symbol, string_file *stream,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
CORE_ADDR pc, const char *result_name);
};
language_specific.obstack = nullptr;
m_language = language_unknown;
ada_mangled = 0;
- section = -1;
+ m_section = -1;
/* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
initialization of unions, so we initialize it manually here. */
owner.symtab = nullptr;
}
symbol (const symbol &) = default;
+ symbol &operator= (const symbol &) = default;
/* Data type of value */
std::vector<bound_minimal_symbol> m_minimal_symbols;
};
+/* Class used to encapsulate the filename filtering for the "info sources"
+ command. */
+
+struct info_sources_filter
+{
+ /* If filename filtering is being used (see M_C_REGEXP) then which part
+ of the filename is being filtered against? */
+ enum class match_on
+ {
+ /* Match against the full filename. */
+ FULLNAME,
+
+ /* Match only against the directory part of the full filename. */
+ DIRNAME,
+
+ /* Match only against the basename part of the full filename. */
+ BASENAME
+ };
+
+ /* Create a filter of MATCH_TYPE using regular expression REGEXP. If
+ REGEXP is nullptr then all files will match the filter and MATCH_TYPE
+ is ignored.
+
+ The string pointed too by REGEXP must remain live and unchanged for
+ this lifetime of this object as the object only retains a copy of the
+ pointer. */
+ info_sources_filter (match_on match_type, const char *regexp);
+
+ DISABLE_COPY_AND_ASSIGN (info_sources_filter);
+
+ /* Does FULLNAME match the filter defined by this object, return true if
+ it does, otherwise, return false. If there is no filtering defined
+ then this function will always return true. */
+ bool matches (const char *fullname) const;
+
+private:
+
+ /* The type of filtering in place. */
+ match_on m_match_type;
+
+ /* Points to the original regexp used to create this filter. */
+ const char *m_regexp;
+
+ /* A compiled version of M_REGEXP. This object is only given a value if
+ M_REGEXP is not nullptr and is not the empty string. */
+ gdb::optional<compiled_regex> m_c_regexp;
+};
+
+/* Perform the core of the 'info sources' command.
+
+ FILTER is used to perform regular expression based filtering on the
+ source files that will be displayed.
+
+ Output is written to UIOUT in CLI or MI style as appropriate. */
+
+extern void info_sources_worker (struct ui_out *uiout,
+ bool group_by_objfile,
+ const info_sources_filter &filter);
+
#endif /* !defined(SYMTAB_H) */