Commit Graph

44196 Commits

Author SHA1 Message Date
Andrew Burgess d13c7322fe gdb: Allow more control over where to find python libraries
The motivation behind this commit is to make it easier to bundle the
Python *.py library files with GDB when statically linking GDB against
libpython.  The Python files will be manually added into the GDB
installation tree, and GDB should be able to find them at run-time.
The installation tree will look like this:

  .
  |-- bin/
  |-- include/
  |-- lib/
  |   `-- python3.8/
  `-- share/

The benefit here is that the entire installation tree can be bundled
into a single archive and copied to another machine with a different
version of Python installed, and GDB will still work, including its
Python support.

In use the new configure options would be used something like this,
first build and install a static Python library:

  mkdir python
  cd python
  # Clone or download Python into a src/ directory.
  mkdir build
  export PYTHON_INSTALL_PATH=$PWD/install
  cd build
  ../src/configure --disable-shared --prefix=$PYTHON_INSTALL_PATH
  make
  make install

Now build and install GDB:

  mkdir binutils-gdb
  cd binutils-gdb
  # Clone or download GDB into a src/ directory.
  mkdir build
  export GDB_INSTALL_DIR=$PWD/install
  cd build
  ../src/configure \
      --prefix=$GDB_INSTALL_DIR \
      --with-python=$PYTHON_INSTALL_PATH/bin/python3 \
      --with-python-libdir=$GDB_INSTALL_DIR/lib
  make all-gdb
  make install-gdb

Finally, copy the Python libraries into the GDB install:

  cp -r $PYTHON_INSTALL_DIR/lib/python3.8/ $GDB_INSTALL_DIR/lib

After this the Python src, build, and install directories are no
longer needed and can be deleted.

If the new --with-python-libdir option is not used then the existing
behaviour is left unchanged, GDB will look for the Python libraries in
the lib/ directory within the python path.  The concatenation of the
python prefix and the string 'lib/' is now done at configure time,
rather than at run time in GDB as it was previous, however, this was
never something that the user had dynamic control over, so there's no
loss of functionality.

gdb/ChangeLog:

	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Add --with-python-libdir option.
	* main.c: Use WITH_PYTHON_LIBDIR.
2020-02-20 10:14:43 +00:00
Tom de Vries d7445728b1 [gdb/testsuite] Handle missing gccgo
Without gccgo installed I see in stdout/stderr:
...
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/print.exp ...
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/handcall.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/max-depth.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/integers.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/unsafe.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/package.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/types.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/chan.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/strings.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/basic-types.exp ...
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/hello.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.go/methods.exp ...
gdb compile failed, default_target_compile: Can't find gccgo.
...

Fix this by introducing a gdb_caching_proc support_go_compile, and using it in
the complaining test-cases.

Tested on x86_64-linux, with and without gccgo installed.

gdb/testsuite/ChangeLog:

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

	* lib/gdb.exp (support_go_compile): New gdb_caching_proc.
	(gdb_simple_compile): Handle compile_flags go by using .go extension
	for source file.
	* gdb.go/chan.exp: Use support_go_compile.
	* gdb.go/handcall.exp: Same.
	* gdb.go/hello.exp: Same.
	* gdb.go/integers.exp: Same.
	* gdb.go/max-depth.exp: Same.
	* gdb.go/methods.exp: Same.
	* gdb.go/package.exp: Same.
	* gdb.go/strings.exp: Same.
	* gdb.go/types.exp: Same.
	* gdb.go/unsafe.exp: Same.
2020-02-20 06:31:24 +01:00
Tom Tromey 869d89506c Two compute_and_set_names simplifications
This patch simplifies compute_and_set_names in a couple of ways.

First, it changes one spot to use obstack_strndup, which is
equivalent, but more concise.

Second, the function ends with two calls to symbol_set_demangled_name.
This can be simplified to a single call.

gdb/ChangeLog
2020-02-19  Tom Tromey  <tom@tromey.com>

	* symtab.c (general_symbol_info::compute_and_set_names): Use
	obstack_strndup.  Simplify call to symbol_set_demangled_name.
2020-02-19 17:22:13 -07:00
Tom de Vries c9c41e6d73 [gdb/testsuite] Fix xpass in gdb.python/lib-types.exp
When running gdb.python/lib-types.exp, we have an xpass:
...
(gdb) python print (str (typedef_const_typedef_class1_ref_obj.type))^M
typedef_const_typedef_class1_ref^M
(gdb) XPASS: gdb.python/lib-types.exp: \
  python print (str (typedef_const_typedef_class1_ref_obj.type)) \
  (PRMS gcc/55641)
...

When running the same with gcc 4.8, we have an xfail instead:
...
(gdb) python print (str (typedef_const_typedef_class1_ref_obj.type))^M
const typedef_const_typedef_class1_ref^M
(gdb) XFAIL: gdb.python/lib-types.exp: \
  python print (str (typedef_const_typedef_class1_ref_obj.type)) \
  (PRMS gcc/55641)
...

Fix the xpass by xfailing only for the gcc 4.8 pattern.

Tested on x86_64-linux, with:
- gcc 7.5.0
- gcc 4.8.5
- clang 5.0.2

gdb/testsuite/ChangeLog:

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

	* gdb.python/lib-types.exp: Make xfail more strict.
2020-02-19 22:57:19 +01:00
Tom de Vries f20ff83737 [gdb/testsuite] Fix funcall_ref.exp xpass
When running gdb.ada/funcall_ref.exp I run into two XPASSes:
...
(gdb) p get ("Hello world!")^M
$1 = (n => 12, s => "Hello world!")^M
(gdb) XPASS: gdb.ada/funcall_ref.exp: p get ("Hello world!")
ptype get ("Hello world!")^M
type = <ref> record^M
    n: natural;^M
    s: access array (1 .. n) of character;^M
end record^M
(gdb) XPASS: gdb.ada/funcall_ref.exp: ptype get ("Hello world!")
...

The xfails are documented in funcall_ref.exp:
...
 # Currently, GCC describes such functions as returning pointers (instead of
 # references).
 setup_xfail *-*-*
