* gdb.mi/mi-catch-load.c: Remove the include of "dlfcn.h".
[__WIN32__]: Include "windows.h" and define macro 'dlopen'
and 'dlclose'.
[!__WIN32__]: Include "dlfcn.h".
* gdb.mi/mi-catch-load.exp: Set up kfail.
If we are running on a Linux platform we should call linux_init_abi
in order to get all the useful hooks it enables.
gdb/ChangeLog:
2013-10-10 Will Newton <will.newton@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_init_abi): Call
linux_init_abi.
This patch renames the "set/show remotebaud" commands into
"set/show serial baud", and moves its implementation into serial.c.
It also moves the "baud_rate" global from top.c to serial.c, where
the new code is being added (the alternative was to add an include
of target.h).
And to facilitate the transition to the new setting name, this
patch also preserves the old commands, and marks them as deprecated
to alert the users of the change.
gdb/ChangeLog:
* cli/cli-cmds.c (show_baud_rate): Moved to serial.c as
serial_baud_show_cmd.
(_initialize_cli_cmds): Delete the code creating the
"set/show remotebaud" commands.
* serial.c (baud_rate): Move here from top.c.
(serial_baud_show_cmd): Move here from cli/cli-cmds.c.
(_initialize_serial): Create "set/show serial baud" commands.
Add "set/show remotebaud" command aliases.
* top.c (baud_rate): Moved to serial.c.
* NEWS: Document the new "set/show serial baud" commands,
replacing "set/show remotebaud".
gdb/doc/ChangeLog:
* gdb.texinfo: Replace "set remotebaud" and "show remotebaud"
by "set serial baud" and "show serial baud" (resp) throughout.
target_read_memory & friends build on top of target_read (thus on top
of the target_xfer machinery), but turn all errors to EIO, an errno
value. I think we'd better convert all these to return a
target_xfer_error too, like target_xfer_partial in a previous patch.
The patch starts by doing that.
(The patch does not add a enum target_xfer_error value for '0'/no
error, and likewise does not change the return type of several of
these functions to enum target_xfer_error, because different functions
return '0' with different semantics.)
I audited the tree for memory_error calls, EIO checks, places where
GDB hardcodes 'errno = EIO', and also for strerror calls. What I
found is that nowadays there's really no need to handle random errno
values, other than the EIOs gdb itself hardcodes. No doubt errno
values would appear in common code back in the day when
target_xfer_memory was the main interface to access memory, but
nowadays, any errno value that deprecated interface could return is
just absorved by default_xfer_partial:
else if (xfered == 0 && errno == 0)
/* "deprecated_xfer_memory" uses 0, cross checked against
ERRNO as one indication of an error. */
return 0;
else
return -1;
There are two places in the code that check for EIO and print "out of
bounds", and defer to strerror for other errors. That's
c-lang.c:c_get_string, and valprint.c.:val_print_string. AFAICT, the
strerror branch can never be reached nowadays, as the only error
possible to get at those points is EIO, given that it's GDB itself
that set that errno value (in target_read_memory, etc.).
breakpoint.c:insert_bp_location always prints the error val as if an
errno, returned by target_insert_breakpoint, with strerr. Now the
error here is either always EIO for mem-break.c targets (again
hardcoded by the target_read_memory/target_write_memory functions), so
this always prints "Input/output error" or similar (depending on
host), or, for remote targets (and probably others), this gem:
Error accessing memory address 0x80200400: Unknown error -1.
This patch makes these 3 places print the exact same error
memory_error prints. This changes output, but I think this is better,
for making memory error output consistent with other commands, and, it
means we have a central place to tweak for memory errors.
E.g., this changes:
Cannot insert breakpoint 1.
Error accessing memory address 0x5fc660: Input/output error.
to:
Cannot insert breakpoint 1.
Cannot access memory at address 0x5fc660
Which I find pretty much acceptable.
Surprisingly, only py-prettyprint.exp had a regression, for needing an
adjustment. I also grepped the testsuite for the old errors, and
found no other hits.
Now that errno values aren't used anywhere in any of these memory
access related routines, I made memory_error itself take a
target_xfer_error instead of an errno. The new
target_xfer_memory_error function added recently is no longer
necessary, and is thus removed.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2013-10-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location): Use memory_error_message to
build the memory error string.
* c-lang.c: Include "gdbcore.h".
(c_get_string): Use memory_error to throw error.
(target_xfer_memory_error): Delete.
(memory_error_message): New, factored out from
target_xfer_memory_error.
(memory_error): Change parameter type to target_xfer_error.
Rewrite.
(read_memory): Use memory_error instead of
target_xfer_memory_error.
* gdbcore.h: Include "target.h".
(memory_error): Change parameter type to target_xfer_error.
(memory_error_message): Declare function.
* target.c (target_read_memory, target_read_stack)
(target_write_memory, target_write_raw_memory): Return
TARGET_XFER_E_IO on error. Adjust comments.
(get_target_memory): Pass TARGET_XFER_E_IO to memory_error,
instead of EIO.
* target.h (target_read, target_insert_breakpoint)
(target_remove_breakpoint): Adjust comments.
* valprint.c (partial_memory_read): Rename parameter, and adjust
comment.
(val_print_string): Use memory_error_message to build the memory
error string.
gdb/testsuite/
2013-10-09 Pedro Alves <palves@redhat.com>
* gdb.python/py-prettyprint.exp (run_lang_tests): Adjust expected
output.
gdb/
2013-10-09 Jan Kratochvil <jan.kratochvil@redhat.com>
* common/filestuff.c (gdb_fopen_cloexec): Remove initialization of
result variable. Rename variable fopen_e_ever_failed to
fopen_e_ever_failed_einval. Retry fopen only for errno EINVAL.
This removes another yet instance of a deprecated_xfer_memory user.
Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17.
gdb/
2013-10-09 Pedro Alves <palves@redhat.com>
* monitor.c (monitor_write_memory, monitor_write_memory_bytes)
(monitor_write_memory_longlongs, monitor_write_memory_block):
Constify 'myaddr' parameter.
(monitor_xfer_memory): Adjust interface as monitor_xfer_partial
helper.
(monitor_xfer_partial): New function.
(init_base_monitor_ops): Don't install a deprecated_xfer_memory
hook. Install a to_xfer_partial hook.
catch-syscall.exp has a series of duplicated output in gdb.sum. This
patch makes sure all test names are unique, using with_test_prefix.
Tested on x86_64 Fedora 17.
gdb/testsuite/
2013-10-09 Pedro Alves <palves@redhat.com>
* gdb.base/catch-syscall.exp (test_catch_syscall_without_args)
(test_catch_syscall_with_args, test_catch_syscall_with_many_args)
(test_catch_syscall_with_wrong_args)
(test_catch_syscall_restarting_inferior)
(test_catch_syscall_fail_nodatadir)
(test_catch_syscall_without_args_noxml)
(test_catch_syscall_with_args_noxml)
(test_catch_syscall_with_wrong_args_noxml): Use with_test_prefix.
* bfd-in2.h: Rebuild.
* opncls.c (bfd_get_alt_debug_link_info): Change type of
buildid_len to bfd_size_type.
gdb
* dwarf2read.c (dwarf2_get_dwz_file): Update for type change in
bfd_get_alt_debug_link_info.
gdb/
2013-10-09 Jan Kratochvil <jan.kratochvil@redhat.com>
New flag OBJF_NOT_FILENAME.
* auto-load.c (auto_load_objfile_script): Check also OBJF_NOT_FILENAME.
* jit.c (jit_object_close_impl): Use OBJF_NOT_FILENAME for
allocate_objfile.
(jit_bfd_try_read_symtab): Use OBJF_NOT_FILENAME for
symbol_file_add_from_bfd.
* jv-lang.c (get_dynamics_objfile): Use OBJF_NOT_FILENAME for
allocate_objfile.
* objfiles.c (allocate_objfile): Assert OBJF_NOT_FILENAME if NAME is
NULL.
* objfiles.h (OBJF_NOT_FILENAME): New.
This patch fixes gdb PR symtab/15597.
The bug is that the .gnu_debugaltlink section includes the build-id of
the alt file, but gdb does not use it.
This patch fixes the problem by changing gdb to do what it ought to
always have done: verify the build id of the file found using the
filename in .gnu_debugaltlink; and if that does not match, try to find
the correct debug file using the build-id and debug-file-directory.
This patch touches BFD. Previously, gdb had its own code for parsing
.gnu_debugaltlink; I changed it to use the BFD functions after those
were introduced. However, the BFD functions are incorrect -- they
assume that .gnu_debugaltlink is formatted like .gnu_debuglink.
However, it it is not. Instead, it consists of a file name followed
by the build-id -- no alignment, and the build-id is not a CRC.
Fixing this properly is a bit of a pain. But, because
separate_alt_debug_file_exists just has a FIXME for the build-id case,
I did not fix it properly. Instead I introduced a hack. This leaves
BFD working just as well as it did before my patch.
I'm willing to do something better here but I could use some guidance
as to what. It seems that the build-id code in BFD is largely punted
on.
FWIW gdb is the only user of bfd_get_alt_debug_link_info outside of
BFD itself.
I moved the build-id logic out of elfread.c and into a new file.
This seemed cleanest to me.
Writing a test case was a bit of a pain. I added a couple new
features to the DWARF assembler to handle this.
Built and regtested on x86-64 Fedora 18.
* bfd-in2.h: Rebuild.
* opncls.c (bfd_get_alt_debug_link_info): Add buildid_len
parameter. Change type of buildid_out. Update.
(get_alt_debug_link_info_shim): New function.
(bfd_follow_gnu_debuglink): Use it.
* Makefile.in (SFILES): Add build-id.c.
(HFILES_NO_SRCDIR): Add build-id.h.
* build-id.c: New file, largely from elfread.c. Modified
most functions.
* build-id.h: New file.
* dwarf2read.c (dwarf2_get_dwz_file): Update for change to
bfd_get_alt_debug_link_info. Verify dwz file's build-id.
Search for dwz file using build-id.
* elfread.c (build_id_bfd_get, build_id_verify)
(build_id_to_debug_filename, find_separate_debug_file): Remove.
* gdb.dwarf2/dwzbuildid.exp: New file.
* lib/dwarf.exp (Dwarf::_section): Add "flags" and "type"
parameters.
(Dwarf::_defer_output): Change "section" parameter to
"section_spec"; update.
(Dwarf::gnu_debugaltlink, Dwarf::_note, Dwarf::build_id): New
procs.
Upon trying to print the value of a variant record, a user noticed
the following problem:
(gdb) print rt
warning: Unknown upper bound, using 1.
warning: Unknown upper bound, using 1.
$1 = (a => ((a1 => (4), a2 => (4)), (a1 => (8), a2 => (8))))
The expected output is:
(gdb) print rt
$1 = (a => ((a1 => (4, 4), a2 => (8, 8)), (a1 => (4, 4),
a2 => (8, 8))))
The problems comes from the fact that components "a1" and "a2" are
defined as arrays whose upper bound is dynamic. To determine the value
of that upper bound, GDB relies on the GNAT encoding and searches
for the parallel ___U variable. Unfortunately, the search fails
while doing a binary search inside the partial symtab of the unit
where the array and its bound (and therefore the parallel ___U variable)
are defined.
It fails because partial symbols are sorted using strcmp_iw_ordered,
while Ada symbol lookups are performed using a different comparison
function (ada-lang.c:compare_names). The two functions are supposed
to be compatible, but a change performed in April 2011 modified
strcmp_iw_ordered, introducing case-sensitivity issues. As a result,
the two functions would now disagree when passed the following
two arguments:
string1="common__inner_arr___SIZE_A_UNIT"
string2="common__inner_arr__T4s___U"
The difference starts at "_SIZE_A_UNIT" vs "T4s___U". So, it's mostly
a matter of comparing '_' with 'T'.
On the one hand, strcmp_iw_ordered would return -1, while compare_names
returned 11. The change that made all the difference is that
strcmp_iw_ordered now performs a case-insensitive comparison,
and only resorts to case-sentitive comparison if the first comparison
finds an equality. This changes everything, because while 'T' (84)
and 't' (116) are on opposite sides of '_' (95).
This patch aims at restoring the compatibility between the two
functions, by adding case-sensitivity handling in the Ada comparison
function.
gdb/ChangeLog:
* ada-lang.c (compare_names_with_case): Renamed from
compare_names, adding a new parameter "casing" and its handling.
New function documentation.
(compare_names): New function, implemented using
compare_names_with_case.
This moves the demangled_names_hash from the objfile into the per-BFD
object. This is part of the objfile splitting project.
The demangled names hash is independent of the program space. And, it
is needed by the symbol tables. Both of these things indicate that it
must be pushed into the per-BFD object, which this patch does.
Built and regtested on x86-64 Fedora 18.
* objfiles.c (free_objfile_per_bfd_storage): Delete the
demangled_names_hash.
(free_objfile): Don't delete the demangled_names_hash.
* objfiles.h (struct objfile_per_bfd_storage)
<demangled_names_hash>: New field.
(struct objfile) <demangled_names_hash>: Move to
objfile_per_bfd_storage.
* symfile.c (reread_symbols): Don't delete the
demangled_names_hash.
* symtab.c (create_demangled_names_hash): Update.
(symbol_set_names): Update.
Right now we always share per-BFD data across objfiles, if there is a
BFD. This works fine. However, we're going to start sharing more
data, and sometimes this data will come directly from sections of the
BFD. If such a section has SEC_RELOC set, then the data coming from
that section will not be truly sharable -- the section will be
program-space-dependent, and re-read by gdb for each objfile.
This patch disallows per-BFD sharing in this case. This is a bit
"heavy" in that we could in theory examine each bit of shared data for
suitability. However, that is more complicated, and SEC_RELOC is rare
enough that I think we needn't bother.
Note that the "no sharing" case is equivalent to "gdb works as it
historically did". That is, the sharing is a new(-ish) optimization.
Built and regtested on x86-64 Fedora 18.
* gdb_bfd.c (struct gdb_bfd_data) <relocation_computed,
needs_relocations>: New fields.
(gdb_bfd_requires_relocations): New function.
* gdb_bfd.h (gdb_bfd_requires_relocations): Declare.
* objfiles.c (get_objfile_bfd_data): Disallow sharing if
the BFD needs relocations applied.
We recently made GDB auto-delete thread-specific breakpoints when the
corresponding thread is removed from the thread list, but we hadn't
mentioned it in the manual.
gdb/
2013-10-07 Pedro Alves <palves@redhat.com>
PR breakpoints/11568
* gdb.texinfo (Thread-Specific Breakpoints): Mention what happens
when the thread is removed from the thread list.
It seems "gone" may confuse people, while that was exactly what it was
trying to avoid. Switch to saying "no longer in the thread list",
which is really the predicate GDB uses.
gdb/
2013-10-07 Pedro Alves <palves@redhat.com>
PR breakpoints/11568
* breakpoint.c (remove_threaded_breakpoints): Say "no longer in
the thread list" instead of "gone".
will hold the signal number when the inferior terminates due to the
uncaught signal.
I've made modifications on infrun.c:handle_inferior_event such that
$_exitcode gets cleared when the inferior signalled, and vice-versa.
This assumption was made because the variables are mutually
exclusive, i.e., when the inferior terminates because of an uncaught
signal it is not possible for it to return. I have also made modifications
such that when a corefile is loaded, $_exitsignal gets set to the uncaught
signal that "killed" the inferior, and $_exitcode is cleared.
The patch also adds a NEWS entry, documentation bits, and a testcase. The
documentation entry explains how to use $_exitsignal and $_exitcode in a
GDB script, by making use of the new $_isvoid convenience function.
gdb/
2013-10-06 Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS: Mention new convenience variable $_exitsignal.
* corelow.c (core_open): Reset exit convenience variables. Set
$_exitsignal to the uncaught signal which generated the corefile.
* infrun.c (handle_inferior_event): Reset exit convenience
variables. Set $_exitsignal for TARGET_WAITKIND_SIGNALLED.
(clear_exit_convenience_vars): New function.
* inferior.h (clear_exit_convenience_vars): New prototype.
gdb/testsuite/
2013-10-06 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/corefile.exp: Test whether $_exitsignal is set and
$_exitcode is void when opening a corefile.
* gdb.base/exitsignal.exp: New file.
* gdb.base/segv.c: Likewise.
* gdb.base/normal.c: Likewise.
gdb/doc/
2013-10-06 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (Convenience Variables): Document $_exitsignal.
Update entry for $_exitcode.
* NEWS: Mention support for DWP file format version 2.
* dwarf2read.c (dwarf2_section_info): Convert asection field to a
union of asection, containing_section. New fields virtual_offset
and is_virtual. Change type of readin filed from int to char.
(dwo_sections, dwo_file): Tweak comments.
(dwp_v2_section_ids): New enum.
(dwp_sections): New fields abbrev, info, line, loc, macinfo, macro,
str_offsets, types.
(virtual_v1_dwo_sections): Renamed from virtual_dwo_sections.
All uses updated.
(virtual_v2_dwo_sections): New struct.
(dwp_hash_table): New fields version, nr_columns. Change type of
section_pool field to a union.
(dwp_file): New field version.
(dwarf2_has_info): Check for virtual sections.
(get_containing_section): New function.
(get_section_bfd_owner, get_section_bfd_section): Call it.
(dwarf2_locate_sections): Update.
(dwarf2_section_empty_p): Update.
(dwarf2_read_section): Handle virtual sections.
(locate_dwz_sections): Update.
(create_dwp_hash_table): Document and handle V2 format.
(locate_v1_virtual_dwo_sections): Renamed from
locate_virtual_dwo_sections and update. All callers updated.
(create_dwo_unit_in_dwp_v1): Renamed from create_dwo_in_dwp.
Delete arg htab. Rename arg section_index to unit_index.
All callers updated.
(MAX_NR_V1_DWO_SECTIONS): Renamed from MAX_NR_DWO_SECTIONS.
All uses updated.
(create_dwp_v2_section, create_dwo_unit_in_dwp_v2): New functions.
(lookup_dwo_unit_in_dwp): Add V2 support.
(dwarf2_locate_dwo_sections): Update.
(dwarf2_locate_common_dwp_sections): Renamed from
dwarf2_locate_dwp_sections and update. All callers updated.
(dwarf2_locate_v2_dwp_sections): New function.
(open_and_init_dwp_file): Add V2 support.
(read_str_index): New locals str_section, str_offsets_section.
The ptid_t contructors, accessors and predicates are documented in
_three_ places, and each place uses a different wording.
E.g, the descriptions in the .c file of the new ptid_lwp_p, ptid_tid_p
weren't updated in the final revision like the descriptions in the .h
file were. Clearly, switching to a style that has a single central
description avoids such issues.
Worse, some of the existing descriptions are plain wrong, such as:
/* Attempt to find and return an existing ptid with the given PID, LWP,
and TID components. If none exists, create a new one and return
that. */
ptid_t ptid_build (int pid, long lwp, long tid);
The function does nothing that complicated. It's just a simple
constructor.
So this gets rid of all the unnecessary descriptions, leaving only the
ones near the function declarations in the header file, and
fixes/clarifies those that remain.
gdb/
2013-10-04 Pedro Alves <palves@redhat.com>
* common/ptid.c (null_ptid, minus_one_ptid, ptid_build)
(pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid)
(ptid_equal, ptid_is_pid, ptid_lwp_p, ptid_tid_p): Replace
describing comments with references to ptid.h.
* common/ptid.h: Remove intro description of constructors,
accessors and predicates.
(struct ptid): Reformat.
(minus_one_ptid, ptid_build, pid_to_ptid, ptid_get_pid)
(ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid): Change
describing comments.
This patch fixes a small typo after the BUILD_THREAD -> ptid_build
conversion.
gdb/ChangeLog:
* aix-thread.c (sync_threadlists): Add missing ')' in call
to ptid_build.
We're casting "addr" into "addr_ptr", but this variable is actually
a parameter with that very same type...
gdb/ChangeLog:
* aix-thread.c (ptrace32): Remove cast to addr_ptr.
gdb/ChangeLog:
* mi/mi-main.c (run_one_inferior): Add function description.
Make ARG a pointer to an integer whose value determines whether
we should "run" or "start" the program.
(mi_cmd_exec_run): Add handling of the "--start" option.
Reject all other command-line options.
* NEWS: Add entry for "-exec-run"'s new "--start" option.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI Program Execution): Document "-exec-run"'s
new "--start" option.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-start.c, gdb.mi/mi-start.exp: New files.
This patch moves pending_event to remote_notif_state. All pending
events are destroyed in remote_notif_state_xfree. However,
discard_pending_stop_replies release pending event too, so the pending
event of stop notification is released twice, we need some refactor
here. We add a new function discard_pending_stop_replies_in_queue
which only discard events in stop_reply_queue, and let
remote_notif_state_xfree release pending event for all notif_client.
After this change, discard_pending_stop_replies is only attached to
ifnerior_exit observer, so the INF can't be NULL any more. The
NULL checking is removed too.
gdb:
2013-10-04 Yao Qi <yao@codesourcery.com>
* remote-notif.h (REMOTE_NOTIF_ID): New enum.
(struct notif_client) <pending_event>: Moved
to struct remote_notif_state.
<id>: New field.
(struct remote_notif_state) <pending_event>: New field.
(notif_event_xfree): Declare.
* remote-notif.c (handle_notification): Adjust.
(notif_event_xfree): New function.
(do_notif_event_xfree): Call notif_event_xfree.
(remote_notif_state_xfree): Call notif_event_xfree to free
each element in field pending_event.
* remote.c (discard_pending_stop_replies): Remove declaration.
(discard_pending_stop_replies_in_queue): Declare.
(remote_close): Call discard_pending_stop_replies_in_queue
instead of discard_pending_stop_replies.
(remote_start_remote): Adjust.
(stop_reply_xfree): Call notif_event_xfree.
(notif_client_stop): Adjust initialization.
(remote_notif_remove_all): Rename it to ...
(remove_stop_reply_for_inferior): ... this. Update comments.
Don't check INF is NULL.
(discard_pending_stop_replies): Return early if notif_state is
NULL. Adjust. Don't check INF is NULL.
(remote_notif_get_pending_events): Adjust.
(discard_pending_stop_replies_in_queue): New function.
(remote_wait_ns): Likewise.
Hi,
This FIXME goes into my eyes, when I am about to modify something here,
/* Name is allocated by name_of_child. */
/* FIXME: xstrdup should not be here. */
This FIXME was introduced in the python pretty-pretter patches.
Python pretty-printing [6/6]
https://sourceware.org/ml/gdb-patches/2009-05/msg00467.html
create_child_with_value is called in two paths,
1. varobj_list_children -> create_child -> create_child_with_value,
2. install_dynamic_child -> install_dynamic_child -> varobj_add_child
-> create_child_with_value
In path #1, 'name' is allocated by name_of_child, as the original
comment said, we don't have to duplicate NAME in
create_child_with_value. In path #2, 'name' is got from
PyArg_ParseTuple, and we have to duplicate NAME.
This patch removes the call to xstrdup in create_child_with_value
and call xstrudp in update_dynamic_varobj_children (path #2).
gdb:
2013-10-04 Yao Qi <yao@codesourcery.com>
* varobj.c (create_child_with_value): Remove 'const' from the
type of parameter 'name'.
(varobj_add_child): Likewise.
(install_dynamic_child): Remove 'const' from the type of
parameter 'name'.
(varobj_add_child): Likewise.
(create_child_with_value): Likewise. Update comments. Don't
duplicate 'name'.
(update_dynamic_varobj_children): Duplicate 'name'
and pass it to install_dynamic_child.
* python/py-value.c (convert_value_from_python): Move PyInt_Check
conversion logic to occur after PyLong_Check. Comment on order
change significance.
* python/py-arch.c (archpy_disassemble): Comment on order of
conversion for integers and longs.
If enabling PTRACE_O_TRACEFORK fails, we never test for
PTRACE_O_TRACESYSGOOD support. Before PTRACE_O_TRACESYSGOOD is checked,
we have:
/* First, set the PTRACE_O_TRACEFORK option. If this fails, we
know for sure that it is not supported. */
ret = ptrace (PTRACE_SETOPTIONS, child_pid, (PTRACE_TYPE_ARG3) 0,
(PTRACE_TYPE_ARG4) PTRACE_O_TRACEFORK);
if (ret != 0)
{
ret = ptrace (PTRACE_KILL, child_pid, (PTRACE_TYPE_ARG3) 0,
(PTRACE_TYPE_ARG4) 0);
if (ret != 0)
{
warning (_("linux_check_ptrace_features: failed to kill child"));
return;
}
ret = my_waitpid (child_pid, &status, 0);
if (ret != child_pid)
warning (_("linux_check_ptrace_features: failed "
"to wait for killed child"));
else if (!WIFSIGNALED (status))
warning (_("linux_check_ptrace_features: unexpected "
"wait status 0x%x from killed child"), status);
return; <<<<<<<<<<<<<<<<<
}
Note that early return. If PTRACE_O_TRACEFORK isn't supported, we're
not checking PTRACE_O_TRACESYSGOOD. This didn't use to be a problem
before the unification of this whole detection business in
linux-ptrace.c. Before, the sysgood detection was completely
separate:
static void
linux_test_for_tracesysgood (int original_pid)
{
int ret;
sigset_t prev_mask;
/* We don't want those ptrace calls to be interrupted. */
block_child_signals (&prev_mask);
linux_supports_tracesysgood_flag = 0;
ret = ptrace (PTRACE_SETOPTIONS, original_pid, 0, PTRACE_O_TRACESYSGOOD);
if (ret != 0)
goto out;
linux_supports_tracesysgood_flag = 1;
out:
restore_child_signals_mask (&prev_mask);
}
So we need to get back the decoupling somehow. I think it's cleaner
to split the seperate feature detections to separate functions. This
patch does that. The new functions are named for their counterparts
that existed before this code was moved to linux-ptrace.c.
Note I've used forward declarations for the new functions to make the
patch clearer, as otherwise the patch would look like I'd be adding a
bunch of new code. A reorder can be done in a follow up patch.
Tested on x86_64 Fedora 17.
gdb/
2013-10-03 Pedro Alves <palves@redhat.com>
* common/linux-ptrace.c (linux_check_ptrace_features): Factor out
the PTRACE_O_TRACESYSGOOD and PTRACE_O_TRACEFORK to separate
functions. Always test for PTRACE_O_TRACESYSGOOD even if
PTRACE_O_TRACEFORK is not supported.
(linux_test_for_tracesysgood): New function.
(linux_test_for_tracefork): New function, factored out from
linux_check_ptrace_features, and also don't kill child_pid here.
Currently, in some scenarios, GDB prints <optimized out> when printing
outer frame registers. An <optimized out> register is a confusing
concept. What this really means is that the register is
call-clobbered, or IOW, not saved by the callee. This patch makes GDB
say that instead.
Before patch:
(gdb) p/x $rax $1 = <optimized out>
(gdb) info registers rax
rax <optimized out>
After patch:
(gdb) p/x $rax
$1 = <not saved>
(gdb) info registers rax
rax <not saved>
However, if for some reason the debug info describes a variable as
being in such a register (**), we still want to print <optimized out>
when printing the variable. IOW, <not saved> is reserved for
inspecting registers at the machine level. The patch uses
lval_register+optimized_out to encode the not saved registers, and
makes it so that optimized out variables always end up in
!lval_register values.
** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>.
Current/recent enough GCC doesn't mark variables/arguments as being in
call-clobbered registers in the ranges corresponding to function
calls, while older GCCs did. Newer GCCs will just not say where the
variable is, so GDB will end up realizing the variable is optimized
out.
frame_unwind_got_optimized creates not_lval optimized out registers,
so by default, in most cases, we'll see <optimized out>.
value_of_register is the function eval.c uses for evaluating
OP_REGISTER (again, $pc, etc.), and related bits. It isn't used for
anything else. This function makes sure to return lval_register
values. The patch makes "info registers" and the MI equivalent use it
too. I think it just makes a lot of sense, as this makes it so that
when printing machine registers ($pc, etc.), we go through a central
function.
We're likely to need a different encoding at some point, if/when we
support partially saved registers. Even then, I think
value_of_register will still be the spot to tag the intention to print
machine register values differently.
value_from_register however may also return optimized out
lval_register values, so at a couple places where we're computing a
variable's location from a dwarf expression, we convert the resulting
value away from lval_register to a regular optimized out value.
Tested on x86_64 Fedora 17
gdb/
2013-10-02 Pedro Alves <palves@redhat.com>
* cp-valprint.c (cp_print_value_fields): Adjust calls to
val_print_optimized_out.
* jv-valprint.c (java_print_value_fields): Likewise.
* p-valprint.c (pascal_object_print_value_fields): Likewise.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
<DWARF_VALUE_REGISTER>: If the register was not saved, return a
new optimized out value.
* findvar.c (address_from_register): Likewise.
* frame.c (put_frame_register): Tweak error string to say the
register was not saved, rather than optimized out.
* infcmd.c (default_print_one_register_info): Adjust call to
val_print_optimized_out. Use value_of_register instead of
get_frame_register_value.
* mi/mi-main.c (output_register): Use value_of_register instead of
get_frame_register_value.
* valprint.c (valprint_check_validity): Likewise.
(val_print_optimized_out): New value parameter. If the value is
lval_register, print <not saved> instead.
(value_check_printable, val_print_scalar_formatted): Adjust calls
to val_print_optimized_out.
* valprint.h (val_print_optimized_out): New value parameter.
* value.c (struct value) <optimized_out>: Extend comment.
(error_value_optimized_out): New function.
(require_not_optimized_out): Use it. Use a different string for
lval_register values.
* value.h (error_value_optimized_out): New declaration.
* NEWS: Mention <not saved>.
gdb/testsuite/
2013-10-02 Pedro Alves <palves@redhat.com>
* gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print,
pattern_rax_rbx_rcx_info>: Set to "<not saved>".
* gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete.
(not_saved_pattern): New.
Replace use of the former with the latter.
gdb/doc/
2013-10-02 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Registers): Expand description of saved registers
in frames. Explain <not saved>.
Running catch-syscall.exp against a gdbserver that actually supports
it, we get:
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit at catch syscall with unused syscall (mlock) (the program exited)
FAIL: gdb.base/catch-syscall.exp: continue until exit (the program exited)
The fail pattern is:
Catchpoint 2 (call to syscall exit_group), 0x000000323d4baa29 in _exit () from /lib64/libc.so.6
(gdb) PASS: gdb.base/catch-syscall.exp: program has called exit_group
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break exit
Breakpoint 3 at 0x323d438bf0
(gdb) continue
Continuing.
[Inferior 1 (process 21081) exited normally]
That "break exit" + "continue" comes from:
> # gdb_continue_to_end:
> # The case where the target uses stubs has to be handled specially. If a
> # stub is used, we set a breakpoint at exit because we cannot rely on
> # exit() behavior of a remote target.
> #
The native-gdbserver.exp board, used to test against gdbserver in
"target remote" mode, triggers that case ($use_gdb_stub is true). So
gdb_continue_to_end doesn't work for catch-syscall.exp as here we
catch the exit_group and continue from that, expecting to see a real
program exit. I was about to post a patch that changes
catch-syscall.exp to call a new function that just always does what
gdb_continue_to_end does in the !$use_gdb_stub case. But, since
GDBserver doesn't really need this, in the end I thought it better to
teach the testsuite that there are stubs that know how to report
program exits, by adding a new "exit_is_reliable" board variable that
then gdb_continue_to_end checks.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/testsuite/
2013-10-02 Pedro Alves <palves@redhat.com>
* README (Board Settings): Document "exit_is_reliable".
* lib/gdb.exp (gdb_continue_to_end): Check whether the board says
running to exit reliably reports program exits.
* boards/native-gdbserver.exp: Set exit_is_reliable in the board
info.
* boards/native-stdio-gdbserver.exp: Likewise.
If we make gdbserver gdb_continue_to_end actually expect a process
exit with GDBserver, we get many testsuite failures with the remote
stdio board:
-PASS: gdb.arch/amd64-disp-step.exp: continue until exit at amd64-disp-step
+FAIL: gdb.arch/amd64-disp-step.exp: continue until exit at amd64-disp-step (the program exited)
-PASS: gdb.base/break.exp: continue until exit at recursive next test
+FAIL: gdb.base/break.exp: continue until exit at recursive next test (the program exited)
-PASS: gdb.base/chng-syms.exp: continue until exit at breakpoint first time through
+FAIL: gdb.base/chng-syms.exp: continue until exit at breakpoint first time through (the program exited)
... etc. ...
This is what the log shows for all of them:
(gdb) continue
Continuing.
Child exited with status 0
GDBserver exiting
[Inferior 1 (process 22721) exited normally]
(gdb) FAIL: gdb.arch/amd64-disp-step.exp: continue until exit (the program exited)
The problem is the whole "Child exited ... GDBserver exiting" output,
that comes out of GDBserver, and that the testsuite is not expecting.
I pondered somehow making the testsuite adjust to this. But,
testsuite aside, I think GDBserver should not be outputting this at
all when GDB is connected through stdio. GDBserver will be printing
this in GDB's console, but the user can already tell from the regular
output that the inferior is gone.
Again, manually:
(gdb) tar remote | ./gdbserver/gdbserver - program
Remote debugging using | ./gdbserver/gdbserver - program
Process program created; pid = 22486
stdin/stdout redirected
Remote debugging using stdio
done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x000000323d001530 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) c
Continuing.
Child exited with status 1
^^^^^^^^^^^^^^^^^^^^^^^^^^
GDBserver exiting
^^^^^^^^^^^^^^^^^
[Inferior 1 (process 22486) exited with code 01]
(gdb)
Suppressing those two lines makes the output be exactly like when
debugging against a remote tcp gdbserver:
(gdb) c
Continuing.
[Inferior 1 (process 22914) exited with code 01]
(gdb)
2013-10-02 Pedro Alves <palves@redhat.com>
* server.c (process_serial_event): Don't output "GDBserver
exiting" if GDB is connected through stdio.
* target.c (mywait): Likewise, be silent if GDB is connected
through stdio.
This avoids duplicating the logic comparing two symbol_search
objects (in search_symbols_equal and compare_search_syms).
gdb/ChangeLog:
* symtab.c (search_symbols_equal): Delete.
(sort_search_symbols_remove_dups): Replace call to
search_symbols_equal by call to compare_search_syms,
adjusting as necessary.
* arm-wince-tdep.c: Remove inclusion of "solib.h" and
"solib-target.h". Include "windows-tdep.h".
(arm_wince_init_abi): Call windows_init_abi. Remove call to
set_solib_ops and set_gdbarch_has_dos_based_file_system.
* configure.tgt (arm*-wince-pe | arm*-*-mingw32ce*): Append
windows-tdep.o to gdb_target_obs.
* amd64-windows-tdep.c: Remove inclusion of "solib.h" and
"solib-target.h".
(amd64_windows_init_abi): Don't call set_solib_ops and
set_gdbarch_iterate_over_objfiles_in_search_order. Call
windows_init_abi instead.
* i386-cygwin-tdep.c: Remove inclusion of "solib.h" and
"solib-target.h".
(i386_cygwin_init_abi): Don't call set_solib_ops,
set_gdbarch_has_dos_based_file_system and
set_gdbarch_iterate_over_objfiles_in_search_order. Call
windows_init_abi instead.
* windows-tdep.c: Include "solib.h" and "solib-target.h".
(windows_init_abi): New function.
(windows_iterate_over_objfiles_in_search_order): Make it
static.
* windows-tdep.h (windows_init_abi): Declare.
(windows_iterate_over_objfiles_in_search_order): Remove
declaration.
The current implementation is forgetting to populate the thread list
when attaching to the process. This results in an incomplete list of
threads when debugging a threaded program.
Unfortunately, as the added comments hints, there appears to be
no way of getting the list of threads via ptrace, other than by
spawning the "ps" command, and parsing its output. Not great,
but it appears to be the best we can do.
gdb/gdbserver/ChangeLog:
* lynx-low.c (lynx_add_threads_after_attach): New function.
(lynx_attach): Remove call to add_thread. Add call to
lynx_add_threads_after_attach instead.
So far elinos.py was assuming that the whole ELinOS environment was
around to find the system libraries; if some environment variables
were missing, the script would just abort.
This was a bit extreme. It is possible to do better than that: to get
the core system libraries, one doesn't need to have a full environment
but just the path to the CDK. The path to kernel project is only
needed for the optional Xenomai libs.
gdb/ChangeLog:
* system-gdbinit/elinos.py (get_elinos_environment): Return an
incomplete dictionnary instead of None in case of missing
environment variables.
(elinos_init): in case of an incomplete environment, best
effort to load system libraries instead of abort.
When building the program with the shared GNAT runtime, the debugger
is unable to insert Ada exception catchpoints until that runtime
has been mapped to memory. In other words, we expect the user to start
the program first, before attempting to insert that catchpoint.
The detection mechanism that tries to provide some useful tips to
the user fails when the program itself contains a trampoline symbol
matching the symbol that the catchpoint is trying to use. This
results in the following error message:
(gdb) catch exception
Your Ada runtime appears to be missing some debugging information.
Cannot insert Ada exception catchpoint in this configuration.
Instead, we expected the following error message:
(gdb) catch exception
Unable to insert catchpoint. Try to start the program first.
gdb/ChangeLog:
* ada-lang.c (ada_has_this_exception_support): Ignore
mst_solib_trampoline minimal symbols.
* i386-darwin-nat.c (darwin_complete_target): Install methods for
hardware watchpoint.
(i386_darwin_dr_set): Support 32 and 64 bit states.
(i386_darwin_dr_get): Likewise.
(i386_darwin_dr_set_control): Make static.
(i386_darwin_dr_set_addr, i386_darwin_dr_get_addr)
(i386_darwin_dr_get_status, i386_darwin_dr_get_control): Likewise.
It is possible to have a build of glibc where SYS_perf_event_open is not
defined (because when the glibc was compiled, the syscall did not exist),
but have newer kernel headers installed so that linux/perf_event.h is
available. In this setup, you get a build failure:
./common/linux-btrace.c: In function 'kernel_supports_btrace':
./common/linux-btrace.c:316:23: error: 'SYS_perf_event_open' undeclared (first use in this function)
Update the ifdef check to also see if the syscall is available.
URL: https://bugs.gentoo.org/473522
Reported-by: William Throwe <wtt6@cornell.edu>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
(dwp_file): Split loaded_cutus into loaded_cus, loaded_tus.
All uses updated.
(dwarf2_section_empty_p): Rename arg from "info" to "section".
(dwarf2_read_section): Delete unused local "header". Add section
name to error message.
(create_dwo_in_dwp): Tweak comment.
(MAX_NR_DWO_SECTIONS): Combine count of .debug_macro + .debug_macinfo.
(get_section_bfd_owner, get_section_bfd_section): New functions.
(get_section_name, get_section_file_name): New functions.
(get_section_id, get_section_flags): New functions.
(*): Use new functions to access section fields.
(lookup_dwo_unit_in_dwp): Renamed from lookup_dwo_in_dwp. Remove
arg "htab". All callers updated.
(create_debug_types_hash_table): Remove redundant copy of
abbrev_section.
(create_dwo_in_dwp): Tweak comments.
(read_str_index): Tweak comment. Record dwarf form name in static
local.
I tried debugging a remote Windows program on Linux host, and pointed the
sysroot to "/some/path/" rather than "remote:", and I found GDB couldn't
find the dlls in the sysroot. If the dll name is
"C:/Windows/system32/ntdll.dll", I end up with the sysroot+in_pathname
concatenated this way:
(top-gdb) p temp_pathname
$1 = 0x228b690 "/some/pathC:/Windows/system32/ntdll.dll"
^^
That is, a directory separator is missing. This is a regression.
The problem is that solib_find decides that since the target path has
a drive spec, a separator is not necessary, which is clearly wrong in
this case. That check was added in
<https://sourceware.org/ml/gdb-patches/2013-06/msg00028.html>, to
handle the case of sysroot being "remote:". This patch fixes that
original issue in a different way. Instead of checking whether the
path has a drive spec, check whether the sysroot is "remote:". The
patch adds a table that helps visualize the cases that need a
separator. I also confirmed the original issue is still handled as
expected. That is, that "set sysroot remote:" still does the right
thing.
remote_filename_p returns true if the filename is prefixed with
"remote:". In this case, we need to check whether the filename is
exactly "remote:". I thought of different ways or either changing
remote_filename_p or adding another convenience function to remote.c
to avoid exposing the "remote:" prefix out of remote.c. But all
attempts turned out adding lot of over needless complication. So the
patch just exposes the prefix behind a new macro, which allows using a
straighforward strcmp.
gdb/
2013-09-27 Pedro Alves <palves@redhat.com>
* remote.h (REMOTE_SYSROOT_PREFIX): New define.
(remote_filename_p): Add comment.
* remote.c (remote_filename_p): Adjust to use
REMOTE_SYSROOT_PREFIX.
* solib.c (solib_find): When deciding whether we need to add a
directory separator, check whether the sysroot is "remote:"
instead of checking whether the patch has a drive spec. Add
comments.
I noticed these fields aren't really necessary -- if the T stop reply
indicated any we have any special event, the fallthrough doesn't
really do anything.
Tested on x86_64 Fedora 17 w/ local gdbserver, and also confirmed
"catch load" against a Windows gdbserver running under Wine, which
exercises TARGET_WAITKIND_LOADED, still works as expected.
gdb/
2013-09-27 Pedro Alves <palves@redhat.com>
* remote.c (struct stop_reply) <solibs_changed, replay_event>:
Delete fields.
(remote_parse_stop_reply): Adjust, setting event->ws.kind
directly.
AMD64_R15_REGNUM when a register index is expected.
* amd64-windows-tdep.c (amd64_windows_dummy_call_integer_regs):
Substitute in array.
* amd64-tdep.c (amd64_dwarf_regmap): Ditto.
(amd64_push_arguments): Substitute in integer_regnum array.
* NEWS: Mention "set debug symfile".
* Makefile.in (SFILES): Add symfile-debug.c.
(COMMON_OBS): Add symfile-debug.o.
* elfread.c (elf_symfile_read): Use objfile_set_sym_fns to set the
objfile's symbol functions.
* objfiles.h (objfile_set_sym_fns): Declare.
* symfile-debug.c: New file.
* symfile.c (syms_from_objfile_1): Use objfile_set_sym_fns to set the
objfile's symbol functions.
(reread_symbols): Ditto.
All uses updated.
(add_symtab_fns): Update prototype.
* symfile.c (sym_fns_ptr): Delete. Replace with ...
(registered_sym_fns): ... this.
(symtab_fns): Update.
(add_symtab_fns): New arg "flavour". All callers updated.
(find_sym_fns): Rewrite to use new sym_fns registry.
2013-09-25 Andreas Arnez <arnez@linux.vnet.ibm.com>
PR shlibs/8882
* solib-svr4.c (svr4_read_so_list): Skip the vDSO when reading
link map entries.
testsuite/ChangeLog:
2013-09-25 Andreas Arnez <arnez@linux.vnet.ibm.com>
PR shlibs/8882
* gdb.base/corefile.exp: Add a check to assure warning-free
core-file load.
This is no longer useful, as it was introduced to reuse the funcall
handling code in amd64-tdep.c in the context of x64-windows. But
we have since then changed the implementations to be completely
independent of each other.
This reverts the non-windows-specific part of the change called:
amd64: Integer parameters in function calls on Windows
(the x64-windows portion has already been reverted)
gdb/ChangeLog:
Revert:
* i386-tdep.h (enum amd64_reg_class): New, moved here from
amd64-tdep.c.
(struct gdbarch_tdep): Add fields call_dummy_num_integer_regs,
call_dummy_integer_regs, and classify.
* amd64-tdep.h (amd64_classify): Add declaration.
* amd64-tdep.c (amd64_dummy_call_integer_regs): New static constant.
(amd64_reg_class): Delete, moved to i386-tdep.h.
(amd64_classify): Make non-static. Move declaration to amd64-tdep.h.
Replace call to amd64_classify by call to tdep->classify.
(amd64_push_arguments): Get the list of registers to use for
passing integer parameters from the gdbarch tdep structure,
rather than using a hardcoded one. Replace calls to amd64_classify
by calls to tdep->classify.
(amd64_push_dummy_call): Get the register number used for
the "hidden" argument from tdep->call_dummy_integer_regs.
(amd64_init_abi): Initialize tdep->call_dummy_num_integer_regs
and tdep->call_dummy_integer_regs. Set tdep->classify.
This is no longer useful, as it was introduced to reuse the funcall
handling code in amd64-tdep.c in the context of x64-windows. But
we have since then changed the implementations to be completely
independent of each other.
This reverts the non-windows-specific part of the change called:
amd64-windows: memory args passed by pointer during function calls.
(the x64-windows portion has already been reverted)
gdb/ChangeLog:
Revert:
* i386-tdep.h (gdbarch_tdep): Add field memory_args_by_pointer.
* amd64-tdep.c (amd64_push_arguments): Add handling of architectures
where tdep->memory_args_by_pointer is non-zero.
This is no longer useful, as it was introduced to reuse the funcall
handling code in amd64-tdep.c in the context of x64-windows. But
we have since then changed the implementations to be completely
independent of each other.
This reverts the non-windows-specific part of the change called:
amd64-windows: 32 bytes allocated on stack by caller for integer
parameter regs
(the x64-windows portion has already been reverted)
gdb/ChangeLog:
Revert:
* i386-tdep.h (struct gdbarch_tdep): Add new field
integer_param_regs_saved_in_caller_frame.
* amd64-tdep.c (amd64_push_dummy_call): Allocate some memory on
stack if tdep->integer_param_regs_saved_in_caller_frame is set.
This patch provides a standalone implementation of function calls
on amd64-windows, instead of providing some bits and pieces hooking
into the function call implementation meant for sysV (in amd64-tdep).
It makes better sense to do it this way, because the two ABIs are
actually very different; for instance, the concept of argument
classification, which is so central in the sysV ABI and drove the
the implementation in amd64-tdep, makes no sense for Windows. It
is therefore better for the Windows implementation to be completely
separate, rather than rely on adaptations of the sysV implementation.
gdb/ChangeLog:
* amd64-tdep.c: #include "value.h"
(amd64_windows_classify): Delete.
(amd64_windows_passed_by_integer_register)
(amd64_windows_passed_by_xmm_register)
(amd64_windows_passed_by_pointer)
(amd64_windows_adjust_args_passed_by_pointer)
(amd64_windows_store_arg_in_reg, amd64_windows_push_arguments)
(amd64_windows_push_dummy_call): New functions.
(amd64_windows_init_abi): Remove setting of
tdep->call_dummy_num_integer_regs, tdep->call_dummy_integer_regs,
tdep->classify, tdep->memory_args_by_pointer and
tdep->integer_param_regs_saved_in_caller_frame.
Add call to set_gdbarch_push_dummy_call.
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (open_and_init_dwp_file): Try open_dwp_file also with
objfile->original_name.
gdb/testsuite/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.dwarf2/dwp-symlink.c: New file.
* gdb.dwarf2/dwp-symlink.exp: New file.
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Pass down original filename for objfile.
* coffread.c (coff_symfile_read): Update symbol_file_add_separate call.
* elfread.c (elf_symfile_read): Likewise.
* jit.c (jit_object_close_impl): Update allocate_objfile call, no
longer set ORIGINAL_NAME.
(jit_bfd_try_read_symtab): Update symbol_file_add_from_bfd call.
* jv-lang.c (get_dynamics_objfile): Update allocate_objfile call.
* machoread.c (macho_add_oso_symfile): Add parameter name. Update
symbol_file_add_from_bfd call.
(macho_symfile_read_all_oso): Update two macho_add_oso_symfile calls.
(macho_check_dsym): Add parameter filenamep. Change function comment.
Set *filenamep.
(macho_symfile_read): New variable dsym_filename. Update
macho_check_dsym call. Use it for symbol_file_add_separate.
* objfiles.c (allocate_objfile): Add parameter name. New comment for
it. Use it for objfile->original_name.
(objfile_name): Return OBFD's filename, if available.
* objfiles.h (allocate_objfile): Add new parameter name.
* solib.c (solib_read_symbols): Update symbol_file_add_from_bfd call.
* symfile-mem.c (symbol_file_add_from_memory): Update
symbol_file_add_from_bfd call.
* symfile.c (read_symbols): Update symbol_file_add_separate call, new
comment for it.
(symbol_file_add_with_addrs): New parameter name, add function comment
for it. Remove variable name. Update allocate_objfile call.
(symbol_file_add_separate): New parameter name, add function comment
for it. Update symbol_file_add_with_addrs call.
(symbol_file_add_from_bfd): New parameter name. Update
symbol_file_add_with_addrs call.
(symbol_file_add): Update symbol_file_add_from_bfd call.
(reread_symbols): New variable original_name. Save
objfile->original_name by it.
* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
second parameter.
The recent change to make GDB auto-delete thread-specific breakpoints
when the corresponding thread is deleted
(https://sourceware.org/ml/gdb-patches/2013-09/msg00038.html) caused
gdb.base/nextoverexit.exp to regress.
Breakpoint 1, main () at .../gdb/testsuite/gdb.base/nextoverexit.c:21
21 exit (0);
(gdb) next
[Inferior 1 (process 25208) exited normally]
Thread-specific breakpoint -5 deleted - thread 1 is gone.
Thread-specific breakpoint -6 deleted - thread 1 is gone.
Thread-specific breakpoint -7 deleted - thread 1 is gone.
Thread-specific breakpoint 0 deleted - thread 1 is gone.
(gdb) FAIL: gdb.base/nextoverexit.exp: next over exit (the program exited)
We shouldn't be seeing this for internal or momentary breakpoints. In
fact, we shouldn't even be trying to delete them, as whatever created
them will take care or it, and therefore it's dangerous to delete them
behind the creator's back.
I thought it'd still be good to tag thread-specific internal/momentary
breakpoints such that we'll no longer try to keep them insert in the
target, as they'll cause stops and thread hops in other threads, so I
tried disabling them instead. That caused a problem when following a
child fork, and detaching from the parent, as we try to reset the
step-resume etc. breakpoints to the new child's thread
(breakpoint_re_set_thread), after the parent thread is already gone
(and the breakpoints are marked disabled). I fixed that by
re-enabling internal/momentary breakpoints there, but, that didn't
feel super safe either (maybe we'd need a new flag in struct
breakpoint instead, to tag the thread-specific breakpoint as "not to
be inserted"). It felt like I was heading down a design rat hole,
and, other things will usually delete internal/momentary breakpoints
soon enough, so I left that little optimization for some other day.
So, internal/momentary breakpoints are no longer deleted/disabled at
all, and we end up with a one-liner fix.
Tested on x86_64 Fedora 17.
gdb/
2013-09-19 Pedro Alves <palves@redhat.com>
* breakpoint.c (remove_threaded_breakpoints): Skip non-user
breakpoints.
This removes another instance of a deprecated_xfer_memory user.
gdb/
2013-09-19 Pedro Alves <palves@redhat.com>
Thomas Schwinge <thomas@codesourcery.com>
Yue Lu <hacklu.newborn@gmail.com>
* gnu-nat.c (gnu_read_inferior, gnu_write_inferior): Make static.
Take a gdb_byte pointer instead of a char pointer.
* gnu-nat.c (gnu_xfer_memory): Adjust interface as
gnu_xfer_partial helper.
(gnu_xfer_partial): New function.
(gnu_target): Don't install a deprecated_xfer_memory hook.
Install a to_xfer_partial hook.
gdb/
2013-09-19 Jan Kratochvil <jan.kratochvil@redhat.com>
Constification.
* main.c (captured_main): Replace catch_command_errors by
catch_command_errors_const. Twice.
* symfile.c (symbol_file_add_main_1): Make args parameter const.
(symbol_file_add): Make name parameter const.
(symbol_file_add_main, symbol_file_add_main_1): Make args parameter const.
(symfile_bfd_open): Make name parameter const, rename it to cname. Add
variable name. Change their usage accordingly.
* symfile.h (symbol_file_add, symfile_bfd_open): Make first parameter
const.
(symbol_file_add_main): Make args parameter const.
Ulrich Weigand <uweigand@de.ibm.com>
* xcoffread.c (struct coff_symbol): Use CORE_ADDR as type
of c_value member.
(read_xcoff_symtab): Use CORE_ADDR as type of fcn_start_addr.
2013-09-18 Pedro Alves <palves@redhat.com>
Yue Lu <hacklu.newborn@gmail.com>
* gnu-nat.c (inf_validate_procs, gnu_wait, gnu_resume)
(gnu_create_inferior)
(gnu_attach, gnu_thread_alive, gnu_pid_to_str, cur_thread)
(set_sig_thread_cmd): Use the lwpid field of ptids to
store/extract thread ids instead of the tid field.
* i386gnu-nat.c (gnu_fetch_registers): Adjust.
instead of ptid_t.tid.
In preparation for reusing gnu-nat.c in gdbserver, switch to storing
thread ids in the lwpid field of ptid_t rather than in the tid
field. The Hurd's thread model is 1:1, so it doesn't feel wrong
anyway.
gdb/
2013-09-18 Pedro Alves <palves@redhat.com>
* gnu-nat.c (inf_validate_procs, gnu_wait, gnu_resume)
(gnu_create_inferior)
(gnu_attach, gnu_thread_alive, gnu_pid_to_str, cur_thread)
(set_sig_thread_cmd): Use the lwpid field of ptids to
store/extract thread ids instead of the tid field.
* i386gnu-nat.c (gnu_fetch_registers): Adjust.
https://sourceware.org/ml/gdb-patches/2013-08/msg00170.html
gdb/ChangeLog
* infcmd.c (default_print_one_register_info): Add detection of
optimized out values.
(default_print_registers_info): Switch to using
get_frame_register_value.
gdb/testsuite/ChangeLog
* gdb.dwarf2/dw2-reg-undefined.exp: Change pattern for info
register to "<optimized out>", and also print the registers.
Skip the test on Cygwin too.
2013-09-18 Pedro Alves <palves@redhat.com>
PR server/15967
* gdb.server/wrapper.exp: Also return unsupported for Cygwin, and
change text.
By inspection, I noticed that when I made the gnu-nat use
ptid(pid,0,tid) to represent a thread, instead of using ptid(tid,0,0),
in <https://sourceware.org/ml/gdb-patches/2008-08/msg00175.html>, I
introduced a bug.
The change was:
else
{
- int tid = PIDGET (thread_id_to_pid (atoi (args)));
+ int tid = ptid_get_tid (thread_id_to_pid (atoi (args)));
if (tid < 0)
error (_("Thread ID %s not known. Use the \"info threads\" command to\n"
"see the IDs of currently known threads."), args);
and thread_id_to_pid does:
ptid_t
thread_id_to_pid (int num)
{
struct thread_info *thread = find_thread_id (num);
if (thread)
return thread->ptid;
else
return pid_to_ptid (-1);
}
(pid_to_ptid (-1) is the same as minus_one_ptid.)
So before, we were really looking at the pid, where thread_id_to_pid
stores the -1.
The right fix is to compare the whole ptid to minus_one_ptid, of
course.
Completely untested, but I think it's obvious enough, so I went ahead
and put it in.
gdb/
2013-09-18 Pedro Alves <palves@redhat.com>
* gnu-nat.c (set_sig_thread_cmd): Compare the thread's ptid to
minus_one_ptid instead of looking at the ptid's tid field and
comparing that to -1.
PR gdb/11568 is about thread-specific breakpoints being left behind
when the corresponding thread exits.
Currently:
(gdb) b start thread 2
Breakpoint 3 at 0x400614: file thread-specific-bp.c, line 23.
(gdb) b end
Breakpoint 4 at 0x40061f: file thread-specific-bp.c, line 29.
(gdb) c
Continuing.
[Thread 0x7ffff7fcb700 (LWP 14925) exited]
[Switching to Thread 0x7ffff7fcc740 (LWP 14921)]
Breakpoint 4, end () at thread-specific-bp.c:29
29 }
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fcc740 (LWP 14921) "thread-specific" end () at thread-specific-bp.c:29
(gdb) info breakpoints
Num Type Disp Enb Address What
2 breakpoint keep y 0x0000000000400614 in start at thread-specific-bp.c:23
breakpoint already hit 1 time
3 breakpoint keep y 0x0000000000400614 in start at thread-specific-bp.c:23 thread 2
stop only in thread 2
4 breakpoint keep y 0x000000000040061f in end at thread-specific-bp.c:29
breakpoint already hit 1 time
Note that the thread-specific breakpoint 3 stayed around, even though
thread 2 is gone.
There's no way that breakpoint can trigger again (*), so the PR argues
that the breakpoint should just be removed, like local watchpoints.
I'm ambivalent on this -- it could be reasonable to disable the
breakpoint (kind of like breakpoint in shared library code when the
DSO is unloaded), so the user could still use it as visual template
for creating other breakpoints (copy/paste command lists, etc.), or we
could have a way to change to which thread a breakpoint applies. But,
several people pushed this direction, and I don't plan on arguing...
(*) - actually, there is ... thread numbers are reset on "run", so
the user could do "break foo thread 2", "run", and expect the
breakpoint to hit again on the second thread. But given gdb's thread
numbering can't really be stable, that'd only work sufficiently well
for thread 1, so we'd better call it unsupported.
So with the patch, whenever a thread is deleted from GDB's list, GDB
goes through the thread-specific breakpoints and deletes corresponding
breakpoints. Since this is user-visible, GDB prints out:
Thread-specific breakpoint 3 deleted - thread 2 is gone.
And of course, we end up with:
(gdb) info breakpoints
Num Type Disp Enb Address What
2 breakpoint keep y 0x0000000000400614 in start at thread-specific-bp.c:23
breakpoint already hit 1 time
4 breakpoint keep y 0x000000000040061f in end at thread-specific-bp.c:29
breakpoint already hit 1 time
2013-09-17 Muhammad Waqas <mwaqas@codesourcery.com>
Pedro Alves <palves@redhat.com>
PR gdb/11568
* breakpoint.c (remove_threaded_breakpoints): New function.
(_initialize_breakpoint): Attach remove_threaded_breakpoints
as thread_exit observer.
2013-09-17 Muhammad Waqas <mwaqas@codesourccery.com>
Jan Kratochvil <jan.kartochvil@redhat.com>
Pedro Alves <palves@redhat.com>
PR gdb/11568
* gdb.thread/thread-specific-bp.c: New file.
* gdb.thread/thread-specific-bp.exp: New file.
function. It adds a check for $_isvoid during the test of "show convenience"
output.
gdb/testsuite/
2013-09-17 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/defaults.exp (<show_conv_list>): Add check for $_isvoid
convenience function.
"info threads" changes the default source for "break" and "list", to
whatever the location of the first/bottom thread in the thread list
is...
(gdb) b start
(gdb) c
...
(gdb) list
*lists "start"*
(gdb) b 23
Breakpoint 3 at 0x400614: file test.c, line 23.
(gdb) info threads
Id Target Id Frame
* 2 Thread 0x7ffff7fcb700 (LWP 1760) "test" start (arg=0x0) at test.c:23
1 Thread 0x7ffff7fcc740 (LWP 1748) "test" 0x000000323dc08e60 in pthread_join (threadid=140737353922304, thread_return=0x0) at pthread_join.c:93
(gdb) b 23
Breakpoint 4 at 0x323dc08d90: file pthread_join.c, line 23.
^^^^^^^^^^^^^^^
(gdb) list
93 lll_wait_tid (pd->tid);
94
95
96 /* Restore cancellation mode. */
97 CANCEL_RESET (oldtype);
98
99 /* Remove the handler. */
100 pthread_cleanup_pop (0);
101
102
The issue is that print_stack_frame always sets the current sal to the
frame's sal. print_frame_info (which print_stack_frame calls to do
most of the work) also sets the last displayed sal, but only if
print_what isn't LOCATION. Now the call in question, from within
thread.c:print_thread_info, does pass in LOCATION as print_what, but
print_stack_frame doesn't have the same check print_frame_info has.
We could consider adding it, but setting these globals depending on
print_what isn't very clean, IMO. What we have is two logically
distinct operations mixed in the same function(s):
#1 - print frame, in the format specified by {print_what,
print_level and print_args}.
#2 - We're displaying a frame to the user, and I want the default
sal to point here, because the program stopped here, or the user
did some context-changing command (up, down, etc.).
So I added a new parameter to print_stack_frame & friends for point
#2, and went through all calls in the tree adjusting as necessary.
Tested on x86_64 Fedora 17.
gdb/
2013-09-17 Pedro Alves <palves@redhat.com>
PR gdb/15911
* ada-tasks.c (task_command_1): Adjust call to print_stack_frame.
* bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd, bsd_kvm_pcb_cmd):
* corelow.c (core_open):
* frame.h (print_stack_frame, print_frame_info): New
'set_current_sal' parameter.
* infcmd.c (finish_command, kill_command): Adjust call to
print_stack_frame.
* inferior.c (inferior_command): Likewise.
* infrun.c (normal_stop): Likewise.
* linux-fork.c (linux_fork_context): Likewise.
* record-full.c (record_full_goto_entry, record_full_restore):
Likewise.
* remote-mips.c (common_open): Likewise.
* stack.c (print_stack_frame): New 'set_current_sal' parameter.
Use it.
(print_frame_info): New 'set_current_sal' parameter. Set the last
displayed sal depending on the new paremeter instead of looking at
print_what.
(backtrace_command_1, select_and_print_frame, frame_command)
(current_frame_command, up_command, down_command): Adjust call to
print_stack_frame.
* thread.c (print_thread_info, restore_selected_frame)
(do_captured_thread_select): Adjust call to print_stack_frame.
* tracepoint.c (tfind_1): Likewise.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_frame): Likewise.
* mi/mi-interp.c (mi_on_normal_stop): Likewise.
* mi/mi-main.c (mi_cmd_exec_return, mi_cmd_trace_find): Likewise.
gdb/testsuite/
* gdb.threads/info-threads-cur-sal-2.c: New file.
* gdb.threads/info-threads-cur-sal.c: New file.
* gdb.threads/info-threads-cur-sal.exp: New file.
* gdb.base/catch-load.c: Remove the include of "dlfcn.h".
[__WIN32__]: Include "windows.h" and define macro dlopen
and dlclose.
[!__WIN32__]: Include "dlfcn.h".
* gdb.base/catch-load.exp (one_catch_load_test): Match
directory separator.
"You should provide one parameter..." while it should be saying "... one
argument...". Replaced.
2013-09-16 Sergio Durigan Junior <sergiodj@redhat.com>
* value.c (isvoid_internal_fn): Replace "parameter" with
"argument".
<https://sourceware.org/ml/gdb-patches/2013-09/msg00301.html>
<https://sourceware.org/ml/gdb-patches/2013-09/msg00383.html>
This patch adds a new convenience function called $_isvoid, whose
only purpose is to check whether an expression is void or not.
This became necessary because the new convenience variable
$_exitsignal (not yet approved) has a mutual exclusive behavior
with $_exitcode, i.e., when one is "defined" (i.e., non-void),
the other is cleared (i.e., becomes void). Doug wanted a way to
identify which variable to use, and checking for voidness is the
obvious solution.
It is worth mentioning that my first attempt, after a conversation with
Doug, was to actually implement a new $_isdefined() convenience
function. I would do that (for convenience variables) by calling
lookup_only_internalvar. However, I found a few problems:
- Whenever I called $_isdefined ($variable), $variable became defined
(with a void value), and $_isdefined always returned true.
- Then, I tried to implement $_isdefined ("variable"), and do the "$" +
"variable" inside GDB, thus making it impossible for GDB to create the
convenience variable. However, it was hard to extract the string
without having to mess with values and their idiossincrasies.
Therefore, I decided to abandon this attempt (specially because I
didn't want to spend too much time struggling with it).
Anyway, after talking to Doug again we decided that it would be easier
to implement $_isvoid, and this will probably help in cases like
<http://stackoverflow.com/questions/3744554/testing-if-a-gdb-convenience-variable-is-defined>.
I wrote a NEWS entry for it, and some new lines on the documentation.
gdb/
2013-09-16 Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS: Mention new convenience function $_isvoid.
* value.c (isvoid_internal_fn): New function.
(_initialize_values): Add new convenience function $_isvoid.
gdb/doc/
2013-09-16 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (Convenience Functions): Mention new convenience
function $_isvoid.
gdb/testsuite/
2013-09-16 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/gdbvars.c (foo_void): New function.
(foo_int): Likewise.
* gdb.base/gdbvars.exp (test_convenience_functions): New
function. Call it.
Apply the same fix that was applied to aarch64-linux-nat.c.
2013-09-16 Will Newton <will.newton@linaro.org>
* linux-aarch64-low.c (aarch64_linux_set_debug_regs): Zero
out regs.
Remove AT_HWCAP macro definintion as it is provided in
added include file.
* s390-tdep.c: Remove system header <elf.h>
Add "elf/common.h" header for AT_HWCAP definition.
(s390_core_read_description): Use correct CORE_ADDR
for hwcap local variable used as third parameter
of function target_auxv_search.
gdb/
2013-09-13 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* symfile.c (reread_symbols): Move variable obfd_filename to a more
inner block.
Corrected mi documentation about -list-target-features, example now uses the
correct mi command.
2013-09-13 Sanimir Agovic <sanimir.agovic@intel.com>
* gdb.texinfo (GDB/MI Miscellaneous Commands): Use
-list-target-features in the example.
gdb/doc/
2013-09-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (MiniDebugInfo): Prepare file debug and use it to create
mini_debuginfo. Strip binary before adding mini_debuginfo to it.
gdb/testsuite/
2013-09-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/gnu-debugdata.exp (objcopy 1): Move it lower and use only
debug part of the binary.
gdb/doc/
2013-09-11 Jan Kratochvil <jan.kratochvil@redhat.com>
Sync documentation with gdb.base/gnu-debugdata.exp.
* gdb.texinfo (MiniDebugInfo): Add comment and "D" in the example.
New regexpr now correctly deals with trailing canonical pathname.
Before only the following output was matched:
(gdb) cd
Working directory /users/foo
In addition it now matches an optional trailing canonical pathname:
(gdb) cd
Working directory /users/foo
(canonically /nfs/users/foo).
Triggered by `realpath .` != `pwd`
2013-09-10 Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/
* gdb.base/default.exp: Adjust regexpr for 'cd' to match optional
canonical pathname.
Tested by building for --target=arm-eabi, and playing with the debug
output a bit.
gdb/
2013-09-06 Pedro Alves <palves@redhat.com>
* remote-sim.c (dump_mem, gdbsim_fetch_register)
(gdbsim_store_register, gdbsim_kill, gdbsim_load)
(gdbsim_create_inferior, gdbsim_open, gdbsim_close)
(gdbsim_detach, gdbsim_resume_inferior, gdbsim_wait)
(gdbsim_files_info, gdbsim_mourn_inferior): Send debug output to
gdb_stdlog.
These two are still written in the pre-auto-dependency-tracking style.
They probably were written before that, and committed afterwards
without adjustment. An easy oversight to make.
gdb/gdbserver/
2013-09-06 Pedro Alves <palves@redhat.com>
* Makefile.in (linux-btrace.o, mips-linux-watch.o): Remove
explicit header dependencies and use $COMPILE/$POSTCOMPILE.
Somehow, my builds yesterdays didn't trip on this...
../src/gdb/gdbserver/linux-amd64-ipa.c: In function ‘initialize_low_tracepoint’:
../src/gdb/gdbserver/linux-amd64-ipa.c:172:3: error: ‘ipa_tdesc’ undeclared (first use in this function)
../src/gdb/gdbserver/linux-amd64-ipa.c:172:3: note: each undeclared identifier is reported only once for each function it appears in
gdb/gdbserver/
2013-09-06 Pedro Alves <palves@redhat.com>
* linux-amd64-ipa.c: Include tracepoint.h.
* linux-i386-ipa.c: Include tracepoint.h.
This brings in some standard functionality hitherdo missing from
the CRIS/CRISv32 port thanks to the new call to gdbarch_init_osabi,
as well as clearly showing that there is Linux support for this
platform by virtue of the existence of a cris-linux-tdep.c file.
2013-09-06 Ricard Wanderlof <ricardw@axis.com>
* Makefile.in (ALL_TARGET_OBS): Add cris-linux-tdep.o.
* configure.tgt: Add cris-linux-tdep.o and linux-tdep.o to
gdb_target_obs for cris target.
* cris-tdep.c (struct gdbarch_tdep): Move to cris-tdep.h.
(cris_gdbarch_init): Move calls to
set_gdbarch_fetch_tls_load_module_address and
set_solib_svr4_fetch_link_map_offsets to cris-linux-tdep.c.
Add call to gdbarch_init_osabi.
* cris-linux-tdep.c: New file.
* cris-tdep.h: New file.
https://sourceware.org/ml/gdb-patches/2013-09/msg00179.html
gdb/ChangeLog
* cli/cli-interp.c (_initialize_cli_interp): Add a
command_loop_proc to interp_procs.
* event-top.c (cli_command_loop): Change signature to match
interp_command_loop_ftype.
* event-top.h (cli_command_loop): Same.
* interps.c (interp_new): Require every interpreter to have a
command_loop_proc.
(current_interp_command_loop): Just call the command_loop_proc on
the current interpreter.
* tui/tui-interp.c (_initialize_tui_interp): Add a
command_loop_proc to interp_procs.
One misspelled function call, and one superfluous typedef. The latter
causes an error of the following type when building:
linux-crisv32-low.c:372: error: conflicting types for 'elf_gregset_t'
/.../target/include/asm/elf.h:36:
error: previous declaration of 'elf_gregset_t' was here
2013-09-06 Ricard Wanderlof <ricardw@axis.com>
* linux-crisv32-low.c (elf_gregset_t): Delete typedef.
(initialize_low_arch): Call init_registers_crisv32 rather than
init_register_crisv32.
gdb/gdbserver/
2013-09-05 Pedro Alves <palves@redhat.com>
* server.h (gdb_client_data, handler_func, callback_handler_func)
(delete_file_handler, add_file_handler, append_callback_event)
(delete_callback_event, start_event_loop, initialize_event_loop):
Move to event-loop.h and include it.
* event-loop.h: New file.
gdb/gdbserver/
2013-09-05 Pedro Alves <palves@redhat.com>
* server.h (perror_with_name, error, fatal, warning, paddress)
(pulongest, plongest, phex_nz, pfildes): Move to utils.h, and
include it.
* utils.h: New file.
server.h nowadays includes gdb_locale.h, which already brings this in.
gdb/gdbserver/
2013-09-05 Pedro Alves <palves@redhat.com>
* server.h (_): Delete.
A couple years ago, dwarf_expr_fetch used to return a CORE_ADDR. It
was made to return a ULONGEST since, and the 'dwarf_regnum' local
adjusted accordingly, but, we kept printing it with paddress.
gdbarch_dwarf2_reg_to_regnum takes the register number as 'int', so
there's really no point in using ULONGEST/pulongest either.
gdb/
2013-09-05 Pedro Alves <palves@redhat.com>
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): 'dwarf_regnum'
local is now int instead of ULONGEST. Print it with %d
instead of paddress.
I noticed that value_of_register (used for getting values _of_
registers ($pc, $rax, etc.), rather than variables _in_ registers),
kind of builds a franken-value, by propagating the lval and address of
the frame register value, but not the entire location, like necessary
for lval_computed (if some unwinder ever returns that, the resulting
value will misbehave). This gets in the way of printing optimized out
(not saved) lval_registers differently from other optimized out
values, as it doesn't make sure the resulting value is lval_register.
I started out by just doing something like:
- VALUE_LVAL (reg_val) = lval;
- set_value_address (reg_val, addr);
+ VALUE_LVAL (reg_val) = lval_register;
... just like value_of_register_lazy below. That's sufficient to fix
the issue.
Then I noticed this is using frame_register, which we should avoid
nowadays, for it returns elements of a value, but not all that's
sometimes necessary (unavailable-ness is all or nothing with it, for
instance), and considered using get_frame_register_value instead
(which returns a struct value), and value_contents_copy, just like
value_fetch_lazy's handling of lval_register. But at that point, I
realized we might as well just defer all that work to
value_of_register_lazy/value_fetch_lazy...
Doing it this way adds a frame_find_by_id lookup (from within
value_fetch_lazy), while we already have a frame pointer handy in
value_of_register. I considered factoring out the lazy register
fetching out of value_fetch_lazy, into a function that takes a frame
pointer and call that instead, avoiding the lookup, but then it looked
like too much complication for an early optimization, and went back to
keeping it simple.
Tested on x86_64 Fedora 17.
gdb/
2013-09-05 Pedro Alves <palves@redhat.com>
* findvar.c (value_of_register): Rework in terms of
value_of_register_lazy.
I stumbled on the TUI's register-changed decision code before (used to
decided whether the register should be highlighted in the register
window), for it is trying to compare all the different possible states
and contents or previous/current register contents, and as such may
need updating whenever the value machinery changes to have more state.
It's just much simpler and more future proof to compare the
previous/current printable representation instead.
The bit in tui_register_format that returns early if the register has
no name gets a bit in the way of the new prototype (what to return in
that case? NULL, empty string, etc.?). Fortunately, that check isn't
really necessary. All the callers will have already skipped unnamed
registers.
gdb/
2013-09-05 Pedro Alves <palves@redhat.com>
* tui/tui-regs.c (tui_register_format): Don't look at the
register's name here. Return string representing register
value instead of storing it in the data element.
(tui_get_register): Compare register string representations
instead of register value states and contents.
I've stumbled on this by inspection.
When the TUI's register window is first displayed, it always shows the
registers of the current frame, instead of of the selected frame,
which is obviously bogus.
E.g.,
(gdb) step # into "function"
(gdb) up
(gdb) tui reg general # or C-x 2, C-x 2
shows the registers of "function", rather than the caller's.
A subsequent:
(gdb) frame
or
(gdb) down
(gdb) up
can be used as workaround to "fix" it.
gdb/
2013-09-05 Pedro Alves <palves@redhat.com>
PR tui/15933
* tui/tui-regs.c (tui_show_registers): Show registers of the
selected frame, not the current frame.
(queue_and_load_dwo_tu): New function.
(lookup_dwo_signatured_type): Set per_cu.tu_read.
(maybe_queue_comp_unit): Rename this_cu argument to dependent_cu.
Make dependent_cu optional.
(dw2_do_instantiate_symtab): If we just loaded a CU from a DWO,
and an older .gdb_index is in use, queue and load all its TUs too.
testsuite/
* gdb.base/enumval.c (ZERO): New enum value.
(main): Use it
* gdb.base/enumval.exp: Test ability to print ZERO.
gdb/
2013-09-04 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
* cli/cli-cmds.c (find_and_open_script): Add OPF_RETURN_REALPATH to
variable search_flags.
* defs.h (OPF_DISABLE_REALPATH): Rename to ...
(OPF_RETURN_REALPATH): ... here.
* dwarf2read.c (try_open_dwop_file): Set OPF_RETURN_REALPATH for flags.
* exec.c (exec_file_attach): Remove OPF_DISABLE_REALPATH from openp
call. Twice.
* nto-tdep.c (nto_find_and_open_solib): Add OPF_RETURN_REALPATH for
openp call.
* solib.c (solib_find): Likewise. Four times.
* source.c (openp): Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH
in the function comment and for the realpath_fptr variable.
(source_full_path_of): Add OPF_RETURN_REALPATH for openp call.
(find_and_open_source): Likewise. Twice.
* symfile.c (symfile_bfd_open): Likewise, also twice.
Pedro Alves <palves@redhat.com>
* symfile.c (add_symbol_file_command): Error out on unknown
option. Handle EXPECTING_SEC_ADDR/EXPECTING_SEC_NAME before '-'
options and collapse into single conditional branch.
2013-09-13 Muhammad Bilal <mbilal@codesourcery.com>
Pedro Alves <palves@redhat.com>
* gdb.base/relocate.exp: Check that invalid options are
rejected.
detach_fork.
* inf-ptrace.c (inf_ptrace_follow_fork): Likewise.
* inf-ttrace.c (inf_ttrace_follow_fork): Likewise.
* inferior.h (detach_fork): Remove.
* infrun.c (detach_fork): Adjust comment and make it
static.
(follow_fork): Pass detach_fork parameter to
target_follow_fork.
* linux-nat.c (linux_child_follow_fork): New parameter
detach_fork.
* target.c (target_follow_fork): New parameter detach_fork.
Pass detach_fork as parameter and print its value.
* target.h (struct target_ops) <to_follow_fork>: New int
parameter.
(target_follow_fork): New parameter detach_fork.
The field "bfd" no longer exists in struct target_section.
Use the_bfd_section->owner instead.
gdb/ChangeLog:
* solib-ia64-hpux.c (ia64_hpux_relocate_section_addresses):
Replace sec->bfd by sec->the_bfd_section->owner.
I'm seeing trace-buffer-size.exp failing (with gdbserver):
(gdb) PASS: gdb.trace/trace-buffer-size.exp: tstatus check 2
show trace-buffer-size 4
Requested size of trace buffer is 4.
(gdb) PASS: gdb.trace/trace-buffer-size.exp: show trace buffer size
set trace-buffer-size -1
memory clobbered past end of allocated block
Remote connection closed
(gdb) FAIL: gdb.trace/trace-buffer-size.exp: set trace buffer size 2
set trace-buffer-size unlimited
(gdb) PASS: gdb.trace/trace-buffer-size.exp: set trace-buffer-size unlimited
That "memory clobbered past end of allocated block" is mcheck triggering.
Valgrind shows:
==23624== Invalid write of size 1
==23624== at 0x418DD8: clear_trace_buffer (tracepoint.c:1443)
==23624== by 0x418F3A: init_trace_buffer (tracepoint.c:1497)
==23624== by 0x41D95B: cmd_bigqtbuffer_size (tracepoint.c:4061)
==23624== by 0x41DEEC: handle_tracepoint_general_set (tracepoint.c:4193)
clear_trace_buffer does:
static void
clear_trace_buffer (void)
{
trace_buffer_start = trace_buffer_lo;
trace_buffer_free = trace_buffer_lo;
trace_buffer_end_free = trace_buffer_hi;
trace_buffer_wrap = trace_buffer_hi;
/* A traceframe with zeroed fields marks the end of trace data. */
((struct traceframe *) trace_buffer_free)->tpnum = 0;
((struct traceframe *) trace_buffer_free)->data_size = 0;
traceframe_read_count = traceframe_write_count = 0;
traceframes_created = 0;
}
And the tpnum+data_size fields are over 4 bytes... This fixes it by
ensuring we allocate space at least for an EOB. We have code
elsewhere that relies on the EOB being present (like e.g.,
find_traceframe), so this seems simplest.
gdb/gdbserver/
2013-09-02 Pedro Alves <palves@redhat.com>
* tracepoint.c (TRACEFRAME_EOB_MARKER_SIZE): New macro.
(init_trace_buffer): Ensure at least TRACEFRAME_EOB_MARKER_SIZE is
allocated.
(trace_buffer_alloc): Use TRACEFRAME_EOB_MARKER_SIZE.
When I added gdb_read_memory, with bits factored out from elsewhere, I
missed adjusting this error return. gdb_read_memory has an interface
similar to Like GDB's xfer_partial:
> /* Read trace frame or inferior memory. Returns the number of bytes
> actually read, zero when no further transfer is possible, and -1 on
> error. Return of a positive value smaller than LEN does not
> indicate there's no more to be read, only the end of the transfer.
Returning EIO, a positive value, is obviously bogus, for the caller
will confuse it with a successful partial transfer.
Found by inspection.
Tested on x86_64 Fedora 17.
gdb/gdbserver/
2013-09-02 Pedro Alves <palves@redhat.com>
* server.c (gdb_read_memory): Return -1 on traceframe memory read
error instead of EIO.
* NEWS: Add entry mentioning support for native Windows x64
SEH data.
* amd64-windows-tdep.c: #include "objfiles.h", "frame-unwind.h",
"coff/internal.h", "coff/i386.h", "coff/pe.h" and "libcoff.h".
(struct amd64_windows_frame_cache): New struct.
(amd64_windows_w2gdb_regnum): New global.
(pc_in_range, amd64_windows_frame_decode_epilogue)
(amd64_windows_frame_decode_insns, amd64_windows_find_unwind_info)
(amd64_windows_frame_cache, amd64_windows_frame_prev_register)
(amd64_windows_frame_this_id): New functions.
(amd64_windows_frame_unwind): New static global.
(amd64_windows_skip_prologue): New function.
(amd64_windows_init_abi): Call frame_unwind_prepend_unwinder
with amd64_windows_frame_unwind. Call set_gdbarch_skip_prologue
with amd64_windows_skip_prologue.
When I looked for print_stack_frame calls in MI, I wondered why this
one passing down SRC_AND_LOC. print_stack_frame does:
/* For mi, alway print location and address. */
if (ui_out_is_mi_like_p (current_uiout))
print_what = LOC_AND_ADDRESS;
So it really doesn't matter which value is passed down, but, to avoid
confusion in readers, it's better to use the MI standard here.
There's another SRC_AND_LOC in mi-interp.c, but that one makes sense.
gdb/
2013-08-30 Pedro Alves <palves@redhat.com>
* mi/mi-main.c (mi_cmd_trace_find): Use LOC_AND_ADDRESS instead of
SRC_AND_LOC.
I noticed SRC_LINE has special handling within print_stack_frame (mid
statement handling), so I audited all uses, and noticed the one in
restore_selected_frame. I actually added this warning myself back in
2008, but reading back, I think we can do better. "reparsed frame" is
probably confusing to users.
Old:
warning: Couldn't restore frame #2 in current thread, at reparsed frame #0
45 w = 0;
(gdb)
New:
warning: Couldn't restore frame #2 in current thread. Bottom (innermost) frame selected:
#0 foo () at foo.c:45
45 w = 0;
(gdb)
Tested on x86_64 Fedora 17.
gdb/
2013-08-30 Pedro Alves <palves@redhat.com>
* thread.c (restore_selected_frame): Use SRC_AND_LOC, and change
warning text.
1 is SRC_AND_LOC.
Then, this is passing -1 as print_level argument to print_stack_frame.
-1 is not a valid print_level value (it's a regular boolean). But, it
used to be, before
<https://sourceware.org/ml/gdb-patches/2004-04/msg00585.html>.
What happened is that bsd-kvm.c did not exist at the time of that
patch, but went into the tree about a month after, without being
adjusted to the new interface.
Fixed now, exactly as e.g., ocd.c had been adjusted:
> --- ocd.c 18 Jan 2004 19:26:51 -0000 1.28
> +++ ocd.c 23 Apr 2004 14:29:12 -0000
> @@ -225,7 +225,7 @@
> flush_cached_frames ();
> registers_changed ();
> stop_pc = read_pc ();
> - print_stack_frame (get_selected_frame (), -1, 1);
> + print_stack_frame (get_selected_frame (), 0, SRC_AND_LOC);
gdb/
2013-08-30 Pedro Alves <palves@redhat.com>
* bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd, bsd_kvm_pcb_cmd):
Adjust arguments to print_stack_frame.
This is declaring a function that no longer exists. It was deleted
back in 2003-01-13:
...
show_and_print_stack_frame, print_only_stack_frame_stub,
print_only_stack_frame): Delete functions.
gdb/
2013-08-30 Pedro Alves <palves@redhat.com>
* frame.h (show_and_print_stack_frame): Delete declaration.
Thread support got broken when adding 64bit support on ppc-aix.
Upon digging further, I found that the following patch...
| * gdb_ptrace.h: Use ptrace64 instead of ptrace if HAVE_PTRACE64
| is defined.
| * rs6000-nat.c: Check for __ld_info64_ if compiling 64 BIT gdb.
| (rs6000_ptrace32): Call ptrace64 instead of ptrace if present.
| (rs6000_ptrace64): Call ptace64 instead of ptracex if present.
| * configure.ac: Check for ptrace64.
| * configure, config.in: Regenerate.
... is responsible for this regression:
(gdb) x /x &__n_pthreads
0xf06a8258 <__n_pthreads>: Cannot access memory at address 0xf06a8258
Prior to the patch, we have:
(gdb) x /x &__n_pthreads
0xf06a8258 <__n_pthreads>: 0x00000003
The problem occurs inside rs6000_ptrace32, while calling ptrace64.
The address is given to rs6000_ptrace32 as an "int *", while
ptrace64 takes a "long long". The cast causes the address to be
sign-extended, which results in GDB trying to read the wrong address.
This patch fixes the issue by casting the address to a "uintptr_t"
instead, and letting the compiler do the implicit conversion to
"long long" in the function call.
gdb/ChangeLog:
* rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
instead of "long long" in call to ptrace64.