Commit Graph

104359 Commits

Author SHA1 Message Date
Andrew Burgess
ed5797ee2c gdb/objc: fix bug in objc_language::opcode_print_table
In this commit:

  commit b7c6e27dbb
  Date:   Tue Aug 4 17:07:59 2020 +0100

      gdb: Convert language_data::la_op_print_tab to a method

A bug was introduced, the objc language now returns the wrong op_print
table.  Fixed in this commit.

gdb/ChangeLog:

	* objc-lang.c (objc_language::opcode_print_table): Return
	objc_op_print_tab.
2020-12-23 20:53:14 +00:00
Andrew Burgess
46157d77c3 gdb: move pascal_language into p-lang.h
Move the pascal_language class declaration into the p-lang.h header
file.  This allows for the function implementations to be spread over
the different p-*.c files without the need for global trampoline
functions.

As a consequence of this change many of the Pascal value and type
printing helper functions have become member functions within the
pascal_language class.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* p-exp.y (exp): Update call to pascal_is_string_type.
	(pascal_parse): Rename to...
	(pascal_language::parser): ...this.
	* p-lang.c (is_pascal_string_type): Rename to...
	(pascal_is_string_type): ...this.
	(pascal_one_char): Rename to...
	(pascal_language::print_one_char): ...this.
	(pascal_printchar): Rename to...
	(pascal_language::printchar): ...this.  Update call to
	print_one_char member function.
	(pascal_op_print_tab): Rename to...
	(pascal_language::op_print_tab): ...this.
	(class pascal_language): Moved to p-lang.h.
	(pascal_language::language_arch_info): Function implementation
	moved out of class declaration.
	(pascal_language::printstr): Likewise.
	* p-lang.h (pascal_parse): Delete declaration.
	(pascal_is_string_type): Declare.
	(pascal_print_type): Delete declaration.
	(pascal_print_typedef): Delete declaration.
	(pascal_value_print_inner): Delete declaration.
	(pascal_value_print): Delete declaration.
	(pascal_type_print_method_args): Delete declaration.
	(is_pascal_string_type): Delete declaration.
	(pascal_printchar): Delete declaration.
	(pascal_builtin_types): Delete declaration.
	(pascal_type_print_base): Delete declaration.
	(pascal_type_print_varspec_prefix): Delete declaration.
	(class pascal_language): Moved here from p-lang.c.
	* p-typeprint.c (pascal_type_print_varspec_suffix): Delete
	declaration.
	(pascal_type_print_derivation_info): Delete declaration.
	(pascal_print_type): Rename to...
	(pascal_language::print_type): ...this.  Update calls to member
	functions.
	(pascal_print_typedef): Rename to...
	(pascal_language::print_typedef): ...this.  Update calls to member
	functions.
	(pascal_type_print_derivation_info): Rename to...
	(pascal_language::type_print_derivation_info): ...this.
	(pascal_type_print_method_args): Rename to...
	(pascal_language::type_print_method_args): ...this.
	(pascal_type_print_varspec_prefix): Rename to...
	(pascal_language::type_print_varspec_prefix): ...this.  Update
	calls to member functions.
	(pascal_print_func_args): Rename to...
	(pascal_language::print_func_args): ...this.  Update calls to
	member functions.
	(pascal_type_print_func_varspec_suffix): Rename to...
	(pascal_language::type_print_func_varspec_suffix): ...this.
	Update calls to member functions.
	(pascal_type_print_varspec_suffix): Rename to...
	(pascal_language::type_print_varspec_suffix): ...this.  Update
	calls to member functions.
	(pascal_type_print_base): Rename to...
	(pascal_language::type_print_base): ...this.  Update calls to
	member functions.
	* p-valprint.c (pascal_value_print_inner): Rename to...
	(pascal_language::value_print_inner): ...this.  Update calls to
	member functions.
	(pascal_value_print): Rename to...
	(pascal_language::value_print): ...this.  Update calls to member
	functions.