...

Using gnatmake 4.8, we can reproduce the XFAILs:
...
(gdb) p get ("Hello world!")^M
$1 = (access foo.bar) 0x6147b0 <system.secondary_stack.chunk+48>^M
(gdb) XFAIL: gdb.ada/funcall_ref.exp: p get ("Hello world!")
ptype get ("Hello world!")^M
type = access record^M
    n: natural;^M
    s: access array (1 .. n) of character;^M
end record^M
(gdb) XFAIL: gdb.ada/funcall_ref.exp: ptype get ("Hello world!")
...

Fix the XPASSes by:
- removing the xfail setup
- switching the order of the two tests
- detecting the "access record" type and declaring the first test unsupported,
  and skipping the second test

Tested on x86_64-linux, both with gnatmake 4.8.5 and gnatmake 7.5.0.

gdb/testsuite/ChangeLog:

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

	* gdb.ada/funcall_ref.exp: Replace xfail setup by unsupported check.
2020-02-19 22:33:42 +01:00
Simon Marchi 298e963730 gdb: dwarf2/read.c: remove unused objfile parameters/variables
This is a simple cleanup.  These functions used to use the objfile's
obstack for allocation in the hash tables, but they don't anymore.
Remove the unnecessary objfile parameters, which in turn allows removing
some local variables.

gdb/ChangeLog:

	* dwarf2/read.c (allocate_signatured_type_table,
	allocate_dwo_unit_table, allocate_type_unit_groups_table,
	allocate_dwo_file_hash_table, allocate_dwp_loaded_cutus_table):
	Remove objfile parameter, update all callers.
2020-02-19 16:04:53 -05:00
Doug Evans 084104828c rust/25535 Apply embedded offset to enum variant calculation
Hopefully straightforward (and I didn't miss anything ...).

gdb/ChangeLog
2020-02-19  Doug Evans  <dje@google.com>

	PR rust/25535
	* rust-lang.c (rust_print_enum): Apply embedded_offset to
	rust_enum_variant calculation.

gdb/testsuite/ChangeLog
2020-02-19  Doug Evans  <dje@google.com>

	PR rust/25535
	* gdb.rust/simple.exp: Add test.
	* gdb.rust/simple.rs: Add test.
2020-02-19 13:59:31 -07:00
Tom de Vries 623563f79d [gdb/testsuite] Fix corefile-buildid.exp with check-read1
When running gdb.base/corefile-buildid.exp using check-read1, I run into:
...
FAIL: gdb.base/corefile-buildid.exp: shared: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: symlink shared: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: shared sepdebug: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: symlink shared sepdebug: info files \
  (timeout)
...

This is caused by attempting to match the output of an "info files" command
using a single gdb_test in check_exec_file.

Fix this by doing line-by-line matching in check_exec_file.

Tested on x86_64-linux, using make targets check and check-read1.

gdb/testsuite/ChangeLog:

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

	* gdb.base/corefile-buildid.exp (check_exec_file): Match info files
	output line-by-line.
2020-02-19 21:33:39 +01:00
Tom Tromey dfdeeca1cc Fix declaration of mips_pc_is_mips
A build where CORE_ADDR is not the same as bfd_vma pointed out that
mips_pc_is_mips is declared using bfd_vma as the parameter type, but
defined using CORE_ADDR.  This patch fixes the declaration.

gdb/ChangeLog
2020-02-19  Tom Tromey  <tromey@adacore.com>

	* mips-tdep.h (mips_pc_is_mips): Parameter type is CORE_ADDR.
2020-02-19 12:18:09 -07:00
Tom Tromey 2ef5453be5 Use obstack_strdup in ada-lang.c
I happened across a spot that was still using obstack_alloc and
strcpy, rather than obstack_strdup.  This patch makes the obvious fix.

gdb/ChangeLog
2020-02-19  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (cache_symbol): Use obstack_strdup.
2020-02-19 11:17:35 -07:00
Andrew Burgess 9f1528a1bd Merge changes from GCC for the config/ directory
GCC's config/ChangeLog since the last time this merge was done
(in the binutils-gdb commit 0b4d000cc4) is included at the
end of this commit message.

It is worth noting that the binutils-gdb commit 301a9420d9
added the file config/debuginfod.m4 which is not present in GCC's
config/ directory.  This file is preserved, unmodified, after this
commit.

In order to regenerate all of the configure files, I configured with
--enable-maintainer-mode, and built the 'all' target.  I then did the
same thing on a source tree without this patch, and only committed
those files that changed when this patch was added.

GCC's config/ChangeLog entries:

  2020-02-12  Sandra Loosemore  <sandra@codesourcery.com>

  	PR libstdc++/79193
  	PR libstdc++/88999

  	* no-executables.m4: Use a non-empty program to test for linker
  	support.

  2020-02-01  Andrew Burgess  <andrew.burgess@embecosm.com>

  	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Update shell syntax.

  2020-01-27  Andrew Burgess  <andrew.burgess@embecosm.com>

  	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Add new
  	--with-libXXX-type=... option.  Use this to guide the selection of
  	either a shared library or a static library.

  2020-01-24  Maciej W. Rozycki  <macro@wdc.com>

  	* toolexeclibdir.m4: New file.

  2019-09-10  Christophe Lyon  <christophe.lyon@st.com>

  	* futex.m4: Handle *-uclinux*.
  	* tls.m4 (GCC_CHECK_TLS): Likewise.

  2019-09-06  Florian Weimer  <fweimer@redhat.com>

  	* futex.m4 (GCC_LINUX_FUTEX): Include <unistd.h> for the syscall
  	function.

  2019-07-08  Richard Sandiford  <richard.sandiford@arm.com>

  	* bootstrap-Og.mk: New file.

  2019-06-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
              Andrew Stubbs  <ams@codesourcery.com>

  	* gthr.m4 (GCC_AC_THREAD_HEADER): Add case for gcn.

  2019-05-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

  	* ax_count_cpus.m4: New file.

  2019-05-02  Richard Biener  <rguenther@suse.de>

  	PR bootstrap/85574
  	* bootstrap-lto.mk (extra-compare): Set to gcc/lto1$(exeext).

  2019-04-16  Martin Liska  <mliska@suse.cz>

  	* bootstrap-lto-lean.mk: Filter out -flto in STAGEtrain_CFLAGS.

  2019-04-09  Martin Liska  <mliska@suse.cz>

  	* bootstrap-lto-lean.mk: New file.

  2019-03-02  Johannes Pfau  <johannespfau@gmail.com>

  	* mh-mingw: Also set __USE_MINGW_ACCESS flag for C++ code.

  2018-10-31  Joseph Myers  <joseph@codesourcery.com>

  	PR bootstrap/82856
  	* math.m4, tls.m4: Use AC_LANG_SOURCE.

  	Merge from binutils-gdb:
  	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

  	* override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69.

config/ChangeLog:

	* ax_count_cpus.m4: New file, backported from GCC.
	* bootstrap-Og.mk: New file, backported from GCC.
	* bootstrap-lto-lean.mk: New file, backported from GCC.
	* bootstrap-lto.mk: Changes backported from GCC.
	* futex.m4: Changes backported from GCC.
	* gthr.m4: Changes backported from GCC.
	* lib-link.m4: Changes backported from GCC.
	* mh-mingw: Changes backported from GCC.
	* no-executables.m4: Changes backported from GCC.
	* tls.m4: Changes backported from GCC.
	* toolexeclibdir.m4: New file, backported from GCC.

binutils/ChangeLog:

	* configure: Regenerate.

gdb/ChangeLog:

	* configure: Regenerate.

gdbserver/ChangeLog:

	* configure: Regenerate.

gdbsupport/ChangeLog:

	* configure: Regenerate.

intl/ChangeLog:

	* configure: Regenerate.

libiberty/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog.bin-gdb:

	* configure: Regenerate.
2020-02-19 17:51:24 +00:00
Tom Tromey d3c22fa82e Remove useless NULL check in python.c
I noticed that do_start_initialization, in python.c, checks the result
of xmalloc.  However, xmalloc cannot fail, so this check is useless.
This patch also changes the code to use XNEWVEC.

gdb/ChangeLog
2020-02-19  Tom Tromey  <tromey@adacore.com>

	* python/python.c (do_start_initialization): Use XNEWVEC.  Remove
	NULL check.
2020-02-19 07:50:21 -07:00
Tom de Vries d3308cfdec [gdb/testsuite] Fix c++/14186 kpass in cpexprs.exp
With gdb.cp/cpexprs.exp, we see:
...
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) const (PRMS c++/14186)
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) volatile (PRMS c++/14186)
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) const volatile (PRMS c++/14186)
...

