This is the beginning of a series of patches where the goal is to turn
the target ops vector into a class and all the target op function
pointers into methods of this class.
Currently, the target ops is a struct of function pointers. At the
end of the series, it becomes a class with methods, and the existing
low target definitions become subclasses. That is, we end up with the
following class hierarchy:
process_stratum_target
^
|-- linux-low
|-- lynx-low
|-- nto-low
|-- win32-low
process_stratum_target either defines the default behavior for the
target ops or leaves them as pure virtual for the subclasses to
override.
The transformation is done by first introducing a helper class, called
'process_target', that is initially empty. An instance of this class
is added to the end of the current target ops vector. This new field
is called 'pt'. We will gradually carry target ops to the new class,
one by one, whereas the invocation of the target op will be converted
to a method call on 'pt'.
For instance, target op 'attach' is currently invoked as
(*the_target->attach) (args)
After moving 'attach' as a method to 'process_target', it will be
invoked as
the_target->pt->attach (args)
In this process, the concrete target vector definitions
(e.g. linux-low, win32-low, nto-low, etc.) are turned into derived
classes of 'process_target', so that they can either inherit the
default behavior of the target ops or can override the method.
We prefer to make this transition gradually rather than in a single
giant patch, to yield bite-size patches. The goal is that after each
patch gdbserver will still be buildable and testable.
The general rule of thumb when converting a target op to a method is
this:
(1) If the function call is protected with a NULL-check with an
obvious default behavior, simply implement that default behavior in
the base class (e.g.: supports_non_stop).
(2) If there is no NULL-check guard, the method becomes pure
virtual, and the derived targets are required to implement the method
(e.g.: attach).
(3) If there is a NULL-check but no apparent default behavior, or if
the NULL-check is utilized to populate a feature support packet,
introduce a 'supports_XYZ' method (e.g.: pid_to_exec_file).
The overall strategy is to preserve the existing behavior as much as
possible.
When we're done moving all the target ops into 'process_target', the
target op vector will contain nothing but the field 'pt'. At that
point, the auxiliary class 'process_target' will simply meld into
'process_stratum_target' and the method calls of the form
'the_target->pt->xyz' will be turned into 'the_target->xyz'.
The "linux-low" target has been built and reg-tested on X86_64 Linux
(Ubuntu). The "win32-low" target has been built (but not tested) via
cross-compilation to a x86_64-w64-mingw32 target. The "lynx-low" and
"nto-low" targets were neither built nor tested.
gdbserver/ChangeLog:
2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* target.h (class process_target): New class definition.
(struct process_stratum_target) <pt>: New field with type
'process_target*'.
* linux-low.h (class linux_process_target): Define as a derived
class of 'process_target'.
* linux-low.cc (linux_target_ops): Add a linux_process_target*
as the 'pt' field.
* lynx-low.h (class lynx_process_target): Define as a derived
class of 'process_target'.
* lynx-low.cc (lynx_target_ops): Add a lynx_process_target*
as the 'pt' field.
* nto-low.h (class nto_process_target): Define as a derived
class of 'process_target'.
* nto-low.cc (nto_target_ops): Add an nto_process_target*
as the 'pt' field.
* win32-low.h (class win32_process_target): Define as a derived
class of 'process_target'.
* win32-low.cc (win32_target_ops): Add a win32_process_target*
as the 'pt' field.
* elf-bfd.h (struct elf_backend_data): Add symbol_section_index
callback.
* elfxx-target.h (elf_backend_symbol_section_index): Provide
default definition.
(elfNN_bed): Initialise the symbol_section_index field.
* elf.c (swap_out_syms): Call symbol_section_index, if defined, on
OS and PROC specific section indicies. Warn if converting other
reserved incidies to SHN_ABS.
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.
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 Nelson Chu <nelson.chu@sifive.com>
gas/
* testsuite/gas/riscv/c-add-addi.d: New testcase.
* testsuite/gas/riscv/c-add-addi.s: Likewise.
opcodes/
* riscv-opc.c (riscv_opcodes): Convert add/addi to the compressed
c.mv/c.li if rs1 is zero.
Change-Id: Id939b5e6db80d267a832545f3ffef7b9ba881f7d
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.
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.
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.
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.
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.
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.
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.
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.
* config/tc-i386.c (output_insn): Mark cvtpi2ps and cvtpi2pd
with GNU_PROPERTY_X86_FEATURE_2_MMX.
* testsuite/gas/i386/i386.exp: Run property-3 and
x86-64-property-3.
* testsuite/gas/i386/property-3.d: New file.
* testsuite/gas/i386/property-3.s: Likewise.
* testsuite/gas/i386/x86-64-property-3.d: Likewise.
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.
Since plugin can be used only once in try_load_plugin, call dlclose
before return.
PR binutils/25355
* plugin.c (plugin_list_entry): Remove handle.
(try_load_plugin): Call dlclose before return.
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.
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.