2020-12-23 20:53:14 +00:00
Andrew Burgess
82fc57fd6b gdb: move go_language class declaration into header file
Move the go_language class into go-lang.h, this allows us to have
member functions implemented directly in the different go-*.c files
instead of having to trampoline out to global functions.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* go-exp.y (go_parse): Rename to...
	(go_language::parser): ...this.
	* go-lang.c (go_demangle): Rename to...
	(go_language::demangle_symbol): ...this.
	(go_language::expression_ops): Implementation moved here out of
	class declaration.
	(go_op_print_tab): Rename to...
	(go_language::op_print_tab): ...this, update comment.
	(class go_language): Declaration moved to go-lang.h.
	(go_language::language_arch_info): Implementation moved here out
	of class declaration.
	* go-lang.h (go_parse): Delete declaration.
	(go_demangle): Delete declaration.
	(go_print_type): Delete declaration.
	(go_value_print_inner): Delete declaration.
	(class go_language): Declaration moved here from go-lang.c.
	* go-typeprint.c (go_print_type): Rename to...
	(go_language::print_type): ...this.
	* go-valprint.c (go_value_print_inner): Rename to...
	(go_language::value_print_inner): ...this.
	* symtab.c (demangle_for_lookup): Call demangle_symbol method on
	the go_language object.
2020-12-23 20:53:14 +00:00
Andrew Burgess
76ca72bc5b gdb: remove LA_EMIT_CHAR macro
Now that every use of the LA_EMIT_CHAR macro is within a language_defn
member function we can simply call the emitchar member function
directly instead of using the LA_EMIT_CHAR macro.

If we are ever inside a language object, for example, cplus_language,
while current_language points at something other than cplus_language
then this commit will result in a change in behaviour.  However, I
believe if we did have such a difference then this would be a bug in
GDB.  AS such I'm going to claim there _should_ be no user visible
changes from this commit.

gdb/ChangeLog:

	* c-lang.c (language_defn::printchar): Call emitchar, not
	LA_EMIT_CHAR.
	* f-lang.h (f_language::printchar): Likewise.
	* language.h (LA_EMIT_CHAR): Delete macro.
	* rust-lang.c (rust_language::printchar): Call emitchar, not
	LA_EMIT_CHAR.
2020-12-23 20:53:14 +00:00
Andrew Burgess
c5ee319e6c gdb: rename c_printchar as language_defn::printchar
This commit removes the global function c_printchar and moves the
implementation into language_defn::printchar.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* c-lang.c (c_printchar): Rename to...
	(language_defn::printchar): ...this.
	* c-lang.h (c_printchar): Delete declaration.
	* language.c (language_defn::printchar): Delete this
	implementation.  Is now implemented in c-lang.c.
2020-12-23 20:53:14 +00:00
Andrew Burgess
2c75ccb24c gdb: avoid accessing global C++ language implementation functions
The function c_printchar is called from two places; it provides the
implementation of language_defn::printchar and it is called from
dwarf2_compute_name.

It would be nice to rename c_printchar as language_defn::printchar and
so avoid the trampoline.

To achieve this, instead of calling c_printchar directly from the
DWARF code, I lookup the C++ language object and call the printchar
member function.

In a later commit I can then rename c_printchar.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* dwarf2/read.c (dwarf2_compute_name): Call methods on C++
	language object instead of calling global functions directly.
2020-12-23 20:53:14 +00:00
Andrew Burgess
016382f8a4 gdb: delete unused function print_char_chars
Spotted that print_char_chars appears to be unused, delete it.  There
should be no user visible changes after this commit.

gdb/ChangeLog:

	* valprint.c (print_char_chars): Delete definition.
	* valprint.h (print_char_chars): Delete declaration.
2020-12-23 20:53:14 +00:00
Samuel Thibault
05ecfa4726 Add myself to gdb/MAINTAINERS
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Add myself.
2020-12-23 17:22:17 +00:00
Samuel Thibault
06f6f78f62 hurd: Add changelog for dca11eb872 2020-12-23 17:19:27 +00:00
Samuel Thibault
dca11eb872 hurd: Fix getting VM_MIN/MAX_ADDRESS
gnu-nat.c was getting the inclusion of vm_param.h only by luck. We need
to explicitly include it to be sure to get the definitions of
VM_MIN/MAX_ADDRESS.

gdb/ChangeLog:

	* gnu-nat.c: Include <mach/vm_param.h>.
2020-12-23 16:56:36 +00:00
GDB Administrator
9423103f54 Automatic date update in version.in 2020-12-23 00:00:06 +00:00
Shahab Vahedi
e512699ac8 Remove trailing white spaces in gdb/frame.{c,h}
gdb/ChangeLog:

	* frame.c: Remove trailing white spaces.
	* frame.h: Likewise.
2020-12-23 00:52:45 +01:00
Shahab Vahedi
acf10cacc6 arc: Make variable name in comments uppercase
The word "regnum" in comments should be uppercase, because it
reflects a variable name in the code.

gdb/ChangeLog

	* arc-linux-tdep.c: Replace "regnum" with "REGNUM" in comments.