The tests have been KPASSing since Sept 4 2017, due to commit 3693fdb3c8
'Make "p S::method() const::static_var" work too'.

Fix this by removing the corresponding kfail.

gdb/testsuite/ChangeLog:

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

	* gdb.cp/cpexprs.exp: Remove c++/14186 kfail.
2020-02-19 13:41:10 +01:00
Tom de Vries 86cbc5dc16 [gdb/testsuite] Be quiet about missing prelink in solib-overlap.exp
When running gdb.base/solib-overlap.exp, I get:
...
Running src/gdb/testsuite/gdb.base/solib-overlap.exp ...
sh: prelink: command not found

                === gdb Summary ===

nr of untested testcases         1
...

The verbose output on stdout/stderr is due to using system to execute
prelink, which also means that the output is not captured in gdb.log and
gdb.sum.

Fix this by using exec instead of system.

Tested on x86_64-linux, with:
- no prelink installed, and
- a fake prelink installed, using "cp /usr/bin/echo ~/bin/prelink".

gdb/testsuite/ChangeLog:

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

	* gdb.base/solib-overlap.exp: Use exec instead of system to execute
	prelink.
2020-02-19 08:24:44 +01:00
Tom de Vries 9db2b96b07 [gdb/testsuite] Ignore pass in gdb_caching_proc
Before commit d4295de4f3 "[gdb/testsuite] Handle missing gnatmake in
gnat_runtime_has_debug_info", calling the gdb_caching_proc
gnat_runtime_has_debug_info could generate a pass because of using
gdb_compile_ada.

This has been fixed in that commit by using a factored out variant
gdb_compile_ada_1, which does not call pass.

Additionally, fix cases like this in more generic way: by ignoring pass calls
during execution of a gdb_caching_proc.

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

	* lib/cache.exp (ignore_pass, gdb_do_cache_wrap): New proc.
	(gdb_do_cache): Use gdb_do_cache_wrap.
	* gdb.base/gdb-caching-proc.exp (test_proc): Use gdb_do_cache_wrap.
