- Rationale:
It is possible for compilers to indicate the desired byte order
interpretation of scalar variables using the DWARF attribute:
DW_AT_endianity
A type flagged with this variable would typically use one of:
DW_END_big
DW_END_little
which instructs the debugger what the desired byte order interpretation
of the variable should be.
The GCC compiler (as of V6) has a mechanism for setting the desired byte
ordering of the fields within a structure or union. For, example, on a
little endian target, a structure declared as:
struct big {
int v;
short a[4];
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );
could be used to ensure all the structure members have a big-endian
interpretation (the compiler would automatically insert byte swap
instructions before and after respective store and load instructions).
- To reproduce
GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes
in all situations when the scalar_storage_order attribute is used.
A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found
in the URL field of the following PR:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509
- Test-case:
A new test case (testsuite/gdb.base/endianity.*) is included with this
patch.
Manual testing for mixed endianity code has also been done with GCC V8.
See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4
- Observed vs. expected:
Without this change, using scalar_storage_order that doesn't match the
target, such as
struct otherendian
{
int v;
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );
would behave like the following on a little endian target:
Breakpoint 1 at 0x401135: file endianity.c, line 41.
(gdb) run
Starting program: /home/pjoot/freeware/t/a.out
Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64
Breakpoint 1, main () at endianity.c:41
41 struct otherendian o = {3};
(gdb) n
43 do_nothing (&o); /* START */
(gdb) p o
$1 = {v = 50331648}
(gdb) p /x
$2 = {v = 0x3000000}
whereas with this gdb enhancement we can access the variable with the user
specified endianity:
Breakpoint 1, main () at endianity.c:41
41 struct otherendian o = {3};
(gdb) p o
$1 = {v = 0}
(gdb) n
43 do_nothing (&o); /* START */
(gdb) p o
$2 = {v = 3}
(gdb) p o.v = 4
$3 = 4
(gdb) p o.v
$4 = 4
(gdb) x/4xb &o.v
0x7fffffffd90c: 0x00 0x00 0x00 0x04
(observe that the 4 byte int variable has a big endian representation in the
hex dump.)
gdb/ChangeLog
2019-11-21 Peeter Joot <peeter.joot@lzlabs.com>
Byte reverse display of variables with DW_END_big, DW_END_little
(DW_AT_endianity) dwarf attributes if different than the native
byte order.
* ada-lang.c (ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* ada-valprint.c (printstr):
(ada_val_print_string):
* ada-lang.c (value_pointer):
(ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* c-lang.c (c_get_string):
Use type_byte_order instead of gdbarch_byte_order.
* c-valprint.c (c_val_print_array):
Use type_byte_order instead of gdbarch_byte_order.
* cp-valprint.c (cp_print_class_member):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2loc.c (rw_pieced_value):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2read.c (read_base_type): Handle DW_END_big,
DW_END_little
* f-lang.c (f_get_encoding):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (default_read_var_value):
Use type_byte_order instead of gdbarch_byte_order.
* gdbtypes.c (check_types_equal):
Require matching TYPE_ENDIANITY_NOT_DEFAULT if set.
(recursive_dump_type): Print TYPE_ENDIANITY_BIG,
and TYPE_ENDIANITY_LITTLE if set.
(type_byte_order): new function.
* gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro.
(struct main_type) <flag_endianity_not_default>:
New field.
(type_byte_order): New function.
* infcmd.c (default_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
* p-lang.c (pascal_printstr):
Use type_byte_order instead of gdbarch_byte_order.
* p-valprint.c (pascal_val_print):
Use type_byte_order instead of gdbarch_byte_order.
* printcmd.c (print_scalar_formatted):
Use type_byte_order instead of gdbarch_byte_order.
* solib-darwin.c (darwin_current_sos):
Use type_byte_order instead of gdbarch_byte_order.
* solib-svr4.c (solib_svr4_r_ldsomap):
Use type_byte_order instead of gdbarch_byte_order.
* stap-probe.c (stap_modify_semaphore):
Use type_byte_order instead of gdbarch_byte_order.
* target-float.c (target_float_same_format_p):
Use type_byte_order instead of gdbarch_byte_order.
* valarith.c (scalar_binop):
(value_bit_index):
Use type_byte_order instead of gdbarch_byte_order.
* valops.c (value_cast):
Use type_byte_order instead of gdbarch_byte_order.
* valprint.c (generic_emit_char):
(generic_printstr):
(val_print_string):
Use type_byte_order instead of gdbarch_byte_order.
* value.c (unpack_long):
(unpack_bits_as_long):
(unpack_value_bitfield):
(modify_field):
(pack_long):
(pack_unsigned_long):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (unsigned_pointer_to_address):
(signed_pointer_to_address):
(unsigned_address_to_pointer):
(address_to_signed_pointer):
(default_read_var_value):
(default_value_from_register):
Use type_byte_order instead of gdbarch_byte_order.
* gnu-v3-abi.c (gnuv3_make_method_ptr):
Use type_byte_order instead of gdbarch_byte_order.
* riscv-tdep.c (riscv_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
gdb/testsuite/ChangeLog
2019-11-21 Peeter Joot <peeter.joot@lzlabs.com>
* gdb.base/endianity.c: New test.
* gdb.base/endianity.exp: New file.
Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
I think it would be clearer to not use gen_ret_current_ui_field_ptr to
generate the implementation of current_ui_gdb_stdout_ptr et al. It
doesn't save much code, but adds a layer of complexity for the reader.
Plus, it doesn't work well with IDEs, for example if you ask to find all
usages the m_gdb_stdout field.
gdb/ChangeLog:
* top.c (current_ui_gdb_stdout_ptr): Spell out by hand.
(current_ui_gdb_stdin_ptr): Likewise.
(current_ui_gdb_stderr_ptr): Likewise.
(current_ui_gdb_stdlog_ptr): Likewise.
(current_ui_current_uiout_ptr): Likewise.
(gen_ret_current_ui_field_ptr): Remove.
Change-Id: I86f821c9d119453701caedf0e47124ccddfbab2d
The SOM backend creates BFD sections for "spaces", and "sub-spaces".
"sub-spaces" are what we normally think of as a section, "spaces"
aggregate "sub-spaces". Thus it does not really make sense to include
"spaces" for size -A since that would double count total size.
It so happens that real sections ought to have at least one of the
ALLOC and HAS_CONTENTS flags set, so this patch excludes "spaces" but
excluding BFD sections with no flags set.
PR 273
* size.c (sysv_internal_sizer, sysv_internal_printer): Exclude
sections with no flag bits set.
* testsuite/binutils-all/size.exp: Allow $CODE$ as a text section.
This code in elf_link_add_object_symbols:
ret = elf_add_dt_needed_tag (abfd, info, soname, add_needed);
if (ret < 0)
goto error_return;
/* If we have already included this dynamic object in the
link, just ignore it. There is no reason to include a
particular dynamic object more than once. */
if (ret > 0)
return TRUE;
prevents a shared library from being loaded twice by ensuring that any
library soname doesn't match the soname of one already loaded. This
happens before sym_hashes are allocated, which leaves sym_hashes NULL.
cmse_scan looks at library symbols, and when attempting to look up a
global symbol will segfault if sym_hashes is zero.
* elf32-arm.c (elf32_arm_size_stubs): Exclude dynamic library
BFDs that have not been loaded.
The problem reported in PR mi/25055 is that the output of the backtrace
command, when executed as breakpoint command does not show when executing
using the MI interpreter:
...
$ gdb a.out
Reading symbols from a.out...
(gdb) break main
Breakpoint 1 at 0x4003c0: file test.c, line 19.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>bt
>end
(gdb) interpreter-exec mi "-exec-run"
^done
Breakpoint 1, main () at test.c:19
19 return foo (4);
(gdb)
...
Interestingly, the function print_frame is called twice during -exec-run:
- once during tui_on_normal_stop where the ui_out is temporarily set to
tui->interp_ui_out (), resulting in the part after the comma in
"Breakpoint 1, main () at test.c:19"
- once during execute_control_command, where the ui_out is the default for the
current interpreter: mi_ui_out, which ignores calls to output text.
The commit 3a87ae656c "Use console uiout when executing breakpoint commands"
fixes the problem by temporarily switching to the ui_out of INTERP_CONSOLE in
execute_control_command.
This however caused a regression in redirection (escaping '#' using '\' for
git commit message convenience):
...
$ rm -f gdb.txt; gdb a.out
Reading symbols from a.out...
(gdb) break main
Breakpoint 1 at 0x4003c0: file test.c, line 19.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>bt
>end
(gdb) set logging redirect on
(gdb) set logging on
Redirecting output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) run
\#0 main () at test.c:19
(gdb) q
A debugging session is active.
Inferior 1 [process 22428] will be killed.
Quit anyway? (y or n) y
$ cat gdb.txt
Starting program: /data/gdb_versions/devel/a.out
Breakpoint 1, main () at test.c:19
19 return foo (4);
...
The problem is that the '#0 main () at test.c:19' ends up in the gdb output
output rather than in gdb.txt. This is due to the fact that the redirect is
setup for the current ui_out (which is tui->interp_ui_out ()), while the
backtrace output is printed to the INTERP_CONSOLE ui_out.
Fix this by limiting switching to INTERP_CONSOLE ui_out to when INTERP_MI is
active.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-11-21 Tom de Vries <tdevries@suse.de>
PR gdb/24956
* cli/cli-script.c (execute_control_command): Only switch to
INTERP_CONSOLE's ui_out when INTERP_MI is active.
gdb/testsuite/ChangeLog:
2019-11-21 Tom de Vries <tdevries@suse.de>
PR gdb/24956
* gdb.base/ui-redirect.exp: Test output of user-defined command.
Change-Id: Id1771e7fcc9496a7d97ec2b2ea6b1487596f1ef7
Commit 33d569b709 ("gdb/python: Return
None from Progspace.block_for_pc on error") added a few tests on
gdb.python/py-progspace.exp which use 'print', but forgot to use
parentheses when passing the arguments to be printed. This fails on
Python 3.
This commit adds these missing parentheses. Pushed as obvious.
gdb/testsuite/ChangeLog:
2019-11-20 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.python/py-progspace.exp: Add missing parentheses on some
'print' commands.
Change-Id: Iac0a7578855d128bbee3b98e7ea5888dae55fc00
The current code checks for the presence of a SVE target description by
comparing the number of registers. This is a bit fragile since the number
of registers can change whenever we add new sets. Like PAC, for example.
If the comparison breaks, then we're left with SVE registers in the
description, but gdbserver doesn't send the registers to GDB, which in
turn displays stale information to the user.
The following patch changes the check to use the SVE feature string instead,
which hopefully should be more stable.
gdb/gdbserver/ChangeLog:
2019-11-20 Luis Machado <luis.machado@linaro.org>
* linux-aarch64-low.c (is_sve_tdesc): Check against target feature
instead of register count.
* tdesc.c (tdesc_contains_feature): New function.
* tdesc.h (tdesc_contains_feature): New prototype.
Change-Id: I28b782cb1677560ca9a06a1be442974b25aabae4
The "winheight" command is broken. I probably broke it in one of my
TUI refactoring patches, though I didn't track down exactly which one.
The bug is that the code does:
*buf_ptr = '\0';
... but then never advances buf_ptr past this point, so no window name
is seen.
This patch refactors the code a bit so that a copy of the argument
string is not needed, also fixing the bug.
A new test case is included.
gdb/ChangeLog
2019-11-19 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_partial_win_by_name): Move from tui-data.c.
Now static. Change type of "name".
(tui_set_win_height_command): Don't copy "arg".
* tui/tui-data.h (tui_partial_win_by_name): Don't declare.
* tui/tui-data.c (tui_partial_win_by_name): Move to tui-win.c.
gdb/testsuite/ChangeLog
2019-11-19 Tom Tromey <tom@tromey.com>
* gdb.tui/winheight.exp: New file.
Change-Id: I0871e93777a70036dbec9c9543f862f42e3a81e5
When DebugActiveProcess fails, the error message is fairly generic:
error (_("Can't attach to process."));
It would be more useful for diagnosing problems if the Windows error
code was included in the message. This patch implements this.
gdb/ChangeLog
2019-11-19 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_nat_target::attach): Include GetLastError
result in error when DebugActiveProcess fails.
Change-Id: Ie1bf502a0d96bb7c09bd5b1c5e0c924ba58cd68c
objcopy --add-gnu-debuglink=foo.a.dbg foo.a just doesn't make any
sense. Who puts executables in archives?
PR 24499
* objcopy.c (copy_file): Ignore --add-gnu-debuglink for archives.
This should make objcopy -B redundant for the common case of producing
ELF output where the -O target defaults to the desired arch:mach.
PR 24968
* objcopy.c (copy_object): For ELF output and non-ELF input without
arch, take arch from output file if not given by -B. Don't
bfd_get_arch_info when we already have iarch.
This PR copies a fuzzed PE input file to ELF output, in the process
confusing the ELF backend by copying COFF-only section flags to the
output. SEC_COFF_SHARED has the same value as SEC_ELF_COMPRESS. One
approach to fixing this problem is of course not to reuse flag bits,
but we've run out. So this patch only copies section flags that are
in the bfd_applicable_section_flags set when changing the flavour of
the output file.
PR 25191
* objcopy.c (is_nondebug_keep_contents_section): Use bfd_get_flavour.
(copy_object): Likewise.
(setup_section): Likewise. If flavour of input and output files
differ, restrict section flags to the intersection of input and
output bfd_applicable_section_flags.
The testcase in this PR triggered "BFD_ASSERT (p2->is_sym)" by
sneakily generating a C_FILE sym whose value pointed into auxents.
The fix then is in the last changed line of this patch, to check
p->is_sym as well as p->u.syment.n_sclass. The other changes fix
various overflow checks that weren't as solid as they could be.
PR 25197
* coffgen.c (coff_find_nearest_line_with_names): Check that C_FILE
u.syment.n_value does point at another C_FILE sym and not into
some auxent that happens to look like a C_FILE. Properly check
for integer overflow and avoid possible pointer wrap-around.
Simplify pr17512 checks.
The GNU coding standard does indicate there should be no space in
messages like these, but we tend to put a space in all other
messages. This patch cures the inconsistency in:
$ binutils/strip-new -F elf32-little -N .text -o pr25200 pr25200.bin
binutils/strip-new: pr25200: R_X86_64_PLT32 unsupported
binutils/strip-new:pr25200: sorry, cannot handle this file
* bucomm.c (bfd_nonfatal_message): Add a space between program
name and file.
The recently added gdb.base/ctf-whatis.exp test is a slightly modified
version of gdb.base/whatis.exp, with a few tests removed, and the
source compiled with different compiler options. This patch merges
the two tests together into a single test script.
I tested using a version of GCC with CTF support added.
gdb/testsuite/ChangeLog:
* gdb.base/ctf-whatis.c: Delete.
* gdb.base/ctf-whatis.exp: Delete.
* gdb.base/whatis.exp: Rewrite to compile as both dwarf and ctf.
Change-Id: I09e11c70f197b79d2b1e0ae8c86a21c622be6c51
The recently added gdb.base/ctf-cvexpr.exp is just a copy of
gdb.base/cvexpr.exp but compiled with different options. This patch
merges these two tests together into a single test script.
I tested this change using a version of GCC with CTF support added.
gdb/testsuite/ChangeLog:
* gdb.base/ctf-cvexpr.exp: Delete.
* gdb.base/cvexpr.exp: Rewrite to compile as both dwarf and ctf.
Change-Id: If678c3e38cb444867defa970203d26563f15dba4
Most versions of GCC in the wild don't support CTF debug format right
now, so, rather than attempting to compile the tests and failing each
time, this patch introduces a guard function to check if the compiler
supports CTF. If we don't have CTF support then the CTF tests are
skipped.
This patch only updates 3 of the 4 CTF tests, the fourth will be
handled in the next patch.
gdb/testsuite/ChangeLog:
* gdb.base/ctf-constvars.exp: Skip test if CTF is not supported in
the compiler. Clean up header comment a little.
* gdb.base/ctf-ptype.exp: Likewise.
* gdb.base/ctf-whatis.exp: Likewise.
* lib/gdb.exp (skip_ctf_tests): New proc.
Change-Id: I505c11169a9bc9871a31fc0c61e119f92f32cc63
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117
A segfault can happen in a specific scenario when using TUI + a
corefile, as explained in the bug mentioned above. The problem
happens when opening a corefile on GDB:
$ gdb ./core program
entering TUI (C-x a), and then issuing a "run" command. GDB segfaults
with the following stack trace:
(top-gdb) bt
#0 0x00000000004cd5da in target_ops::shortname (this=0x0) at ../../binutils-gdb/gdb/target.h:449
#1 0x0000000000ac08fb in target_shortname () at ../../binutils-gdb/gdb/target.h:1323
#2 0x0000000000ac09ae in tui_locator_window::make_status_line[abi:cxx11]() const (this=0x23e1fa0 <_locator>) at ../../binutils-gdb/gdb/tui/tui-stack.c:86
#3 0x0000000000ac1043 in tui_locator_window::rerender (this=0x23e1fa0 <_locator>) at ../../binutils-gdb/gdb/tui/tui-stack.c:231
#4 0x0000000000ac1632 in tui_show_locator_content () at ../../binutils-gdb/gdb/tui/tui-stack.c:369
#5 0x0000000000ac63b6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at ../../binutils-gdb/gdb/tui/tui.c:321
#6 0x0000000000aaf9be in tui_inferior_exit (inf=0x2d446a0) at ../../binutils-gdb/gdb/tui/tui-hooks.c:181
#7 0x000000000044cddf in std::_Function_handler<void (inferior*), void (*)(inferior*)>::_M_invoke(std::_Any_data const&, inferior*&&) (__functor=..., __args#0=@0x7fffffffd650: 0x2d446a0)
at /usr/include/c++/9/bits/std_function.h:300
#8 0x0000000000757db9 in std::function<void (inferior*)>::operator()(inferior*) const (this=0x2cf3168, __args#0=0x2d446a0) at /usr/include/c++/9/bits/std_function.h:690
#9 0x0000000000757876 in gdb::observers::observable<inferior*>::notify (this=0x23de0c0 <gdb::observers::inferior_exit>, args#0=0x2d446a0)
at ../../binutils-gdb/gdb/gdbsupport/observable.h:106
#10 0x000000000075532d in exit_inferior_1 (inftoex=0x2d446a0, silent=1) at ../../binutils-gdb/gdb/inferior.c:191
#11 0x0000000000755460 in exit_inferior_silent (inf=0x2d446a0) at ../../binutils-gdb/gdb/inferior.c:234
#12 0x000000000059f47c in core_target::close (this=0x2d68590) at ../../binutils-gdb/gdb/corelow.c:265
#13 0x0000000000a7688c in target_close (targ=0x2d68590) at ../../binutils-gdb/gdb/target.c:3293
#14 0x0000000000a63d74 in target_stack::push (this=0x23e1800 <g_target_stack>, t=0x23c38c8 <the_amd64_linux_nat_target>) at ../../binutils-gdb/gdb/target.c:568
#15 0x0000000000a63dbf in push_target (t=0x23c38c8 <the_amd64_linux_nat_target>) at ../../binutils-gdb/gdb/target.c:583
#16 0x0000000000748088 in inf_ptrace_target::create_inferior (this=0x23c38c8 <the_amd64_linux_nat_target>, exec_file=0x2d58d30 "/usr/bin/cat", allargs="", env=0x25f12b0, from_tty=1)
at ../../binutils-gdb/gdb/inf-ptrace.c:128
#17 0x0000000000795ccb in linux_nat_target::create_inferior (this=0x23c38c8 <the_amd64_linux_nat_target>, exec_file=0x2d58d30 "/usr/bin/cat", allargs="", env=0x25f12b0, from_tty=1)
at ../../binutils-gdb/gdb/linux-nat.c:1094
#18 0x000000000074eae9 in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at ../../binutils-gdb/gdb/infcmd.c:639
...
The problem happens because 'tui_locator_window::make_status_line'
needs the value of 'target_shortname' in order to update the status
line. 'target_shortname' is a macro which expands to:
#define target_shortname (current_top_target ()->shortname ())
and, in our scenario, 'current_top_target ()' returns NULL, which
obviously causes a segfault. But why does it return NULL, since,
according to its comment on target.h, it should never do that?
What is happening is that we're being caught in the middle of a
"target switch". We had the 'core_target' on top, because we were
inspecting a corefile, but when the user decided to invoke "run" GDB
had to actually create the inferior, which ends up detecting that we
have a target already, and tries to close it (from target.c):
/* See target.h. */
void
target_stack::push (target_ops *t)
{
/* If there's already a target at this stratum, remove it. */
strata stratum = t->stratum ();
if (m_stack[stratum] != NULL)
{
target_ops *prev = m_stack[stratum];
m_stack[stratum] = NULL;
target_close (prev); // <-- here
}
...
When the current target ('core_target') is being closed, it checks for
possible observers registered with it and calls them. TUI is one of
those observers, it gets called, tries to update the status line, and
GDB crashes.
The real problem is that we are clearing 'm_stack[stratum]', but
forgetting to adjust 'm_top'. Interestingly, this scenario is covered
in 'target_stack::unpush', but Pedro said he forgot to call it here..
The fix, therefore, is to call '::unpush' if there's a target on the
stack.
This patch has been tested on the Buildbot and no regressions have
been found. I'm also submitting a testcase for it.
gdb/ChangeLog:
2019-11-18 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1765117
* target.c (target_stack::push): Call 'unpush' if there's a
target on top of the stack.
gdb/testsuite/ChangeLog:
2019-11-18 Sergio Durigan Junior <sergiodj@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1765117
* gdb.tui/corefile-run.exp: New file.
Change-Id: I39e2f8b538c580c8ea5bf1d657ee877e47746c8f
This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to
some other non-zero value) when gold outputs an ifunc local or global
symbol, or a unique global symbol to either .dynsym or .symtab.
STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range
and therefore require interpretation according to OSABI.
I'm not sure why parameters->target() is const Target& while
parameters->sized_target() is Sized_target*, but it's inconvenient to
use the latter in Symbol_table::finalize. So this patch adds another
const_cast complained about in layout.cc and gold.cc.
PR 24853
* symtab.h (set_has_gnu_output, has_gnu_output_): New.
* symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_.
(Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_.
(Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize):
Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals.
* object.cc (Sized_relobj_file::do_finalize_local_symbols): Call
set_has_gnu_output when STT_GNU_IFUNC locals will be output.
valgrind reports leaks in many python tests, such as:
==17162== VALGRIND_GDB_ERROR_BEGIN
==17162== 8,208 (5,472 direct, 2,736 indirect) bytes in 57 blocks are definitely lost in loss record 7,551 of 7,679
==17162== at 0x4835753: malloc (vg_replace_malloc.c:307)
==17162== by 0x6EAFD1: _PyObject_New (object.c:279)
==17162== by 0x4720E6: blpy_iter(_object*) (py-block.c:92)
==17162== by 0x698772: PyObject_GetIter (abstract.c:2577)
==17162== by 0x2343BE: _PyEval_EvalFrameDefault (ceval.c:3159)
==17162== by 0x22E9E2: function_code_fastcall (call.c:283)
==17162== by 0x2340A8: _PyObject_Vectorcall (abstract.h:127)
==17162== by 0x2340A8: call_function (ceval.c:4987)
==17162== by 0x2340A8: _PyEval_EvalFrameDefault (ceval.c:3486)
==17162== by 0x22E9E2: function_code_fastcall (call.c:283)
==17162== by 0x82172B: _PyObject_Vectorcall (abstract.h:127)
==17162== by 0x82172B: method_vectorcall (classobject.c:67)
==17162== by 0x6AF474: _PyObject_Vectorcall (abstract.h:127)
==17162== by 0x6AF474: _PyObject_CallNoArg (abstract.h:153)
==17162== by 0x6AF474: _PyObject_CallFunctionVa (call.c:914)
==17162== by 0x6B0673: callmethod (call.c:1010)
==17162== by 0x6B0673: _PyObject_CallMethod_SizeT (call.c:1103)
==17162== by 0x477DFE: gdb_PyObject_CallMethod<> (python-internal.h:182)
==17162== by 0x477DFE: get_py_iter_from_func(_object*, char const*) (py-framefilter.c:272)
==17162== by 0x4791B4: py_print_args (py-framefilter.c:706)
==17162== by 0x4791B4: py_print_frame(_object*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, htab*) (py-framefilter.c:960)
==17162== by 0x47A130: gdbpy_apply_frame_filter(extension_language_defn const*, frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (py-framefilter.c:1236)
==17162== by 0x369C39: apply_ext_lang_frame_filter(frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (extension.c:563)
==17162== by 0x4EC9C9: backtrace_command_1 (stack.c:2031)
==17162== by 0x4EC9C9: backtrace_command(char const*, int) (stack.c:2183)
...
Most of the leaks in python tests are due to the fact that many
PyObject xxxxx_dealloc functions are missing the line to free self
or obj such as:
Py_TYPE (self)->tp_free (self);
or
Py_TYPE (obj)->tp_free (obj);
With this patch, the number of python tests leaking decreases from 52 to 12.
gdb/ChangeLog
2019-11-18 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* python/py-block.c (blpy_dealloc): Call tp_free.
(blpy_block_syms_dealloc): Likewise.
* python/py-finishbreakpoint.c (bpfinishpy_dealloc): Likewise.
* python/py-inferior.c (infpy_dealloc): Likewise.
* python/py-lazy-string.c (stpy_dealloc): Likewise.
* python/py-linetable.c (ltpy_iterator_dealloc): Likewise.
* python/py-symbol.c (sympy_dealloc): Likewise.
* python/py-symtab.c (stpy_dealloc): Likewise.
* python/py-type.c (typy_iterator_dealloc): Likewise.
As reported by PhilippeW, valgrind reports that symtab is uninitialized
when compiling with GCC 4.8.5, which is the default compiler on CentOS 7.
This is apparently a compiler bug fixed in later versions, but to keep
CentOS 7 working, this patch initializes the union explicitly instead of
using a class initializer.
gdb/ChangeLog:
2019-11-18 Christian Biesinger <cbiesinger@google.com>
* symtab.h (struct symbol) <owner>: Initialize explicitly in the
constructor instead of using a class initializer.
Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1
This patch renames elf_backend_modify_program_headers and moves the
elf.c code tweaking the ELF file header for -pie -Ttext-segment to a
new function, _bfd_elf_modify_headers, which then becomes the default
elf_backed_modify_headers and is called from any other target
elf_backed_modify_headers.
* elf-bfd.h (struct elf_backend_data <elf_backend_modify_headers>):
Rename from elf_backend_modify_program_headers.
(_bfd_elf_modify_headers): Declare.
* elf.c (assign_file_positions_except_relocs): Set
elf_program_header_size. Always call elf_backend_modify_headers.
Extract code modifying file header..
(_bfd_elf_modify_headers): ..to here. New function.
* elf32-arm.c (elf_backend_modify_headers): Renamed from
elf_backend_modify_program_headers.
* elf32-i386.c: Similarly.
* elf64-x86-64.c: Similarly.
* elfxx-target.h: Similarly. Default elf_backend_modify_headers
to _bfd_elf_modify_headers.
* elf-nacl.h (nacl_modify_headers): Rename from
nacl_modify_program_headers.
* elf-nacl.c (nacl_modify_headers): Rename from
nacl_modify_program_headers and call _bfd_elf_modify_headers.
* elf32-rx.c (elf32_rx_modify_headers): Similarly.
* elf32-spu.c (spu_elf_modify_headers): Similarly.
* elfnn-ia64.c (elfNN_ia64_modify_headers): Similarly.
* elf32-sh.c (elf_backend_modify_program_headers): Don't undef.
This patch introduces a new "sorry, cannot handle this file" bfd error
status. The idea is to use this error in cases where bfd hasn't found
a bfd_bad_value error, ie. an input file or set of options that are
invalid, but rather an input file that is simply too difficult to
process. Typically this might happen with fuzzed object files such as
the one in the PR, a wildly improbable core file. Some things are
just not worth wasting time over to fix "properly".
PR 25196
* bfd.c (bfd_error_type): Add bfd_error_sorry.
(bfd_errmsgs): Likewise.
* elf.c (rewrite_elf_program_header): Don't abort on confused
lma/alignment. Replace bfd_error_bad_value with bfd_error_sorry.
(_bfd_elf_validate_reloc): Use bfd_error_sorry.
(_bfd_elf_final_write_processing): Likewise.
* bfd-in2.h: Regenerate.
Add a flag to control the version of CIE that is generated. By
default gas produces CIE version 1, and this continues to be the
default after this patch.
However, a user can now provide --gdwarf-cie-version=NUMBER to switch
to either version 3 or version 4 of CIE, version 2 was never released,
and so causes an error as does any number less than 1 or greater than
4.
Producing version 4 CIE requires two new fields to be added to the
CIE, an address size field, and an segment selector field. For a flat
address space the DWARF specification indicates that the segment
selector should be 0, and the address size fields just contains the
address size in bytes. For now we support 4 or 8 byte addresses, and
the segment selector is always produced as 0. At some future time we
might need to allow targets to override this.
gas/ChangeLog:
* as.c (parse_args): Parse --gdwarf-cie-version option.
(flag_dwarf_cie_version): New variable.
* as.h (flag_dwarf_cie_version): Declare.
* dw2gencfi.c (output_cie): Switch from DW_CIE_VERSION to
flag_dwarf_cie_version.
* doc/as.texi (Overview): Document --gdwarf-cie-version.
* NEWS: Likewise.
* testsuite/gas/cfi/cfi.exp: Add new tests.
* testsuite/gas/cfi/cie-version-0.d: New file.
* testsuite/gas/cfi/cie-version-1.d: New file.
* testsuite/gas/cfi/cie-version-2.d: New file.
* testsuite/gas/cfi/cie-version-3.d: New file.
* testsuite/gas/cfi/cie-version-4.d: New file.
* testsuite/gas/cfi/cie-version.s: New file.
include/ChangeLog:
* dwarf2.h (DW_CIE_VERSION): Delete.
Change-Id: I9de19461aeb8332b5a57bbfe802953d0725a7ae8
There is no need to keep mingw-strerror around; we can just always use
the code from posix-strerror. The main reason we had that code, it
seems, is to handle winsock error codes, but gnulib's version
handles those.
Unfortunately the code can't be moved into common-utils.c because
libinproctrace.so uses common-utils but not gnulib.
gdb/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c.
* configure: Regenerate.
* configure.ac: Don't source common.host.
* gdbsupport/common.host: Remove.
* gdbsupport/mingw-strerror.c: Remove.
* gdbsupport/posix-strerror.c: Rename to...
* gdbsupport/safe-strerror.c: ...this.
gdb/gdbserver/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Add safe-strerror.c.
* configure: Regenerate.
* configure.ac: Don't source common.host.
Change-Id: I9e6d8a752fc398784201f370cafee65e0ea05474
This adds the no-dist option to the gnulib configure script. gdb
doesn't use "make dist", so there's no need for this. Adding this
option makes the Makefiles less verbose.
gnulib/ChangeLog
2019-11-15 Tom Tromey <tromey@adacore.com>
* aclocal.m4, configure, Makefile.in, import/Makefile.in:
Rebuild.
* configure.ac: Remove obsolete comment. Add no-dist.
Change-Id: I5224e18af9acd5284acb79d5756b0e84b00406e9
Christian's recent patches to gnulib made me realize that readline
should be changed to use AC_CONFIG_MACRO_DIRS (ACLOCAL_AMFLAGS is
deprecated) and that it can put the automake options into
configure.ac. I also added no-define to the automake options. This
doesn't matter much (we don't generate a config.h here), but gnulib
does it, and it does make configure slightly smaller.
readline/ChangeLog
2019-11-15 Tom Tromey <tromey@adacore.com>
* configure, Makefile.in: Rebuild.
* configure.ac: Use AC_CONFIG_MACRO_DIRS. Pass options to
AM_INIT_AUTOMAKE.
* Makefile.am (AUTOMAKE_OPTIONS, ACLOCAL_AMFLAGS): Remove.
Change-Id: If421599cc9dd9c4c3c37b9b439ab2c22c01742ed
To make these calls threadsafe. localtime_r is provided by gnulib if
necessary, and for ctime_r we can just use it because it is in a linux-
specific file.
gdb/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* maint.c (scoped_command_stats::print_time): Use localtime_r
instead of localtime (provided through gnulib if necessary).
* nat/linux-osdata.c (time_from_time_t): Use ctime_r instead
of ctime.
Change-Id: I329bbdc39d5b576f51859ba00f1617e024c30cbd
Makes sure to assign the return value of strerror_r to an int,
so that we get a compile error if we accidentally get the
wrong version.
gdb/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
* gdbsupport/common.m4: No longer check for strerror_r.
* gdbsupport/posix-strerror.c (safe_strerror): Always call the
POSIX version of strerror_r, now that gnulib provides it if
necessary.
gdb/gdbserver/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
gnulib/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/extra/config.rpath: New file.
* import/glthread/lock.c: New file.
* import/glthread/lock.h: New file.
* import/glthread/threadlib.c: New file.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/lib-ld.m4: New file.
* import/m4/lib-link.m4: New file.
* import/m4/lib-prefix.m4: New file.
* import/m4/lock.m4: New file.
* import/m4/strerror_r.m4: New file.
* import/m4/threadlib.m4: New file.
* import/strerror_r.c: New file.
* update-gnulib.sh: Import strerror_r-posix.
Change-Id: I5cfeb12a5203a4cd94a78581541e6085a68685c3
This is a lot simpler and as a side-effect this will correctly
regenerate import/Makefile and config.h during rebuilds if
necessary.
gnulib/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.am: New file.
* Makefile.in: Replace with generated file.
* aclocal-m4-deps.mk: Remove.
* configure.ac: Use the foreign option for automake and specify
the aclocal search path here.
* update-gnulib.sh: Don't generate aclocal-m4-deps.mk anymore.
Also don't specify the aclocal include path here, now that it
is in configure.ac.
Change-Id: I6a2c4d41cf4f0e21d5c813197bad63ed5c08e408
Adds descriptions for some recent-ish configure options to README.
Also updates the minimum Python version per commit
6c28e44a35.
2019-11-14 Christian Biesinger <cbiesinger@google.com>
* README (`configure' options): Update.
Change-Id: I8ce8ca6935afbd130295e143802c585cf1e735f9