2020-12-22 12:27:00 +01:00
Anton Kolesov
04c9f85efc gdb: Add native support for ARC in GNU/Linux
With this patch in place it is possible to build a GDB that
can run on ARC (GNU/Linux) hosts for debugging ARC targets.

The "arc-linux-nat.c" is a rather small one that mostly deals
with registers and a few thread related hooks.

v2 [1]:
- Remove "void" from the input of "_initialize_arc_linux_nat ()"

[1] Tom's remark after the first patch
https://sourceware.org/pipermail/gdb-patches/2020-November/173223.html

gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add arc-linux-nat.c.
	* configure.host (host to gdb names): Add arc*-*-linux*.
	* configure.nat (gdb_host_cpu): Add arc.
	* arc-linux-nat.c: New.
2020-12-22 12:18:40 +01:00
Shahab Vahedi
46023bbe81 arc: Take into account the REGNUM in supply/collect gdb hooks
All the arc_linux_supply_*() target operations and the
arc_linux_collect_v2_regset() in arc-linux-tdep.c were
supplying/collecting all the registers in regcache as if the
REGNUM was set to -1.

The more efficient behavior is to examine the REGNUM and act
accordingly.  That is what this patch does.

gdb/ChangeLog:

	* arc-linux-tdep.c (supply_register): New.
	(arc_linux_supply_gregset, arc_linux_supply_v2_regset,
	arc_linux_collect_v2_regset): Consider REGNUM.
2020-12-22 12:16:17 +01:00
Anton Kolesov
d4af727286 arc: Add support for signal frames for Linux targets
Implement functions needed to unwind signal frames on ARC Linux targets.

gdb/ChangeLog

	* arc-linux-tdep.c (arc_linux_sc_reg_offsets): New static variable.
	(arc_linux_is_sigtramp): New function.
	(arc_linux_sigcontext_addr): Likewise.
	(arc_linux_init_osabi): Use them.
2020-12-22 12:05:19 +01:00
Anton Kolesov
b4e3cd0440 arc: Add support for signal handlers
This patch adds the necessary infrastructure to handle signal frames for
ARC architecture.  It is fairly similar to what any other architecture
would have.  Linux specific parts will be in a separate patch.

v2 [1]:
- Make the logic of "arc_sigtramp_frame_sniffer ()" simpler.

[1] Tom's remark for the first version
https://sourceware.org/pipermail/gdb-patches/2020-November/173221.html

gdb/ChangeLog:

	* arc-tdep.c (arc_make_sigtramp_frame_cache): New function.
	(arc_sigtramp_frame_this_id): Likewise.
	(arc_sigtramp_frame_prev_register): Likewise.
	(arc_sigtramp_frame_sniffer): Likewise.
	(arc_siftramp_frame_unwind): New global variable.
	(arc_gdbarch_init): Use sigtramp capabilities.
	(arc_dump_tdep): Print sigtramp fields.
	* arc-tdep.h (gdbarch_tdep): Add sigtramp fields.
2020-12-22 12:04:31 +01:00
GDB Administrator
6bf6909bf4 Automatic date update in version.in 2020-12-22 00:00:06 +00:00
Tom Tromey
6c078f0bfe Move enum noside earlier in expression.h
For the expression rewrite series, I needed to move enum noside
earlier in expression.h.  Because this is a pure move, and because it
seems harmless and uncontroversial to move an enum definition earlier
in a file, I'm pushing it in early, to reduce the size of that series.

Tested by rebuilding.

gdb/ChangeLog
2020-12-21  Tom Tromey  <tom@tromey.com>

	* expression.h (enum noside): Move earlier.
2020-12-21 12:55:53 -07:00
Peter Waller
e1ff6226d8 Preserve gdb_std{out, err, log, targ, targerr} across interpreter_exec_cmd
Calls through interpreter_exec_cmd can cause the output state to be modified in
a way which doesn't get back after the execution.

It looks like the intent is that interp::resume should put things back how they
should be, however, mi_interp::resume modifies gdb_stdout and nothing currently
restores it to the previous state.

To see the broken behaviour:

  gdb -ex starti -ex bt -ex 'interpreter-exec mi echo' -ex bt -ex q echo <<<''

Prior to this patch, on a terminal environment, the first backtrace is
coloured, and the second backtrace is not. The reason is that
stdio_file::can_emit_style_escape becomes false, because the gdb_stdout gets
overwritten in mi_interp::resume and not replaced.