2020-02-19 07:05:13 +01:00
Maciej W. Rozycki bf84f70666 gdbserver: Add RISC-V/Linux support
Implement RISC-V/Linux support for both RV64 and RV32 systems, including
XML target description handling based on features determined, GPR and
FPR regset support including dynamic sizing of the latter, and software
breakpoint handling.  Define two NT_FPREGSET regsets of a different size
matching the FPR sizes supported for generic `gdbserver' code to pick
from according to what the OS supplies.

Also handle a glibc bug where ELF_NFPREG is defined in terms of NFPREG,
however NFPREG is nowhere defined.

2020-02-19  Maciej W. Rozycki  <macro@wdc.com>
	    Andrew Burgess  <andrew.burgess@embecosm.com>

	gdb/
	* NEWS: Mention RISC-V GNU/Linux GDBserver support.

	gdbserver/
	* linux-riscv-low.cc: New file.
	* Makefile.in (SFILES): Add linux-riscv-low.cc, arch/riscv.c,
	and nat/riscv-linux-tdesc.c.
	* configure.srv <riscv*-*-linux*> (srv_tgtobj)
	(srv_linux_regsets, srv_linux_usrregs, srv_linux_thread_db):
	Define.
2020-02-19 01:24:37 +00:00
Andrew Burgess d1c9b20ff9 gdb/riscv: Update API for looking up target descriptions
In preparation for adding the RISC-V gdbserver, this commit
restructures the API for looking up target descriptions.

The current API is riscv_create_target_description, which creates a
target description from a riscv_gdbarch_features, but also caches the
created target descriptions so that for a given features object we
always get back the same target description object.  This is important
for GDB due to the way gdbarch objects are reused.

As the same target description is always returned to GDB, and can be
returned multiple times, it is returned as a const, however, the
current cache actually stores a non-const target description.  This is
improved in this patch so that the cache holds a const target
description.

For gdbsever, this caching of the target descriptions is not needed,
the gdbserver looks up one target description to describe the target
it is actually running on and that is it.  Further the gdbserver
actually needs to modify the target description that is looked up, so
for the gdbsever, returning a const target description is not
acceptable.

This commit aims to address this by creating two parallel target
description APIs, on is the old riscv_create_target_description,
however, this no longer performs any caching, and just creates a new
target description, and returns it as non-const.

The second API is riscv_lookup_target_description, this one performs
the caching, and calls riscv_create_target_description to create a
target description when needed.

In order to make sure the correct API is used in the correct place I
have guarded the code using the GDBSERVER define.  For GDB the
riscv_create_target_description is static, and not generally usable
throughout GDB, only the lookup API is global.  In gdbserver, the
lookup functions, and the cache are not defined or created at all,
only the riscv_create_target_description API is available.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* arch/riscv.c (struct riscv_gdbarch_features_hasher): Only define
	if GDBSERVER is not defined.
	(riscv_tdesc_cache): Likewise, also store const target_desc.
	(STATIC_IN_GDB): Define.
	(riscv_create_target_description): Update declaration with
	STATIC_IN_GDB.
	(riscv_lookup_target_description): New function, only define if
	GDBSERVER is not defined.
	* arch/riscv.h (riscv_create_target_description): Declare only
	when GDBSERVER is defined.
	(riscv_lookup_target_description): New declaration when GDBSERVER
	is not defined.
	* nat/riscv-linux-tdesc.c (riscv_linux_read_description): Rename to...
	(riscv_linux_read_features): ...this, and return
	riscv_gdbarch_features instead of target_desc.
	* nat/riscv-linux-tdesc.h: Include 'arch/riscv.h'.
	(riscv_linux_read_description): Rename to...
	(riscv_linux_read_features): ...this.
	* riscv-linux-nat.c (riscv_linux_nat_target::read_description):
	Update to use riscv_gdbarch_features and
	riscv_lookup_target_description.
	* riscv-tdep.c (riscv_find_default_target_description): Use
	riscv_lookup_target_description instead of
	riscv_create_target_description.
2020-02-19 01:24:37 +00:00
Tom de Vries 89e2fdc56a [gdb/testsuite] Be quiet about untested dtrace-prob.exp
When running gdb.base/dtrace-probe.exp, I get this on stdout/stderr:
...
Running src/gdb/testsuite/gdb.base/dtrace-probe.exp ...
gdb compile failed, ld: error in \
  build/gdb/testsuite/outputs/gdb.base/dtrace-probe/dtrace-probe.o\
  (.eh_frame); no .eh_frame_hdr table will be created
ld: crt1.o: in function `_start':
start.S:110: undefined reference to `main'
ld: build/gdb/testsuite/outputs/gdb.base/dtrace-probe/dtrace-probe-p.o:\
  (.SUNW_dof+0x88): undefined reference to `main'
