displaced_step_closure is a type defined in multiple -tdep.c files.
Trying to xfree it from the common code (infrun.c) is a problem when we
try to poison xfree for non-POD types. Because there can be multiple of
these types in the same build, this patch makes a hierarchy of classes
with a virtual destructor. When the common code deletes the object
through a displaced_step_closure pointer, it will invoke the right
destructor.
The amd64 used a last-member array with a variable size. That doesn't
work with new, so I changed it for an std::vector. Other architectures
which used a simple byte buffer as a closure now use a shared
buf_displaced_step_closure, a closure type that only contains a
gdb::byte_vector.
Reg-tested on the buildbot.
gdb/ChangeLog:
* infrun.h: Include common/byte-vector.h.
(struct displaced_step_closure): New struct.
(struct buf_displaced_step_closure): New struct.
* infrun.c (displaced_step_closure::~displaced_step_closure):
Provide default implementation.
(displaced_step_clear): Deallocate step closure with delete.
* aarch64-tdep.c (displaced_step_closure): Rename to ...
(aarch64_displaced_step_closure): ... this, extend
displaced_step_closure.
(aarch64_displaced_step_data) <dsc>: Change type to
aarch64_displaced_step_closure.
(aarch64_displaced_step_copy_insn): Adjust to type change, use
unique_ptr.
(aarch64_displaced_step_fixup): Add cast for displaced step
closure.
* amd64-tdep.c (displaced_step_closure): Rename to ...
(amd64_displaced_step_closure): ... this, extend
displaced_step_closure.
<insn_buf>: Change type to std::vector<gdb_byte>.
<max_len>: Remove.
(fixup_riprel): Change type of DSC parameter, adjust to type
change of insn_buf.
(fixup_displaced_copy): Change type of DSC parameter.
(amd64_displaced_step_copy_insn): Instantiate
amd64_displaced_step_closure.
(amd64_displaced_step_fixup): Add cast for closure type, adjust
to type change of insn_buf.
* arm-linux-tdep.c (arm_linux_cleanup_svc): Change type of
parameter DSC.
(arm_linux_copy_svc): Likewise.
(cleanup_kernel_helper_return): Likewise.
(arm_catch_kernel_helper_return): Likewise.
(arm_linux_displaced_step_copy_insn): Instantiate
arm_displaced_step_closure.
* arm-tdep.c (arm_pc_is_thumb): Add cast for closure.
(displaced_read_reg): Change type of parameter DSC.
(branch_write_pc): Likewise.
(load_write_pc): Likewise.
(alu_write_pc): Likewise.
(displaced_write_reg): Likewise.
(arm_copy_unmodified): Likewise.
(thumb_copy_unmodified_32bit): Likewise.
(thumb_copy_unmodified_16bit): Likewise.
(cleanup_preload): Likewise.
(install_preload): Likewise.
(arm_copy_preload): Likewise.
(thumb2_copy_preload): Likewise.
(install_preload_reg): Likewise.
(arm_copy_preload_reg): Likewise.
(cleanup_copro_load_store): Likewise.
(install_copro_load_store): Likewise.
(arm_copy_copro_load_store) Likewise.
(thumb2_copy_copro_load_store): Likewise.
(cleanup_branch): Likewise.
(install_b_bl_blx): Likewise.
(arm_copy_b_bl_blx): Likewise.
(thumb2_copy_b_bl_blx): Likewise.
(thumb_copy_b): Likewise.
(install_bx_blx_reg): Likewise.
(arm_copy_bx_blx_reg): Likewise.
(thumb_copy_bx_blx_reg): Likewise.
(cleanup_alu_imm): Likewise.
(arm_copy_alu_imm): Likewise.
(thumb2_copy_alu_imm): Likewise.
(cleanup_alu_reg): Likewise.
(install_alu_reg): Likewise.
(arm_copy_alu_reg): Likewise.
(thumb_copy_alu_reg): Likewise.
(cleanup_alu_shifted_reg): Likewise.
(install_alu_shifted_reg): Likewise.
(arm_copy_alu_shifted_reg): Likewise.
(cleanup_load): Likewise.
(cleanup_store): Likewise.
(arm_copy_extra_ld_st): Likewise.
(install_load_store): Likewise.
(thumb2_copy_load_literal): Likewise.
(thumb2_copy_load_reg_imm): Likewise.
(arm_copy_ldr_str_ldrb_strb): Likewise.
(cleanup_block_load_all): Likewise.
(cleanup_block_store_pc): Likewise.
(cleanup_block_load_pc): Likewise.
(arm_copy_block_xfer): Likewise.
(thumb2_copy_block_xfer): Likewise.
(cleanup_svc): Likewise.
(install_svc): Likewise.
(arm_copy_svc): Likewise.
(thumb_copy_svc): Likewise.
(arm_copy_undef): Likewise.
(thumb_32bit_copy_undef): Likewise.
(arm_copy_unpred): Likewise.
(arm_decode_misc_memhint_neon): Likewise.
(arm_decode_unconditional): Likewise.
(arm_decode_miscellaneous): Likewise.
(arm_decode_dp_misc): Likewise.
(arm_decode_ld_st_word_ubyte): Likewise.
(arm_decode_media): Likewise.
(arm_decode_b_bl_ldmstm): Likewise.
(arm_decode_ext_reg_ld_st): Likewise.
(thumb2_decode_dp_shift_reg): Likewise.
(thumb2_decode_ext_reg_ld_st): Likewise.
(arm_decode_svc_copro): Likewise.
(thumb2_decode_svc_copro): Likewise.
(install_pc_relative): Likewise.
(thumb_copy_pc_relative_16bit): Likewise.
(thumb_decode_pc_relative_16bit): Likewise.
(thumb_copy_pc_relative_32bit): Likewise.
(thumb_copy_16bit_ldr_literal): Likewise.
(thumb_copy_cbnz_cbz): Likewise.
(thumb2_copy_table_branch): Likewise.
(cleanup_pop_pc_16bit_all): Likewise.
(thumb_copy_pop_pc_16bit): Likewise.
(thumb_process_displaced_16bit_insn): Likewise.
(decode_thumb_32bit_ld_mem_hints): Likewise.
(thumb_process_displaced_32bit_insn): Likewise.
(thumb_process_displaced_insn): Likewise.
(arm_process_displaced_insn): Likewise.
(arm_displaced_init_closure): Likewise.
(arm_displaced_step_fixup): Add cast for closure.
* arm-tdep.h: Include infrun.h.
(displaced_step_closure): Rename to ...
(arm_displaced_step_closure): ... this, extend
displaced_step_closure.
<u::svc::copy_svc_os>: Change type of parameter DSC.
<cleanup>: Likewise.
(arm_process_displaced_insn): Likewise.
(arm_displaced_init_closure): Likewise.
(displaced_read_reg): Likewise.
(displaced_write_reg): Likewise.
* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn):
Adjust.
* i386-tdep.h: Include infrun.h.
(i386_displaced_step_closure): New typedef.
* i386-tdep.c (i386_displaced_step_copy_insn): Use
i386_displaced_step_closure.
(i386_displaced_step_fixup): Adjust.
* rs6000-tdep.c (ppc_displaced_step_closure): New typedef.
(ppc_displaced_step_copy_insn): Use ppc_displaced_step_closure
and unique_ptr.
(ppc_displaced_step_fixup): Adjust.
* s390-linux-tdep.c (s390_displaced_step_closure): New typedef.
(s390_displaced_step_copy_insn): Use s390_displaced_step_closure
and unique_ptr.
(s390_displaced_step_fixup): Adjust.
The corresponding definitions have already been removed.
gdb/ChangeLog:
* interps.h (interp_resume, interp_suspend, interp_set_temp):
Remove declarations.
This changes gdb_bfd_data to use std::vector rather than VEC.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* gdb_bfd.c (struct gdb_bfd_data) <included_bfds>: Now a
std::vector.
(gdb_bfd_record_inclusion): Update.
(bfdp): Remove typedef.
This changes gdb_bfd_data to be allocated with new and destroyed with
delete.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* gdb_bfd.c (gdb_bfd_ref): Use new.
(struct gdb_bfd_data): Add constructor, destructor, and member
initializers.
(gdb_bfd_unref): Use delete.
This introduces a helper function, new_bfd_ref, that calls gdb_bfd_ref
and returns a gdb_bfd_ref_ptr. Then it updates several places to use
this.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* exec.c (exec_file_attach): Use new_bfd_ref.
* symfile-mem.c (symbol_file_add_from_memory): Use new_bfd_ref.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec, gdb_bfd_fdopenr): Use
new_bfd_ref.
* gdb_bfd.h (new_bfd_ref): New function.
The [wait -i $gdb_spawn_id] in the test is dangerous in the sense that
it won't be subject to timeout logic. So if GDB fails quiting, this
testcase hangs forever, hanging the test run with it. See:
https://sourceware.org/ml/gdb-patches/2016-10/msg00728.html
Instead of 'wait'ing directly, use gdb_test_multiple and expect 'eof'.
Tested that the testcase no longer hangs by hacking the test to send
"info threads" instead of "quit".
Tested with
--target_board={unix, native-gdbserver,native-extended-gdbserver}
and tested with
--host_board=local-remote-host
as well.
gdb/testsuite/ChangeLog:
2017-10-20 Pedro Alves <palves@redhat.com>
* gdb.base/quit.exp: Use gdb_test_multiple and expect 'eof' before
'wait -i'. Use gdb_assert and remote_close.
After commit bf46927112 ("Eliminate catch_errors"), GCC started
inlining captured_command_loop in captured_main. And setting a
breakpoint on captured_command_loop makes the inferior GDB stop in
captured_main, _after_ captured_command_loop's call to
interp_pre_command_loop, which prints the inferior GDB's prompt, has
already executed, confusing the gdb.gdb/ selftest tests:
(gdb) FAIL: gdb.gdb/complaints.exp: run until breakpoint at captured_command_loop
WARNING: Couldn't test self
Debugging GDB with GDB manually, we see:
(top-gdb) b captured_command_loop
Breakpoint 1 at 0x71ee60: file src/gdb/main.c, line 324.
(top-gdb) r
[....]
(gdb) <<<<<< PROMPT HERE
Thread 1 "gdb" hit Breakpoint 1, captured_main (data=<optimized out>) at src/gdb/main.c:1147
1147 captured_command_loop ();
(top-gdb)
Note the stop at 'captured_main', and the "PROMPT HERE" line. That
prompt does not show up when debugging a non-optimized build of GDB.
Fix this by preventing inlining of captured_command_loop.
Ref: https://sourceware.org/ml/gdb-patches/2017-10/msg00522.html
gdb/ChangeLog:
2017-10-20 Pedro Alves <palves@redhat.com>
* main.c (captured_command_loop): Add attribute noinline.
This removes the remaining cleanups from break-catch-syscall.c by
storing temporary strings in a vector.
ChangeLog
2017-10-19 Tom Tromey <tom@tromey.com>
* break-catch-syscall.c (catch_syscall_completer): Use
std::string, gdb::unique_xmalloc_ptr.
This changes call_function_by_hand_dummy to use std::string, removing
a cleanup.
ChangeLog
2017-10-19 Tom Tromey <tom@tromey.com>
* infcall.c (call_function_by_hand_dummy): Use std::string.
Removes the use of a hard-coded line number from a test.
gdb/testsuite/ChangeLog:
* gdb.linespec/ls-errs.exp (do_test): Update comment, use line
number from variable rather than hard-coded.
The buildbots are showing that the previous change to
xml_fetch_content_from_file causes __wur warnings/errors:
../../binutils-gdb/gdb/xml-support.c: In function gdb::unique_xmalloc_ptr<char> xml_fetch_content_from_file(const char*, void*):
../../binutils-gdb/gdb/xml-support.c:1028:43: error: ignoring return value of size_t fread(void*, size_t, size_t, FILE*), declared with attribute warn_unused_result [-Werror=unused-result]
fread (text.get (), 1, len, file.get ());
^
This commit fixes it.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* xml-support.c (xml_fetch_content_from_file): Check fread's
return.
Comparing test results between
--target_board=native-gdbserver
--target_board=native-stdio-gdbserver
I noticed that gdb.base/bigcore.exp is failing with native-stdio-gdbserver:
Running src/gdb/testsuite/gdb.base/bigcore.exp ...
FAIL: gdb.base/bigcore.exp: continue (timeout)
...
The problem is that:
1. When debugging with "target remote | CMD", the inferior's
stdout/stderr streams are connected to a pipe.
2. The bigcore.c program prints a lot to the screen before it
reaches the breakpoint location that the "continue" shown above
wants to reach.
3. GDB is not flushing the inferior's output pipe while the inferior
is running.
4. The pipe becomes full.
5. The inferior thus deadlocks.
The bug is #3 above, which is what this commit fixes. A new test is
added, that specifically exercises this scenario. The test fails
before the fix, and passes after, and gdb.base/bigcore.exp also starts
passing.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* ser-base.c (ser_base_read_error_fd): Delete the file handler if
async.
(handle_error_fd): New function.
(ser_base_async): Add/delete an event loop file handler for
error_fd.
gdb/testsuite/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* gdb.base/long-inferior-output.c: New file.
* gdb.base/long-inferior-output.exp: New file.
There doesn't seem to be a good reason we're reading the file one
chunk at a time.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* xml-support.c (xml_fetch_content_from_file): Don't read in
chunks. Instead use fseek to determine the file's size, and read
it in one go.
Consider a conversion operator such as:
operator foo const* const* ();
There are two small parser problems, highlighted by this test:
(gdb) p operator foo const* const*
There is no field named operatorfoo const* const *
GDB is looking up the symbol "operatorfoo const* const*" -- it is missing a
space between the keyword "operator" and the type name "foo const* const*".
Additionally, this input of the user-defined type needs to be canonicalized
so that different "spellings" of the type are recognized:
(gdb) p operator const foo* const *
There is no field named operator const foo* const *
gdb/ChangeLog:
* c-exp.y (oper): Canonicalize conversion operators of user-defined
types.
Add whitespace to front of type name.
gdb/testsuite/ChangeLog:
* gdb.cp/cpexprs.cc (base) <operator fluff const* const*>: New
method.
(main): Call it.
* gdb.cp/cpexprs.exp: Add new conversion operator to test matrix.
Add additional user-defined conversion operator tests.
A previous patch called gdb_assert_not_reached whenever reading
the accessibility of a nested typedef definition. Wisely, Pedro has asked me
not do this.
This patch changes the previous one so that it issues a complaint instead.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_add_typedef): Issue a complaint on unhandled
DW_AT_accessibility.
I've noticed now that due to a last-minute change, commit 739b3f1d8f
("Make native gdbserver boards no longer be "remote" (in DejaGnu
terms)") managed to miss loading "local-board" in the
native-stdio-gdbserver board...
gdb/testsuite/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* boards/native-stdio-gdbserver.exp: Load "local-board".
In my multi-target branch, I had managed to break GDB exiting
successfuly in response to "quit" or SIGHUP/SIGTERM when:
- you're debugging with "target extended-remote",
- have more than one inferior loaded in gdb, some running, and at
least one not running, and,
- quit gdb with the inferior that is not running yet selected.
The testsuite still passed cleanly anyway. I only noticed because I
was left with a bunch of core dumps in the gdb/testsuite/ directory --
the testsuite infrastructure closes GDB's pty after running each
testcase, which results in GDB getting a SIGHUP and should make GDB
exit gracefully. If GDB crashes at that point though, there's no
indication about it in gdb.sum/gdb.log.
This commit adds a multitude of tests exercising quitting GDB with
live inferiors, some of which would have caught the problem.
gdb/testsuite/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* gdb.base/quit-live.c: New file.
* gdb.base/quit-live.exp: New file.
This changes the remaining spots in disasm.c to use the RAII ui-out
emitters, removing a few cleanups. This also fixes a regression that
Simon pointed out.
2017-10-17 Tom Tromey <tom@tromey.com>
* disasm.c (do_mixed_source_and_assembly_deprecated): Use
gdb::optional, ui_out_emit_list, ui_out_emit_tuple.
(do_mixed_source_and_assembly): Likewise.
When building I got:
../../binutils-gdb/gdb/regcache.c:935:24: error: the address of ‘ssize_t read(int, void*, size_t)’ will never be NULL [-Werror=address]
This happens because "read" used to be a parameter to this function,
which was then removed; but the assertion wasn't updated.
I don't think the assertion is relevant any more, to this removes it.
I'm checking it in as obvious.
2017-10-17 Tom Tromey <tom@tromey.com>
* regcache.c (regcache::xfer_part): Remove assertion.
Fixes a double-free regression introduced by commit b7b030adc4
("Return unique_xmalloc_ptr from target_read_stralloc"):
gdb.sum:
Running src/gdb/testsuite/gdb.base/catch-syscall.exp ...
ERROR: Process no longer exists
Valgrind shows:
(gdb) catch syscall
==3687== Thread 1:
==3687== Invalid free() / delete / delete[] / realloc()
==3687== at 0x4C29CF0: free (vg_replace_malloc.c:530)
==3687== by 0x610862: xfree(void*) (common-utils.c:101)
==3687== by 0x440D5D: gdb::xfree_deleter<char>::operator()(char*) const (gdb_unique_ptr.h:34)
==3687== by 0x446CC6: std::unique_ptr<char, gdb::xfree_deleter<char> >::reset(char*) (unique_ptr.h:344)
==3687== by 0x81BE50: xml_fetch_content_from_file(char const*, void*) (xml-support.c:1042)
==3687== by 0x81DA86: xml_init_syscalls_info(char const*) (xml-syscall.c:366)
==3687== by 0x81DBDD: init_syscalls_info(gdbarch*) (xml-syscall.c:398)
==3687== by 0x81E131: get_syscall_by_number(gdbarch*, int, syscall*) (xml-syscall.c:599)
==3687== by 0x5BE86F: catch_syscall_command_1(char*, int, cmd_list_element*) (break-catch-syscall.c:481)
==3687== by 0x4B46B1: do_sfunc(cmd_list_element*, char*, int) (cli-decode.c:138)
==3687== by 0x4B76B8: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1952)
==3687== by 0x7E91C7: execute_command(char*, int) (top.c:615)
==3687== Address 0x14332ae0 is 0 bytes inside a block of size 4,096 free'd
==3687== at 0x4C2AB8B: realloc (vg_replace_malloc.c:785)
==3687== by 0x610792: xrealloc (common-utils.c:62)
==3687== by 0x81BE3E: xml_fetch_content_from_file(char const*, void*) (xml-support.c:1042)
==3687== by 0x81DA86: xml_init_syscalls_info(char const*) (xml-syscall.c:366)
==3687== by 0x81DBDD: init_syscalls_info(gdbarch*) (xml-syscall.c:398)
==3687== by 0x81E131: get_syscall_by_number(gdbarch*, int, syscall*) (xml-syscall.c:599)
==3687== by 0x5BE86F: catch_syscall_command_1(char*, int, cmd_list_element*) (break-catch-syscall.c:481)
==3687== by 0x4B46B1: do_sfunc(cmd_list_element*, char*, int) (cli-decode.c:138)
==3687== by 0x4B76B8: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1952)
==3687== by 0x7E91C7: execute_command(char*, int) (top.c:615)
==3687== by 0x6A422D: command_handler(char*) (event-top.c:583)
==3687== by 0x6A45F2: command_line_handler(char*) (event-top.c:773)
[...]
The problem is that if xrealloc decides it needs a new memory block,
it frees the previous block/pointer, and then text.reset() frees it
again.
gdb/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* xml-support.c (xml_fetch_content_from_file): Call
unique_ptr::release() instead unique_ptr::get() when passing
through xrealloc.
Since xfer_part is already a class method, and only
{raw,cooked}_{read,write} are passed to it. We can remove these two
arguments, but add a bool argument is_raw, indicating raw registers or
cooked registers are accessed.
gdb:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache::xfer_part): Remove parameters read and
write, add parameter is_raw. All callers are updated.
gdb/gdbserver:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* configure.srv: Rename arm-linux.o with arch/arm-linux.o.
Rename arm-get-next-pcs.o with arch/arm-get-next-pcs.o.
Similar to f38307f5 (Replicate src dir in build dir), this patch change
configure and Makefile to generate object files in arch/ directory.
gdb/gdbserver:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* Makefile.in (CONFIG_SRC_SUBDIR): New variable.
(clean): Remove .o files in CONFIG_SRC_SUBDIR.
(distclean): Remove DEPDIR in CONFIG_SRC_SUBDIR.
(arch-i386.o, arch-amd64.o): Remove rules.
(arch/%.o): New rule.
Update POSTCOMPILE and COMPILE.pre.
* configure.ac: Invoke AC_CONFIG_COMMANDS.
* configure: Re-generated.
* configure.srv: Replace arch-i386.o with arch/i386.o.
Replace arch-amd64.o with arch/amd64.o.
We currently do not record access information for typedefs defined inside
classes. Consider:
struct foo
{
typedef int PUBLIC;
private:
typedef int PRIVATE;
PRIVATE b;
};
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
typedef int PUBLIC;
}
This patch fixes this:
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
public:
typedef int PUBLIC;
}
gdb/ChangeLog:
* c-typeprint.c (enum access_specifier): Moved here from
c_type_print_base.
(output_access_specifier): New function.
(c_type_print_base): Consider typedefs when assessing
whether access labels are needed.
Use output_access_specifier as needed.
Output access specifier for typedefs, if needed.
* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
fields.
(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New
accessor macros.
gdb/testsuite/ChangeLog:
* gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef)
(class_with_protected_typedef, class_with_private_typedef)
(struct_with_public_typedef, struct_with_protected_typedef)
(struct_with_private_typedef): New classes/structs.
* gdb.cp/classes.exp (test_ptype_class_objects): Add tests for
typedefs and access specifiers.
Change target_fileio_read_stralloc to return unique_xmalloc_ptr and
fix up the callers. This removes a number of cleanups.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* linux-tdep.c (linux_info_proc, linux_find_memory_regions_full)
(linux_fill_prpsinfo, linux_vsyscall_range_raw): Update.
* target.c (target_fileio_read_stralloc): Update.
* sparc64-tdep.c (adi_is_addr_mapped): Update.
* target.h (target_fileio_read_stralloc): Return
unique_xmalloc_ptr.
This removes a few cleanups in remote.c using the usual techniques:
std::vector, unique_xmalloc_ptr, and gdb::def_vector.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* remote.c (remote_register_number_and_offset): Use std::vector.
(remote_set_syscall_catchpoint): Use gdb::unique_xmalloc_ptr.
(putpkt_binary): Use gdb::def_vector.
(compare_sections_command): Use gdb::byte_vector.
This removes a cleanup from ppc-linux-nat.c, by using
unique_xmalloc_ptr. It also slightly simplifies the code by using
XDUP rather than XNEW and memcpy.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* ppc-linux-nat.c (hwdebug_insert_point): Use
gdb::unique_xmalloc_ptr, XDUP.
This removes some cleanups from parse_probes by using std::string; and
removes some unnecessary cleanups from elsewhere in probe.c.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* probe.c (parse_probes): Use std::string.
(info_probes_for_ops, enable_probes_command)
(disable_probes_command): Remove cleanups.
Change end_symtab_get_static_block to use std::vector. This removes a
cleanup.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* buildsym.c (block_compar): Remove.
(end_symtab_get_static_block): Use std::vector.
This commit finally clears the "isremote" flag in the native-gdbserver
and native-stdio-gdbserver boards. The goal is to make all "native"
boards be considered not remote in DejaGnu terms, like the
native-extended-gdbserver board is too.
DejaGnu automatically considers boards remote if their names don't
match the local hostname. That means that native-gdbserver and
native-extended-gdbserver are considered remote by default by DejaGnu,
even though they run locally. native-extended-gdbserver, however,
overrides its isremote flag to force it to be not remote. So we are
in that weird state where native-gdbserver is considered remote, and
native-extended-gdbserver is considered not remote.
A recent set of commits fixed all the problems (and some more) exposed
by testing with --target_board=native-gdbserver and
--target_board=native-stdio-gdbserver with isremote forced off on
x86-64 GNU/Linux. I believe we're good to go now.
The native-stdio-gdbserver.exp/remote-stdio-gdbserver.exp boards
required deep non-obvious modifications unfortunately... The problem
is that if a board is not remote, then DejaGnu doesn't call
${board}_spawn / ${board}_exec at all, and the
native-stdio-gdbserver.exp board relies on those procedures being
called. To fix that, this commit redesigns how the stdio boards hook
into the testing framework to spawn gdbserver. IMO, this is a good
change anyway, because the way its done currently is a bit of a hack,
and the result turns out to be simpler, even. With this commit, they
now no longer load the "gdbserver" generic config, and hook at the
mi_gdb_target_load/gdb_reload level instead, making them more like
traditional board files.
To share code between native-stdio-gdbserver.exp and
remote-stdio-gdbserver.exp, a new shared stdio-gdbserver-base.exp file
is created.
Instead of having each native board clear isremote manually, boards
source the new "local-board.exp" file.
This also adds a new section to testsuite/README file discussing
local/remote/native, so that we can easily refer to it.
gdb/testsuite/ChangeLog:
2017-10-16 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* README (Local vs Remote vs Native): New section.
* boards/local-board.exp: New file, with bits factored out from
...
* boards/native-extended-gdbserver.exp: ... here. Load
"local-board".
* boards/native-gdbserver.exp: Load "local-board".
(${board}_spawn, ${board}_exec): Delete.
* boards/native-stdio-gdbserver.exp: Most contents factored out to
...
* boards/stdio-gdbserver-base.exp: ... this new file.
* boards/native-stdio-gdbserver.exp: Reimplement, by loading
"stdio-gdbserver-base" and defining a get_target_remote_pipe_cmd
procedure.
* boards/remote-stdio-gdbserver.exp: Load stdio-gdbserver-base
instead of native-stdio-gdbserver. Don't set gdb_server_prog nor
stdio_gdbserver_command.
(${board}_get_remote_address, ${board}_get_comm_port)
(${board}_download, ${board}_upload): Delete.
(get_target_remote_pipe_cmd): New.
Use proc_with_prefix to avoid having to call with_test_prefix with a
duplicate of the proc name. The diff is mostly lines being re-indented.
gdb/testsuite/ChangeLog:
* gdb.python/py-breakpoint.exp (test_bkpt_basic,
test_bkpt_deletion, test_bkpt_cond_and_cmds,
test_bkpt_invisible, test_watchpoints, test_bkpt_internal,
test_bkpt_eval_funcs, test_bkpt_temporary, test_bkpt_address,
test_bkpt_pending, test_bkpt_events): Use proc_with_prefix,
remove with_test_prefix.
This patch replaces the last usages of VEC(mem_range_s) with
std::vector<mem_range>. This allows getting rid of a few cleanups and
of the DEF_VEC_O(mem_range_s).
I added a test for normalize_mem_ranges to make sure I didn't break
anything there.
Regtested on the buildbot.
gdb/ChangeLog:
* memrange.h (struct mem_range): Define operator< and operator==.
(mem_range_s): Remove.
(DEF_VEC_O (mem_range_s)): Remove.
(normalize_mem_ranges): Change parameter type to std::vector.
* memrange.c (compare_mem_ranges): Remove.
(normalize_mem_ranges): Change parameter type to std::vector,
adjust to vector change.
* exec.c (section_table_available_memory): Return vector, remove
parameter.
(section_table_read_available_memory): Adjust to std::vector
change.
* remote.c (remote_read_bytes): Adjust to std::vector
change.
* tracepoint.h (traceframe_available_memory): Change parameter
type to std::vector.
* tracepoint.c (traceframe_available_memory): Change parameter
type to std::vector, adjust.
* gdb/mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to
std::vector change.
* gdb/Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/memrange-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add memrange-selftests.o.
* gdb/unittests/memrange-selftests.c: New file.
This commit works around a GCC 6.3.1 bug several people are hitting:
https://sourceware.org/ml/gdb-patches/2017-09/msg00270.htmlhttps://sourceware.org/ml/gdb-patches/2017-10/msg00418.html
It manifests like this:
../../../binutils-gdb/gdb/probe.c:68:12: error: types may not be defined in a for-range-declaration [-Werror]
for (struct probe *probe : probes)
^~~~~~
Fix it by renaming the range-for named variables to something different
from their type's name.
gdb/ChangeLog:
2017-10-16 Pedro Alves <palves@redhat.com>
* elfread.c (probe_key_free): Rename range-for variable.
* probe.c (parse_probes_in_pspace, find_probes_in_objfile)
(find_probe_by_pc, collect_probes): Rename range-for variable.
4fa7574 (Fix gdb 8.1 Solaris compilation) changes warning.m4 and updates
configure, but gdbserver/configure is not updated.
gdb/gdbserver:
2017-10-16 Yao Qi <yao.qi@linaro.org>
* configure: Regenerated.
features/*.c are generated from *.xml files, in order to get pre-defined
target descriptions, (for native debugging, for example). However, these
pre-generated tdesc_tic6x_* are not used in GDB at all. This patch removes
features/tic6x-*.c files.
gdb:
2017-10-16 Yao Qi <yao.qi@linaro.org>
* features/Makefile (XMLTOC): Remove tic6x-*.xml.
* features/tic6x-c62x.c: Remove.
* features/tic6x-c64x-linux.c: Remove.
* features/tic6x-c64x.c: Remove.
* features/tic6x-c64xp-linux.c: Remove.
* features/tic6x-c64xp.c: Remove.
* tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Don't call
initialize_tdesc_tic6x_*_linux functions.
* tic6x-tdep.c (_initialize_tic6x_tdep): Don't call
initialize_tdesc_tic6x_* functions.
tic6x-uclinux GDBserver uses linux target descriptions, instead of these
non-linux target descriptions. So we can remove these *.dat files.
gdb:
2017-10-16 Yao Qi <yao.qi@linaro.org>
* features/Makefile (WHICH): Remove tic6x-c64xp, tic6x-c64x
tic6x-c62x.
* regformats/tic6x-c62x.dat: Remove.
* regformats/tic6x-c64x.dat: Remove.
* regformats/tic6x-c64xp.dat: Remove.
An earlier patch of mine changed parse_traceframe_info to make it return
a unique_ptr. I forgot to update the version of the function used in an
expat-less build, this patch fixes it.
gdb/ChangeLog:
* tracepoint.c (parse_traceframe_info): Return a unique_ptr
(the !HAVE_LIBEXPAT version).
Commit
Use std::vector in linux_xfer_osdata_processgroups
b129dcac88
broke the build with older gcc (at least 4.7 and 4.8):
In file included from /usr/include/c++/4.7/algorithm:63:0,
from /home/emaisin/src/binutils-gdb/gdb/nat/linux-osdata.c:40:
/usr/include/c++/4.7/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >; _Tp = pid_pgid_entry]’:
/usr/include/c++/4.7/bits/stl_algo.h:2315:70: required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >]’
/usr/include/c++/4.7/bits/stl_algo.h:2347:54: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >; _Size = long int]’
/usr/include/c++/4.7/bits/stl_algo.h:5483:4: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >]’
/home/emaisin/src/binutils-gdb/gdb/nat/linux-osdata.c:480:57: required from here
/usr/include/c++/4.7/bits/stl_algo.h:2277:4: error: passing ‘const pid_pgid_entry’ as ‘this’ argument of ‘bool pid_pgid_entry::operator<(const pid_pgid_entry&)’ discards qualifiers [-fpermissive]
Making the operator< method const fixes it.
gdb/ChangeLog:
* nat/linux-osdata.c (struct pid_pgid_entry) <operator<>: Make
const.
Remove the usage of inferior_list for the all_threads list in
gdbserver. The entry field in thread_info is removed, and replaced by a
simple ptid field.
I added some functions to iterate (for_each_thread) and find threads
(find_thread). However, changing all the users of find_inferior & co to
use these new functions would have made the patch way too big. So I
opted instead to make find_inferior & co some shims, so that the
existing code only needs to be updated minimally. We can then update
the existing code to use the new functions incrementally (I've started
to do the work, but I'll post it afterwards, see [1] if you want a peek).
This patch has been built-tested on all relevant platforms, except
lynx. I also regtested using the native-gdbserver and
native-extended-gdbserver boards on x86.
[1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry
gdb/gdbserver/ChangeLog:
* inferiors.h: (struct inferior_list): Remove.
(struct inferior_list_entry); Remove.
(add_inferior_to_list, clear_inferior_list, one_inferior_p,
A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior,
get_first_inferior): Remove.
(for_each_inferior, for_each_inferior_with_data, find_inferior,
find_inferior_id, find_inferior_in_random): Change signature.
* inferiors.c (all_threads): Change type to
std::list<thread_info *>.
(get_thread): Remove macro.
(find_inferior, find_inferior_id): Change signature, implement
using find_thread.
(find_inferior_in_random): Change signature, implement using
find_thread_in_random.
(for_each_inferior, for_each_inferior_with_data): Change
signature, implement using for_each_thread.
(add_inferior_to_list, remove_inferior): Remove.
(add_thread, get_first_thread, thread_of_pid,
find_any_thread_of_pid, free_one_thread, remove_thread): Update.
(get_first_inferior, one_inferior_p, clear_inferior_list):
Remove.
(clear_inferiors, get_thread_process): Update.
* gdbthread.h: Include <list>.
(struct thread_info) <entry>: Remove field.
<id>: New field.
(all_threads): Change type to std::list<thread_info *>.
(get_first_inferior): Add doc.
(find_thread, for_each_thread, find_thread_in_random): New
functions.
(current_ptid, pid_of, ptid_of, lwpid_of): Update.
* linux-arm-low.c (update_registers_callback): Update.
* linux-low.c (second_thread_of_pid_p): Update.
(kill_one_lwp_callback, linux_detach_lwp_callback,
delete_lwp_callback, status_pending_p_callback, same_lwp,
find_lwp_pid, num_lwps, iterate_over_lwps_filter,
iterate_over_lwps, not_stopped_callback,
resume_stopped_resumed_lwps, count_events_callback,
select_singlestep_lwp_callback, select_event_lwp_callback,
unsuspend_one_lwp, linux_wait_1, send_sigstop_callback,
suspend_and_send_sigstop_callback, wait_for_sigstop,
stuck_in_jump_pad_callback, move_out_of_jump_pad_callback,
lwp_running, linux_set_resume_request, resume_status_pending_p,
need_step_over_p, start_step_over, linux_resume_one_thread,
proceed_one_lwp, unsuspend_and_proceed_one_lwp,
reset_lwp_ptrace_options_callback): Update.
* linux-mips-low.c (update_watch_registers_callback): Update.
* regcache.c (regcache_invalidate_one, regcache_invalidate):
Update.
(free_register_cache_thread_one): Remove.
(regcache_release): Update.
* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt,
handle_qxfer_threads_worker): Update.
(handle_query): Update, use list iterator.
(visit_actioned_threads, handle_pending_status,
queue_stop_reply_callback, gdb_wants_all_threads_stopped,
clear_pending_status_callback, set_pending_status_callback,
find_status_pending_thread_callback, handle_status,
process_serial_event): Update.
* target.c (thread_search_callback): Update.
* thread-db.c (thread_db_get_tls_address): Update.
* tracepoint.c (tracepoint_finished_step, tracepoint_was_hit):
Update.
* win32-i386-low.c (update_debug_registers_callback): Update.
* win32-low.c (delete_thread_info, child_delete_thread,
continue_one_thread, suspend_one_thread,
get_child_debug_event): Adjust.
Remove the usage of inferior_list for the all_processes list in
gdbserver, replace it with an std::list. The entry field in process_info
is removed, and replaced by a simple pid field.
The pid_of macro, used for both processes and threads, is replaced with
separate functions. For completeness, I changed ptid_of and lwpid_of to
functions as well.
gdb/gdbserver/ChangeLog:
* gdbthread.h (ptid_of, pid_of, lwpid_of): New functions.
* inferiors.h: Include <list>.
(struct process_info) <entry>: Remove field.
<pid>: New field.
(pid_of): Change macro to function.
(ptid_of, lwpid_of): Remove macro.
(all_processes): Change type to std::list<process_info *>.
(ALL_PROCESSES): Remove macro.
(for_each_process, find_process): New function.
* inferiors.c (all_processes): Change type to
std::list<process_info *>.
(find_thread_process): Adjust.
(add_process): Likewise.
(remove_process): Likewise.
(find_process_pid): Likewise.
(get_first_process): Likewise.
(started_inferior_callback): Remove.
(have_started_inferiors_p): Adjust.
(attached_inferior_callback): Remove.
(have_attached_inferiors_p): Adjust.
* linux-low.c (check_zombie_leaders): Likewise.
* linux-x86-low.c (x86_arch_setup_process_callback): Remove.
(x86_linux_update_xmltarget): Adjust.
* server.c (handle_query): Likewise.
(gdb_reattached_process): Remove.
(handle_status): Adjust.
(kill_inferior_callback): Likewise.
(detach_or_kill_inferior): Remove.
(print_started_pid): Likewise.
(print_attached_pid): Likewise.
(detach_or_kill_for_exit): Update.
(process_serial_event): Likewise.
* linux-arm-low.c (arm_new_fork): Likewise.
As a small step towards removing inferior_list/inferior_list_entry, this
patch replaces the usage of inferior_list for the list of dlls by an
std::list. The dll_info type now uses an std::string for name and has a
simple constructor.
I am able to build gdbserver with mingw on Linux, but I am not able to
test this on a Windows machine (the only platform that uses this code).
gdb/gdbserver/ChangeLog:
* dll.h: Include <list>.
(struct dll_info): Add constructor.
<entry>: Remove field.
(all_dlls): Change type to std::list<dll_info>.
* dll.c: Include <algorithm>.
(get_dll): Remove macro.
(all_dlls): Change type to std::list<dll_info *>.
(free_one_dll): Remove.
(match_dll): Likewise.
(loaded_dll): Adjust.
(unloaded_dll): Adjust to all_dlls type change, use
std::find_if. Inline code from match_dll.
(clear_dlls): Adjust to all_dlls type change.
* server.c (emit_dll_description): Remove.
(handle_qxfer_libraries): Adjust to all_dlls type change,
integrate emit_dll_description's functionality.
Since this target method returns an allocated object, return a
unique_ptr. It allows getting rid a some cleanups here and there.
I had to shuffle the includes around. First, target.h now needs to
include tracepoint.h, to get the definition of traceframe_info_up.
However, the definition of enum trace_find_type was later in target, so
I had to move it to tracepoint.h, so that the declaration of tfind_1
could know about it. I then had to remove the include of target.h from
tracepoint.h, which caused a circular dependency (it was probably
included to get enum trace_find_type in the first place anyway).
Regression tested on the buildbot.
gdb/ChangeLog:
* target.h: Include tracepoint.h.
(enum trace_find_type): Move to tracepoint.h.
(struct target_ops) <to_traceframe_info>: Return a unique ptr.
* tracepoint.h: Don't include target.h
(enum trace_find_type): Move from target.h.
(parse_traceframe_info): Return a unique ptr.
* tracepoint.c (current_traceframe_info): Change type to unique
ptr.
(free_traceframe_info): Remove.
(clear_traceframe_info): Don't manually free
current_traceframe_info.
(free_result): Remove.
(parse_traceframe_info): Return a unique ptr.
(get_traceframe_info): Adjust to unique ptr.
* ctf.c (ctf_traceframe_info): Return a unique ptr.
* remote.c (remote_traceframe_info): Return a unique ptr.
* tracefile-tfile.c (tfile_traceframe_info): Return a unique
ptr.
* target-debug.h (target_debug_print_traceframe_info_up): New
macro.
* target-delegates.c: Regenerate.
Straightforward change from a VEC to std::vector. This allows making
the destruction of a traceframe_info trivial.
I added a constructor with parameters to mem_range to be able to
emplace_back directly with the values. It is necessary to leave a
default constructor there because mem_range is still used in a VEC.
gdb/ChangeLog:
* memrange.h (struct mem_range): Add constructors.
* tracepoint.h (struct traceframe_info) <memory>: Change type to
std::vector<mem_range>.
* tracepoint.c (free_traceframe_info): Don't manually free
vector.
(traceframe_info_start_memory): Adjust to vector change.
(traceframe_available_memory): Likewise.
* tracefile-tfile.c (build_traceframe_info): Likewise.
* ctf.c (ctf_traceframe_info): Likewise.
Straightforward change to get rid of a VEC. We need to new/delete
traceframe_info instead of malloc/free it. I found three places that
allocate a traceframe_info (ctf_traceframe_info, tfile_traceframe_info
and parse_traceframe_info) and only one that frees it
(free_traceframe_info).
gdb/ChangeLog:
* tracepoint.h (struct traceframe_info) <tvars>: Change type to
std::vector<int>.
* tracepoint.c (free_traceframe_info): Deallocate with delete.
(traceframe_info_start_tvar): Adjust to vector change.
(parse_traceframe_info): Allocate with new.
* ctf.c (ctf_traceframe_info): Allocate with new, adjust to
vector change.
* tracefile-tfile.c (build_traceframe_info): Adjust to vector
change.
tfile_traceframe_info): Allocate with new.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to vector
change.
... so it doesn't shadow the traceframe_info type. It think it's a
clearer name anyway.
gdb/ChangeLog:
* tracepoint.c (traceframe_info): Rename to...
(current_traceframe_info): ...this.
(clear_traceframe_info): Adjust.
(get_traceframe_info): Adjust.
This simplifies the code quite a bit, by removing the array of PID_T
that's actually an array of pairs of PID_T.
This code is only used to implement "info os procgroups". I tested by hand
as well as by running gdb.base/info-os.exp for unix, native-gdbserver
and native-extended-gdbserver.
gdb/ChangeLog:
* nat/linux-osdata.c: Include algorithm.
(compare_processes): Remove.
(struct pid_pgid_entry): New struct.
(linux_xfer_osdata_processgroups): Use std::vector instead of
XNEWVEC.
psymbol_allocation_list is basically a vector implementation. We can
replace it with an std::vector, now that objfile has been C++-ified.
I sent this to the buildbot, there are a few suspicious failures, but
I don't think they are related to this patch. For example on powerpc:
new FAIL: gdb.base/catch-syscall.exp: execve: syscall execve has returned
new FAIL: gdb.base/catch-syscall.exp: execve: continue to main
new FAIL: gdb.base/catch-syscall.exp: execve: continue until exit
I get the same failures when testing manually on gcc112, without this
patch.
gdb/ChangeLog:
* objfiles.h: Don't include symfile.h.
(struct partial_symbol): Remove forward-declaration.
(struct objfile) <global_psymbols, static_psymbols>: Change type
to std::vector<partial_symbol *>.
* objfiles.c (objfile::objfile): Don't memset those fields.
(objfile::~objfile): Don't free those fields.
* psympriv.h (struct psymbol_allocation_list): Remove
forward-declaration.
(add_psymbol_to_list): Change psymbol_allocation_list parameter
to std::vector.
(start_psymtab_common): Change parameters to std::vector.
* psymtab.c: Include algorithm.
(require_partial_symbols): Call shrink_to_fit.
(find_pc_sect_psymbol): Adjust to vector change.
(match_partial_symbol): Likewise.
(lookup_partial_symbol): Likewise.
(psym_relocate): Likewise.
(dump_psymtab): Likewise.
(recursively_search_psymtabs): Likewise.
(compare_psymbols): Remove.
(sort_pst_symbols): Adjust to vector change.
(start_psymtab_common): Likewise.
(end_psymtab_common): Likewise.
(psymbol_bcache_full): De-constify return value.
(add_psymbol_to_bcache): Likewise.
(extend_psymbol_list): Remove.
(append_psymbol_to_list): Adjust to vector change.
(add_psymbol_to_list): Likewise.
(init_psymbol_list): Likewise.
(maintenance_info_psymtabs): Likewise.
(maintenance_check_psymtabs): Likewise.
* symfile.h (struct psymbol_allocation_list): Remove.
* symfile.c (reread_symbols): Adjust to vector change.
* dbxread.c (start_psymtab): Change type of parameters.
(dbx_symfile_read): Adjust to vector change.
(read_dbx_symtab): Likewise.
(start_psymtab): Change type of parameters.
* dwarf2read.c (dwarf2_build_psymtabs): Adjust to vector change.
(create_partial_symtab): Likewise.
(add_partial_symbol): Likewise.
(write_one_signatured_type): Likewise.
(recursively_write_psymbols): Likewise.
* mdebugread.c (parse_partial_symbols): Likewise.
* xcoffread.c (xcoff_start_psymtab): Change type of parameters.
(scan_xcoff_symtab): Adjust to vector change.
(xcoff_initial_scan): Likewise.
Replace this usage of GROW_VECT with an std::string. I don't think
there's a reason for this variable to be static, other than it was
cumbersome to manage its lifetime (i.e. use a cleanup) before.
Tested by comparing the gdb.ada/*.exp test results before and after the
patch.
gdb/ChangeLog:
* ada-typeprint.c (print_dynamic_range_bound): Use std::string.
These tests want to use raw "run", so skip them on targets that can't
do that.
Also adds a small utility procedure that clearly conveys intent instead of
explicitly checking use_gdb_stub in the testcases.
This makes sure these testcases continue to be skipped with
--target_board=native-gdbserver once that board stops setting
is_remote.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (target_can_use_run_cmd): New procedure.
* gdb.base/annota1.exp: Use it instead of is_remote.
* gdb.base/annota3.exp: Use it instead of is_remote.
* gdb.cp/annota2.exp: Use it instead of is_remote.
* gdb.cp/annota3.exp: Use it instead of is_remote.
* gdb.multi/bkpt-multi-exec.exp: Use it instead of is_remote.
Currently we get:
Running ..../src/gdb/testsuite/gdb.base/testenv.exp ...
FAIL: gdb.base/testenv.exp: test no TEST_GDB var
FAIL: gdb.base/testenv.exp: test with one TEST_GDB var
FAIL: gdb.base/testenv.exp: test with two TEST_GDB var
FAIL: gdb.base/testenv.exp: test with one TEST_GDB var, after unset
FAIL: gdb.base/testenv.exp: test with TEST_GDB_GLOBAL
FAIL: gdb.base/testenv.exp: test with TEST_GDB_GLOBAL unset
The problem is that the testcase relies on stdio. While we could fix
this for gdbserver by read output from inferior_spawn_id, a better fix
it to not rely on stdio at all. That's what this commit does.
Instead, it reads variables off of the inferior to extract the
necessary information.
Along the way, most of the .exp file is reimplemented/cleaned up using
more modern mechanisms. E.g., with_test_prefix, proc_with_prefix,
save_vars, etc. Also, a missing check for "is_remote host" is added.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/testenv.exp: Check use_gdb_stub instead of is_remote.
(test_num_test_vars, run_and_count_vars, find_env)
(test_set_unset_env, test_inherit_env_var): New procedures.
(top level): Use them.
If we make the native-gdbserver board be !is_remote, then the few
tests that use the selftest-support.exp routines to debug gdb itself
start running, and fail, with something like:
Running ..../src/gdb/testsuite/gdb.gdb/selftest.exp ...
ERROR: tcl error sourcing ..../src/gdb/testsuite/gdb.gdb/selftest.exp.
ERROR: gdbserver does not support run [....] without extended-remote
while executing
"error "gdbserver does not support $command without extended-remote""
(procedure "gdb_test_multiple" line 25)
invoked from within
"gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
-re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb..."
(procedure "selftest_setup" line 45)
This commit makes sure those tests continue to be skipped.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Extend comments, and
also skip on stub-like targets.
Currently, with --target_board=native-extended-gdbserver, we get:
Running .../src/gdb/testsuite/gdb.base/find-unmapped.exp ...
FAIL: gdb.base/find-unmapped.exp: find global_var_0, global_var_2, 0xff
FAIL: gdb.base/find-unmapped.exp: find global_var_1, global_var_2, 0xff
FAIL: gdb.base/find-unmapped.exp: find global_var_2, (global_var_2 + 16), 0xff
This commit makes the test pass there, and also enables in on
--target_board=native-gdbserver, and other remote targets.
I've filed PR gdb/22293 to track the missing-warning problem.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
PR gdb/22293
* gdb.base/find-unmapped.exp: Don't skip if is_remote target.
(top level): Move some tests to ...
(test_not_found): ... this new procedure.
(top level): Call it.
Nowadays, we have six tic6x expedite registers, which are duplicated.
tic6x-c64xp-expedite = A15,PC
tic6x-c64x-expedite = A15,PC
tic6x-c62x-expedite = A15,PC
tic6x-c64xp-linux-expedite = A15,PC
tic6x-c64x-linux-expedite = A15,PC
tic6x-c62x-linux-expedite = A15,PC
in features/Makefile, we have
echo "expedite:$(if $($*-expedite),$($*-expedite),$($(firstword $(subst -, ,$(notdir $*)))-expedite))" \
>> $(outdir)/$*.tmp
which means for a given bar/foo-baz.xml, we'll look for either
bar/foo-baz-expedite or foo-expedite. We can define only one generic
expedite register for all different ti6cx and s390x target descriptions.
Actually, we've done that for x86 target descriptions.
Re-run 'make GDB=/path/build/gdb all' to regenerate regformats/*.dat files,
and they are not changed.
gdb:
2017-10-13 Yao Qi <yao.qi@linaro.org>
* features/Makefile: Remove tic6x-*-expedite, add tic6x-expedite.
Remove s390x-*-expedite, add s390x-expedite.
This changes objfiles to use new and delete rather than xmalloc and
free. Simon noticed that it uses a non-POD and so shouldn't be
allocated with XCNEW; and I wanted to be able to use another non-POD as
a member; this patch is the result.
Regression tested by the buildbot.
2017-10-13 Tom Tromey <tom@tromey.com>
* compile/compile-object-run.c (do_module_cleanup): Use delete.
* solib.c (update_solib_list, reload_shared_libraries_1): Use
delete.
* symfile.c (symbol_file_add_with_addrs): Use new.
(symbol_file_add_separate): Update comment.
(syms_from_objfile_1, remove_symbol_file_command): Use delete.
* jit.c (jit_object_close_impl): Use new.
(jit_unregister_code): Use delete.
* objfiles.c (objfile::objfile): Rename from allocate_objfile.
(~objfile): Rename from free_objfile.
(free_objfile_separate_debug, do_free_objfile_cleanup)
(free_all_objfiles, objfile_purge_solibs): Use delete.
* objfiles.h (struct objfile): Add constructor and destructor.
Use DISABLE_COPY_AND_ASSIGN. Add initializers to data members.
(allocate_objfile, free_objfile): Don't declare.
(struct objstats): Add initializers.
With --target_board=native-extended-gdbserver, we get:
Running .../src/gdb/testsuite/gdb.base/term.exp ...
FAIL: gdb.base/term.exp: info terminal at breakpoint
(gdb) info terminal
No saved terminal information.
Fix it by running the test everywhere, and expecting different output
on non-native targets.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/term.exp: Don't skip if is_remote target. Instead,
expect different "info terminal" output if testing with a
non-native target.
This testcase works fine with gdbserver nowadays. So remove the
kfail.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
PR python/12966
* gdb.python/py-evthreads.exp: Remove is_remote target kfail.
Fixes:
Running ..../src/gdb/testsuite/gdb.python/py-evthreads.exp ...
FAIL: gdb.python/py-evthreads.exp: run to breakpoint 1
FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2
FAIL: gdb.python/py-evthreads.exp: thread 2
FAIL: gdb.python/py-evthreads.exp: reached breakpoint 3
FAIL: gdb.python/py-evthreads.exp: thread 3
FAIL: gdb.python/py-evthreads.exp: continue thread 1
[... cascading time outs ...]
By following the usual pattern that makes sure that non-stop is enabled
before connecting to gdbserver.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.python/py-evthreads.exp: Start GDB with "set non-stop on"
already.
1. Otherwise, when we make native-gdbserver board no longer is_remote,
we get:
Running .../src/gdb/testsuite/gdb.base/corefile.exp ...
ERROR: tcl error sourcing .../src/gdb/testsuite/gdb.base/corefile.exp.
ERROR: gdbserver does not support attach 9327 without extended-remote
while executing
"error "gdbserver does not support $command without extended-remote""
That's fixed by using can_spawn_for_attach instead.
2. The gdb_protocol check fixes this current problem with
--target_board=extended-remote-gdbserver:
Running .../src/gdb/testsuite/gdb.base/corefile.exp ...
FAIL: gdb.base/corefile.exp: run: with core
FAIL: gdb.base/corefile.exp: run: core file is cleared
FAIL: gdb.base/corefile.exp: attach: with core
FAIL: gdb.base/corefile.exp: attach: core file is cleared
gdb.log:
(...)
attach 10859
Don't know how to attach. Try "help target".
(...)
The fix for #2 alone would fix#1 too, but can_spawn_for_attach
expresses the requirement directly, so I still left it there.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/corefile.exp (corefile_test_run): Skip if gdb_protocol
is set.
(corefile_test_attach): Likewise. Check can_spawn_for_attach
instead of is_remote.
1. Otherwise, when the native-gdbserver board stops setting is_remote,
this test would stop running there.
2. Makes the test run with --target_board=native-extended-gdbserver
too.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/remote.exp: Check gdb_protocol instead of is_remote.
(top level): Add comment.
(Dropped 'u' while at it because we're supposed to prefer American
English spelling...)
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/remote.exp (top level): Fix comment typo and add
missing return.
Fixes:
Running .../src/gdb/testsuite/gdb.base/solib-nodir.exp ...
FAIL: gdb.base/solib-nodir.exp: library loaded
... by using the new "set cwd" command.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/solib-nodir.exp: Split is_remote and skip_shlib_tests
calls and add comments. Skip test if use_gdb_stub is set.
(top level): Use "set cwd" command instead of "cd" command.
This commit makes --target_board=native-gdbserver (and in principle
all other is_remote boards) pass all the same gdb.base/scope.exp tests
as native testing.
I first wrote the gdb.base/scope.exp change described in the ChangeLog
below and in the new comments in the patch, knowing that gdb_file_cmd
was the right thing to use here.
However, that revealed that the native-extended-gdbserver board should
be overriding gdb_file_cmd+gdb_reload instead of gdb_load, as is
hinted at by the comments on top of the default implementations in
testsuite/lib/gdb.exp, because otherwise a gdb_run_cmd after
gdb_file_cmd misses setting "set remote exec-file". However, if we do
that and remove gdb_load, then we regress gdb.base/dbx.exp, so for now
keep the gdb_load override as well.
gdb/testsuite/ChangeLog:
2017-10-13 Pedro Alves <palves@redhat.com>
* gdb.base/scope.exp: Use build_executable + clean_restart +
gdb_file_cmd instead of prepare_for_testing and no longer skip
"before run" tests on is_remote target boards. Update comments.
* boards/native-extended-gdbserver.exp
(extended_gdbserver_load_last_file): New, factored out from ...
(gdb_load): ... this. Move further below and add comment.
(extended_gdbserver_gdb_file_cmd, gdb_file_cmd, gdb_reload): New.
I'm not sure whether this gdb64 was ever a thing in the upstream repo,
but it certainly doesn't exist nowadays.
AFAICT, this came in with the original big merge with the HP tree:
https://sourceware.org/ml/gdb-patches/1999-q2/msg00149.html
gdb/testsuite/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
* gdb.base/attach.exp: Remove references to gdb64.
* gdb.base/dbx.exp: Remove references to gdb64.
This works fine with remote target boards.
gdb/testsuite/ChangeLog:
2017-10-12 Simon Marchi <simon.marchi@polymtl.ca>
Pedro Alves <palves@redhat.com>
* gdb.base/label.exp: Remove is_remote target check.
Currently we get:
Running .../src/gdb/testsuite/gdb.base/auxv.exp ...
WARNING: can't generate a core file - core tests suppressed - check ulimit -c
After this commit we get all the same PASSes as when native testing.
The problem is that the testcase wants to create a core dump in a
temporary directory and it is using the "cd" command to start the
inferior with that directory as current directory, but that command
only affects the inferior's cwd when native debugging. Fix it by
using using the new "set cwd" command instead, which works with
gdbserver as well.
This still won't work with stub-like targets, because with those when
we connect the inferior is already running. It'd be possible to make
it work by making the inferior itself change dirs, but we'll need to
make the native-gdbserver board no longer set is_remote first.
gdb/testsuite/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
* gdb.base/auvx.exp (coredir): Update comment.
(top level) <core_works>: Use "set cwd" command instead of "cd"
command.
This updates a couple of member functions in pv_area to return bool.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* prologue-value.h (pv_area::store_would_trash): Return bool.
(pv_area::find_reg): Likewise.
* prologue-value.c (pv_area::store_would_trash): Return bool.
(pv_area::find_reg): Likewise.
This patch is an initial C++-ification of pv_area, from
prologue-value. It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions. This allows the removal of
make_cleanup_free_pv_area.
gdb/ChangeLog
2017-10-12 Tom Tromey <tom@tromey.com>
* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members. Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument. Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.
I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types. A few things need to be
fixed in the mean time, this is one.
The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info. However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation. This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.
My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill. Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place). This is
what this patch does.
Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.
There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:
aarch64-linux-gnu
alpha-linux-gnu
arm-linux-gnueabihf
hppa-linux-gnu
m68k-linux-gnu
mips64el-linux-gnuabi64
powerpc64-linux-gnu
s390x-linux-gnu
sh4-linux-gnu
sparc64-linux-gnu
x86_64-linux-gnu
x86_64-w64-mingw32
A buildbot run didn't find any regression.
[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html
gdb/ChangeLog:
* linux-nat.h (linux_nat_set_delete_thread): New declaration.
* linux-nat.c (linux_nat_delete_thread): New variable.
(lwp_free): Invoke linux_nat_delete_thread if set.
(linux_nat_set_delete_thread): New function.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
thread delete callback.
* arm-linux-nat.c (arm_linux_delete_thread): New function.
(_initialize_arm_linux_nat): Assign thread delete callback.
* s390-linux-nat.c (s390_delete_thread): New function.
(_initialize_s390_nat): Assign thread delete callback.
* x86-linux-nat.c (x86_linux_add_target): Likewise.
* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
function.
* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
declaration.
* nat/x86-linux.c (x86_linux_delete_thread): New function.
* nat/x86-linux.h (x86_linux_delete_thread): New declaration.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (the_low_target): Add thread delete
callback.
* linux-arm-low.c (arm_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-bfin-low.c (the_low_target): Likewise.
* linux-crisv32-low.c (the_low_target): Likewise.
* linux-low.c (delete_lwp): Invoke delete_thread callback if
set.
* linux-low.h (struct linux_target_ops) <delete_thread>: New
field.
* linux-m32r-low.c (the_low_target): Add thread delete callback.
* linux-mips-low.c (mips_linux_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-ppc-low.c (the_low_target): Likewise.
* linux-s390-low.c (the_low_target): Likewise.
* linux-sh-low.c (the_low_target): Likewise.
* linux-tic6x-low.c (the_low_target): Likewise.
* linux-tile-low.c (the_low_target): Likewise.
* linux-x86-low.c (the_low_target): Likewise.
* linux-xtensa-low.c (the_low_target): Likewise.
Another case of a stale check. We support following forks in the
remote protocol nowadays.
gdb/testsuite/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/catch-fork-static.exp: No longer skip on is_remote
target boards.
This gets rid of a number of FAILs with
--target_board=native-extended-gdbserver.
The fact that checkpointing does not work has nothing to do with
dejagnu's native and remote concepts. It only works with native Linux
targets because the implementation is currently baked with
linux-nat.c.
gdb/testsuite/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/checkpoint.exp: Don't check is_remote or isnative.
Instead skip if there's any gdb_protocol set.
1. is_remote is not the right check.
2. Both Simon & Pedro ran it continuously for some time against
native-gdbserver and didn't see a failure.
3. The test has been running against native-extended-gdbserver anyway.
gdb/testsuite/ChangeLog:
2017-10-12 Simon Marchi <simon.marchi@polymtl.ca>
Pedro Alves <palves@redhat.com>
* gdb.base/dprintf-non-stop.exp: Remove is_remote target check.
Check for gdbserver instead of dejagnu remote. Unlike what the
comment says, the test actually fails with target remote + gdbserver
(it does pass with extended-remote). The result is:
FAIL -> KFAIL with --target_board=native-gdbserver
KPASS -> PASS with --target_board=native-extended-gdbserver
gdb/testsuite/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/argv0-symlink.exp: kfail on remote gdbserver,
instead of on dejagnu remote boards.
We support follow-fork in the remote protocol nowadays.
Also, the right way to enable non-stop mode is to do it before
connecting, and for use_gdb_stub boards, that means we have to do it
at gdb_load time. The "modern" pattern for that is to pass non-stop
in GDBFLAGS.
This makes the test pass with --target_board=native-gdbserver.
gdb/testsuite/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/inferior-died.exp: Remove is_remote and isnative
checks. Use build_executable + clean_restart instead of
prepare_for_testing. Pass "set non-stop on" via GDBFLAGS instead
of enabling non-stop after starting gdb.
This commit makes the gdb.threads/non-ldr-exc-*.exp tests run (and
pass) with --target_board=native-gdbserver.
(These tests were already running with
--target_board=native-extended-gdbserver, because that board is not
is_remote.)
The "No exec event support in the remote protocol." comment is stale.
It's actually supported.
gdb/ChangeLog:
2017-10-12 Pedro Alves <palves@redhat.com>
* gdb.threads/non-ldr-exc-1.exp: No longer skip if is_remote target.
* gdb.threads/non-ldr-exc-2.exp: Ditto.
* gdb.threads/non-ldr-exc-3.exp: Ditto.
* gdb.threads/non-ldr-exc-4.exp: Ditto.
This removes the last cleanups from the TUI, by using std::string
rather than manual memory management.
Regression tested against gdb.tui/*.exp on Fedora 26 x86-64.
gdb/ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use
std::string.
* tui/tui-layout.c (enum tui_status): Use std::string.
prepare_re_set_context returns a null cleanup and doesn't seem
generally useful. This patch removes it plus a few more cleanups; and
changes breakpoint_re_set to use scoped_restore rather than its own
manual mechanism.
2017-10-11 Tom Tromey <tom@tromey.com>
* breakpoint.c (prepare_re_set_context): Remove.
(breakpoint_re_set_one): Update. Don't use cleanups.
(breakpoint_re_set): Use scoped_restore, std::string, and
scoped_restore_current_language.
This removes some cleanups from breakpoint.c, replacing them with C++
data structures.
2017-10-11 Tom Tromey <tom@tromey.com>
* breakpoint.c (commands_command_1): Use std::string.
(cleanup_executing_breakpoints): Remove.
(bpstat_do_actions_1): Use scoped_restore.
(bpstat_check_watchpoint): Use std::string.
(decode_static_tracepoint_spec): Likewise.
(break_range_command): Likewise.
(watch_command_1): Likewise.
(compare_breakpoints): Change argument types.
(clear_command): Use std::vector.
(cleanup_executing_breakpoints): Remove.
(update_global_location_list): Use unique_xmalloc_ptr.
(strace_command): Remove unused declaration.
Support for collecting and supplying general purpose and floating
point registers is provided along with signal frame unwinding. While
FreeBSD/arm kernels do populate NT_FPREGSET notes, they are always
zero-filled, so this implementation ignores them. Recent FreeBSD/arm
kernels generate NT_ARM_VFP notes which are used to supply
floating-point registers. As with Linux, the AT_HWCAP feature flags
are used to determine the correct target description.
gdb/ChangeLog:
* Makefile.in (ALL_TARGET_OBS): Add arm-fbsd-tdep.o.
(ALLDEPFILES): Add arm-fbsd-tdep.c.
* NEWS: Mention new FreeBSD/arm target.
* configure.tgt: Add arm*-*-freebsd*.
* arm-fbsd-tdep.c: New file.
* arm-fbsd-tdep.h: New file.
Revert parts of commit b3ac9c7756 ("Put more info in NT_PRPSINFO Linux
notes"), <https://sourceware.org/ml/binutils/2013-02/msg00024.html>, and
remove support for a Linux core PRPSINFO note writer override, now that
all variants are handled automatically within BFD itself.
gdb/
* linux-tdep.c (linux_make_corefile_notes): Remove call to
`gdbarch_elfcore_write_linux_prpsinfo'.
* gdbarch.sh (elfcore_write_linux_prpsinfo): Remove architecture
method.
(elf_internal_linux_prpsinfo): Remove declaration.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
Fix commit 70a38d42c5 ("New entry points for writing Linux NT_PRPSINFO
notes."), <https://sourceware.org/ml/binutils/2013-02/msg00023.html>,
and commit b3ac9c7756 ("Put more info in NT_PRPSINFO Linux notes"),
<https://sourceware.org/ml/binutils/2013-02/msg00024.html>, and handle
both variants of the 32-bit Linux core PRPSINFO note across all targets.
The 32-bit Linux core PRPSINFO note matches the 32-bit kernel structure,
defined as follows:
(gdb) ptype struct elf_prpsinfo
type = struct elf_prpsinfo {
char pr_state;
char pr_sname;
char pr_zomb;
char pr_nice;
unsigned long pr_flag;
__kernel_uid_t pr_uid;
__kernel_gid_t pr_gid;
pid_t pr_pid;
pid_t pr_ppid;
pid_t pr_pgrp;
pid_t pr_sid;
char pr_fname[16];
char pr_psargs[80];
}
(gdb)
where the individual data types of most members are the same across all
32-bit Linux ports, with the exception of `__kernel_uid_t' and
`__kernel_gid_t'. These are defined in <asm-generic/posix_types.h> as
32-bit `unsigned int' by default, however overridden as 16-bit `unsigned
short' in port-specific <asm/posix_types.h> for a few targets, mostly
earlier ports of Linux, specifically: ARM, CRIS, FR-V, M32R, m68k,
MN10300/AM33, s390, SuperH, SPARC and i386.
The default is the same as the PowerPC variant already handled, as from
the commits referred. Make the special PowerPC case generic then,
removing the GDB part, and provide a backend flag to switch between the
two cases possible, with the 32-bit one being the default and the 16-bit
one explicitly selected. Set the flag in the target backends affected.
bfd/
* elf-bfd.h (elf_backend_data): Add `linux_prpsinfo32_ugid16'
member.
(elfcore_write_ppc_linux_prpsinfo32): Remove prototype.
* elf32-ppc.c (elfcore_write_ppc_linux_prpsinfo32): Remove.
(elf_external_ppc_linux_prpsinfo32)
(swap_ppc_linux_prpsinfo32_out): Move to...
* elf-linux-core.h (elf_external_linux_prpsinfo32_ugid32)
(swap_linux_prpsinfo32_ugid32_out): ... these.
(elf_external_linux_prpsinfo32): Rename to...
(elf_external_linux_prpsinfo32_ugid16): ... this.
(swap_linux_prpsinfo32_out): Rename to...
(swap_linux_prpsinfo32_ugid16_out): ... this.
* elfxx-target.h [!elf_backend_linux_prpsinfo32_ugid16]
(elf_backend_linux_prpsinfo32_ugid16): Define.
(elfNN_bed): Initialize `linux_prpsinfo32_ugid16' member.
* elf.c (elfcore_write_linux_prpsinfo32): Handle both variants
of the 32-bit Linux core PRPSINFO note.
* elf32-am33lin.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-arm.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-cris.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-frv.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-i386.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-m32r.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-m68k.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-s390.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-sh.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-sparc.c (elf_backend_linux_prpsinfo32_ugid16): Define.
gdb/
* ppc-linux-tdep.c (ppc_linux_init_abi): Remove call to
`set_gdbarch_elfcore_write_linux_prpsinfo'.
Simple replacement of VEC with std::vector.
gdb/ChangeLog:
* symfile.c (registered_sym_fns): Make struct, not typedef.
(DEF_VEC_O (registered_sym_fns)): Remove.
(symtab_fns): Change type to std::vector.
(add_symtab_fns): Adjust.
(find_sym_fns): Adjust.
There was a problem with generation of the disassembler options for ARC in GDB,
because a BFD architecture name was used as a CPU name, but they have different
meaning even if some architectures have same name as respective CPUs. Target
description specifies a BFD architecture, which is different from ARC CPU, as
accepted by the disassembler (and most other ARC tools), because CPU values are
much more fine grained - there can be multiple CPU values per single BFD
architecture. As a result this code should translate architecture to some CPU
value. Since there is no info on exact CPU configuration, it is best to use
the most feature-rich CPU, so that the disassembler will recognize all
instructions available to the specified architecture.
gdb/ChangeLog
yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com>
* arc-tdep.c (arc_gdbarch_init): Pass proper cpu value to disassembler.
* arc-tdep.h (arc_arch_is_em): New function.
(arc_arch_is_hs): Likewise.
gdb/testsuite/ChangeLog
yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com>
* gdb.arch/arc-tdesc-cpu.exp: New file.
* gdb.arch/arc-tdesc-cpu.xml: Likewise.
GCC commit a94975e57 ("C++ warning on vexing parse") introduces new
warnings "unnecessary parentheses in the declaration of ...". These
cause the build of binutils and gdb to fail. This patch removes those
parentheses for a successful build.
gdb/ChangeLog:
2017-10-11 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com>
* macrotab.h (macro_lookup_inclusion): Remove unnecessary
parentheses in the declaration.
(macro_lookup_inclusion): Likewise.
(macro_lookup_definition): Likewise.
* p-lang.h (pascal_builtin_types): Likewise.
* tui/tui-data.c (tui_win_list): Likewise.
* tui/tui-data.h (tui_win_list): Likewise.
* utils.h (make_cleanup_free_section_addr_info): Likewise.
(This patch is from Mark Rages <markrages@gmail.com>.)
The Nordic nRF52 memory map, reported from black magic probe:
Num Enb Low Addr High Addr Attrs
0 y 0x00000000 0x00080000 flash blocksize 0x1000 nocache
1 y 0x10001000 0x10001210 flash blocksize 0x210 nocache
2 y 0x20000000 0x20010000 rw nocache
The region at 0x10001000 is "UICR" and it is a section of flash that is
erased all at once.
Notice the odd size: 0x210 is the size of the region defined in the
datasheet.
But because the block size was listed as 0x210, gdb was insisting on
issuing two erase commands divisible by 0x210, starting below 0x10001000.
This patch fixes it by doing the alignment computation from the start of
the region, not from address 0.
gdb/ChangeLog:
* target-memory.c (block_boundaries): Fix for block address not
aligned on block size.
The get_integer_valueof outputs the value it has read as part of the
test name. This causes test names to vary from run to run, and adds
some noise when diffing test results. e.g.:
-PASS: gdb.threads/process-dies-while-detaching.exp: multi-process: continue: killed outside: get integer valueof "mypid" (28770)
+PASS: gdb.threads/process-dies-while-detaching.exp: multi-process: continue: killed outside: get integer valueof "mypid" (32238)
This patch removes that, since it's probably not very useful.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (get_integer_valueof): Don't output read value in test name.
This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays. This results in a good number of simplifications.
(I checked that Insight doesn't use those functions.)
The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.
I.e., before:
-thread-select 123456789
&"Thread ID 123456789 not known.\n"
^error,msg="Thread ID 123456789 not known."
(gdb)
After:
-thread-select 123456789
^error,msg="Thread ID 123456789 not known."
(gdb)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here. Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type. Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.
gdb/testsuite/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.
If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
template<typename Function, typename... Args>
int catch_errors (const char *errstring, return_mask mask,
Function &&func, Args... args);
and then with:
extern void function_with_args (int, int);
extern void function_with_no_args ();
calls to the above functions would be wrapped like this:
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_args, arg1, arg2);
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_no_args);
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
One spot in gdb uses a cleanup to free a splay tree. This patch
introduces a unique_ptr specialization for this case.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (free_splay_tree): Remove.
(list_available_thread_groups): Use splay_tree_up.
* common/gdb_splay_tree.h: New file.
The do_nothing function in mi-main.c is used as a splay tree
key-deleting function; but NULL serves the same purpose and is used
elsewhere in gdb. This patch removes the unneeded function.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (do_nothing): Remove.
(list_available_thread_groups): Update.
The gdb.multi/multi-arch-exec.exp testcase currently tests execing
from -m64 to -m32, but does not test the other direction. For
thoroughness, this commit fixes that. Without the fix in the previous
commit for example ("Multi-arch exec, more register reading
avoidance"), on x86_64 we would get different symptoms depending on
"execing direction". Vis:
Continuing.
Truncated register 50 in remote 'g' packet
Truncated register 50 in remote 'g' packet
(gdb) FAIL: gdb.multi/multi-arch-exec.exp: first_arch=1: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture
Vs:
Continuing.
Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): daffffffffffffff0000[snip]
Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): daffffffffffffff0000[snip]
(gdb) FAIL: gdb.multi/multi-arch-exec.exp: first_arch=2: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture
gdb/testsuite/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
Test both arch1=>arch2 and arch2=>arch1.
* gdb.multi/multi-arch-exec.exp (exec1, srcfile1, binfile1, exec2)
(srcfile2, binfile2, march1, march2): Remove globals. Largely
factored out to...
(append_arch1_options, append_arch2_options, append_arch_options)
(build_executables): New procedures.
(do_test): New 'first_arch' parameter. Use it to define 'from_exec'
local.
(top level): Add new 'first_arch' testing axis.
As mentioned in commit bf93d7ba99 ("Add thread after updating
gdbarch when exec'ing"), we should avoid doing register reads after a
process does an exec and before we've updated that inferior's gdbarch.
Otherwise, we may interpret the registers using the wrong
architecture.
There's still (at least) one case where we still read registers
post-exec with the pre-exec architecture. That's when infrun decides
it needs to switch context to the exec'ing thread. I.e., if the exec
event is processed at a time when the current thread is not already
the exec'ing thread, then we get (with the test added by this commit):
continue
Continuing.
Truncated register 50 in remote 'g' packet
Truncated register 50 in remote 'g' packet
(gdb) FAIL: gdb.multi/multi-arch-exec.exp: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture
The fix is to avoid reading registers when switching context in this
case.
(I'd be nice to get rid of the constant stop_pc reading when switching
threads, but that'd be a deeper change.)
gdb/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* infrun.c (handle_inferior_event_1) <TARGET_WAITKIND_EXECD>: Skip
reading registers when switching context.
gdb/testsuite/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* gdb.multi/multi-arch-exec.c: Include <pthread.h> and <assert.h>.
(barrier): New.
(thread_start, all_started): New functions.
(main): Spawn new thread and wait until it is scheduled.
* gdb.multi/multi-arch-exec.exp: Build $srcfile1 with the pthreads
option.
(do_test): Add 'selected_thread' parameter. Run to all_started
instead of main. Explicitly set the breakpoint at main. Switch
to the SELECTED_THREAD thread.
(top level): Test handling the exec event with either the main
thread or the second thread selected.
FreeBSD architectures are either ILP32 or LP64 resulting in two
different layouts for siginfo_t. Previously, the 'bits_per_word'
member of bfd_arch_info was used to determine the layout to use for a
given FreeBSD architecture. However, mipsn32 architectures inherit
from a 64-bit mips architecture where bits_per_word is 64. As a
result, $_siginfo was not properly extracted from FreeBSD/mipsn32 core
dumps. Fix this by using gdbarch_long_bit instead of 'bits_per_word'
to determine if a FreeBSD architecture is ILP32 or LP64.
gdb/ChangeLog:
* fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit.
(fbsd_convert_siginfo): Likewise.
* fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise.
GDB currently doesn't build with Guile 2.2 (see PR 21104). If one has
both Guile 2.2 and 2.0 installed, GDB will pick up Guile 2.2 first and
fail building. Until somebody does the work of adapting the GDB code to
Guile 2.2, we should not try using it. This patch therefore removes it
from configure.
gdb/ChangeLog:
* configure.ac (try_guile_versions): Remove guile-2.2.
* configure: Regenerate.
Commit f38307f5 changed COMPILE.post and POSTCOMPILE to remove
$(basename) from the dependency file name computation. However, it
did not update the `-include' at the end of the Makefile.in; this in
effect disabled automatic dependency tracking.
This patch restores the $(basename) wrapper so that the dependency
files are named "file.Po" rather than "file.o.Po".
I also tested the non-gcc3 dependency mode, which pointed out that
this case hadn't been working since the switch to C++. This is also
fixed in this patch.
Tested by rebuilding.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* Makefile.in (COMPILE.post, POSTCOMPILE): Restore $(basename).
(COMPILE.pre): Use $(CXX).
Use the type system instead of callers needing to know how the
returned string's memory is supposed to be managed.
gdb/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* cp-support.c (cp_remove_params): Return a gdb::unique_xmalloc_ptr.
Use bool.
(overload_list_add_symbol): Adjust to use gdb::unique_xmalloc_ptr.
* cp-support.h (cp_remove_params): Now returns a
gdb::unique_xmalloc_ptr.
* dwarf2read.c (find_slot_in_mapped_hash): Now returns bool.
Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr.
* psymtab.c (psymtab_search_name): Adjust to cp_remove_params
returning a gdb::unique_xmalloc_ptr.
(lookup_partial_symbol): Adjust to use gdb::unique_xmalloc_ptr.
* stack.c (find_frame_funname): Adjust to cp_remove_params
returning a gdb::unique_xmalloc_ptr.
Fix a typo introduced in commit c56e7c4390 ("Make ctxobj.exp and
print-file-var.exp work on all platforms.").
This doesn't really affect the outcome of the testcase. I only
noticed the typo because I stepped through the program manually.
To avoid such problems if the test is extended, this moves the STOP
marker until after the program self-validates the values. With the
typo in place, this alone would have resulted in a test FAIL. I.e.,
it'd have caught the typo.
gdb/testsuite/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* gdb.base/print-file-var-main.c: Fix get_version_2 value check
logic. Move STOP marker after the value checks.
* gdb.base/print-file-var.exp (continue to STOP marker): Tighten
regexp.
This removes a number of cleanups from dwarf2read.c in a
straightforward way.
Note that some places in dwarf2read create dangling cleanups. I don't
believe any of the changes in this patch interact with those spots.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_get_dwz_file): Use
gdb::unique_xmalloc_ptr.
(find_slot_in_mapped_hash): Likewise.
(dwarf2_physname): Likewise.
(create_dwo_unit_in_dwp_v1): Use std::string.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_cutu): Likewise.
(inherit_abstract_dies): Use std::vector.
(read_array_type): Likewise.
(dwarf_decode_macros): Remove unused declaration.
(unsigned_int_compar): Remove.
(dwarf2_build_psymtabs_hard): Use scoped_restore.
(psymtabs_addrmap_cleanup): Remove.
Currently frame_prepare_for_sniffer returns a cleanup. This patch
changes it to return void, and exposes frame_cleanup_after_sniffer to
the caller.
Normally I would write an RAII class for this sort of thing; but
because there was just a single caller of frame_prepare_for_sniffer,
and because this caller is already using try/catch, I thought it
seemed ok to require explicit calls in this instance.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* frame-unwind.c (frame_unwind_try_unwinder): Update.
* frame.h (frame_cleanup_after_sniffer): Declare.
(frame_prepare_for_sniffer): Return void.
* frame.c (frame_cleanup_after_sniffer): No longer static. Change
type of argument.
(frame_prepare_for_sniffer): Return void.
This removes make_cleanup_value_free, in favor of a unique_ptr
specialization.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* utils.h (make_cleanup_value_free): Remove.
* utils.c (do_value_free, struct cleanup): Remove.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>:
Use gdb_value_up.
* value.h (struct value_deleter): New.
(gdb_value_up): New typedef.
This changes search_symbols to return a std::vector, replacing the
previous linked list approach. This allows the removal of some
cleanups, as well as the use of std::sort and std::unique, saving some
code and extra allocations in sort_search_symbols_remove_dups.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* symtab.c (free_search_symbols, do_free_search_symbols_cleanup)
(make_cleanup_free_search_symbols): Remove.
(search_symbols): Return std::vector.
(symbol_search::compare_search_syms): Now member of
symbol_search. Change arguments.
(sort_search_symbols_remove_dups): Change arguments. Rewrite.
(symtab_symbol_info, rbreak_command): Update.
* symtab.h (struct symbol_search) <next>: Remove.
Add constructors.
(symbol_search::operator<): New function.
(symbol_search::operator==): New function.
(search_symbols): Remove std::vector.
(free_search_symbols, make_cleanup_free_search_symbols): Remove.
(symbol_search::compare_search_syms): Declare.
This patch moves aarch64-insn.o to arch/aarch64-insn.o. Then, all
arch/*.c are built to arch/*.o, so we don't need a Makefile rule to build
*.o from arch/*.c. This patch removes it too.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_64_TARGET_OBS): Replace aarch64-insn.o with
arch/aarch64-insn.o.
Remove one rule.
* configure.tgt: Replace aarch64-insn.o with arch/aarch64-insn.o.
It is tested by building GDB for some targets, arm-elf, arm-netbsd,
arm-linux, and aarch64-linux.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_TARGET_OBS): Replace arm.o, arm-get-next-pcs.o,
and arm-linux.o with arch/arm.o, arch/arm-get-next-pcs.o and
arch/arm-linux.o respectively.
* configure.tgt: Likewise.
This patch changes the build that arch/i386.c is built to arch/i386.o,
instead of i386.o.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_TARGET_OBS): Rename i386.o to arch/i386.o.
* configure.tgt (i386_tobjs): Replace i386.o with arch/i386.o.
I see a build error when building GDB under msys+mingw gcc 32bit:
g++ -x c++ -std=gnu++11 -g -O2 -I. -I../../../binutils-gdb/gdb/gdbserver -I../../../binutils-gdb/gdb/gdbserver/../common -I../../../binutils-gdb/gdb/gdbserver/../regformats -I../../../binutils-gdb/gdb/gdbserver/.. -I../../../binutils-gdb/gdb/gdbserver/../../include -I../../../binutils-gdb/gdb/gdbserver/../gnulib/import -Ibuild-gnulib-gdbserver/import -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized -Wno-format -Werror -DGDBSERVER -c -o win32-low.o -MT win32-low.o -MMD -MP -MF .deps/win32-low.Tpo ../../../binutils-gdb/gdb/gdbserver/win32-low.c
../../../binutils-gdb/gdb/gdbserver/win32-low.c: In function 'BOOL create_process(const char*, char*, DWORD, PROCESS_INFORMATION*)':
../../../binutils-gdb/gdb/gdbserver/win32-low.c:566:48: error: 'get_inferior_cwd' was not declared in this scope
const char *inferior_cwd = get_inferior_cwd ();
^
make[4]: *** [win32-low.o] Error 1
It can be fixed by simply including the right header file.
gdb/gdbserver/ChangeLog:
2017-10-06 Yuanhui Zhang <asmwarrior@gmail.com>
* win32-low.c: Include "common-inferior.h".
Nowadays, there are much duplications in configure.tgt to update
gdb_target_obs, some cpu specific object files are added to gdb_target_obs
to some different target triplets of the same cpu. The same problem
exists for os specific object files too. It is fragile to update them,
and build with all targets enabled doesn't find the problem.
This patch splits the gdb_target_obs update to three steps, cpu steps, os
steps, and the rest.
I tested this patch by build gdb for each different target triplets
respectively,
aarch64-elf aarch64-rtems aarch64-freebsd aarch64-linux alpha-elf
alpha-linux alpha-netbsd alpha-openbsd arm-elf arm-wince-pe arm-linux
arm-netbsd arm-symbianelf avr cris-elf frv-elf h8300-elf i386-elf
i386-darwin i386-dicos i386-freebsd i386-netbsdelf i386-openbsd
i386-nto i386-solaris i386-linux i386-gnu i386-cygwin i386-mingw32
i386-go32 ia64-linux-gnu ia64-vms lm32-elf m32c-elf m32r-elf m32r-linux
m68hc11-elf m68k-elf m68k-linux m68k-netbsd m68k-openbsd m88k-openbsd
mep-elf microblaze-xilinx-elf microblaze-linux-gnu mips-elf moxie-elf
ms1-elf nios2-elf nios2-linux-gnu hppa-elf hppa-linux hppa-netbsd
hppa-openbsd powerpc-eabi powerpc-freebsd powerpc-netbsd powerpc-openbsd
powerpc-linux powerpc-lynx178 rl78-elf rx-elf s390-linux-gnu score-elf
sh-elf sh-linux sh-openbsd sh64-elf sh64-linux sh64-openbsd sparc64-linux
sparc-linux sparc-freebsd sparc64-freebsd sparc-netbsd sparc64-netbsd
sparc-openbsd sparc64-openbsd spu-elf tic6x-elf tic6x-uclinux v850-elf
vax-netbsd vax-openbsd x86_64-linux-gnu x86_64-darwin x86_64-dicos
x86_64-elf x86_64-freebsd x86_64-mingw32 x86_64-netbsd x86_64-openbsd
x86_64-rtems xstormy16-elf xtensa-elf xtensa-linux
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* configure.tgt (i386_tobjs): New variable.
(amd64_tobjs): New variable.
Set $cpu_obs and $os_obs.
Nowadays, GDB build tree is almost flat, but source tree isn't. We
have arch/ nat/ target/ common/ cli/ mi/ tui/ python/ guile/ directories.
We need to some rules in Makefile for source files in different source
directories, like,
# Rules for compiling .c files in the various source subdirectories.
%.o: ${srcdir}/arch/%.c
$(COMPILE) $<
$(POSTCOMPILE)
%.o: ${srcdir}/nat/%.c
$(COMPILE) $<
$(POSTCOMPILE)
so we should take care of some special case that files' base name is the
same, like,
# Specify an explicit rule for gdb/common/agent.c, to avoid a clash with the
# object file generate by gdb/agent.c.
common-agent.o: $(srcdir)/common/agent.c
$(COMPILE) $(srcdir)/common/agent.c
$(POSTCOMPILE)
As we add more and more files in different directories, it becomes tricky
to name files, because we need take this into account.
This patch takes the first step toward "Replicate src dir in build dir",
that is, we create arch/ directory in buildtree, and put amd64.o there
as an example. Dependency tracking is updated for files with directory
name. Currently, when we build amd64.o,
"-c -o amd64.o -MT amd64.o -MMD -MP -MF .deps/amd64.Tpo"
with this patch applied, it becomes,
"-c -o arch/amd64.o -MT arch/amd64.o -MMD -MP -MF arch/.deps/amd64.o.Tpo"
"make clean" removes the object files, and "make distclean" removes .deps
additionally. configure file create .deps directory in each of
CONFIG_SRC_SUBDIR, and pass it to Makefile.in, so that "make clean" and
"make distclean" can remove stuffs there.
If people agree with this change, I'll add more directories to
CONFIG_SRC_SUBDIR.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (CONFIG_SRC_SUBDIR): New.
(ALL_64_TARGET_OBS): Replace amd64.o with arch/amd64.o.
(clean): Remove object files and dependency files.
(distclean): Remove the directory.
* configure.ac: Invoke AC_CONFIG_COMMANDS.
* configure: Re-generated.
* configure.tgt: Replace amd64.o with arch/amd64.o.
gdb/ChangeLog:
2017-10-05 Jose E. Marchesi <jose.marchesi@oracle.com>
PR build/22188
* arm-tdep.c (arm_decode_misc_memhint_neon): Fix decoding of CPS
and SETEND.
Commit 5cd63fda03 ("Fix "Remote 'g' packet reply is too long"
problems with multiple inferiors") caused a number of regressions on
native GNU/Linux, all related to follow-fork support. E.g.:
src/gdb/target.c:3141: internal-error: gdbarch* default_thread_architecture(target_ops*, ptid_t): Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
Resyncing due to internal error.
FAIL: gdb.base/catch-signal-fork.exp: got SIGHUP after fork (GDB internal error)
This commit fixes it.
gdb/ChangeLog:
2017-10-05 Pedro Alves <palves@redhat.com>
* linux-nat.c (linux_child_follow_fork): When following the parent
and detaching the child, consult the parent thread's architecture
instead of the child's.
The ax.h header file contains a use of DOUBLEST in the type "union agent_val".
However, that type is never used anywhere, so it can be simply removed.
gdb/ChangeLog:
2017-10-05 Ulrich Weigand <uweigand@de.ibm.com>
* ax.h: Do not include "doublest.h".
(union agent_val): Remove.
This cleans up a number of interfaces in dfp.c / dfp.h. Specifically:
- The decimal_from_string / decimal_to_string routines are C++-ified
to operate on std::string instead of character buffers. In the
decimal_from_string, the boolean return value now actually is bool
instead of an int.
- The decimal_from_integral and decimal_from_doublest routines take
an struct value as input. This is not really appropriate at the low
level the DFP routines sit, so this replaced them with new routines
decimal_from_longest / decimal_from_ulongest / decimal_from_doublest
that operate on contents instead.
- To mirror the decimal_from_[u]longest, a new decimal_to_longest
routine is added as well, which can be used in unpack_long to
avoid an unnecessary conversion via DOUBLEST.
Note that the decimal_from_longest / decimal_from_ulongest routines
are actually more powerful than decimal_from_integral: the old routine
would only accept integer *types* of at most four bytes size, while
the new routines accept all integer *values* that fit in an [u]int32_t,
no matter which type they came from. The DFP tests are updated to
allow for this larger range of integers that can be converted.
gdb/ChangeLog:
2017-10-05 Ulrich Weigand <uweigand@de.ibm.com>
* dfp.h (MAX_DECIMAL_STRING): Move to dfp.c.
(decimal_to_string): Return std::string object.
(decimal_from_string): Accept std::string object. Return bool.
(decimal_from_integral, decimal_from_doublest): Remove.
(decimal_from_longest): Add prototype.
(decimal_from_ulongest): Likewise.
(decimal_to_longest): Likewise.
(decimal_from_doublest): Likewise.
* dfp.c: Do not include "gdbtypes.h" or "value.h".
(MAX_DECIMAL_STRING): Move here.
(decimal_to_string): Return std::string object.
(decimal_from_string): Accept std::string object. Return bool.
(decimal_from_integral): Remove, replace by ...
(decimal_from_longest, decimal_from_ulongest): ... these new functions.
(decimal_to_longest): New function.
(decimal_from_floating): Remove, replace by ...
(decimal_from_doublest): ... this new function.
(decimal_to_doublest): Update to new decimal_to_string interface.
* value.c (unpack_long): Use decimal_to_longest.
* valops.c (value_cast): Use decimal_from_doublest instead of
decimal_from_floating. Use decimal_from_[u]longest isntead of
decimal_from_integral.
* valarith.c (value_args_as_decimal): Likewise.
* valprint.c (print_decimal_floating): Update to new
decimal_to_string interface.
* printcmd.c (printf_decfloat): Likewise.
* c-exp.y (parse_number): Update to new decimal_from_string interface.
gdb/testsuite/ChangeLog:
2017-10-05 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.base/dfp-exprs.exp: Update tests to larger range of supported
integer-to-dfp conversion.
* gdb.base/dfp-test.exp: Likewise.
As a first small step to getting rid of doublest.h, this patch removes the
include of "floatformat.h" in "doublest.h". This is actually not needed
for the file itself. A few source files now need to include "floatformat.h"
directly, since they got it indirectly via "doublest.h" and still need it.
In reviewing which files need it, I found a number of files that include
"floatformat.h" directly without actually needing it at all. Similarly,
a number of files include "doublest.h" without needing it. I've also
removed those unnecessary include statements.
gdb/ChangeLog:
2017-10-05 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.h: Do not include "floatformat.h". Remove stale comments.
* gdbtypes.c: Include "floatformat.h".
* value.c: Likewise.
* m68k-tdep.c: Likewise.
* findvar.c: Do not include "floatformat.h".
* amd64-darwin-tdep.c: Likewise.
* arm-linux-tdep.c: Likewise.
* i386-darwin-tdep.c: Likewise.
* i387-tdep.c: Likewise.
* m68k-linux-tdep.c: Likewise.
* mep-tdep.c: Likewise.
* mips-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* s390-linux-tdep.c: Likewise.
* sparc-obsd-tdep.c: Likewise.
* sparc-tdep.c: Likewise.
* sparc64-tdep.c: Likewise.
* spu-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* vax-tdep.c: Likewise.
* xstormy16-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
* top.c: Do not include "doublest.h".
* aarch64-tdep.c: Likewise.
* alpha-tdep.c: Likewise.
* arm-linux-tdep.c: Likewise.
* m68k-linux-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* xstormy16-tdep.c: Likewise.
The N32 signal frame uses an identical layout to N64, so reuse the N64
handler. The N32 signal trampoline does use one different instruction
relative to N64, so a separate tramp_frame is required.
gdb/ChangeLog:
* mips-fbsd-tdep.c (MIPS_INST_ADDIU_A0_SP_N32): Define.
(mipsn32_fbsd_sigframe): Define.
(mips_fbsd_init_abi): Install mipsn32_fbsd_sigframe unwinder
for FreeBSD/mipsn32.
FreeBSD recently added two additional ELF auxiliary vectors. FreeBSD's
AT_HWCAP uses a different number compared to AT_HWCAP on Linux as the
numerical value was already in use for a different vector on FreeBSD.
include/ChangeLog:
* elf/common.h (AT_FREEBSD_EHDRFLAGS, AT_FREEBSD_HWCAP): Define.
gdb/ChangeLog:
* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and
AT_HWCAP.
When debugging two inferiors (or more) against gdbserver, and the
inferiors have different architectures, such as e.g., on x86_64
GNU/Linux and one inferior is 64-bit while the other is 32-bit, then
GDB can get confused with the different architectures in a couple
spots.
In both cases I ran into, GDB incorrectly ended up using the
architecture of whatever happens to be the selected inferior instead
of the architecture of some other given inferior:
#1 - When parsing the expedited registers in stop replies.
#2 - In the default implementation of the target_thread_architecture
target method.
These resulted in instances of the infamous "Remote 'g' packet reply
is too long" error. For example, with the test added in this commit,
we get:
~~~
Continuing.
Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): ad064000000000000[snip]
(gdb) FAIL: gdb.multi/multi-arch.exp: inf1 event with inf2 selected: continue to hello_loop
c
Continuing.
Truncated register 50 in remote 'g' packet
(gdb) PASS: gdb.multi/multi-arch.exp: inf2 event with inf1 selected: c
~~~
This commit fixes that.
gdb/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* remote.c (get_remote_arch_state): New 'gdbarch' parameter. Use
it instead of target_gdbarch.
(get_remote_state, get_remote_packet_size): Adjust
get_remote_arch_state calls, passing down target_gdbarch
explicitly.
(packet_reg_from_regnum, packet_reg_from_pnum): New parameter
'gdbarch' and use it instead of target_gdbarch.
(get_memory_packet_size): Adjust get_remote_arch_state calls,
passing down target_gdbarch explicitly.
(struct stop_reply) <arch>: New field.
(remote_parse_stop_reply): Use the stopped thread's architecture,
not the current inferior's. Save the architecture in the
stop_reply.
(process_stop_reply): Use the stop reply's architecture.
(process_g_packet, remote_fetch_registers)
(remote_prepare_to_store, store_registers_using_G)
(remote_store_registers): Adjust get_remote_arch_state calls,
using the regcache's architecture.
(remote_get_trace_status): Adjust get_remote_arch_state calls,
passing down target_gdbarch explicitly.
* spu-multiarch.c (spu_thread_architecture): Defer to the target
beneath instead of calling target_gdbarch.
* target.c (default_thread_architecture): Use the specified
inferior's architecture, instead of the current inferior's
architecture (via target_gdbarch).
gdb/testsuite/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* gdb.multi/hangout.c: Include <unistd.h>.
(hangout_loop): New function.
(main): Call alarm. Call hangout_loop in a loop.
* gdb.multi/hello.c: Include <unistd.h>.
(hello_loop): New function.
(main): Call alarm. Call hangout_loop in a loop.
* gdb.multi/multi-arch.exp: Test running to a breakpoint one
inferior with the other selected.
A following patch will change the default target_thread_architecture
method, like this:
struct gdbarch *
default_thread_architecture (struct target_ops *ops, ptid_t ptid)
{
- return target_gdbarch ();
+ inferior *inf = find_inferior_ptid (ptid);
+ gdb_assert (inf != NULL);
+ return inf->gdbarch;
}
This is because target_gdbarch is really just
current_inferior()->gdbarch, and it's wrong to return that
architecture when the inferior of the passed in PTID is NOT the
current inferior -- the inferior for PTID may be running a different
architecture. E.g., a mix of 64-bit and 32-bit inferiors in the same
debug session.
Doing that change above however exposes a problem in "maint print
registers", caught be the testsuite:
-PASS: gdb.base/maint.exp: maint print registers
+FAIL: gdb.base/maint.exp: maint print registers (GDB internal error)
...
gdb/inferior.c:309: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
The call stack looks like this:
#0 0x000000000068b707 in internal_error(char const*, int, char const*, ...) (file=0xa9b958 "gdb/inferior.c", line=309, fmt=0xa9b8e0 "%s: Assertion `%s' failed.") at gdb/common/errors.c:54
#1 0x00000000006e1c40 in find_inferior_pid(int) (pid=0) at gdb/inferior.c:309
#2 0x00000000006e1c8d in find_inferior_ptid(ptid_t) (ptid=...) at gdb/inferior.c:323
#3 0x00000000007c18dc in default_thread_architecture(target_ops*, ptid_t) (ops=0xf86d60 <dummy_target>, ptid=...)
at gdb/target.c:3134
#4 0x00000000007b5414 in delegate_thread_architecture(target_ops*, ptid_t) (self=0xf86d60 <dummy_target>, arg1=...)
at gdb/target-delegates.c:2527
#5 0x00000000007647b3 in get_thread_regcache(ptid_t) (ptid=...) at gdb/regcache.c:466
#6 0x00000000007647ff in get_current_regcache() () at gdb/regcache.c:475
#7 0x0000000000767495 in regcache_print(char const*, regcache_dump_what) (args=0x0, what_to_dump=regcache_dump_none)
at gdb/regcache.c:1599
#8 0x0000000000767550 in maintenance_print_registers(char const*, int) (args=0x0, from_tty=1)
at gdb/regcache.c:1613
I.e., the test does "maint print registers" while the inferior is not
running yet. This is expected to work, and there's already a hack in
get_thread_arch_regcache to make it work.
Instead of pilling on hacks in the internal of regcache and
target_ops, this commit moves the null_ptid special casing to where it
belongs -- higher up in the call chain in the implementation of "maint
print registers" & co directly.
gdb/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* regcache.c (get_thread_arch_regcache): Remove null_ptid special
case.
(regcache_print): Handle !target_has_registers here instead.
A following patch will remove this hack from within regcache's
implementation:
struct regcache *
get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
{
struct address_space *aspace;
/* For the benefit of "maint print registers" & co when debugging an
executable, allow dumping the regcache even when there is no
thread selected (target_thread_address_space internal-errors if
no address space is found). Note that normal user commands will
fail higher up on the call stack due to no
target_has_registers. */
aspace = (ptid_equal (null_ptid, ptid)
? NULL
: target_thread_address_space (ptid));
i.e., it'll no longer be possible to try to build a regcache for
null_ptid. That change alone would regress the gdbarch self tests
though, causing this:
(gdb) maintenance selftest
[...]
Running selftest register_to_value.
src/gdb/inferior.c:309: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.gdb/unittest.exp: maintenance selftest (GDB internal error)
The problem is that the way the mocking environment for those unit
tests is written is a bit fragile: it creates a special purpose
regcache (and sentinel's frame), using whatever is the current
inferior_ptid (usually null_ptid), and assumes get_current_regcache
will find that in the regcache::current_regcache list.
This commit changes the way the mock environment is created. It
eliminates the special regcache and frame and instead creates a fuller
mock environment, with a custom mock target_ops, and then a mock
inferior and thread "running" on that target.
If there's already a running target when you type "maint selftest",
then we error out, instead of pushing a new target on top of the
existing one (and thus killing the debug session). This results in:
(gdb) maint selftest
(...)
Self test failed: arch i386: target already pushed
Self test failed: arch i386:x86-64: target already pushed
Self test failed: arch i386:x64-32: target already pushed
Self test failed: arch i8086: target already pushed
Self test failed: arch i386:intel: target already pushed
Self test failed: arch i386:x86-64:intel: target already pushed
Self test failed: arch i386:x64-32:intel: target already pushed
Self test failed: arch i386:nacl: target already pushed
Self test failed: arch i386:x86-64:nacl: target already pushed
Self test failed: arch i386:x64-32:nacl: target already pushed
Self test failed: self-test failed at /home/pedro/gdb/mygit/src/gdb/selftest-arch.c:86
(...)
Ran 19 unit tests, 1 failed
I think that's OK, because self tests are really meant to be run from
a clean state right after GDB is started. I'm adding that erroring
out just as safe measure just in case someone types "maint selftest"
on the command line while already debugging something (as I've done
it).
(In my multi-target branch, where this patch originated from, we don't
actually need to error out, because there each inferior has its own
target stack).
Also, note that the current code was doing:
current_inferior()->gdbarch = gdbarch;
without taking care to restore the previous gdbarch. This means that
GDB's state was being left inconsistent after running the self tests,
further supporting the point that there's probably not much
expectation that mixing "maint selftests" and regular debugging in the
same GDB invocation really works. This patch fixes that, regardless.
gdb/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* frame.c (create_test_frame): Delete.
* frame.h (create_test_frame): Delete.
* gdbarch-selftests.c: Include gdbthread.h and target.h.
(class regcache_test): Delete.
(test_target_has_registers, test_target_has_stack)
(test_target_has_memory, test_target_prepare_to_store)
(test_target_store_registers): New functions.
(test_target_ops): New class.
(register_to_value_test): Error out if there's already a
process_stratum (or higher) target pushed. Create a fuller mock
environment, with mock target_ops, inferior, address space, thread
and inferior_ptid.
* progspace.c (struct address_space): Move to ...
* progspace.h (struct address_space): ... here.
* regcache.h (regcache::~regcache, regcache::raw_write)
[GDB_SELF_TEST]: No longer virtual.
New in v3:
- Replace use_gdb_stub with can_spawn_for_attach.
- Call kill_wait_spawned_process on spawn_ids.
Commit
Use std::set in mi-main.c
52f9abe4c7
changed the logic of the "-list-thread-groups --available" by mistake
when a pid is passed. It prints all the processes except the one
specified by the given pid. The correct behavior is to only print the
process corresponding to that pid. this patch fixes that and adds a test.
gdb/ChangeLog:
* mi/mi-main.c (list_available_thread_groups): Reverse filter logic.
gdb/testsuite/ChangeLog:
* gdb.mi/list-thread-groups-available.exp: New file.
* gdb.mi/list-thread-groups-available.c: New file.
I tried building GDB with TRY/CATCH mapped to raw C++ try/catch (by
defining GDB_XCPT to GDB_XCPT_RAW_TRY in
gdb/common/common-exceptions.h), and that caught a case of code
written between try and catch. This commit fixes it.
gdb/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Move code
out of 'between TRY and CATCH'.
(Adding missing ChangeLog entry)
While we still have cleanups (i.e., make_cleanup & co), we must be
sure to add END_CATCH at the end of a TRY/CATCH/END_CATCH construct.
However, it's currently too easy to miss adding the END_CATCH, because
the code compiles anyway without it. I realized this when I noticed
that another patch I was working on missed several adding END_CATCH in
several new TRY/CATCH uses.
This commit fixes that by making TRY open a new scope that is only
closed by END_CATCH. This way, if you forget to add the END_CATCH,
then compilation fails due to the unbalanced curly braces.
This caught a couple places where we were missing END_CATCH in current
master, also fixed by the patch.
gdb/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (complete_command): Add missing END_CATCH.
* common/common-exceptions.h (TRY): Open an outermost scope.
Expand intro comment.
(CATCH): Reindent.
(END_CATCH): Close the outermost scope.
* completer.c (complete_line_internal): Add missing END_CATCH.
While we still have cleanups (i.e., make_cleanup & co), we must be
sure to add END_CATCH at the end of a TRY/CATCH/END_CATCH construct.
However, it's currently too easy to miss adding the END_CATCH, because
the code compiles anyway without it. I realized this when I noticed
that another patch I was working on missed several adding END_CATCH in
several new TRY/CATCH uses.
This commit fixes that by making TRY open a new scope that is only
closed by END_CATCH. This way, if you forget to add the END_CATCH,
then compilation fails due to the unbalanced curly braces.
This caught a couple places where we were missing END_CATCH in current
master, also fixed by the patch.
gdb/ChangeLog:
2017-10-04 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (complete_command): Add missing END_CATCH.
* common/common-exceptions.h (TRY): Open an outermost scope.
Expand intro comment.
(CATCH): Reindent.
(END_CATCH): Close the outermost scope.
* completer.c (complete_line_internal): Add missing END_CATCH.
This is the "natural" extension necessary for the "set cwd" command
(and the whole "set the inferior's cwd" logic) to work on gdbserver.
The idea here is to have a new remote packet, QSetWorkingDir (name
adopted from LLDB's extension to the RSP, as can be seen at
<https://raw.githubusercontent.com/llvm-mirror/lldb/master/docs/lldb-gdb-remote.txt>),
which sends an hex-encoded string representing the working directory
that the remote inferior will use. There is a slight difference from
the packet proposed by LLDB: GDB's version will accept empty
arguments, meaning that the user wants to clear the previously set
working directory for the inferior (i.e., "set cwd" without arguments
on GDB).
For UNIX-like targets this feature is already implemented on
nat/fork-inferior.c, and all gdbserver has to do is to basically
implement "set_inferior_cwd" and call it whenever such packet arrives.
For other targets, like Windows, it is possible to use the existing
"get_inferior_cwd" function and do the necessary steps to make sure
that the inferior will use the specified working directory.
Aside from that, the patch consists basically of updates to the
testcase (making it available on remote targets) and the
documentation.
No regressions found.
gdb/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0): Add entry about new
'set-cwd-on-gdbserver' feature.
(New remote packets): Add entry for QSetWorkingDir.
* common/common-inferior.h (set_inferior_cwd): New prototype.
* infcmd.c (set_inferior_cwd): Remove "static".
(show_cwd_command): Expand text to include remote debugging.
* remote.c: Add PACKET_QSetWorkingDir.
(remote_protocol_features) <QSetWorkingDir>: New entry for
PACKET_QSetWorkingDir.
(extended_remote_set_inferior_cwd): New function.
(extended_remote_create_inferior): Call
"extended_remote_set_inferior_cwd".
(_initialize_remote): Call "add_packet_config_cmd" for
QSetWorkingDir.
gdb/gdbserver/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* inferiors.c (set_inferior_cwd): New function.
* server.c (handle_general_set): Handle QSetWorkingDir packet.
(handle_query): Inform that QSetWorkingDir is supported.
* win32-low.c (create_process): Pass the inferior's cwd to
CreateProcess.
gdb/testsuite/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/set-cwd.exp: Make it available on
native-extended-gdbserver.
gdb/doc/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (Starting your Program) <The working directory.>:
Mention remote debugging.
(Working Directory) <Your Program's Working Directory>:
Likewise.
(Connecting) <Remote Packet>: Add "set-working-dir"
and "QSetWorkingDir" to the table.
(Remote Protocol) <QSetWorkingDir>: New item, explaining the
packet.
This commit adds new "set/show cwd" commands, which are used to
set/show the current working directory of the inferior that will be
started.
The idea here is that "set cwd" will become the de facto way of
setting the inferior's cwd. Currently, the user can use "cd" for
that, but there are side effects: with "cd", GDB also switches to
another directory, and that can impact the loading of scripts and
other files. With "set cwd", we separate the logic into a new
command.
To maintain backward compatibility, if the user issues a "cd" command
but doesn't use "set cwd", then the inferior's cwd will still be
changed according to what the user specified. However, "set cwd" has
precedence over "cd", so it can always be used to override it.
"set cwd" works in the following way:
- If the user sets the inferior's cwd by using "set cwd", then this
directory is saved into current_inferior ()->cwd and is used when
the inferior is started (see below).
- If the user doesn't set the inferior's cwd by using "set cwd", but
rather use the "cd" command as before, then this directory is
inherited by the inferior because GDB will have chdir'd into it.
On Unix-like hosts, the way the directory is changed before the
inferior execution is by expanding the user set directory before the
fork, and then "chdir" after the call to fork/vfork on
"fork_inferior", but before the actual execution. On Windows, the
inferior cwd set by the user is passed directly to the CreateProcess
call, which takes care of the actual chdir for us.
This way, we'll make sure that GDB's cwd is not affected by the user
set cwd.
gdb/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (New commands): Mention "set/show cwd".
* cli/cli-cmds.c (_initialize_cli_cmds): Mention "set cwd" on
"cd" command's help text.
* common/common-inferior.h (get_inferior_cwd): New prototype.
* infcmd.c (inferior_cwd_scratch): New global variable.
(set_inferior_cwd): New function.
(get_inferior_cwd): Likewise.
(set_cwd_command): Likewise.
(show_cwd_command): Likewise.
(_initialize_infcmd): Add "set/show cwd" commands.
* inferior.h (class inferior) <cwd>: New field.
* nat/fork-inferior.c: Include "gdb_tilde_expand.h".
(fork_inferior): Change inferior's cwd before its execution.
* windows-nat.c (windows_create_inferior): Pass inferior's cwd
to CreateProcess.
gdb/gdbserver/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* inferiors.c (current_inferior_cwd): New global variable.
(get_inferior_cwd): New function.
* inferiors.h (struct process_info) <cwd>: New field.
gdb/doc/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (Starting your Program) <The working directory.>:
Mention new "set cwd" command.
(Working Directory) <Your Program's Working Directory>:
Rephrase to explain that "set cwd" exists and is the default
way to change the inferior's cwd.
gdb/testsuite/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/set-cwd.c: New file.
* gdb.base/set-cwd.exp: Likewise.
Currently, whenever we want to handle paths provided by the user and
perform tilde expansion on GDB, we rely on "tilde_expand", which comes
from readline. This was enough for our use cases so far, but the
situation will change when we start dealing with paths on gdbserver as
well, which is what the next patches implement.
Unfortunately it is not possible to use "tilde_expand" in this case
because gdbserver doesn't use readline. For that reason I decided to
implement a new "gdb_tilde_expand" function, which is basically a
wrapper for "glob" and its GNU extension, GLOB_TILDE_CHECK. With the
import of the "glob" module from gnulib, we're sure that "glob" always
supports this extension.
gdb/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* Makefile.in (SFILES): Add gdb_tilde_expand.c.
(HFILES_NO_SRCDIR): Add gdb_tilde_expand.h.
(COMMON_OBS): Add gdb_tilde_expand.o.
* common/gdb_tilde_expand.c: New file.
* common/gdb_tilde_expand.h: Likewise.
gdb/gdbserver/ChangeLog:
2017-10-04 Sergio Durigan Junior <sergiodj@redhat.com>
* Makefile.in (SFILES): Add $(srcdir)/common/gdb_tilde_expand.c.
(OBS): Add gdb_tilde_expand.o.
Remove a duplicate `struct objfile' declaration mistakenly added with
commit 3e29f34a4e ("MIPS: Keep the ISA bit in compressed code
addresses").
gdb/
* gdbarch.sh (objfile): Remove duplicate declaration.
* gdbarch.h: Regenerate.
I made a mistake earlier and used string_printf where I should have used
string_vprintf.
I'm checking this in as obvious.
2017-10-03 Tom Tromey <tom@tromey.com>
* utils.c (internal_vproblem): Use string_vprintf.
This removes a cleanup by using std::string in info_symbol_command.
2017-10-03 Tom Tromey <tom@tromey.com>
* printcmd.c (info_symbol_command): Use std::string.
This removes a cleanup by using std::string in
gdb_safe_append_history.
2017-10-03 Tom Tromey <tom@tromey.com>
* top.c (gdb_safe_append_history): Use std::string.
This removes new_ui and delete_ui in favor of ordinary 'new' and
'delete', and then removes make_delete_ui_cleanup in favor of
std::unique_ptr.
2017-10-03 Tom Tromey <tom@tromey.com>
* event-top.c (stdin_event_handler): Update.
* main.c (captured_main_1): Update.
* top.h (make_delete_ui_cleanup): Remove.
(struct ui): Add constructor and destructor.
(new_ui, delete_ui): Remove.
* top.c (make_delete_ui_cleanup): Remove.
(new_ui_command): Use std::unique_ptr.
(delete_ui_cleanup): Remove.
(ui::ui): Rename from new_ui. Update.
(free_ui): Remove.
(ui::~ui): Rename from delete_ui. Update.
This changes load_progress to use gdb::byte_vector, removing a
cleanup.
2017-10-03 Tom Tromey <tom@tromey.com>
* symfile.c (load_progress): Use gdb::byte_vector.
This converts internal_vproblem and defaulted_query to use
std::string.
2017-10-03 Tom Tromey <tom@tromey.com>
* utils.c (internal_vproblem): Use std::string.
(defaulted_query): Likewise.
This removes set_batch_flag_and_make_cleanup_restore_page_info and
make_cleanup_restore_page_info in favor of a new RAII class. This
then allows for the removal of make_cleanup_restore_uinteger and
make_cleanup_restore_integer
ChangeLog
2017-10-03 Tom Tromey <tom@tromey.com>
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Update.
* top.c (execute_command_to_string): Update.
* utils.c (make_cleanup_restore_page_info): Remove.
(do_restore_page_info_cleanup): Remove.
(set_batch_flag_and_restore_page_info):
New.
(make_cleanup_restore_page_info): Remove.
(set_batch_flag_and_make_cleanup_restore_page_info): Remove.
(~set_batch_flag_and_restore_page_info): New
(make_cleanup_restore_uinteger): Remove.
(make_cleanup_restore_integer): Remove.
(struct restore_integer_closure): Remove.
(restore_integer): Remove.
* utils.h (struct set_batch_flag_and_restore_page_info): New
class.
(set_batch_flag_and_make_cleanup_restore_page_info): Remove.
(make_cleanup_restore_page_info): Remove.
(make_cleanup_restore_uinteger) Remove.
(make_cleanup_restore_integer) Remove.
This changes record_full_gdb_operation_disable_set to return a
scoped_restore rather than a cleanup, and fixes all the users.
ChangeLog
2017-10-03 Tom Tromey <tom@tromey.com>
* record-full.h (record_full_gdb_operation_disable_set): Return
scoped_restore_tmpl<int>.
* infrun.c (adjust_pc_after_break): Update.
(handle_signal_stop): Update.
* record-full.c (record_full_gdb_operation_disable_set): Return
scoped_restore_tmpl<int>.
(record_full_wait_1, record_full_insert_breakpoint)
(record_full_remove_breakpoint, record_full_save)
(record_full_goto_insn): Update.
Printing a string slice ("&str") in Rust would print until the
terminating \0; but that is incorrect because a slice has a length.
This fixes &str printing, and arranges to preserve the type name when
slicing a slice, so that printing a slice of an "&str" works as well.
This is PR rust/22236.
2017-10-02 Tom Tromey <tom@tromey.com>
PR rust/22236:
* rust-lang.c (rust_val_print_str): New function.
(val_print_struct): Call it.
(rust_subscript): Preserve name of slice type.
2017-10-02 Tom Tromey <tom@tromey.com>
PR rust/22236:
* gdb.rust/simple.rs (main): New variable "fslice".
* gdb.rust/simple.exp: Add slice tests. Update string tests.
Something like "ptype &x[..]" (where "x" was a slice) would crash gdb.
rust_subscript wasn't handling slicing in the EVAL_AVOID_SIDE_EFFECTS
case.
2017-10-02 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_subscript): Handle slices in
EVAL_AVOID_SIDE_EFFECTS case.
2017-10-02 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.exp: Test ptype of a slice.
rust_slice_type_p was not recognizing &str as a slice type, so indexing
into (or making a slice of) a slice was not working.
2017-10-02 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_slice_type_p): Recognize &str as a slice type.
2017-10-02 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.exp: Test index of slice.
I noticed that one function in rust-lang.h was not declared using
"extern". In the interested of uniformity, this patch adds it.
Tested by rebuilding.
2017-10-02 Tom Tromey <tom@tromey.com>
* rust-lang.h (rust_slice_type): Add "extern".
G++ 4.8 trips on:
In file included from /opt/gcc-4.8/include/c++/4.8.5/algorithm:62:0,
from ../../src/gdb/ada-lang.c:65:
/opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >; _Tp = ada_exc_info]’:
/opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2283:70: required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >]’
/opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2315:54: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >; _Size = long int]’
/opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:5461:36: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<ada_exc_info*, std::vector<ada_exc_info> >]’
../../src/gdb/ada-lang.c:13153:61: required from here
/opt/gcc-4.8/include/c++/4.8.5/bits/stl_algo.h:2245:19: error: passing ‘const ada_exc_info’ as ‘this’ argument of ‘bool ada_exc_info::operator<(const ada_exc_info&)’ discards qualifiers [-fpermissive]
while (__pivot < *__last)
^
Seems to be a libstdc++ bug meanwhile fixed by:
https://gcc.gnu.org/ml/libstdc++/2012-04/msg00074.
In any case, there's no reason these methods can't be const.
gdb/ChangeLog:
2017-10-02 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* ada-lang.h (ada_exc_info::operator<): Make const.
(ada_exc_info::operator==): Make const.
* ada-lang.c (ada_exc_info::operator<, ada_exc_info::operator==):
Make const.
In gdbserver, target descriptions need to be initialized by calling
init_target_desc. Because i386_create_target_description is shared with
GDB, it doesn't do that, the callers must take care of it. These two
platforms currently don't.
I am not able to build them, so I couldn't test.
gdb/gdbserver/ChangeLog:
* lynx-i386-low.c (lynx_i386_arch_setup): Call init_target_desc.
* nto-x86-low.c (nto_x86_arch_setup): Likewise.
This changes read_memory_robust to return a std::vector, allowing the
removal of free_memory_read_result_vector and associated cleanups.
This patch also changes the functions it touches to be a bit more
robust with regards to deallocation; it's perhaps possible that
read_memory_robust could have leaked in some situations.
This patch is based on my earlier series to remove some MI cleanups.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* target.c (read_whatever_is_readable): Change type of "result".
Update.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Change return type. Update.
* mi/mi-main.c (mi_cmd_data_read_memory_bytes): Update. Use
bin2hex, std::string.
* target.h (memory_read_result_s): Remove typedef.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Return std::vector.
Change captured_mi_execute_command to use a scoped_restore, removing a
cleanup. The old code copied the current token, but I don't believe
that is necessary.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (captured_mi_execute_command): Use scope_restore.
Change ada_exceptions_list to return a std::vector and fix up the
users. This allows removing a cleanup in MI.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Update.
* ada-lang.h (struct ada_exc_info): Remove typedef. Declare
operator< and operator==.
(ada_exceptions_list): Return a std::vector.
* ada-lang.c (ada_exc_info::operator<): Rename from
compare_ada_exception_info.
(ada_exc_info::operator==): New.
(sort_remove_dups_ada_exceptions_list): Change type of
"exceptions".
(ada_add_standard_exceptions, ada_add_exceptions_from_frame)
(ada_add_global_exceptions): Likewise.
(ada_exceptions_list_1): Return a std::vector.
(ada_exceptions_list): Likewise.
Change a couple of spots in mi-main.c to use std::set. This
simplifies the code and removes some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (struct print_one_inferior_data) <inferiors>: Now a
'std::set *'.
(print_one_inferior): Update.
(free_vector_of_ints): Remove.
(list_available_thread_groups): Change "ids" to std::set.
(mi_cmd_list_thread_groups): Update.
(struct collect_cores_data) <core>: Now a std::set.
(collect_cores): Update.
(unique): Remove.
(print_one_inferior): Update.
Change a couple of spots in mi-main.c to use std::string, and change
one place to use field_fmt. This removes some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (mi_execute_cli_command): Use std::string.
(mi_execute_async_cli_command): Likewise.
(mi_cmd_trace_frame_collected): Use field_fmt.
This changes mi_cmd_data_write_memory_bytes to use gdb::byte_vector,
removing some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (mi_cmd_data_write_memory_bytes): Use
gdb::byte_vector.
There was a leftover cleanup declaration in mi_parse. Remove it.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-parse.c (mi_parse): Remove unused declaration.
This string copy in mi_cmd_disassemble seems not to be needed, so
don't do it.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Don't copy "oarg".
This removes some cleanups from mi-cmd-var.c. varobj_gen_name now
returns a string, simplifying mi_cmd_var_create. In
mi_cmd_var_delete, a string copy is apparently unnecessary, so it's
simply removed.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* varobj.h (varobj_gen_name): Return std::string.
* varobj.c (varobj_gen_name): Return std::string.
* mi/mi-cmd-var.c (mi_cmd_var_create): Use std::string.
(mi_cmd_var_delete): Don't copy "name".
This changes mi_argv_to_format to return a string, allowing the
removal of some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-break.c (mi_argv_to_format): Return std::string.
(mi_cmd_break_insert_1): Update.
This removes make_cleanup_defer_target_commit_resume in favor of using
scoped_restore.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* target.h (make_scoped_defer_target_commit_resume): Update.
* target.c (make_scoped_defer_target_commit_resume): Rename from
make_cleanup_defer_target_commit_resume. Return a
scoped_restore.
* infrun.c (proceed): Use make_scoped_defer_target_commit_resume.
This removes an unused outer cleanup from symtab.c, and an unused
cleanup declaration as well.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* symtab.c (search_symbols): Remove unused outer cleanup.
(make_source_files_completion_list): Remove unused declaration.
Remove a cleanup from mt-tdep.c, using gdb::byte_vector.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mt-tdep.c (mt_push_dummy_call): Use gdb::byte_vector.
This removes a cleanup from xstormy16-tdep.c, using gdb::byte_vector.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* xstormy16-tdep.c (xstormy16_push_dummy_call): Use
gdb::byte_vector.
This removes a cleanup from complaints.c by using std::string.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* complaints.c (vcomplaint): Use std::string.
This removes some cleanups from tracepoint.c by using std::string. It
also removes some unused cleanup declarations.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* tracepoint.c (trace_variable_command): Use std::string.
(encode_actions_1): Remove unused declarations.
(create_tsv_from_upload): Use std::string.
This removes some cleanups from cp-support.c, using std::string.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* cp-support.c (gdb_demangle): Use std::string.
This removes some cleanups from stack.c by using std::string or
gdb::unique_xmalloc_ptr. One cleanup remains in this file; I did not
remove it here because it is handled in another patch series that has
yet to be resolved.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* stack.c (parse_frame_specification): Use std::string
(info_frame_command): Use gdb::unique_xmalloc_ptr.
This removes a cleanup from tilegx-tdep.c, by using gdb::byte_vector.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* tilegx-tdep.c (tilegx_push_dummy_call): Use gdb::byte_vector.
This removes a couple of cleanups from utils.c through the use of
std::string.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* utils.c (vfprintf_maybe_filtered): Use std::string.
(vfprintf_unfiltered): Likewise.
This removes a cleanup from display_gdb_prompt by using std::string.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* event-top.c (top_level_prompt): Return std::string.
(display_gdb_prompt): Update.
This adds string_vprintf, a va_list variant of string_printf. This
will be used in later patches.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* unittests/common-utils-selftests.c (format): New function.
(string_vprintf_tests): New function.
(_initialize_common_utils_selftests): Register new tests.
* common/common-utils.c (string_vprintf): New function.
* common/common-utils.h (string_vprintf): Declare.
This finally eliminates an old hack left in place when tracepoint RSP
support was migrated from tracepoint.c to remote.c, back in
35b1e5cca0 ("Make tracepoint operations go through target vector.")
over 7 years ago.
Tested on x86_64 GNU/Linux.
gdb/ChangeLog:
2017-09-29 Pedro Alves <palves@redhat.com>
* remote.c (target_buf, target_buf_size): Delete.
(remote_get_noisy_reply): Remove buf_p and sizeof_buf parameters.
Use the connection's packet buffer instead.
All callers adjusted.
(_initialize_remote): Remove references to target_buf and
target_buf_size.
If we had this in place before, then the regression fixed by the
previous commit would have been been visible is all test runs. E.g.:
Running src/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp ...
FAIL: gdb.threads/multi-create-ns-info-thr.exp: continue to breakpoint 6
Debugging manually we'd see this:
gdbserver: Cannot get thread handle for LWP 1467: generic error
Instead of:
gdbserver: PID mismatch! Expected 27472, got 27471
which is misleading - gdbserver didn't 27471, that was stale stack
data from previous function invocations.
gdb/gdbserver/ChangeLog:
2017-09-29 Pedro Alves <palves@redhat.com>
* proc-service.c (ps_pdread): Return PS_ERR if reading memory
fails.
Commit 8629910955 ("Add thread_db_notice_clone to gdbserver")
introduced calls into libthread_db without making sure that the
current thread is pointing to a know-stopped thread. This resulted in
sometimes thread_db_notice_clone failing->find_one_thread failing like
this, as seen when running gdb.threads/multi-create-ns-info-thr.exp:
~~~
Thread <6> executing
Thread <7> executing
gdbserver: PID mismatch! Expected 27472, got 27471
gdbserver: Cannot find thread after clone.
Thread <1000> executing
Thread <1001> executing
~~~
Things go south from here and sometimes that ends up resulting in
gdbserver crashing and the test failing.
gdb/gdbserver/ChangeLog:
2017-09-29 Pedro Alves <palves@redhat.com>
* linux-low.c (handle_extended_wait): Pass parent thread instead
of process to thread_db_notice_clone.
* linux-low.h (thread_db_notice_clone): Replace parent process
parameter with parent thread parameter.
* thread-db.c (find_one_thread): Add comment.
(thread_db_notice_clone): Replace parent process parameter with
parent thread parameter. Temporarily switch to the parent thread.
This file was only under gdb/ currently because it predates the
gdb/unittests/ directory.
gdb/ChangeLog:
2017-09-28 Pedro Alves <palves@redhat.com>
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/common-utils-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add common-utils-selftests.o.
(COMMON_OBS): Remove utils-selftests.o.
* utils-selftests.c: Move to ...
* unittests/common-utils-selftests.c: ... here and rename self
test to "string_printf".
This is a "tiny patch", no assignment required.
2017-09-28 Alexander Shaposhnikov <alexander.v.shaposhnikov@gmail.com>
* dwarf2read.c (open_and_init_dwp_file): Protect against dwp_file
having NULL cus or tus.
Many tdep files need to perform conversions between two floating-point
types, usually when accessing FP registers. Most targets now use the
convert_typed_floating helper routine to do so. However, a small number
still use the old method of converting via a DOUBLEST. Since we want
to get rid of DOUBLEST, these targets need to be moved to the new
method as well.
The main obstacle is that for convert_typed_floating we need an actual
*type*, not just a floatformat.
In arm-tdep.c, this is very straightforward, since there is already a
type using the ARM extended floatformat.
For sh-tdep.c and sh64-tdep.c, no such type already exists, so I've
added one to the gdbarch_tdep struct as done on other targets.
gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
* arm-tdep.c: (convert_from_extended): Remove.
(convert_to_extended): Likewise.
(arm_extract_return_value): Use convert_typed_floating.
(arm_store_return_value): Likewise.
* sh-tdep.h (struct gdbarch_tdep): Add sh_littlebyte_bigword_type.
* sh-tdep.c: Do not include "floatformat.h".
(sh_littlebyte_bigword_type): New function.
(sh_register_convert_to_virtual): Use convert_typed_floating.
(sh_register_convert_to_raw): Likewise.
* sh64-tdep.c: (struct gdbarch_tdep): Add sh_littlebyte_bigword_type.
(sh64_littlebyte_bigword_type): New function.
(sh64_extract_return_value): Use convert_typed_floating.
(sh64_register_convert_to_virtual): Likewise.
(sh64_register_convert_to_raw): Likewise.
For historical reasons, the TYPE_FLOATFORMAT element is still set to hold
an array of two floatformat structs, one for big-endian and the other for
little-endian. When accessing the element via floatformat_from_type,
the code would check the type's byte order and return the appropriate
floatformat.
However, these days this is quite unnecessary, since the type's byte order
is already known at the time the type is allocated and the floatformat is
installed into TYPE_FLOATFORMAT. Therefore, we can just install the correct
version here.
Also, moves the (now trivially simple) floatformat_from_type accessor to
gdbtypes.{c,h}, since it doesn't really need to be in doublest.c now.
gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.h (floatformat_from_type): Move to gdbtypes.h.
* doublest.c (floatformat_from_type): Move to gdbtypes.c.
* gdbtypes.h (union type_specific): Make field floatformat hold
just a single struct floatformat, not an array.
(floatformat_from_type): Move here.
* gdbtypes.c (floatformat_from_type): Move here. Update to
changed TYPE_FLOATFORMAT definition.
(verify_floatformat): Update to changed TYPE_FLOATFORMAT.
(recursive_dump_type): Likewise.
(init_float_type): Install correct floatformat for byte order.
(arch_float_type): Likewise.
This changes the interfaces to init_type and arch_type to take the
type length in bits as input (instead of as bytes). The routines
assert that the length is a multiple of TARGET_CHAR_BIT.
For consistency, arch_flags_type is changed likewise, so that now
all type creation interfaces always use length in bits.
All callers are updated in the straightforward manner.
The assert actually found a bug in read_range_type, where the
init_integer_type routine was called with a wrong argument (probably
a bug introduced with the conversion to use init_integer_type).
gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
* gdbtypes.c (init_type): Change incoming argument from
length-in-bytes to length-in-bits. Assert length is a
multiple of TARGET_CHAR_BITS.
(arch_type, arch_flags_type): Likewise.
(init_integer_type): Update call to init_type.
(init_character_type): Likewise.
(init_boolean_type): Likewise.
(init_float_type): Likewise.
(init_decfloat_type): Likewise.
(init_complex_type): Likewise.
(init_pointer_type): Likewise.
(objfile_type): Likewise.
(arch_integer_type): Update call to arch_type.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(arch_float_type): Likewise.
(arch_decfloat_type): Likewise.
(arch_complex_type): Likewise.
(arch_pointer_type): Likewise.
(gdbtypes_post_init): Likewise.
* dwarf2read.c (dwarf2_init_float_type): Update call to init_type.
(read_base_type): Likewise.
* mdebugread.c (basic_type): Likewise.
* stabsread.c (dbx_init_float_type): Likewise.
(rs6000_builtin_type): Likewise.
(read_range_type): Likewise. Also, fix call to init_integer_type
with erroneous length argument.
* ada-lang.c (ada_language_arch_info): Update call to arch_type.
* d-lang.c (build_d_types): Likewise.
* f-lang.c (build_fortran_types): Likewise.
* go-lang.c (build_go_types): Likewise.
* opencl-lang.c (build_opencl_types): Likewise.
* jit.c (finalize_symtab): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* target-descriptions.c (tdesc_gdb_type): Likewise. Also,
update call to arch_flags_type.
* linux-tdep.c (linux_get_siginfo_type_with_fields): Update call to
arch_type.
* fbsd-tdep.c (fbsd_get_siginfo_type): Likewise.
* windows-tdep.c (windows_get_tlb_type): Likewise.
* avr-tdep.c (avr_gdbarch_init): Update call to arch_type.
* ft32-tdep.c (ft32_gdbarch_init): Likewise.
* m32c-tdep.c (make_types): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
(rl78_psw_type): Update call to arch_flags_type.
* m68k-tdep.c (m68k_ps_type): Update call to arch_flags_type.
* rx-tdep.c (rx_psw_type): Likewise.
(rx_fpsw_type): Likewise.
* sparc-tdep.c (sparc_psr_type): Likewise.
(sparc_fsr_type): Likewise.
* sparc64-tdep.c (sparc64_pstate_type): Likewise.
(sparc64_ccr_type): Likewise.
(sparc64_fsr_type): Likewise.
(sparc64_fprs_type): Likewise.
This also makes delete_command static; but now I wonder if it is used
in Insight and should not be touched.
gdb/ChangeLog
2017-09-27 Tom Tromey <tom@tromey.com>
* breakpoint.h (delete_command): Don't declare.
* breakpoint.c (delete_command, enable_once_command)
(enable_count_command, enable_delete_command, breakpoint_1)
(maintenance_info_breakpoints, stopin_command, stopat_command)
(delete_command, delete_trace_command, save_breakpoints)
(save_breakpoints_command, save_tracepoints_command): Constify.