gdb/ChangeLog:

	* interps.c (interpreter_exec_cmd): Restore streams pointers.

gdb/testsuite/ChangeLog:

	* gdb.base/style-interp-exec-mi.exp: New.
	* gdb.base/style-interp-exec-mi.c: New.

Signed-off-by: Peter Waller <p@pwaller.net>
Change-Id: Id87423b262d058857ea9dca5866ca6471741e512
2020-12-21 09:38:22 -05:00
Simon Marchi
ca01f1bf3d gdb/testsuite: use gdb_test in gdb.base/list.exp
Use gdb_test instead of send_gdb + gdb_expect.  Use proc_with_prefix to
help with name uniqueness.

gdb/testsuite/ChangeLog:

	* gdb.base/list.exp: Replace send_gdb + gdb_expect with
	  gdb_test.  Use proc_with_prefix.

Change-Id: Ieee8fb2c80f596f60397fab7633773a7f8c8c879
2020-12-21 09:16:44 -05:00
Markus Metzger
0fe69a94d4 testsuite, gdb.btrace: fix 32-bit PIE false positives
For 32-bit position independent executables, GCC generates an extra call to

    __x86.get_pc_thunk.<reg>

which appears in the function call history.  It is correct to appear there
but this confuses the tests, which check for an expected sequence of
functions.

Build with nopie to avoid this complication.

gdb/testsuite/ChangeLog:
2020-12-04  Markus Metzger  <markus.t.metzger@intel.com>

	* gdb.btrace/exception.exp: Build with nopie.
	* gdb.btrace/function_call_history.exp: Likewise.
	* gdb.btrace/unknown_functions.exp: Likewise.
2020-12-21 09:00:28 +01:00
Markus Metzger
806e7575e2 testsuite, gdb.btrace: skip multi-inferior.exp on gdbserver targets
The gdb.btrace/multi-inferior.exp test creates multiple inferiors to check
that recording is per-inferior.

When run with the native-gdbserver board, this test hangs when trying to
add the second inferior over the remote connection.  Skip the test.

Note that the test runs fine with the native-extended-gdbserver board file
and we want to keep testing that configuration.

gdb/testsuite/ChangeLog:
2020-12-11  Markus Metzger  <markus.t.metzger@intel.com>

	* gdb.btrace/multi-inferior.exp: Skip if use_gdb_stub.
2020-12-21 08:59:25 +01:00
Markus Metzger
493d2172ac testsuite, gdb.python: make py-record-*.exp test names unique
gdb/testsuite/ChangeLog:
2020-12-14  Markus Metzger  <markus.t.metzger@intel.com>

	* gdb.python/py-record-btrace.exp: Make test names unique.
	* gdb.python/py-record-full.exp: Likewise.
2020-12-21 08:58:25 +01:00
Markus Metzger
1a1c0afcee testsuite, gdb.btrace: make test names unique
gdb/testsuite/ChangeLog:
2020-12-04  Markus Metzger  <markus.t.metzger@intel.com>

	* gdb.btrace/data.exp: Make test names unique.
	* gdb.btrace/delta.exp: Likewise.
	* gdb.btrace/enable.exp: Likewise.
	* gdb.btrace/function_call_history.exp: Likewise.
	* gdb.btrace/nohist.exp: Likewise.
	* gdb.btrace/non-stop.exp: Likewise.
	* gdb.btrace/rn-dl-bind.exp: Likewise.
	* gdb.btrace/step.exp: Likewise.
	* gdb.btrace/stepi.exp: Likewise.
	* gdb.btrace/tailcall.exp: Likewise.
2020-12-21 08:57:37 +01:00
Markus Metzger
98d837f0ef gdb, record: rephrase the 'not recording' error message
When trying to use one of the record commands without having enabled
recording first, GDB gives the error message:

    (gdb) record function-call-history
    No record target is currently active.
    Use one of the "target record-<TAB><TAB>" commands first.

In the record help, however, we say:

    (gdb) help record
    record, rec
    Start recording.

    List of record subcommands:

    record btrace, record b -- Start branch trace recording.
    record delete, record del, record d -- Delete the rest of execution log and start recording it anew.
    record full -- Start full execution recording.
    record function-call-history -- Prints the execution history at function granularity.
    record goto -- Restore the program to its state at instruction number N.
    record instruction-history -- Print disassembled instructions stored in the execution log.
    record save -- Save the execution log to a file.
    record stop, record s -- Stop the record/replay target.

