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.