ld: build/gdb/testsuite/outputs/gdb.base/dtrace-probe/dtrace-probe-p.o:\
  (.SUNW_dof+0xb8): undefined reference to `main'
collect2: error: ld returned 1 exit status

                === gdb Summary ===

nr of untested testcases         1
...

There is no reason to be this verbose about the failure to compile.

Fix this by using quiet as additional option to gdb_compile in
dtrace_build_usdt_test_program.  Note that the error message still occurs in
gdb.log.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

	* lib/dtrace.exp (dtrace_build_usdt_test_program): Use quiet as
	gdb_compile option.
2020-02-19 00:05:40 +01:00
Simon Marchi 373d7ac0f1 gdb: change print format of flag enums with value 0
If a flag enum has value 0 and the enumeration type does not have an
enumerator with value 0, we currently print:

  $1 = (unknown: 0x0)

I don't like the display of "unknown" here, since for flags, 0 is a
an expected value.  It just means that no flags are set.  This patch
makes it so that we print it as a simple 0 in this situation:

  $1 = 0

If there is an enumerator with value 0, it is still printed using that
enumerator, for example (from the test):

  $1 = FE_NONE

gdb/ChangeLog:

	* valprint.c (generic_val_print_enum_1): When printing a flag
	enum with value 0 and there is no enumerator with value 0, print
	just "0" instead of "(unknown: 0x0)".

gdb/testsuite/ChangeLog:

	* gdb.base/printcmds.exp (test_print_enums): Update expected
	output.
2020-02-18 17:33:04 -05:00
Simon Marchi b29a2df000 gdb: print unknown part of flag enum in hex
When we print the "unknown" part of a flag enum, it is printed in
decimal.  I think it would be more useful if it was printed in hex, as
it helps to determine which bits are set more than a decimal value.

gdb/ChangeLog:

	* valprint.c (generic_val_print_enum_1): Print unknown part of
	flag enum in hex.

gdb/testsuite/ChangeLog:

	* gdb.base/printcmds.exp (test_print_enums): Expect hex values
	for "unknown".
2020-02-18 17:33:04 -05:00
Simon Marchi 6740f0cc3b gdb: allow duplicate enumerators in flag enums
I have come across some uses cases where it would be desirable to treat
an enum that has duplicate values as a "flag enum".  For example, this
one here [1]:

    enum membarrier_cmd {
            MEMBARRIER_CMD_QUERY                                = 0,
            MEMBARRIER_CMD_GLOBAL                               = (1 << 0),
            MEMBARRIER_CMD_GLOBAL_EXPEDITED                     = (1 << 1),
            MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED            = (1 << 2),
            MEMBARRIER_CMD_PRIVATE_EXPEDITED                    = (1 << 3),
            MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED           = (1 << 4),
            MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE          = (1 << 5),
            MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = (1 << 6),

            /* Alias for header backward compatibility. */
            MEMBARRIER_CMD_SHARED = MEMBARRIER_CMD_GLOBAL,
    };

The last enumerator is kept for backwards compatibility.  Without this
patch, this enumeration wouldn't be considered a flag enum, because two
enumerators collide.   With this patch, it would be considered a flag
enum, and the value 3 would be printed as:

  MEMBARRIER_CMD_GLOBAL | MEMBARRIER_CMD_GLOBAL_EXPEDITED

Although if people prefer, we could display both MEMBARRIER_CMD_GLOBAL
and MEMBARRIER_CMD_SHARED in the result.  It wouldn't be wrong, and
could perhaps be useful in case a bit may have multiple meanings
(depending on some other bit value).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/membarrier.h?id=0bf999f9c5e74c7ecf9dafb527146601e5c848b9#n125

gdb/ChangeLog:

	* dwarf2/read.c (update_enumeration_type_from_children): Allow
	flag enums to contain duplicate enumerators.
	* valprint.c (generic_val_print_enum_1): Update comment.

gdb/testsuite/ChangeLog:

	* gdb.base/printcmds.c (enum flag_enum): Add FE_TWO_LEGACY
	enumerator.
2020-02-18 17:32:57 -05:00
Simon Marchi edd45eb06b gdb: fix printing of flag enums with multi-bit enumerators
GDB has this feature where if an enum looks like it is meant to
represent binary flags, it will present the values of that type as a
bitwise OR of the flags that are set in the value.

The original motivation for this patch is to fix this behavior:

  enum hello { AAA = 0x1, BBB = 0xf0 };

  (gdb) p (enum hello) 0x11
  $1 = (AAA | BBB)

This is wrong because the bits set in BBB (0xf0) are not all set in the
value 0x11, but GDB presents it as if they all were.

I think that enumerations with enumerators that have more than one bit
set should simply not qualify as "flag enum", as far as this
heuristic is concerned.  I'm not sure what it means to have flags of
more than one bit.  So this is what this patch implements.

I have added an assert in generic_val_print_enum_1 to make sure the flag
enum types respect that, in case they are used by other debug info
readers, in the future.

I've enhanced the gdb.base/printcmds.exp test to cover this case.  I've
also added tests for printing flag enums with value 0, both when the
enumeration has and doesn't have an enumerator for value 0.

gdb/ChangeLog:

	* dwarf2/read.c: Include "count-one-bits.h".
	(update_enumeration_type_from_children): If an enumerator has
	multiple bits set, don't treat the enumeration as a "flag enum".
	* valprint.c (generic_val_print_enum_1): Assert that enumerators
	of flag enums have 0 or 1 bit set.

gdb/testsuite/ChangeLog:

	* gdb.base/printcmds.c (enum flag_enum): Prefix enumerators with
	FE_, add FE_NONE.
	(three): Update.
	(enum flag_enum_without_zero): New enum.
	(flag_enum_without_zero): New variable.
	(enum not_flag_enum): New enum.
	(three_not_flag): New variable.
	* gdb.base/printcmds.exp (test_artificial_arrays): Update.
	(test_print_enums): Add more tests for printing flag enums.
2020-02-18 17:28:23 -05:00
Bernd Edlinger 6d0cf4464e Fix build with gcc-4.8.x
Use an explicit conversion from unique_ptr<T> to
displaced_step_closure_up to avoid a compiler bug
with gcc-4.8.4:

../../binutils-gdb/gdb/amd64-tdep.c:1514:10: error: cannot bind
   'std::unique_ptr<amd64_displaced_step_closure>' lvalue to
   'std::unique_ptr<amd64_displaced_step_closure>&&'

gdb:
2020-02-18  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use an explicit
	conversion.
	* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
	* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
2020-02-18 22:22:56 +01:00
Simon Marchi 7001c1b7dc gdb: update email address for Palmer Dabbelt
gdb/ChangeLog:

	* MAINTAINERS: Change palmer@sifive.com to palmer@dabbelt.com.
2020-02-18 14:37:18 -05:00
Tom de Vries d4295de4f3 [gdb/testsuite] Handle missing gnatmake in gnat_runtime_has_debug_info
After de-installing gnatmake, I get on stdout/stderr:
...
Running src/gdb/testsuite/gdb.base/gdb-caching-proc.exp ...
FAIL: gdb-caching-proc.exp: failed to compile gnat-debug-info test binary
  ...
FAIL: gdb-caching-proc.exp: failed to compile gnat-debug-info test binary
...

In gdb.sum, we see these FAILs (each paired with an UNSUPPORTED as well)
followed by:
...
PASS: gdb-caching-proc.exp: gnat_runtime_has_debug_info consistency
...

Likewise, after re-installing gnatmake, I get a PASS for each of the
UNSUPPORTEDs, and the FAILs disappear.

The FAIL comes from gnat_runtime_has_debug_info, the PASS/UNSUPPORTED comes
from gdb_compile_ada.

Fix this by removing the corresponding fail call in
gnat_runtime_has_debug_info, as well as using a new variant gdb_compile_ada_1
that doesn't call pass/unsupported.

Tested on x86_64-linux, with gnatmake installed and de-installed.

gdb/testsuite/ChangeLog:

2020-02-18  Tom de Vries  <tdevries@suse.de>

	* lib/ada.exp (gdb_compile_ada_1): Factor out of ...
	(gdb_compile_ada): ... here.
	(gnat_runtime_has_debug_info): Remove fail call for gdb_compile_ada
	failure.  Use gdb_compile_ada_1 instead of gdb_compile_ada.
2020-02-18 10:18:36 +01:00
Simon Marchi fdb61c6c39 gdb: introduce displaced_step_closure_up type alias
To help with readability, add the type displaced_step_closure_up, an
alias for std::unique_ptr<displaced_step_closure>, and use it throughout
the code base.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use
	displaced_step_closure_up.
	* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
	(struct displaced_step_closure_up):
	* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
	* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn):
	Likewise.
	* gdbarch.sh (displaced_step_copy_insn): Likewise.
	* gdbarch.c, gdbarch.h: Re-generate.
	* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Use
	displaced_step_closure_up.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
	* infrun.h (displaced_step_closure_up): New type alias.
	(struct displaced_step_inferior_state) <step_closure>: Change
	type to displaced_step_closure_up.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Use
	displaced_step_closure_up.
	* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
2020-02-14 16:46:38 -05:00
Tom Tromey a4a38eb437 Cache .gnu_debugdata BFD
While looking at the output of "maint info bfd" with multiple
inferiors, I noticed that there were duplicate entries for
.gnu_debugdata.

There is no reason to re-create this BFD each time it is needed.  This
patch arranges to share the data.

gdb/ChangeLog
2020-02-14  Tom Tromey  <tom@tromey.com>

	* minidebug.c (gnu_debug_key): New global.
	(find_separate_debug_file_in_section): Use it.

Change-Id: If139f89f0f07db33f399afdbcfbf5aaeffe4de46
2020-02-14 14:16:24 -07:00
Tom Tromey f251f50533 Have testsuite find gdbserver in new location
This updates the gdb testsuite to look for gdbserver in its new
location.  The old location is also checked for, on the theory that
perhaps someone sets GDB to a full path for install testing.

gdb/testsuite/ChangeLog
2020-02-14  Tom Tromey  <tom@tromey.com>

	* lib/gdbserver-support.exp (find_gdbserver): Find gdbserver in
	build directory.
	* boards/gdbserver-base.exp: Update path to gdbserver.

Change-Id: If03db762ba53882ddfaf2d2d516de14c3fa03938
2020-02-14 14:14:38 -07:00
Simon Marchi e8217e61f5 gdb: make gdbarch_displaced_step_copy_insn return an std::unique_ptr
This callback dynamically allocates a specialized displaced_step_closure, and
gives the ownership of the object to its caller.  So I think it would make
sense for the callback to return an std::unique_ptr, this is what this patch
implements.

gdb/ChangeLog:

	* gdbarch.sh (displaced_step_copy_insn): Change return type to an
	std::unique_ptr.
	* gdbarch.c: Re-generate.
	* gdbarch.h: Re-generate.
	* infrun.c (displaced_step_prepare_throw): Adjust to std::unique_ptr
	change.
	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Change return
	type to std::unique_ptr.
	* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
	* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
	* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
	* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Likewise.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
	* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
2020-02-14 15:29:08 -05:00
Simon Marchi d8d83535e6 gdb: cleanup of displaced_step_inferior_state::reset/displaced_step_clear
displaced_step_inferior_state::reset and displaced_step_clear appear to
have the same goal, but they don't do the same thing.
displaced_step_inferior_state::reset clears more things than
displaced_step_clear, but it misses free'ing the closure, which
displaced_step_clear does.

This patch replaces displaced_step_clear's implementation with just a call to
displaced_step_inferior_state::reset.  It then changes
displaced_step_inferior_state::step_closure to be a unique_ptr, to indicate the
fact that displaced_step_inferior_state owns the closure (and so that it is
automatically freed when the field is reset).

The test gdb.base/step-over-syscall.exp caught a problem when doing this, which
I consider to be a latent bug which my cleanup exposes.  In
handle_inferior_event, in the TARGET_WAITKIND_FORKED case, if we displaced-step
over a fork syscall, we make sure to restore the memory that we used as a
displaced-stepping buffer in the child.  We do so using the
displaced_step_inferior_state of the parent.  However, we do it after calling
displaced_step_fixup for the parent, which clears the information in the
parent's displaced_step_inferior_state.  It worked fine before, because
displaced_step_clear didn't completely clear the displaced_step_inferior_state
structure, so the required information (in this case the gdbarch) was
still available after clearing.

I fixed it by making GDB restore the child's memory before calling the
displaced_step_fixup on the parent.  This way, the data in the
displaced_step_inferior_state structure is still valid when we use it for the
child.  This is the error you would get in
gdb.base/step-over-syscall.exp without this fix:

    /home/smarchi/src/binutils-gdb/gdb/gdbarch.c:3911: internal-error: ULONGEST gdbarch_max_insn_length(gdbarch*): Assertion `gdbarch != NULL' failed.