Change the above error message to

    (gdb) record function-call-history
    No recording is currently active.
    Use the "record full" or "record btrace" command first.

to align with the help text.

gdb/ChangeLog:
2020-12-03  Markus Metzger  <markus.t.metzger@intel.com>

	* record.c (require_record_target): Rephrase error message.
	(info_record_command): Likewise.

gdb/testsuite/ChangeLog:
2020-12-03  Markus Metzger  <markus.t.metzger@intel.com>

	* gdb.btrace/enable.exp: Update error message.
	* gdb.btrace/multi-inferior.exp: Likewise.
	* gdb.btrace/reconnect.exp: Likewise.
	* gdb.python/py-record-btrace.exp: Likewise.
	* gdb.python/py-record-full.exp: Likewise.
2020-12-21 08:56:26 +01:00
Joel Brobecker
904cb749cf gdb.texinfo: Document GMP as mandatory requirement to build GDB
gdb/doc/ChangeLog

        * gdb.texinfo (Requirements): Add GMP to list of requirements.
2020-12-21 06:21:41 +04:00
GDB Administrator
0335338177 Automatic date update in version.in 2020-12-21 00:00:06 +00:00
Tom de Vries
c541fa7c91 [gdb/testsuite] Add save_target_board_info
Add a proc save_target_board_info, similar to save_vars, such that we can do:
...
save_target_board_info { multilib_flags } {
    global board
    set board [target_info name]
    unset_board_info multilib_flags
    set_board_info multilib_flags "$override_multilib_flags"
    ...
}
...
and use it in gdb_compile_shlib.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-20  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (save_target_board_info): New proc.
	(gdb_compile_shlib): Use save_target_board_info.
2020-12-20 09:35:36 +01:00
GDB Administrator
3dc9a557a1 Automatic date update in version.in 2020-12-20 00:00:07 +00:00
H.J. Lu
97aac4ec32 gold: Move sym declaration just before use
Move sym declaration just before use to avoid -Wmaybe-uninitialized
warning from GCC 11.

	PR gold/27097
	* incremental.cc (Sized_relobj_incr::do_add_symbols): Move sym
	declaration just before use.
	(Sized_incr_dynobj::do_add_symbols): Likewise.
	* plugin.cc (Sized_pluginobj::do_add_symbols): Likewise.
2020-12-19 13:37:04 -08:00
Tom de Vries
60108e47b5 [gdb/testsuite] Introduce supports_scalar_storage_order_attribute
Introduce support test procs:
- supports_scalar_storage_order_attribute, and
- supports_gnuc
and use them in test-case gdb.base/endianity.exp.

Tested on x86_64-linux with gcc-7.5.0, gcc-4.8.5, and clang 10.0.1.

gdb/testsuite/ChangeLog:

2020-12-19  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (supports_scalar_storage_order_attribute)
	(supports_gnuc): New proc.
	* gdb.base/endianity.exp: Define TEST_SSO.  Eliminate
	test_compiler_info calls.  Add unsupported message.
	* gdb.base/endianity.c: Use TEST_SSO.
2020-12-19 16:43:17 +01:00
Hannes Domani
fa639f555a Don't compare types of enum fields
Comparing types of enum fields results in a crash, because they don't
have a type.

It can be reproduced by comparing the types of 2 instances of the same
enum type in different objects:

enum.h:

    enum e
    {
      zero,
      one,
    };

enum-1.c:

    #include <enum.h>
    int func();
    enum e e1;
    int main()
    {
      return e1 + func();
    }

enum-2.c:

    #include <enum.h>
    enum e e2;
    int func()
    {
      return e2;
    }

$ gcc -g -oenum enum-1.c enum-2.c
$ gdb -q enum.exe
Reading symbols from enum.exe...
(gdb) py print(gdb.parse_and_eval("e1").type==gdb.parse_and_eval("e2").type)

Thread 1 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 6184.0x1cc4]
check_typedef (type=0x0) at C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:2745
2745      while (type->code () == TYPE_CODE_TYPEDEF)

gdb/ChangeLog:

2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

	PR exp/27070
	* gdbtypes.c (check_types_equal): Don't compare types of enum fields.

gdb/testsuite/ChangeLog:

2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

	PR exp/27070
	* gdb.python/compare-enum-type-a.c: New test.
	* gdb.python/compare-enum-type-b.c: New test.
	* gdb.python/compare-enum-type.exp: New file.
	* gdb.python/compare-enum-type.h: New test.
