Consider the following declarations:
type Range_Type is (One, Two, Three);
type Array_Type is array (Range_Type range One .. Two) of Integer;
A : Array_Type := (1, 2);
Trying to print A can yield:
(gdb) print a
$1 = (one => 1, 2)
The bound of the first element should not have been printed, since
"one" is the first enumerate of type Range_Type. Similarly, with
the following declarations:
type Array2_Type is array (Range_Type range Two .. Three) of Integer;
A2 : Array2_Type := (2, 3);
GDB is failing to print the bound of the first element of "A2":
(gdb) print a2
$2 = (2, 3)
This is because the index type for both types Array_Type and Array2_Type
are subranges (by DWARF definition for arrays), of an anonymous subrange
type. When deciding whether to print the bound of the first element,
we handle subranges, but only up to one level. This patch enhanced
the code to handle any number of subrange levels.
gdb/ChangeLog:
* ada-valprint.c (print_optional_low_bound): Get index_type's
target type for as long as it is a TYPE_CODE_RANGE.
No testcase with this patch, but this will be tested via the testcase
of another patch, which uses the DWARF assembler to generate debugging
info for an array indexed by an enum.
On x86-solaris, the gcore command sometimes triggers the following
internal error:
(gdb) gcore
/[...]/procfs.c:5523: internal-error: procfs_make_note_section: Assertion `thread_args.note_data != note_data' failed.
The problem is extremely elusive, for reasons that will become clearer
as I explain what is going on.
The program used to produce this issue was really simple:
| void break_me (void) { }
|
| int
| main (void)
| {
| break_me ();
| return 0;
| }
The procfs_make_note_section builds a buffer incrementally with
the contents of the core's notes section. The interesting bits are:
char *note_data = NULL;
[...]
note_data = (char *) elfcore_write_prpsinfo (obfd,
note_data,
note_size,
fname,
psargs);
This is the first call to bfd's elfcore which initializes note_data.
After that, we have a few more calls, which keep updating notes_data
and note_size, but our interest lies in the following part of
the function:
thread_args.note_data = note_data;
[...]
proc_iterate_over_threads (pi, procfs_corefile_thread_callback,
&thread_args);
/* There should be always at least one thread. */
gdb_assert (thread_args.note_data != note_data);
The comment implies that the assert is to verify that our loop
iterated over at least one thread. The check is relying on the
fact that the notes_data returned by the elfcore module changes
at each iteration, via (in procfs_corefile_thread_callback):
args->note_data = procfs_do_thread_registers (args->obfd, ptid,
args->note_data,
args->note_size,
args->stop_signal);
(which calls elfcore_write_lwpstatus).
But, while it happens most of the time, thanks to a call to realloc
in elfcore_write_note (the function that actually appends the data
at the end of the notes buffer),...
buf = (char *) realloc (buf, *bufsiz + newspace);
... this is by no means guarantied. In fact, under the right
circumstances, the buffer was grown twice without changing
addresses. Unfortunately, the circumstances are very sensitive,
thus making this bug very elusive.
This patch fixes the problem by simply removing the assert.
This means we're losing the assertion that there is at least one
thread, but I think that's OK. If we still want to keep the
assertion, we have the option of either checking the buffer
size, or else adding a boolean flag in the context structure
that we'd set to true as soon as we have a thread.
gdb/ChangeLog:
* procfs.c (procfs_make_note_section): Remove assertion and
associated comment.
Functions remote_read_bytes and get_core_siginfo are the callees of
target to_xfer_partial interface, so argument 'len' should be changed
to type ULONGEST.
gdb:
2014-01-24 Yao Qi <yao@codesourcery.com>
* remote.c (remote_read_bytes): Change type of len to ULONGEST.
* corelow.c (get_core_siginfo): Likewise.
Hi,
This patch changes the type of 'len' from ssize_t to ULONGEST.
At the beginning Siddhesh Poyarekar proposed this patch
[PATCH] Memory reads and writes should have size_t length
https://sourceware.org/ml/gdb-patches/2012-05/msg01073.html
to change type of 'len' to size_t. However, after Jan's review, we
decide to change it to ssize_t, because callers of these functions
may pass signed type to them.
AFAICS, the target layer is a boundary. In one side, we pass size_t
or ssize_t to target related APIs, and in the other side, the
implementation side, we used LONGEST (ULONGEST in latest code) because
of to_xfer_partial.
Since remote_write_bytes_aux and remote_write_bytes belong to the
implementation of remote target, we should use ULONGEST for len, IMO.
Regression tested on x86_64-linux. Is it OK?
gdb:
2014-01-24 Yao Qi <yao@codesourcery.com>
* remote.c (remote_write_bytes_aux): Change type of 'len' to
ULONGEST. Don't check 'len' is negative.
(remote_write_bytes): Change type of 'len' to ULONGEST.
This fixes a bug in FrameDecorator.py.
FrameVars seems to assume that Frame.block can return None if there is
no block. However, it actually throws an exception.
I saw this bug while developing a frame filter, but unfortunately I
don't know how to reproduce it. It seems to me that the SAL tests in
_is_limited_frame should exclude the bad cases; and in my attempts to
write a test they do.
Nevertheless I think the fix is reasonably obvious and ought to go in.
2014-01-23 Tom Tromey <tromey@redhat.com>
PR python/16485:
* python/lib/gdb/FrameDecorator.py: (FrameVars.fetch_frame_args):
Handle exception from frame.block.
(FrameVars.fetch_frame_locals): Likewise.
This fixes PR python/16487.
The bug here is that the function-name-handling code in py_print_frame
had a small logic error (really a misplaced closing brace). This
error could lead to a Py_DECREF(NULL), which crashes.
This patch fixes the bug in the obvious way.
Built and regtested on x86-64 Fedora 18. New test case included.
2014-01-23 Tom Tromey <tromey@redhat.com>
PR python/16487:
* python/py-framefilter.c (py_print_frame): Don't call Py_DECREF
on a NULL pointer. Move "goto error" to correct place.
2014-01-23 Tom Tromey <tromey@redhat.com>
PR python/16487:
* gdb.python/py-framefilter.exp: Add test using "Error" filter.
* gdb.python/py-framefilter.py (ErrorInName, ErrorFilter): New
classes.
apply_frame_filter calls ensure_python_env before computing the
gdbarch to use. This means that python_gdbarch can be NULL while in
Python code, and if a frame filter depends on this somehow (easy to
do), gdb will crash.
The fix is to compute the gdbarch first.
Built and regtested on x86-64 Fedora 18.
New test case included.
2014-01-23 Tom Tromey <tromey@redhat.com>
PR python/16491:
* python/py-framefilter.c (apply_frame_filter): Call
ensure_python_env after computing gdbarch.
2014-01-23 Tom Tromey <tromey@redhat.com>
PR python/16491:
* gdb.python/py-framefilter.py (Reverse_Function.function): Read a
string from an inferior frame.
* gdb.python/py-framefilter-mi.exp: Update.
This patch changes the argument type to gdb_byte * in order to align
with the to_xfer_partial interface.
gdb:
2014-01-23 Yao Qi <yao@codesourcery.com>
* target.c (raw_memory_xfer_partial): Change argument type
from void * to gdb_byte *.
(memory_xfer_partial_1, memory_xfer_partial): Likewise.
* syscalls/s390x-linux.xml: New file.
* syscalls/s390-linux.xml: New file.
* s390-linux-tdep.c (XML_SYSCALL_FILENAME_S390): New macro.
(XML_SYSCALL_FILENAME_S390X): Likewise.
(op_svc): New enum value for SVC opcode.
(s390_sigtramp_frame_sniffer): Replace literal by 'op_svc'.
(s390_linux_get_syscall_number): New function.
(s390_gdbarch_init): Register '*get_syscall_number' and the
syscall xml file name.
* data-directory/Makefile.in (SYSCALLS_FILES): Add
"s390-linux.xml" and "s390x-linux.xml".
* NEWS: Announce new feature.
gdb/testsuite/ChangeLog:
* gdb.base/catch-syscall.exp: Activate test on s390*-linux.
The trace-specific test case 'entry-values' concludes fairly late in
the process that this platform doesn't support trace. Before that,
there are some platform specifics that don't work on s390x. The fix
addresses two aspects:
(1) Removal of an excess space character in the regex for the
disassembly. This is needed when there is a function alignment
gap, because then the hex address is immediately followed by a
colon, like in the first 'nopr' line below:
(gdb) disassemble foo+50,+10
Dump of assembler code from 0x32 to 0x3c:
0x0000000000000032 <foo+50>: br %r4
0x0000000000000034: nopr %r7
0x0000000000000036: nopr %r7
0x0000000000000038 <bar+0>: stmg %r11,%r15,88(%r15)
End of assembler dump.
(2) Handling for the s390-specific call instruction.
gdb/testsuite/ChangeLog:
* gdb.trace/entry-values.exp: Remove excess space character from
regex patterns. Handle s390 call instruction.
On ppc64-linux a function symbol does not point to code, but to the
function descriptor. Thus the previous change for this test case
broke it:
https://sourceware.org/ml/gdb-patches/2014-01/msg00275.html
This patch reverts to the original method, re-introducing '_start'
symbols. In addition, it adds sufficient alignment before the label,
such that the label never points into an alignment gap.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-dir-file-name.c (FUNC): Insert alignment and
define "*_start" label. Make "name" static.
* gdb.dwarf2/dw2-dir-file-name.exp: Replace references to
${name} by references to ${name}_start.
When upstream gcc is given a command line with the "-g" option after
"-g3", it doesn't generate a ".debug_macro" section. This is because
the last option wins, thus downgrading the debug level again. Without
any macro debug information in the executable, info-macros.exp
obviously produces many failures.
Since the "-g" option is appended by DejaGnu's target_compile whenever
the "debug" option is set, the fix just removes that option.
gdb/testsuite/ChangeLog:
* gdb.base/info-macros.exp: Remove "debug" from the compile
options.
On 64-bit hosts unsigned long is 64 bit. Use uint32_t instead.
gdb/
2014-01-22 Baruch Siach <baruch@tkos.co.il>
* xtensa-tdep.h (xtensa_elf_greg_t): Change type to uint32_t.
The ARI script flagged the use of the __func__ variable, which
is normally not allowed (not defined in C90). However, this particular
use is OK, as the reference is only made when __STDC_VERSION__ >=
199901L. So, add an "ARI:" comment to explicitly OK this use.
gdb/ChangeLog:
* common/common-utils.h: Add "ARI:" comment beside __func__
reference.
While looking at this macro, I noticed that it wasn't always necessarily
defined. That prompted me to search the current sources to make sure
that all uses were adequately protected, which they were. But to help
prevent future uses to be made unprotected, this patch expands the
current macro documentation a bit.
gdb/ChangeLog:
* common/common-utils.h (FUNCTION_NAME): Expand the macro's
documentation a bit.
gdb/
* configure.ac: Call AM_PROG_INSTALL_STRIP.
* configure: Regenerate.
* aclocal.m4: Regenerate.
* Makefile.in (install_sh, INSTALL_STRIP_PROGRAM, STRIP):
New substituted variables.
(install-strip): New target.
(INSTALL_SCRIPT): New substituted variable.
(FLAGS_TO_PASS): Add it.
(install-only): Use $(INSTALL_SCRIPT) rather than
$(INSTALL_PROGRAM) for gcore.
This moves all the bitfields in struct cmd_list_element to be closer
together. This packs the structure somewhat better. On a 64 bit
machine, this simple rearrangement saves around 50k at startup.
2014-01-20 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.h (struct cmd_list_element): Move all bitfields
together.
This changes various flags struct cmd_list_element into bitfields. In
general I think bitfields are cleaner than flag words, at least in a
case like this where there is no need to pass the flags around
independently of the enclosing struct.
2014-01-20 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.c (add_cmd, deprecate_cmd, add_alias_cmd)
(add_setshow_cmd_full, delete_cmd, lookup_cmd_1)
(deprecated_cmd_warning, complete_on_cmdlist): Update.
* cli/cli-decode.h (CMD_DEPRECATED, DEPRECATED_WARN_USER)
(MALLOCED_REPLACEMENT, DOC_ALLOCATED): Remove.
(struct cmd_list_element) <flags>: Remove.
<cmd_deprecated, deprecated_warn_user, malloced_replacement,
doc_allocated>: New fields.
<hook_in, allow_unknown, abbrev_flag, type, var_type>: Now
bitfields.
* maint.c (maintenance_do_deprecate): Update.
* top.c (execute_command): Update.
Currently, xtensa code using the Linux ptrace interface only include
sys/ptrace.h. This file comes from the C library (glibc and uClibc,
at least), and includes a declaration of the ptrace() functions, along
with some cross architecture constants that are mostly copied from the
file located at include/uapi/linux/ptrace.h in recent Linux kernels.
For xtensa specific constants like PTRACE_GETXTREGS and
PTRACE_SETXTREGS the asm/ptrace.h include from the Linux kernel UAPI
is needed. The code in gdbserver xtensa specific part doesn't call
ptrace() directly, so we can remove the unneeded sys/ptrace.h include.
The gdb xtensa specific code needs both headers, since it calls
ptrace().
gdb/
* xtensa-linux-nat.c: Include asm/ptrace.h.
gdb/gdbserver/
* linux-xtensa-low.c: Include asm/ptrace.h instead of
sys/ptrace.h.
is intended to house other D language support functions.
gdb/ChangeLog:
2014-01-17 Iain Buclaw <ibuclaw@gdcproject.org>
* Makefile.in (SFILES): Add d-support.c.
(COMMON_OBS): Add d-support.o.
* d-lang.h (d_parse_symbol): Add comment, now defined in
d-support.c.
* d-lang.c (parse_call_convention)
(parse_attributes, parse_function_types)
(parse_function_args, parse_type, parse_identifier)
(call_convention_p, d_parse_symbol): Move functions to ...
* d-support.c: ... New file.
While doing something else, I found that those 2 places were incorrectly
declaring a "struct gdb_exception" without using the "volatile" keyword.
This commit fixes that.
2014-01-17 Sergio Durigan Junior <sergiodj@redhat.com>
* breakpoint.c (insert_bp_location): Add "volatile" keyword to "struct
gdb_exception" declaration.
* remote.c (getpkt_or_notif_sane): Likewise.
* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): New
function, contents of dirnames_to_char_ptr_vec_append moved here.
(delim_string_to_char_ptr_vec): New function.
(dirnames_to_char_ptr_vec_append): Rewrite.
* common/gdb_vecs.h (delim_string_to_char_ptr_vec): Declare.
If gdb_proc_service.h ends up including linux/elf.h, we'll trip on
duplicate definitions:
In file included from ../../../gdb/gdbserver/linux-x86-low.c:29:0:
../../../gdb/gdbserver/../../include/elf/common.h:36:0: error: "ELFMAG0"
redefined [-Werror]
... etc ...
Handle this the same way linux-low.c and linux-arm-low.c handle this.
gdb/gdbserver/
2014-01-17 Pedro Alves <palves@redhat.com>
PR PR16445
* linux-x86-low.c (linux-x86-low.c): Don't include elf/common.h if
ELFMAG0 is defined after including gdb_proc_service.h.
This patch rearranges struct value a tiny bit, moving the "regnum"
field into a hole. This saves 8 bytes per value on a 64-bit machine,
and 4 bytes per value on a 32 bit machine. I think it does not
negatively affect readability or performance.
Built and regtested on x86-64 Fedora 18.
2014-01-16 Tom Tromey <tromey@redhat.com>
* value.c (struct value) <regnum>: Move earlier.
I noticed that extended_remote_create_inferior_1 is called from a
single spot. This patch unifies the callee and caller. It's just a
simple cleanup that made the coming refactoring simpler.
2014-01-16 Tom Tromey <tromey@redhat.com>
* remote.c (extended_remote_create_inferior): Rename from
extended_remote_create_inferior_1. Add "ops" argument. Remove
old implementation.
The test fails on s390 with:
-trace-find frame-number 0^M
&"PC not available\n"^M
^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
(gdb) ^M
FAIL: gdb.trace/mi-traceframe-changed.exp: tfile: -trace-find frame-number 0
tfile knows to infer the PC from the tracepoint's address if the PC
wasn't collected (tfile_fetch_registers) but, that only works on
targets whose PC register is a raw register, and on s390, the PC
register is a pseudo register.
But even if GDB doesn't know how to infer the value of PC, saying the
current frame is level -1 is a bug:
^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
^^^^^^^^^
'-1' is the level of the sentinel frame, which should never be visible.
This is caused by the s390's heuristic unwinder accepting the frame
(the fallback heuristic unwinders _always_ accept the frame), but then
the unwind->this_id method throws that "PC not available\n" error.
IOW, the s390's heuristic unwinder was never adjusted to handle
unavailable register values gracefully, which can happen with e.g., a
trimmed core file too.
This is just the minimal necessary for
<unavailable> frames, which at least gets us:
(gdb) tfind
Found trace frame 0, tracepoint 1
#0 <unavailable> in ?? ()
That is, frame #0 instead of -1.
We could get better info out of "info frame" (this patch makes us show
"outermost"), but this change would still be necessary.
gdb/
2014-01-16 Pedro Alves <palves@redhat.com>
* s390-linux-tdep.c (s390_frame_unwind_cache): Swallow
NOT_AVAILABLE_ERROR errors while parsing the prologue or reading
the backchain.
Provide to_resume and to_wait target methods for the btrace record target
to allow reverse stepping and replay support.
Replay is limited in the sense that only stepping and source correlation
are supported. We do not record data and thus can not show variables.
Non-stop mode is not working. Do not allow record-btrace in non-stop mode.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* btrace.h (btrace_thread_flag): New.
(struct btrace_thread_info) <flags>: New.
* record-btrace.c (record_btrace_resume_thread)
(record_btrace_find_thread_to_move, btrace_step_no_history)
(btrace_step_stopped, record_btrace_start_replaying)
(record_btrace_step_thread, record_btrace_decr_pc_after_break)
(record_btrace_find_resume_thread): New.
(record_btrace_resume, record_btrace_wait): Extend.
(record_btrace_can_execute_reverse): New.
(record_btrace_open): Fail in non-stop mode.
(record_btrace_set_replay): Split into this, ...
(record_btrace_stop_replaying): ... this, ...
(record_btrace_clear_histories): ... and this.
(init_record_btrace_ops): Init to_can_execute_reverse.
* NEWS: Announce it.
testsuite/
* gdb.btrace/delta.exp: Check reverse stepi.
* gdb.btrace/tailcall.exp: Update. Add stepping tests.
* gdb.btrace/finish.exp: New.
* gdb.btrace/next.exp: New.
* gdb.btrace/nexti.exp: New.
* gdb.btrace/record_goto.c: Add comments.
* gdb.btrace/step.exp: New.
* gdb.btrace/stepi.exp: New.
* gdb.btrace/multi-thread-step.c: New.
* gdb.btrace/multi-thread-step.exp: New.
* gdb.btrace/rn-dl-bind.c: New.
* gdb.btrace/rn-dl-bind.exp: New.
* gdb.btrace/data.c: New.
* gdb.btrace/data.exp: New.
* gdb.btrace/Makefile.in (EXECUTABLES): Add new.
doc/
* gdb.texinfo: Document limited reverse/replay support
for target record-btrace.
The btrace record target shows the branch trace from the location of the first
branch destination. This is the first BTS records.
After adding incremental updates, we can now add a dummy record for the current
PC when we enable tracing so we show the trace from the location where branch
tracing has been enabled.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* btrace.c: Include regcache.h.
(btrace_add_pc): New.
(btrace_enable): Call btrace_add_pc.
(btrace_is_empty): New.
* btrace.h (btrace_is_empty): New.
* record-btrace.c (require_btrace, record_btrace_info): Call
btrace_is_empty.
testsuite/
* gdb.btrace/Makefile.in (EXECUTABLES): Add delta.
* gdb.btrace/exception.exp: Update.
* gdb.btrace/instruction_history.exp: Update.
* gdb.btrace/record_goto.exp: Update.
* gdb.btrace/tailcall.exp: Update.
* gdb.btrace/unknown_functions.exp: Update.
* gdb.btrace/delta.exp: New.
Read branch trace data incrementally and extend the current trace rather than
discarding it and reading the entire trace buffer each time.
If the branch trace buffer overflowed, we can't extend the current trace so we
discard it and start anew by reading the entire branch trace buffer.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* common/linux-btrace.c (perf_event_read_bts, linux_read_btrace):
Support delta reads.
(linux_disable_btrace): Change return type.
* common/linux-btrace.h (linux_read_btrace): Change parameters
and return type to allow error reporting. Update users.
(linux_disable_btrace): Change return type. Update users.
* common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>:
New.
(btrace_error): New.
(btrace_block) <begin>: Comment on BEGIN == 0.
* btrace.c (btrace_compute_ftrace): Start from the end of
the current trace.
(btrace_stitch_trace, btrace_clear_history): New.
(btrace_fetch): Read delta trace, return if replaying.
(btrace_clear): Move clear history code to btrace_clear_history.
(parse_xml_btrace): Throw an error if parsing failed.
* target.h (struct target_ops) <to_read_btrace>: Change parameters
and return type to allow error reporting.
(target_read_btrace): Change parameters and return type to allow
error reporting.
* target.c (target_read_btrace): Update.
* remote.c (remote_read_btrace): Support delta reads. Pass
errors on.
* NEWS: Announce it.
gdbserver/
* target.h (target_ops) <read_btrace>: Change parameters and
return type to allow error reporting.
* server.c (handle_qxfer_btrace): Support delta reads. Pass
trace reading errors on.
* linux-low.c (linux_low_read_btrace): Pass trace reading
errors on.
(linux_low_disable_btrace): New.
Extend the always failing unwinder to provide the PC based on the call
structure detected in the branch trace.
The unwinder supports normal frames and tailcall frames.
Inline frames are not supported.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* record.h (record_btrace_frame_unwind)
(record_btrace_tailcall_frame_unwind): New declarations.
* dwarf2-frame: Include record.h
(dwarf2_frame_cfa): Throw an error for btrace frames.
* record-btrace.c: Include hashtab.h.
(btrace_get_bfun_name): New.
(btrace_call_history): Call btrace_get_bfun_name.
(struct btrace_frame_cache): New.
(bfcache): New.
(bfcache_hash, bfcache_eq, bfcache_new): New.
(btrace_get_frame_function): New.
(record_btrace_frame_unwind_stop_reason): Allow unwinding.
(record_btrace_frame_this_id): Compute own id.
(record_btrace_frame_prev_register): Provide PC, throw_error
for all other registers.
(record_btrace_frame_sniffer): Detect btrace frames.
(record_btrace_tailcall_frame_sniffer): New.
(record_btrace_frame_dealloc_cache): New.
(record_btrace_frame_unwind): Add new functions.
(record_btrace_tailcall_frame_unwind): New.
(_initialize_record_btrace): Allocate cache.
* btrace.c (btrace_clear): Call reinit_frame_cache.
* NEWS: Announce it.
testsuite/
* gdb.btrace/record_goto.exp: Add backtrace test.
* gdb.btrace/tailcall.exp: Add backtrace test.
The "info threads" command tries to read memory, which is not possible during
replay. This results in an error message and aborts the command without showing
the existing threads.
Provide a to_find_new_threads target method to skip the search while replaying.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (record_btrace_find_new_threads)
(record_btrace_thread_alive): New.
(init_record_btrace_ops): Initialize to_find_new_threads and
to_thread_alive.
Add simple to_wait and to_resume target methods that prevent stepping when the
current replay position is not at the end of the execution log.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (record_btrace_resume): New.
(record_btrace_wait): New.
(init_record_btrace_ops): Initialize to_wait and to_resume.