gdb/ChangeLog:

	* infrun.c (get_displaced_step_closure_by_addr): Adjust to
	std::unique_ptr.
	(displaced_step_clear): Rename to...
	(displaced_step_reset): ... this.  Just call displaced->reset ().
	(displaced_step_clear_cleanup): Rename to...
	(displaced_step_reset_cleanup): ... this.
	(displaced_step_prepare_throw): Adjust to std::unique_ptr.
	(displaced_step_fixup): Likewise.
	(resume_1): Likewise.
	(handle_inferior_event): Restore child's memory before calling
	displaced_step_fixup on the parent.
	* infrun.h (displaced_step_inferior_state) <reset>: Adjust
	to std::unique_ptr.
	<step_closure>: Change type to std::unique_ptr.
2020-02-14 15:11:58 -05:00
Simon Marchi 5f661e0397 gnulib: import count-one-bits module and use it
For a fix I intend to submit, I would need a function that counts the
number of set bits in a word.  There is  __builtin_popcount that is
supported by gcc and clang, but there is also a gnulib module that wraps
that and provides a fallback for other compilers, so I think it would be
good to use it.

I also noticed that there is a bitcount function in arch/arm.c, so I
thought that as a first step I would replace that one with the gnulib
count-one-bits module.  This is what this patch does.

The gnulib module provides multiple functions, with various parameter
length (unsigned int, unsigned long int, unsigned long long int), I
chose the one that made sense for each call site based on the argument
type.

gnulib/ChangeLog:

	* update-gnulib.sh (IMPORTED_GNULIB_MODULES): Import
	count-one-bits module.
	* configure: Re-generate.
	* aclocal.m4: Re-generate.
	* Makefile.in: Re-generate.
	* import/count-one-bits.c: New file.
	* import/count-one-bits.h: New file.
	* import/Makefile.am: Re-generate.
	* import/Makefile.in: Re-generate.
	* import/m4/gnulib-cache.m4: Re-generate.
	* import/m4/gnulib-comp.m4: Re-generate.
	* import/m4/count-one-bits.m4: New file.