2020-12-19 13:41:44 +01:00
Bernd Edlinger
0455b7d325 Warn about static libs vs. source-highlight only when necessary
Avoid the error message when source-highlight is actually available.

2020-12-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* configure.ac: Move the static libs vs. source-highlight
	error message to a better place.
	* configure: Regenerate.
2020-12-19 09:21:07 +01:00
GDB Administrator
a24e049847 Automatic date update in version.in 2020-12-19 00:00:06 +00:00
Hannes Domani
e51765f932 Fix name of main_type field type in pretty printer
It was renamed from type to m_type.

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* gdb-gdb.py.in: Fix main_type field name.
2020-12-18 22:06:01 +01:00
Hannes Domani
e846045952 Remove erroneous 'a' in gdb.register_window_type documentation
gdb/doc/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* python.texi (TUI Windows In Python): Remove erroneous 'a'.
2020-12-18 22:05:14 +01:00
Hannes Domani
4aea001fd8 Add address keyword to Value.format_string
This makes it possible to disable the address in the result string:

const char *str = "alpha";

(gdb) py print(gdb.parse_and_eval("str").format_string())
0x404000 "alpha"
(gdb) py print(gdb.parse_and_eval("str").format_string(address=False))
"alpha"

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* python/py-value.c (valpy_format_string): Implement address keyword.

gdb/doc/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* python.texi (Values From Inferior): Document the address keyword.

gdb/testsuite/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* gdb.python/py-format-string.exp: Add tests for address keyword.
2020-12-18 22:04:16 +01:00
Hannes Domani
b3f9469bfa Fix accessing a method's fields from Python
Considering this example:

struct C
{
  int func() { return 1; }
} c;
int main()
{
  return c.func();
}

Accessing the fields of C::func, when requesting the function by its
type, works:

(gdb) py print(gdb.parse_and_eval('C::func').type.fields()[0].type)
C * const

But when trying to do the same via a class instance, it fails:

(gdb) py print(gdb.parse_and_eval('c')['func'].type.fields()[0].type)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Type is not a structure, union, enum, or function type.
Error while executing Python code.

The difference is that in the former the function type is TYPE_CODE_FUNC:

(gdb) py print(gdb.parse_and_eval('C::func').type.code == gdb.TYPE_CODE_FUNC)
True

And in the latter the function type is TYPE_CODE_METHOD:

(gdb) py print(gdb.parse_and_eval('c')['func'].type.code == gdb.TYPE_CODE_METHOD)
True

So this adds the functionality for TYPE_CODE_METHOD as well.

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* python/py-type.c (typy_get_composite): Add TYPE_CODE_METHOD.

gdb/testsuite/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

	* gdb.python/py-type.exp: Add tests for TYPE_CODE_METHOD.
