aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2016-03-17Suggest running gdbserver for a PID in containerJan Kratochvil2-1/+6
currently gdb -p <pid from a container> will print: warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable It correctly states the problem but it does not say how to solve it. Originally I wanted to suggest also the Docker "-p 1234:1234" parameter but I see the containers are more general topic than just Docker (even LxC etc.). According to Gary future GDBs should be able to work even without gdbserver. But currently gdbserver is still required. gdb/ChangeLog 2016-03-17 Jan Kratochvil <jan.kratochvil@redhat.com> * linux-thread-db.c (check_pid_namespace_match): Extend the message.
2016-03-17PR remote/19496, timeout in forking-threads-plus-bkptPedro Alves3-18/+34
This patch addresses a failure in gdb.threads/forking-threads-plus-breakpoint.exp: FAIL: gdb.threads/forking-threads-plus-breakpoint.exp: cond_bp_target=1: detach_on_fork=on: inferior 1 exited (timeout) Cause: A fork event was reported to GDB before GDB knew about the parent thread, followed immediately by a breakpoint event in a different thread. The parent thread was subsequently added via remote_notice_new_inferior in process_stop_reply, but when the thread was added the thread_info.state was set to THREAD_STOPPED. The fork event was then handled correctly, but when the fork parent was resumed via a call to keep_going, the state was unchanged. The breakpoint event was then handled, which caused all the non-breakpoint threads to be stopped. When the breakpoint thread was resumed, all the non-breakpoint threads were resumed via infrun.c:restart_threads. Our old fork parent wasn't restarted, because it still had thread_info.state set to THREAD_STOPPED. Ultimately the program under debug hung waiting for a pthread_join while the old fork parent was stopped forever by GDB. Fix: Since this is non-stop, then the bug is that the thread should have been added in THREAD_RUNNING state. Consider that infrun may be pulling target events out of the target_ops backend into its own event queue, but, not process them immediately. E.g., infrun may be stopping all threads temporarily for a step-over-breakpoint operation for thread A (stop_all_threads). The waitstatus of all threads is thus left pending in the thread structure (save_status), including the fork event of thread B. Right at this point, if the user does "info threads", that should show thread B (the fork parent) running, not stopped, even if internally, gdb is holding it paused for a little bit. Thus if in non-stop mode, always add new threads in the external user-visible THREAD_RUNNING state. Change remote_notice_new_inferior to accept the internal executing state of the thread instead, with EXECUTING set to 1 when we discover a thread that is running on the target (such as through remote_update_thread_list), and 0 when the thread is really paused (such as when we see a stop reply). Tested on x86_64 Linux and Nios II Linux target with x86 Linux host. gdb/ChangeLog: 2016-03-17 Pedro Alves <palves@redhat.com> Don Breazeal <donb@codesourcery.com> PR remote/19496 * infcmd.c (notice_new_inferior): Use the 'leave_running' argument instead of checking the 'non_stop' global. * remote.c (remote_add_thread): New parameter 'executing'. Use it to set the new thread's executing state. (remote_notice_new_inferior): Rename parameter 'running' to 'executing'. Always set the thread state to THREAD_RUNNING in non-stop mode, and to THREAD_STOPPED in all-stop mode. Pass EXECUTING to remote_add_thread and notice_new_inferior. (remote_update_thread_list): Update to pass executing state, not running state.
2016-03-17S390: Add syscall info for syscalls up to 374Andreas Arnez3-0/+56
Represent new Linux syscalls for s390 and s390x in GDB's syscall info. Add the syscalls from 355 (userfaultfd) up to 374 (mlock2) as well as the previously reserved NUMA syscalls 268-270, 287, and 310. gdb/ChangeLog: * syscalls/s390-linux.xml: Add NUMA syscalls and new syscalls up to 374. * syscalls/s390x-linux.xml: Likewise.
2016-03-17S390: Fix output path for s390-multiarch test caseAndreas Arnez2-5/+9
Since test artifacts are organized in a directory hierarchy, the s390-multiarch test case is not executed correctly any more. This is because it uses an obsolete way of constructing the output paths. This fix invokes standard_testfile instead. gdb/testsuite/ChangeLog: * gdb.arch/s390-multiarch.exp: Use standard_testfile instead of maintaining separate logic for constructing the output path.
2016-03-17linux-record: Simplify with record_mem_at_reg()Andreas Arnez2-414/+170
The function record_linux_system_call() often records a memory area whose address is contained in a register. So far this required two function calls: one for fetching the register value, and another one for recording the memory area. These two function calls are now merged into a new local helper function, and all occurrences are adjusted. This reduces the source code and makes it more readable. gdb/ChangeLog: * linux-record.c (record_mem_at_reg): New helper function. (record_linux_system_call): Exploit new helper function where applicable.
2016-03-17linux-record.c: Fix whitespace issuesAndreas Arnez2-949/+954
This patch changes whitespace only, fixing whitespace issues in linux-record.c. gdb/ChangeLog: * linux-record.c: Fix whitespace issues; tabify, remove trailing spaces.
2016-03-17linux-record: Fix bad fall-through for pipe/pipe2Andreas Arnez2-0/+7
This patch added handling for some syscalls to linux-record.c: https://sourceware.org/ml/gdb-patches/2015-10/msg00452.html But for both `pipe' and `pipe2' the patch lacks a statement after an `if', such that the following `break' is interpreted as the `if'-body instead. This adds the missing (return-) statements for the conditionals. gdb/ChangeLog: * linux-record.c (record_linux_system_call): Add missing return statements to handling of pipe and pipe2 syscalls.
2016-03-16PR remote/19496, interrupted syscall in forking-threads-plus-bkptDon Breazeal3-14/+33
This patch addresses "fork:Interrupted system call" (or wait:) failures in gdb.threads/forking-threads-plus-breakpoint.exp. The test program spawns ten threads, each of which do ten fork/waitpid sequences. The cause of the problem was that when one of the fork children exited before the corresponding fork parent could initiate its waitpid for that child, a SIGCHLD and/or SIGSTOP was delivered and interrupted a fork or waitpid in another thread. The fix was to wrap the system calls in a loop to retry the call if it was interrupted, like: do { pid = fork (); } while (pid == -1 && errno == EINTR); Since this is a Linux-only test I figure it is OK to use errno and EINTR. I tried a number of alternative fixes using SIG_IGN, SA_RESTART, pthread_sigblock, and bsd_signal, but none of these worked as well. Tested on Nios II Linux target with x86 Linux host. gdb/testsuite/ChangeLog: 2016-03-16 Don Breazeal <donb@codesourcery.com> * gdb.threads/forking-threads-plus-breakpoint.c (thread_forks): Retry fork and waitpid on interrupted system call errors. * gdb.threads/forking-threads-plus-breakpoint.exp: (do_test): Use with_timeout_factor to increase timeout to 90.
2016-03-16xml-tdesc.c (tdesc_start_enum): Fix c++ build.Doug Evans2-2/+6
gdb/ChangeLog: * xml-tdesc.c (tdesc_start_enum): Fix c++ build.
2016-03-16Process record: Fix arm-linux syscall argumentsYao Qi2-3/+14
Arguments are passed in r0-r6 on arm linux syscall (both EABI and OABI). This patch is to set arm_linux_record_tdep.arg{1-7} to the right register number. This patch fixes the following test failures... -FAIL: gdb.reverse/getresuid-reverse.exp: check ruid record -FAIL: gdb.reverse/getresuid-reverse.exp: check rgid record -FAIL: gdb.reverse/pipe-reverse.exp: check pipe record -FAIL: gdb.reverse/readv-reverse.exp: check readv record -FAIL: gdb.reverse/readv-reverse.exp: check readv record -FAIL: gdb.reverse/readv-reverse.exp: check readv record -FAIL: gdb.reverse/readv-reverse.exp: check readv record -FAIL: gdb.reverse/waitpid-reverse.exp: check waitpid record gdb: 2016-03-16 Yao Qi <yao.qi@linaro.org> * arm-linux-tdep.c (arm_linux_init_abi): Fix arm_linux_record_tdep.arg1, arm_linux_record_tdep.arg2 and arm_linux_record_tdep.arg3. Set arm_linux_record_tdep.arg4, arm_linux_record_tdep.arg5, arm_linux_record_tdep.arg6, and arm_linux_record_tdep.arg7.
2016-03-15PR 18303, Tolerate malformed input for lookup_symbol-called functionsDon Breazeal10-182/+433
lookup_symbol is often called with user input. Consequently, any function called from lookup_symbol{,_in_language} should attempt to deal with malformed input gracefully. After all, malformed user input is not a programming/API error. This patch does not attempt to find/correct all instances of this. It only fixes locations in the code that trigger test suite failures. This patch fixes PR breakpoints/18303, "Assertion: -breakpoint-insert with windows paths of file in non-current directory". The patch includes three new tests related to this. One is just gdb.linespec/ls-errs.exp copied and converted to use C++ instead of C, and to add a case using a file name containing a Windows-style logical drive specifier. The others include an MI test to provide a regression test for the specific case reported in PR 18303, and a C++ test for proper error handling of access to a program variable when using a file scope specifier that refers to a non-existent file. Tested on x86_64 native Linux. gdb/ChangeLog 2016-01-28 Keith Seitz <keiths@redhat.com> PR breakpoints/18303 * cp-namespace.c (cp_lookup_bare_symbol): Change assertion to look for "::" instead of simply ":". (cp_search_static_and_baseclasses): Return null_block_symbol for malformed input. Remove assertions. * cp-support.c (cp_find_first_component_aux): Do not return a prefix length for ':' unless the next character is also ':'. gdb/testsuite/ChangeLog 2016-01-28 Don Breazeal <donb@codesourcery.com> * gdb.cp/scope-err.cc: New test program. * gdb.cp/scope-err.exp: New test script. * gdb.linespec/ls-errs.c (myfunction): Expanded to have multiple lines and "set breakpoint here" comment. * gdb.linespec/ls-errs.exp: Added C++ testing and new test case. Fixed some whitespace and format issues. * gdb.mi/mi-linespec-err-cp.cc: New test program. * gdb.mi/mi-linespec-err-cp.exp: New test script.
2016-03-15Add cole945@ to earlier entry. Fix typo in same entry.Doug Evans1-1/+2
2016-03-15Add cpsr_flags to aarch64 core regs.Doug Evans3-2/+46
gdb/ChangeLog: * features/aarch64-core.xml (cpsr_flags): New flags type. (cpsr): Use it. * features/aarch64.c: Regenerate.
2016-03-15Remove "end" spec.Doug Evans6-79/+87
gdb/ChangeLog: * features/i386/32bit-core.xml (i386_eflags): Remove "end" spec. * features/i386/32bit-sse.xml (i386_eflags): Ditto. * features/i386/64bit-core.xml (i386_eflags): Ditto. * features/i386/64bit-sse.xml (i386_eflags): Ditto. * features/i386/x32-core.xml (i386_eflags): Ditto.
2016-03-15Extend flags to support multibit and enum bitfields.Doug Evans16-209/+724
gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15Use int instead of LONGEST in tdesc_type sizes.Doug Evans4-13/+75
gdb/ChangeLog: * target-descriptions.c (struct tdesc_type) <u.u.size>: Change type from LONGEST to int. (struct tdesc_type) <u.f.size>: Ditto. (tdesc_set_struct_size): Change type of "size" arg from LONGEST to int. Add assertion size > 0. (tdesc_create_flags): Ditto. * target-descriptions.h (tdesc_set_struct_size): Update. (tdesc_create_flags): Update. * xml-tdesc.c (MAX_FIELD_SIZE, MAX_FIELD_BITSIZE): New macros. (MAX_VECTOR_SIZE): New macro. (tdesc_start_struct): Catch conversion errors from LONGEST to int. (tdesc_start_flags, tdesc_start_field, tdesc_start_vector): Ditto.
2016-03-15maint_print_c_tdesc_cmd: Use type for TYPE_CODE_FLAGS instead of field_type.Doug Evans26-767/+800
gdb/ChangeLog: * target-descriptions.c (maint_print_c_tdesc_cmd): Use "type" for TYPE_CODE_FLAGS instead of "field_type", for consistency. * features/i386/amd64-avx-linux.c: Regenerate. * features/i386/amd64-avx.c: Regenerate. * features/i386/amd64-avx512-linux.c: Regenerate. * features/i386/amd64-avx512.c: Regenerate. * features/i386/amd64-linux.c: Regenerate. * features/i386/amd64-mpx-linux.c: Regenerate. * features/i386/amd64-mpx.c: Regenerate. * features/i386/amd64.c: Regenerate. * features/i386/i386-avx-linux.c: Regenerate. * features/i386/i386-avx.c: Regenerate. * features/i386/i386-avx512-linux.c: Regenerate. * features/i386/i386-avx512.c: Regenerate. * features/i386/i386-linux.c: Regenerate. * features/i386/i386-mmx-linux.c: Regenerate. * features/i386/i386-mmx.c: Regenerate. * features/i386/i386-mpx-linux.c: Regenerate. * features/i386/i386-mpx.c: Regenerate. * features/i386/i386.c: Regenerate. * features/i386/x32-avx-linux.c: Regenerate. * features/i386/x32-avx.c: Regenerate. * features/i386/x32-avx512-linux.c: Regenerate. * features/i386/x32-avx512.c: Regenerate. * features/i386/x32-linux.c: Regenerate. * features/i386/x32.c: Regenerate.
2016-03-15Remove hand-called function from test.Doug Evans3-7/+17
gdb/testsuite/ChangeLog: * gdb.base/skip.c (main): Call test_skip_file_and_function. * gdb.base/skip.exp: Remove hand calling test_skip_file_and_function.
2016-03-15Fix PR gdb/19676: Internal error in linux-thread.db.c if /proc not mountedPedro Alves2-6/+20
If /proc is not mounted, GDB fails an assertion in find_new_threads_once: Continuing. .../src/gdb/linux-thread-db.c:1249: internal-error: find_new_threads_once: Assertion `!target_has_execution' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) That was supposed to catch misuses of td_ta_thr_iter, which is unsafe for live debugging. However, if /proc is not mounted, we still fallback to using it. I didn't bother with a warning, because GDB already prints several others related to failing to open /proc files. gdb/ChangeLog: 2016-03-15 Pedro Alves <palves@redhat.com> PR gdb/19676 * linux-thread-db.c (try_thread_db_load_1): Leave info->td_ta_thr_iter_p NULL iff debugging a live process and we have /proc access. (find_new_threads_once): Assert that we have a non-NULL info->td_ta_thr_iter_p instead of checking whether the target has execution.
2016-03-15Fix PR gdb/19676: Disable displaced stepping if /proc not mountedPedro Alves3-2/+12
On GNU/Linux archs that support displaced stepping, if /proc is not mounted, GDB gets stuck not able to step past breakpoints: (gdb) c Continuing. dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163 2163 LIBC_PROBE (init_complete, 2, LM_ID_BASE, r); Cannot find AT_ENTRY auxiliary vector entry. (gdb) c Continuing. dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163 2163 LIBC_PROBE (init_complete, 2, LM_ID_BASE, r); Cannot find AT_ENTRY auxiliary vector entry. (gdb) That's because GDB can't figure out where the scratch pad is. This is a regression introduced by the earlier changes to make the Linux native target always work in non-stop mode. This commit makes GDB detect the case and fallback to stepping over breakpoints in-line. gdb/ChangeLog: 2016-03-15 Pedro Alves <palves@redhat.com> PR gdb/19676 * infrun.c (displaced_step_prepare): Also disable displaced stepping on NOT_SUPPORTED_ERROR. * linux-tdep.c (linux_displaced_step_location): If reading auxv fails, throw NOT_SUPPORTED_ERROR instead of generic error.
2016-03-15Fix typo in previous gdb/doc/ commitPedro Alves2-1/+5
Should be s/reliability/reliably/. gdb/doc/ChangeLog: 2016-03-15 Pedro Alves <palves@redhat.com> * gdb.texinfo (Tracepoint Actions): Fix typo.
2016-03-15Document possible unreliability of '$_ret'Pedro Alves2-0/+14
gdb/doc/ChangeLog: 2016-03-15 Pedro Alves <palves@redhat.com> Andreas Arnez <arnez@linux.vnet.ibm.com> Marcin Kościelnicki <koriakin@0x04.net> * gdb.texinfo (Tracepoint Actions): Document possible unreliability of '$_ret'.
2016-03-14gdb.base/default.exp: Add missing $_as_string to "show convenience" testSimon Marchi2-0/+6
When adding the $_as_string convenience function, I missed a new test failure in default.exp. The tests lists the convenience functions, so $_as_string should be added to the expected list. Fixes: +FAIL: gdb.base/default.exp: show convenience ($_caller_is = <internal function _caller_is> not found) gdb/testsuite/ChangeLog: * gdb.base/default.exp: Add $_as_string to the list of expected convenience functions.
2016-03-13gdb/s390: Fill gen_return_address hook.Marcin Kościelnicki2-0/+20
gdb/ChangeLog: * s390-linux-tdep.c (s390_gen_return_address): New function. (s390_gdbarch_init): Fill gen_return_address hook.
2016-03-11gdb: New maint info line-table command.Andrew Burgess7-0/+138
Add a new command 'maint info line-table' to display the contents of GDB's internal line table structure. Useful when trying to understand problems (within gdb) relating to line tables. gdb/ChangeLog: * symmisc.c (maintenance_info_line_tables): New function. (maintenance_print_one_line_table): New function. (_initialize_symmisc): Register 'maint info line-table' command. * NEWS: Mention new command. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new 'maint info line-table' command. gdb/testsuite/ChangeLog: * gdb.base/maint.exp: New tests for 'maint info line-table'.
2016-03-11gdb/s390: Fill pseudo register agent expression hooks.Marcin Kościelnicki2-0/+91
gdb/ChangeLog: * s390-linux-tdep.c (s390_ax_pseudo_register_collect): New function. (s390_ax_pseudo_register_push_stack): New function. (s390_gdbarch_init): Fill ax_pseudo_register_collect and ax_pseudo_register_push_stack hooks.
2016-03-10Add $_as_string convenience functionSimon Marchi9-0/+145
This patch is a follow-up to "Add printf format specifier for printing enumerator": https://sourceware.org/ml/gdb-patches/2016-02/msg00144.html Instead of having a solution specific to the printf command, Pedro suggested adding a general purpose function $_as_string() that would cover this use case and more. So, in order to print the textual label of an enum, one can use: (gdb) printf "Visiting node of type %s\n", $_as_string(node) Visiting node of type NODE_INTEGER gdb/ChangeLog: * data-directory/Makefile.in (PYTHON_FILE_LIST): Install gdb/function/as_string.py. * python/lib/gdb/function/as_string.py: New file. * NEWS: Mention the new $_as_string function. gdb/testsuite/ChangeLog: * gdb.python/py-as-string.exp: New file. * gdb.python/py-as-string.c: New file. gdb/doc/ChangeLog: * gdb.texinfo (Convenience Functions): Document $_as_string.
2016-03-09More "Program" -> "Thread NN received signal" testsuite adjustmentPedro Alves10-11/+24
These tests should have been adjusted by f303dbd60d9c (Fix PR threads/19422 - show which thread caused stop), but clearly I had missed grepping for potential-fail cases. gdb/testsuite/ChangeLog 2016-03-09 Pedro Alves <palves@redhat.com> * gdb.threads/attach-into-signal.exp: Adjust to "Program received signal" -> "Thread NN received signal" output change. * gdb.threads/ia64-sigill.exp: Likewise. * gdb.threads/linux-dp.exp: Likewise. * gdb.threads/manythreads.exp: Likewise. * gdb.threads/pending-step.exp: Likewise. * gdb.threads/print-threads.exp: Likewise. * gdb.threads/sigstep-threads.exp: Likewise. * gdb.threads/staticthreads.exp: Likewise. * gdb.threads/tls.exp: Likewise.
2016-03-09gdb: fix doc string of target_can_use_hardware_watchpoint.Jose E. Marchesi2-1/+6
gdb/ChangeLog 2016-03-09 Jose E. Marchesi <jose.marchesi@oracle.com> * target.h: Fix doc string of target_can_use_hardware_watchpoint.
2016-03-09Command line input handling TLCPedro Alves5-318/+219
I didn't manage to usefully split this further into smaller independent pieces, so: - Use "struct buffer" more. - Split out the responsibility of composing a complete command line from multiple input lines split with backslash ( E.g.: (gdb) print \ 1 + \ 2 $1 = 3 (gdb) ) to a separate function. Note we don't need the separate readline_input_state and more_to_come globals at all. They were just obfuscating the logic. - Factor out the tricky mostly duplicated code in command_line_handler and command_line_input. gdb/ChangeLog 2016-03-09 Pedro Alves <palves@redhat.com> * event-top.c (more_to_come): Delete. (struct readline_input_state): Delete. (readline_input_state): Delete. (get_command_line_buffer): New function. (command_handler): Update comments. Don't handle NULL commands here. Do not execute commented lines. (command_line_append_input_line): New function. (handle_line_of_input): New function, partly based on command_line_handler and command_line_input. (command_line_handler): Rewrite. * event-top.h (command_handler): New declaration. (command_loop): Defer command execution to command_handler. (command_line_input): Update comments. Simplify, using struct buffer and handle_line_of_input. * top.h (struct buffer): New forward declaration. (handle_line_of_input): New declaration.
2016-03-09Simplify saved_command_line handlingPedro Alves5-21/+19
There doesn't seem to be much point in trying to reuse this buffer. Prefer simplicity instead. (In case you're wondering whether this fixes an off-by-one: linelength is misnamed; it's really a size including terminating null char.) gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * event-top.c (command_line_handler): Use xfree + xstrdup instead of xrealloc + strcpy. * main.c (captured_main): Use xstrdup instead of xmalloc plus manual clear. * top.c (saved_command_line): Rewrite comment. (saved_command_line_size): Delete. (command_line_input): Use xfree + xstrdup instead of xrealloc + strcpy. * top.h (saved_command_line_size): Delete declaration.
2016-03-09Use struct buffer in gdb_readline_no_editing_callbackPedro Alves2-20/+25
gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * event-top.c: Include buffer.h. (gdb_readline_no_editing_callback): Use struct buffer instead of xrealloc.
2016-03-09Use struct buffer in gdb_readline_no_editingPedro Alves3-22/+34
gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * common/buffer.h (buffer_grow_char): New function. * top.c: Include buffer.h. (gdb_readline_no_editing): Rename 'prompt_arg' parameter to 'prompt'. Use struct buffer instead of xrealloc.
2016-03-09gdb_readline -> gdb_readline_no_editingPedro Alves3-5/+10
Name this such that it's clearer that this is not a wrapper for the real readline, but instead a replacement that provides no command line editing features. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * defs.h (gdb_readline): Delete declaration. * top.c (gdb_readline): Rename to ... (gdb_readline_no_editing): ... this, and make static.
2016-03-09Update prompt_for_continue commentsPedro Alves2-14/+12
These comments are out of date -- we no longer call gdb_readline. And I think that mentioning the event loop is more useful here than whatever GO32 issue had with gdb_readline, which may even no longer be an issue. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * utils.c (prompt_for_continue): Update comments.
2016-03-09Eliminate async_annotation_suffixPedro Alves4-43/+16
The comments and existence of this global are a bit of misleading obfuscation, since this is only ever used to print the prompt annotation, and never changes. Just hardcode "prompt" where necessary, as done for most other annotations. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * event-top.c (async_annotation_suffix): Delete. (top_level_prompt, command_line_handler): Don't use 'async_annotation_suffix' and simplify. * event-top.h (async_annotation_suffix): Delete declaration. (init_main): Remove reference to 'async_annotation_suffix'.
2016-03-09gdb_readline2 -> gdb_readline_no_editing_callbackPedro Alves4-20/+31
The "2" in "gdb_readline2" doesn't really convey much. Rename for clarity. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * event-top.c (gdb_readline2): Rename to ... (gdb_readline_no_editing_callback): ... this. (change_line_handler, stdin_event_handler) (gdb_setup_readline): Adjust. * event-top.h (gdb_readline2): Rename to ... (gdb_readline_no_editing_callback): ... this, and move closer to other readline-related declarations. * mi/mi-interp.c (mi_interpreter_resume): Adjust.
2016-03-09Garbage collect window_hookPedro Alves2-9/+5
I checked, and Insight doesn't set this. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * top.c (window_hook): Delete. (command_loop): Remove references to window_hook.
2016-03-09Test issuing a command split in multiple lines with continuation charsPedro Alves2-0/+40
I happened to break this locally and the testsuite didn't notice it. Add some tests. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * gdb.base/command-line-input.exp: New file.
2016-03-09gdb: Add tracepoint support for powerpc.Marcin Kościelnicki8-3/+31
gdb/gdbserver/ChangeLog: * linux-ppc-low.c (ppc_supports_tracepoints): New function. (struct linux_target_ops): Wire in the above. gdb/testsuite/ChangeLog: * gdb.trace/ftrace.exp: Set arg0exp for ppc. * gdb.trace/mi-trace-unavailable.exp: Set pcnum for ppc. * gdb.trace/pending.exp: Accept leading dot before function name. * gdb.trace/trace-common.h: Add fast tracepoint dummy insn for ppc. * lib/trace-support.exp: Set registers for ppc.
2016-03-09gdb.trace/entry-values.exp: Fixes for powerpc64.Marcin Kościelnicki2-4/+14
On powerpc64, "disassemble foo" doesn't work properly on object files (it can't process the relocations in .opd section) - instead, let's link it into an executable and load that. Also, backtrace displays .main, not main. Accept both. gdb/testsuite/ChangeLog: * gdb.trace/entry-values.exp: Link ${binfile}1.o to ${binfile}1 and use it for disassembly; accept .main in addition to main in backtrace.
2016-03-09gdb.trace/tfind.exp: Force call via global entry point on ppc64le.Marcin Kościelnicki2-2/+16
tfind.exp sets a breakpoint on *gdb_recursion_test, which is the global entry point on ppc64le, and won't be hit, since the call uses the local entry. Fix by calling the function via a pointer in a global variable, forcing use of the global entry. This patch is a slightly modified hunk extracted from https://sourceware.org/ml/gdb-patches/2015-07/msg00353.html gdb/testsuite/ChangeLog: 2016-03-09 Wei-cheng Wang <cole945@gmail.com> Marcin Kościelnicki <koriakin@0x04.net> * gdb.trace/actions.c (gdb_recursion_test_fp): New typedef. (gdb_recursion_test_ptr): New global variable. (gdb_recursion_test): Call gdb_recursion_test_ptr instead of gdb_recursion_test. (gdb_c_test): Ditto.
2016-03-09gdb.trace/change-loc.exp: Don't depend on tracepoint ordering.Marcin Kościelnicki2-4/+21
powerpc (32-bit) loads shared libraries below the main executable, so the PENDING location is the first one, which the current regex doesn't match. Split it into two tests instead, one looking for the pending tracepoint location, and the other for two installed locations. gdb/testsuite/ChangeLog: * gdb.trace/change-loc.exp: Don't depend on tracepoint location ordering.
2016-03-09gdb.trace: Use manually-defined start labels in unavailable-dwarf-piece.expMarcin Kościelnicki3-4/+13
On powerpc64, foo/bar point to a function descriptor, not to function code. Since there are no global labels pointing at the actual function code, let's make our own. Regression-tested on x86_64. gdb/testsuite/ChangeLog: * gdb.trace/unavailable-dwarf-piece.c (foo): Add foo_start_lbl label. (bar): Add bar_start_lbl label. * gdb.trace/unavailable-dwarf-piece.exp: Use foo/bar_start_lbl instead of foo/bar for emitting DWARF and tracing.
2016-03-09gdb/rs6000: Read backchain as unsigned.Marcin Kościelnicki4-3/+30
Previously, backchain was read as a signed quantity, resulting in addresses like 0xfffffffffffeded0 instead of 0xfffeded0 returned by unwinder on 32-bit powerpc. While normally such addresses are masked off, this causes problems for tracepoints, since 0xfffffffffffeded0 is considered unavailable. Fixes a test failure in gdb.trace/entry-values.exp. gdb/ChangeLog: * corefile.c (safe_read_memory_unsigned_integer): New function. * gdbcore.h (safe_read_memory_unsigned_integer): New prototype. * rs6000-tdep.c (rs6000_frame_cache): Read backchain as unsigned.
2016-03-09gdb: Add gen_return_address for powerpc.Marcin Kościelnicki2-0/+23
gdb/ChangeLog: * rs6000-tdep.c: Add "ax.h" and "ax-gdb.h" includes. (rs6000_gen_return_address): New function. (rs6000_gdbarch_init): Wire in the above.
2016-03-09gdb: Add ax_pseudo_register_collect for powerpc.Marcin Kościelnicki2-0/+51
gdb/ChangeLog: * rs6000-tdep.c (rs6000_ax_pseudo_register_collect): New function. (rs6000_gdbarch_init): Wire in the above.
2016-03-09S390: Recognize special jumps in prologue parserAndreas Arnez2-2/+19
Functions compiled with the gcc option `-mhotpatch' may start with a branch-never BRCL instruction as a 6-byte NOP. And functions compiled with `-mstack-size' contain a BRC instruction in their prologue that is actually a conditional trap. Both of these special jumps cause the prologue parser to stop and yield bad unwinding results. This change makes the prologue analyzer recognize such special jumps and ignore them. gdb/ChangeLog: * s390-linux-tdep.c (s390_analyze_prologue): Ignore BRC and BRCL instructions that do nothing or are conditional traps.
2016-03-09S390: Add use of unavailable-stack frame IDAndreas Arnez2-5/+18
When determining the frame ID of an inline frame, GDB currently asserts that a valid ID of the underlying real frame is found, and that it does not match outer_frame_id. From inline_frame_this_id(): /* For now, require we don't match outer_frame_id either (see comment above). */ gdb_assert (!frame_id_eq (*this_id, outer_frame_id)); However, this assertion may fail when the real frame's unwinder can not determine the frame ID. This happened on an s390x target with a binary that lacked call frame information and also confused the prologue analyzer, because then s390_frame_this_id() left the frame ID at its default. To fix this, this change enhances s390_frame_this_id such that an unavailable-stack frame ID is built if no frame base can be determined but the function address is available. gdb/ChangeLog: * s390-linux-tdep.c (s390_prologue_frame_unwind_cache): Store frame func's PC in info->func before any other failure can occur. (s390_frame_this_id): Use frame_id_build_unavailable_stack if info->func has been filled out.
2016-03-09Avoid spaces in osabi namesPedro Alves2-9/+13
It's not possible today to select some of the osabis by name. Specifically, those that have spaces in their names and then the first word is ambiguous... For example: (gdb) set osabi <TAB> [...] FreeBSD ELF FreeBSD a.out [...] (gdb) set osabi FreeBSD ELF Ambiguous item "FreeBSD ELF". In reality, because "set osabi" is an enum command, that was equivalent to trying "set osabi FreeBSD", which is then obviously ambiguous, because of "FreeBSD ELF" and "FreeBSD a.out". Also, even if the first word is not ambiguous, we actually ignore whatever comes after the first word: (gdb) set osabi GNU/Linux (gdb) show osabi The current OS ABI is "GNU/Linux". The default OS ABI is "GNU/Linux". (gdb) set osabi Windows SomeNonsense ^^^^^^^^^^^^ (gdb) show osabi The current OS ABI is "Windows CE". The default OS ABI is "GNU/Linux". (gdb) Fix this by avoiding spaces in osabi names. We could instead make "set osabi" have a custom set hook, or alternatively make the enum set hook (in cli-setshow.c) handle values with spaces, but OTOH, I have a feeling that could cause trouble. E.g., in cases where we might want to write more than one enum value in the same line. We could support quoting as workaround, but, not sure we want that. "No spaces" seems like a simpler rule. gdb/ChangeLog: 2016-03-09 Pedro Alves <palves@redhat.com> * osabi.c (gdb_osabi_names): Avoid spaces in osabi names.