gdb/ChangeLog:

	* arm-tdep.c: Include count-one-bits.h.
	(cleanup_block_store_pc): Use count_one_bits.
	(cleanup_block_load_pc): Use count_one_bits.
	(arm_copy_block_xfer): Use count_one_bits.
	(thumb2_copy_block_xfer): Use count_one_bits.
	(thumb_copy_pop_pc_16bit): Use count_one_bits.
	* arch/arm-get-next-pcs.c: Include count-one-bits.h.
	(thumb_get_next_pcs_raw): Use count_one_bits.
	(arm_get_next_pcs_raw): Use count_one_bits_l.
	* arch/arm.c (bitcount): Remove.
	* arch/arm.h (bitcount): Remove.
2020-02-14 14:41:07 -05:00
Tom Tromey 8084e579e1 Return unique_xmalloc_ptr from call_site_find_chain
call_site_find_chain returns a pointer that the caller must
deallocate.  It seemed better here to return a unique_xmalloc_ptr
instead.

gdb/ChangeLog
2020-02-14  Tom Tromey  <tromey@adacore.com>

	* dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first):
	Update.
	* dwarf2/loc.h (call_site_find_chain): Return unique_xmalloc_ptr.
	* dwarf2/loc.c (call_site_find_chain_1): Return
	unique_xmalloc_ptr.
	(call_site_find_chain): Likewise.
2020-02-14 12:38:04 -07:00
Richard Biener 258bf0ee37 [gdb] Speedup lnp_state_machine::handle_special_opcode
I see for some program at gdb startup:
...
Samples: 102K of event 'cycles:pu', Event count (approx.): 91710925103
Overhead  Command     Shared Object        Symbol
  15.21%  gdb         gdb                  [.]
lnp_state_machine::handle_special
...
where the divisions are the places we stall.  The following
micro-optimizes things but it smells like m_line_header->line_range
is constant, likewise probably m_line_header->maximum_ops_per_instruction
so eventually the divisions could be avoided completely with some
lookup table.