2020-12-18 22:02:13 +01:00
Jameson Nash
a9e48095a8 gdb: define COFF file offsets with file_ptr
The arguments to these functions are file_ptr, so these declarations
were accidentally implicitly down-casting them to signed int. This
allows for reading files between 2 and 4 GB in size in my testing (I
don't have a larger dll currently to test). These may not be natively
supported by Windows, but can appear when using split-dwarf information.

This solves a "can't get string table" error resulting from attempting
to pass a negative offset to bfd_seek. I encountered this occuring while
trying to use a debug file for libLLVM.dll, but searching online reveals
at least one other person may have run into a similar problem with
Firefox?

    https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CA+cU71k2bU0azQxjy4-77ynQj1O+TKmgtaTKe59n7Bjub1y7Tg@mail.gmail.com/

With this patch, the debug file appears to load successfully and I can
see debug information in gdb for the library.

gdb/ChangeLog:

	* coffread.c (linetab_offset): Change type to file_ptr.
	(linetab_size): Likewise.
	(enter_linenos): Change parameter type to file_ptr.
	(init_lineno): Likewise.
	(init_stringtab): Likewise.
	(coff_symtab_read): Likewise.
	(coff_symfile_read): Change variable types to file_ptr.

Change-Id: I6ae3bf31efc51c826734ade6731ea6b1c32129f3
2020-12-18 14:09:05 -05:00
Tom Tromey
86ef42bd73 Run fixed_points.exp with -fgnat-encodings=minimal
This changes the test case gdb.ada/fixed_points.exp to also be run
with -fgnat-encodings=minimal.  This change pointed out that the test
case had a few incorrect expected outputs; these are fixed as well.

Note that the Overprecise_Object test only uses the non-legacy output
with GCC trunk.

gdb/testsuite/ChangeLog
2020-12-18  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/fixed_points.exp: Also run with
	-fgnat-encodings=minimal.  Update expected output.
2020-12-18 11:21:40 -07:00
H.J. Lu
eba7b68cb0 ld: Build and install only unversioned libdep
Build only unversioned libdep and remove the installed libdep.la since
only a single libdep.so is needed.

	PR ld/27082
	* Makefile.am
	(libdep_la_LDFLAGS): Add -module -avoid-version.
	(libdep_la_LINK): New.
	(install-data-local): Depend on $(install-bfdpluginLTLIBRARIES)
	and remove libdep.la.
2020-12-18 04:30:59 -08:00
H.J. Lu
04f8967487 elf: Copy elf_gnu_osabi_retain only for relocatable link
Copy elf_gnu_osabi_retain from input only for relocatable link since
SHF_GNU_RETAIN has no impact on non-relocatable outputs.

bfd/

	PR ld/27091
	* elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain
	from input only for relocatable link.

ld/

	PR ld/27091
	* testsuite/ld-elf/retain7.s: New file.
	* testsuite/ld-elf/retain7a.d: Likewise.
	* testsuite/ld-elf/retain7b.d: Likewise.
2020-12-18 04:24:36 -08:00
Alan Modra
3fafa2e26e Assorted tidies
bfd/
	* elf32-microblaze.c (dbg): Delete unused variable.
	* elf32-nds32.c (relax_group_section_id_list): Make static.
	* som.c (reloc_queue): Make static.
	* xtensa-isa.c (xtisa_errno, xtisa_error_msg): Make static.
include/
	* xtensa-isa-internal.h (xtisa_errno, xtisa_error_msg): Delete.
2020-12-18 10:34:16 +10:30
Alan Modra
7fbd5f4e2c Remove some static buffers
Fixes possible overflow of a static buffer for powerpc with translated
messages, and on v850 when symbol names are large.

	* archive.c (_bfd_ar_spacepad, _bfd_ar_sizepad): Use auto buf.
	* coff-mcore.c (coff_mcore_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_unhandled_reloc): Use asprintf in place
	of fixed size and possibly too small buf for translated message.
	* elf64-ppc.c (ppc64_elf_unhandled_reloc): Likewise.
	* elf32-v850.c (v850_elf_check_relocs): Likewise.
	* ecoff.c (ecoff_type_to_string): Pass in return string buff rather
	than using static buffer2.  Delete dead code.  Remove unnecessary
	parentheses.
	(_bfd_ecoff_print_symbol): Pass auto buff to ecoff_type_to_string.
	* elf32-rx.c (describe_flags): Pass in return string buf rather
	than using static buf.
	(rx_elf_merge_private_bfd_data): Pass buf to describe_flags.
	(rx_elf_print_private_bfd_data): Likewise.
	* mach-o.c (cpusubtype): Pass in return string buffer rather than
	using static buffer.
	(bfd_mach_o_bfd_print_private_bfd_data): Pass buff to cpusubtype.
	* opncls.c (separate_debug_file_exists): Make buffer an auto var.
	(bfd_fill_in_gnu_debuglink_section): Likewise.
	* peXXigen.c (rsrc_resource_name): Pass in return string buffer
	rather than using static buffer.
	(rsrc_sort_entries): Pass buff to rsrc_resource_name.
	* vms-alpha.c (_bfd_vms_write_emh): Pass tbuf to get_vms_time_string.
	* vms-misc.c (get_vms_time_string): Pass in return string tbuf
	rather than using static tbuf.
	* vms.h (get_vms_time_string): Update prototype.
2020-12-18 10:34:16 +10:30
Alan Modra
bd38246a45 Constify more arrays
bfd/
	* coff-z80.c (bfd_howto_type): Make typedef const.
	* elf32-z80.c (bfd_howto_type): Likewise.
	* elf32-m32c.c (EncodingTable): Likewise.
	* elf32-csky.c (csky_arch_for_merge): Likewise.
	(csky_archs): Use typedef.
	* elf32-m68hc11.c (m68hc11_direct_relax_table): Make const.
	(find_relaxable_insn, m68hc11_elf_relax_section): Adjust to suit.
	* elf32-ppc.c (ppc_alt_plt): Make const.
	* elf32-rl78.c (relax_addr16): Likewise.
	* targets.c (_bfd_associated_vector): Likewise.
	(bfd_target_vector, bfd_associated_vector): Likewise.
	* libbfd-in.h (bfd_target_vector, bfd_associated_vector): Likewise.
	* libbfd.h: Regenerate.
include/
	* opcode/arc-attrs.h (CONFLICT_LIST): Make const.
2020-12-18 10:34:16 +10:30
Alan Modra
7f3a18cfb5 Statically initialise target common sections
This tidies initialisation of target common sections, doing so using a
static initialiser rather than via code and deleting unnecessary
symbol_ptr_ptr variables (the one in asection is used instead).

The patch also initialises ecoff.c:bfd_debug_section using
BFD_FAKE_SECTION.  That does change bfd_debug_section slightly,
output_section was NULL now bfd_debug_section, and symbol_ptr_ptr
was NULL now &bfd_debug_section.symbol, but I believe those changes
are safe.

bfd/
	* ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION.
	(ecoff_scom_section, ecoff_scom_symbol): Statically init using
	BFD_FAKE_SECTION and GLOBAL_SYM_INIT.  Delete initialisation code.
	(ecoff_scom_symbol_ptr): Delete.
	* elf32-m32r.c (m32r_elf_scom_section, m32r_elf_scom_symbol),
	(m32r_elf_scom_symbol_ptr),
	* elf32-score.c (score_elf_scom_section, score_elf_scom_symbol),
	(score_elf_scom_symbol_ptr),
	* elf32-score7.c (score_elf_scom_section, score_elf_scom_symbol),
	(score_elf_scom_symbol_ptr),
	* elf32-tic6x.c (tic6x_elf_scom_section, tic6x_elf_scom_symbol),
	(tic6x_elf_scom_symbol_ptr),
	* elf32-v850.c (v850_elf_scom_section, v850_elf_scom_symbol),
	(v850_elf_scom_symbol_ptr),
	(v850_elf_tcom_section, v850_elf_tcom_symbol),
	(v850_elf_tcom_symbol_ptr),
	(v850_elf_zcom_section, v850_elf_zcom_symbol),
	(v850_elf_zcom_symbol_ptr),
	* elf64-mmix.c (mmix_elf_reg_section, mmix_elf_reg_section_symbol),
	(mmix_elf_reg_section_symbol_ptr),
	* elfxx-mips.c (mips_elf_scom_section, mips_elf_scom_symbol),
	(mips_elf_scom_symbol_ptr): Likewise.
gas/
	* ecoff.c (ecoff_frob_symbol): Rename scom_section to
	ecoff_scom_section and statically initialise.
2020-12-18 10:34:16 +10:30
GDB Administrator
3ece0b9527 Automatic date update in version.in 2020-12-18 00:00:17 +00:00
Tom Tromey
844a65387c Remove a use of n_spaces
While removing printfi_filtered, I found a spot that used n_spaces
where the now-ordinary "%*s" approach would do.  This patch makes this
change.

Tested on x86-64 Fedora 32.

gdb/ChangeLog
2020-12-17  Tom Tromey  <tromey@adacore.com>

	* printcmd.c (print_variable_and_value): Don't use n_spaces.
2020-12-17 13:47:03 -07:00
Tom Tromey
32f47895b5 Remove printfi_filtered and fprintfi_filtered
After seeing Simon's patch, I thought maybe it was finally time to
remove printfi_filtered and fprintfi_filtered, in favor of using the
"%*s" approach to indenting.

In this patch I took the straightforward approach of always adding a
leading "%*s", even when the format already started with "%s", to
avoid the trickier form of:

    printf ("%*s", -indent, string)

Regression tested on x86-64 Fedora 32.
Let me know what you think.

gdb/ChangeLog
2020-12-17  Tom Tromey  <tromey@adacore.com>

	* gdbtypes.c (print_args, dump_fn_fieldlists, print_cplus_stuff)
	(print_gnat_stuff, print_fixed_point_type_info)
	(recursive_dump_type): Update.
	* go32-nat.c (go32_sysinfo, display_descriptor): Update.
	* c-typeprint.c (c_type_print_base_struct_union)
	(c_type_print_base_1): Update.
	* rust-lang.c (rust_internal_print_type): Update.
	* f-typeprint.c (f_language::f_type_print_base): Update.
	* utils.h (fprintfi_filtered, printfi_filtered): Remove.
	* m2-typeprint.c (m2_record_fields): Update.
	* p-typeprint.c (pascal_type_print_base): Update.
	* compile/compile-loc2c.c (push, pushf, unary, binary)
	(do_compile_dwarf_expr_to_c): Update.
	* utils.c (fprintfi_filtered, printfi_filtered): Remove.
2020-12-17 13:29:38 -07:00