Well.  Micro-optimizing with this patch improves things
(don't expect [load] CSE over the gdbarch_adjust_dwarf2_line call).

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-02-14  Richard Biener  <rguenther@suse.de>

	* dwarf2/read.c (lnp_state_machine::handle_special_opcode): Apply CSE
	on expression with division operators.
2020-02-14 08:32:53 +01:00
Tom de Vries 8f432634a5 [gdb/testsuite] Remove stale exec in gdb_compile_ada
When running test-case gdb.ada/ptype_tagged_param.exp, I get:
...
PASS: gdb.ada/ptype_tagged_param.exp: compilation foo.adb
...

However, when I then de-install gnatmake and run again, I get the same result.
This is due to a stale exec. After removing the stale exec, I get:
...
UNSUPPORTED: gdb.ada/ptype_tagged_param.exp: compilation foo.adb
...

Fix this removing the stale exec in gdb_compile_ada before compilation.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-13  Tom de Vries  <tdevries@suse.de>

	* lib/ada.exp (gdb_compile_ada): Delete stale exec before compilation.
2020-02-13 15:42:07 +01:00
Tom de Vries 92b6eaf759 [gdb/testsuite] Add unsupported tests in catch_ex_std.exp
If I de-install gnatbind, I run into:
...
FAIL: gdb.ada/catch_ex_std.exp: gnatbind foo
...

Fix this by marking the test unsupported instead:
...
UNSUPPORTED: gdb.ada/catch_ex_std.exp: gnatbind foo
...

Likewise for gnatlink.

Tested on x86_64-linux, with and without gnatbind/gnatlink installed.

gdb/testsuite/ChangeLog:

2020-02-13  Tom de Vries  <tdevries@suse.de>

	* gdb.ada/catch_ex_std.exp: Indicate unsupported if gnatbind/gnatlink
	are missing.
2020-02-13 15:34:06 +01:00
Alok Kumar Sharma f98a845896 Adding myself to gdb/MAINTAINERS
2020-02-13  Alok Kumar Sharma  <AlokKumar.Sharma@amd.com>

	* MAINTAINERS (Write After Approval): Adding myself.

Change-Id: I2e6095a63247902f5fe23d58c2df8f995e41cf58
2020-02-13 16:26:11 +05:30
Tom de Vries f3b0f7fe42 [gdb/testsuite] Fix gnatmake_version_at_least
After de-installing gnatmake, I get:
...
Running src/gdb/testsuite/gdb.ada/rename_subscript_param.exp ...
ERROR: tcl error sourcing src/gdb/testsuite/gdb.ada/rename_subscript_param.exp.
ERROR: couldn't execute "gnatmake": no such file or directory
    while executing
"exec $gnatmake --version"
    (procedure "gnatmake_version_at_least" line 4)
...

Fix this by wrapping the exec call in a catch call.

Tested with and withouth gnatmake installed on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-13  Tom de Vries  <tdevries@suse.de>

	* lib/ada.exp (gnatmake_version_at_least): Wrap exec call in a catch
	call.
2020-02-13 08:37:34 +01:00
Tom Tromey d1437c0ea6 Remove some dead code from event-loop.c
This removes some dead code from event-loop.c.

This patch is from my old series to merge the gdb and gdbserver event
loops; but since it is just removing dead code, it seemed simple to
commit it separately.

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

	* event-loop.c (event_data, gdb_event, event_handler_func):
	Remove.
2020-02-12 17:16:50 -07:00
Tom Tromey 3d4560f707 Move the frame data to the BFD when possible
Now that comp_unit and the remaining frame data are all independent of
the objfile, it can all be stored on the BFD and shared across
inferiors.

As with other code doing this same thing, care must be taken to not
share the data when the objfile requires relocations.  So, two keys
are used: one for the BFD and one for the objfile, and
gdb_bfd_requires_relocations is used to differentiate between the two
cases.

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

	* dwarf2/frame.c (dwarf2_frame_bfd_data): New global.
	(dwarf2_frame_objfile_data): Add comment.
	(find_comp_unit, set_comp_unit): New functions.
	(dwarf2_frame_find_fde): Use find_comp_unit.
	(dwarf2_build_frame_info): Use set_comp_unit.
2020-02-12 15:51:58 -07:00
Tom Tromey 2198230456 Remove the objfile backlink from comp_unit
This removes the objfile backlink from comp_unit.  The only remaining
uses involved fetching the text offset from the objfile.  However,
this is already conveniently computed at all the sites that call
execute_cfa_program, and so it can simply be passed in.

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

	* dwarf2/frame.c (struct comp_unit) <objfile>: Remove.
	(comp_unit): Don't initialize objfile.
	(execute_cfa_program): Add text_offset parameter.
	(execute_cfa_program_test, dwarf2_fetch_cfa_info)
	(dwarf2_frame_cache): Update.
	(dwarf2_build_frame_info): Don't set "objfile" member.
2020-02-12 15:51:58 -07:00
Tom Tromey 4debb23796 Remove a use of the comp_unit backlink
The DWARF frame comp_unit object still has a backlink to the objfile.
In order to be truly objfile-independent, this must be removed.

This patch removes one such use, by passing the gdbarch to
decode_frame_entry directly.

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

	* dwarf2/frame.c (decode_frame_entry_1): Add gdbarch parameter.
	(decode_frame_entry): Likewise.
	(dwarf2_build_frame_info): Update.
2020-02-12 15:51:58 -07:00
Tom Tromey 0d404d447a Add per-unit obstack
This adds an auto_obstack to the DWARF frame comp_unit object, and
then changes the remaining code here to use the comp_unit obstack
rather than the objfile obstack.

At this point, all the storage for frame data is self-contained --
that is, it is independent of the objfile.

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

	* dwarf2/frame.c (struct comp_unit) <obstack>: New member.
	(decode_frame_entry_1): Use the comp_unit obstack.
2020-02-12 15:51:58 -07:00
Tom Tromey a7a3ae5c02 Store the comp_unit instead of the FDE table
This changes the DWARF frame code to store the comp_unit on the
objfile, rather than storing the FDE table.  It also changes the
comp_unit to be heap-allocated using "new".

This change makes it simpler for a later patch to add a field to the
comp_unit, and to have deallaction work properly.  This in turn is
important for making the frame data be independent of the objfile.

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

	* dwarf2/frame.c (struct comp_unit): Add initializers and
	constructor.
	(dwarf2_frame_objfile_data): Store a comp_unit.
	(dwarf2_frame_find_fde): Update.
	(dwarf2_build_frame_info): Use "new".
2020-02-12 15:51:58 -07:00
Tom Tromey a9d6541862 Change fde table to a vector
This removes struct dwarf2_fde_table, replacing it with a typedef of
std::vector.  This simplifies the code somewhat.

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

	* dwarf2/frame.c (struct dwarf2_fde_table): Remove.
	(dwarf2_fde_table): Typedef for std::vector.
	(dwarf2_frame_objfile_data): Remove the deleter.  Now static.
	(dwarf2_frame_find_fde, add_fde, decode_frame_entry_1)
	(decode_frame_entry): Update.
	(dwarf2_build_frame_info): Use "new".
2020-02-12 15:51:58 -07:00
Christian Biesinger 7559c21717 Change booleans to bool in ARM's gdbarch_tdep
gdb/ChangeLog:

2020-02-12  Christian Biesinger  <cbiesinger@google.com>

	* arm-tdep.c (arm_gdbarch_init): Update.
	* arm-tdep.h (struct gdbarch_tdep) <have_fpa_registers,
	have_wmmx_registers, have_vfp_pseudos, have_neon_pseudos,
	have_neon, is_m>: Change to bool.
2020-02-12 16:49:08 -06:00
Christian Biesinger aeefc73cb2 Print more information in arm_dump_tdep
I am keeping the (int) casts because a future patch will change the type
to bool.

gdb/ChangeLog:

2020-02-12  Christian Biesinger  <cbiesinger@google.com>

	* arm-tdep.c (arm_dump_tdep): Print more fields of tdep.
2020-02-12 16:28:48 -06:00
Tom Tromey d27b8e5f14 Remove dwarf_expr_baton
The type dwarf_expr_baton is unused and can be removed.

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

	* dwarf2/loc.c (struct dwarf_expr_baton): Remove.

Change-Id: Id8342da31398b9b4b08f31be7c3d612e9590bbbf
2020-02-12 14:41:33 -07:00
Hannes Domani cd5900f33b Cache the Thread Local Base pointer type in the gdbarch
gdb/ChangeLog:

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

	* windows-tdep.c (struct windows_gdbarch_data): Add tib_ptr_type.
	(windows_get_tlb_type): Use windows_gdbarch_data->tib_ptr_type.
2020-02-12 17:02:35 +01:00
Tom de Vries 38de8abe21 [gdb] Fix -Wstrict-null-sentinel warning (--with-iconv-bin)
When using configure flag --with-iconv-bin=$(which iconv), we run into:
...
gdb/charset.c: In function 'void find_charset_names()':
gdb/charset.c:821:75: error: missing sentinel in function call [-Werror=format=]
     iconv_program = concat (iconv_dir.c_str(), SLASH_STRING, "iconv", NULL);
                                                                           ^
cc1plus: all warnings being treated as errors
...

Fix the warning.

Build and reg-tested on x86_64-linux.

2020-02-12  Lukas Durfina  <ldurfina@tachyum.com>
	    Tom de Vries  <tdevries@suse.de>

	* charset.c (find_charset_names): Cast concat NULL sentinel to char *.
2020-02-12 11:15:33 +01:00
Tom Tromey f056b22b92 Update a comment in psymtab.h
This updates a comment in psymtab.h to reflect the current reality.

gdb/ChangeLog
2020-02-11  Tom Tromey  <tom@tromey.com>

	* psymtab.h: Update comment.

Change-Id: I438bb5929c3ebd1a4c6e9a902490f2ef63014ab3
2020-02-11 18:11:32 -07:00