aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2015-03-26Handle the effect of skipping prologueYao Qi3-0/+36
break-asm-file.exp has some manually written dwarf to create some line number entries like this, [0x0000013d] Extended opcode 2: set Address to 0x40053f [0x00000144] Advance Line by 4 to 7 [0x00000146] Copy [0x00000147] Extended opcode 2: set Address to 0x400541 [0x0000014e] Advance Line by 1 to 8 [0x00000150] Copy [0x00000151] Extended opcode 2: set Address to 0x400547 [0x00000158] Extended opcode 1: End of Sequence 0x40053f is the start address of function func, and is mapped to line 7. 0x400541 is within function func, and is mapped to line 8. (gdb) disassemble /r 0x40053f,+8 Dump of assembler code from 0x40053f to 0x400547: 0x000000000040053f <func+0>: 00 00 add %al,(%rax) 0x0000000000400541 <func+2>: 00 00 add %al,(%rax) 0x0000000000400543 <func+4>: 00 00 add %al,(%rax) 0x0000000000400545 <func+6>: 00 00 add %al,(%rax) in the following test, (gdb) break a/break-asm-file0.s:func Breakpoint 1 at 0x40053f: file a/break-asm-file0.s, line 7. As we can see, breakpoint is set at the start address of function func on x86, which means no prologue is skipped. On other targets, such as arm and aarch64, breakpoint is set at the address *after* the start address, which is mapped to line 8. Then test fails. In fact, it is lucky this test doesn't fail on x86 and x86_64, whose gdbarch method skip_prologue doesn't reply on skip_prologue_using_sal if producer isn't clang. if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL)) { CORE_ADDR post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr); struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr); /* Clang always emits a line note before the prologue and another one after. We trust clang to emit usable line notes. */ if (post_prologue_pc && (cust != NULL && COMPUNIT_PRODUCER (cust) != NULL && startswith (COMPUNIT_PRODUCER (cust), "clang "))) return max (start_pc, post_prologue_pc); } so it doesn't return and go further to prologue analyser. Since ".int 0" isn't an instruction of prologue, nothing is skipped, starting address is used, and test passes. however, on targets which don't have such producer checking, the first line number entry is skipped, and skip_prologue_using_sal returns sal represents the second line number entry. The idea of this patch is to force GDB stop at somewhere which is stilled mapped to line 7 after skipping prologue. I choose to add a new line number entry for the following instruction but mapped to the same line (7), because I see the comments in dwarf2read.c, ... fact that two consecutive line number entries for the same line is a heuristic used by gcc to denote the end of the prologue. then the line table becomes: [0x000000d4] Extended opcode 2: set Address to 0x400529 [0x000000db] Advance Line by 4 to 7 [0x000000dd] Copy [0x000000de] Extended opcode 2: set Address to 0x40052a [0x000000e5] Advance Line by 0 to 7 [0x000000e7] Copy [0x000000e8] Extended opcode 2: set Address to 0x40052b [0x000000ef] Advance Line by 1 to 8 [0x000000f1] Copy [0x000000f2] Extended opcode 2: set Address to 0x40052c [0x000000f9] Extended opcode 1: End of Sequence gdb/testsuite: 2015-03-26 Yao Qi <yao.qi@linaro.org> PR testsuite/18139 * gdb.linespec/break-asm-file0.s (func): New label .Lfunc_2. Add a line number entry for the same line. * gdb.linespec/break-asm-file1.s (func): New label .Lfunc_2. Add a line number entry for the same line.
2015-03-26Remove some hard-coded stuff in testsYao Qi3-10/+23
There are some hard-coded stuff in .s files, such as .int 0 and address offset, which isn't portable. This patch is to replace ".int 0" with nop and address offset with labels. gdb/testsuite: 2015-03-26 Yao Qi <yao.qi@linaro.org> * gdb.linespec/break-asm-file0.s (func2): Use nop instead of .int 0. (func): Likewise. Add .Lfunc_1 label. Use .Lfunc_1 label. * gdb.linespec/break-asm-file1.s (func3): Use nop instead of .int 0. (func): Likewise. Use .Lfunc_1 label.
2015-03-26Compile break-asm-file{0,1}.s without debug infoYao Qi2-5/+24
If I add some nop into break-asm-file1.s like this, --- INDEX:/gdb/testsuite/gdb.linespec/break-asm-file1.s +++ WORKDIR:/gdb/testsuite/gdb.linespec/break-asm-file1.s @@ -31,8 +31,8 @@ _func: .type func, %function func: .Lbegin_func: - .int 0 - .int 0 + nop + nop .Lend_func: .size func, .-func .Lend_text1: I get the following error: Running gdb/testsuite/gdb.linespec/break-asm-file.exp ... gdb/testsuite/gdb.linespec/break-asm-file1.s: Assembler messages:^M gdb/testsuite/gdb.linespec/break-asm-file1.s: Fatal error: duplicate .debug_line sections break-asm-file0.s and break-asm-file1.s have already had debug information (written manually), so don't need to generate debug infor for them. gdb/testsuite: 2015-03-26 Yao Qi <yao.qi@linaro.org> * gdb.linespec/break-asm-file.exp: Don't call prepare_for_testing. Call gdb_compile instead to compile each .s files without debug information.
2015-03-26Relax pattern to match the output of "info frame" in gdb.base/savedregs.expYao Qi2-1/+6
Hi, I see the following two fails in gdb.base/savedregs.exp on aarch64-linux, info frame 2^M Stack frame at 0x7ffffffa60:^M pc = 0x40085c in thrower (/home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.base/savedregs.c:49); saved pc = 0x400898^M called by frame at 0x7ffffffa70, caller of frame at 0x7fffffe800^M source language c.^M Arglist at 0x7ffffffa60, args: ^M Locals at 0x7ffffffa60, Previous frame's sp is 0x7ffffffa60^M (gdb) FAIL: gdb.base/savedregs.exp: Get thrower info frame info frame 2^M Stack frame at 0x7fffffe800:^M pc = 0x400840 in catcher (/home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.base/savedregs.c:42); saved pc = 0x7fb7ffc350^M called by frame at 0x7fffffe800, caller of frame at 0x7fffffe7e0^M source language c.^M Arglist at 0x7fffffe7f0, args: sig=11^M Locals at 0x7fffffe7f0, Previous frame's sp is 0x7fffffe800 (gdb) FAIL: gdb.base/savedregs.exp: Get catcher info frame looks the test expects to match "Saved registers:" from the output of "info frame", but no registers are saved on these two frames, because thrower and catcher are simple and leaf functions. (gdb) disassemble thrower Dump of assembler code for function thrower: 0x0000000000400858 <+0>: mov x0, #0x0 // #0 0x000000000040085c <+4>: strb wzr, [x0] 0x0000000000400860 <+8>: ret End of assembler dump. (gdb) disassemble catcher Dump of assembler code for function catcher: 0x0000000000400838 <+0>: sub sp, sp, #0x10 0x000000000040083c <+4>: str w0, [sp,#12] 0x0000000000400840 <+8>: adrp x0, 0x410000 0x0000000000400844 <+12>: add x0, x0, #0xb9c 0x0000000000400848 <+16>: mov w1, #0x1 // #1 0x000000000040084c <+20>: str w1, [x0] 0x0000000000400850 <+24>: add sp, sp, #0x10 0x0000000000400854 <+28>: ret There are two ways to fix these fails, one is to modify functions to force some registers saved (for example, doing function call in them), and the other one is to relax the pattern to optionally match "Saved registers:". I did both, and feel that the latter is simple, so here is it. gdb/testsuite: 2015-03-26 Yao Qi <yao.qi@linaro.org> * gdb.base/savedregs.exp (process_saved_regs): Make "Saved registers:" optional in the pattern.
2015-03-25btrace: fix tests for 32-bitMarkus Metzger17-428/+1057
The x86-record_goto.S assembly source file does not build on 32-bit. This breaks many tests that use this file. Split it into x86_64-record_goto.S and i686-record_goto.S. Luckily, we can use either one with the same test .exp file. It further turned out that most tests do not really need a fixed binary; they should work pretty well with a newly-compiled C program. The one thing that breaks this is the heavy use of "record goto" to navigate inside the recorded execution. Combine step.exp, next,exp, and finish.exp into a single test step.exp and use normal stepping and reverse-stepping commands for navigation. testsuite/ * gdb.btrace/next.exp: Merged into step.exp. * gdb.btrace/finish.exp: Merged into step.exp. * gdb.btrace/nexti.exp: Merged into stepi.exp. * gdb.btrace/step.exp: Use record_goto.c as test file. Avoid using "record goto" and checking the exact replay position. * gdb.btrace/stepi.exp: Choose test file based on target. Do not check for "Recording format" in "info record" output. * gdb.btrace/record_goto.exp: Choose test file based on target. * gdb.btrace/x86-record_goto.S: Renamed into ... * gdb.btrace/x86_64-record_goto.S: ... this. * gdb.btrace/i686-record_goto.S: New. * gdb.btrace/x86-tailcall.S: Renamed into ... * gdb.btrace/x86_64-tailcall.S: ... this. * gdb.btrace/i686-tailcall.S: New. * gdb.btrace/x86-tailcall.c: Renamed into ... * gdb.btrace/tailcall.c: ... this. Split "return ++answer" into two separate statements. Update test. * gdb.btrace/delta.exp: Use record_goto.c as test file. * gdb.btrace/gcore.exp: Use record_goto.c as test file. * gdb.btrace/nohist.exp: Use record_goto.c as test file. * gdb.btrace/tailcall.exp: Choose test file based on target. * gdb.btrace/Makefile.in: Remove next, finish, and nexti.
2015-03-25btrace: increase buffer size for exception testMarkus Metzger2-0/+6
The trace for throwing and catching an exception can be quite big. Increase the buffer size to avoid spurious fails. testsuite/ * gdb.btrace/exception.exp: Increase BTS buffer size.
2015-03-25Simplify target_async hook interfacePedro Alves9-68/+70
All callers of target_async pass it the same callback (inferior_event_handler). Since both common code and target backends need to be able to put the target in and out of target async mode at any given time, there's really no way that a different callback could be passed. This commit simplifies things, and removes the indirection altogether. Bonus: with this, gdb's target_async method ends up with the same signature as gdbserver's. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-25 Pedro Alves <palves@redhat.com> * target.h <to_async>: Replace 'callback' and 'context' parameters with boolean 'enable' parameter. (target_async): Replace CALLBACK and CONTEXT parameters with boolean ENABLE parameter. * inf-loop.c (inferior_event_handler): Adjust. * linux-nat.c (linux_nat_attach, linux_nat_resume) (linux_nat_resume): Adjust. (async_client_callback, async_client_context): Delete. (handle_target_event): Call inferior_event_handler directly. (linux_nat_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. Remove references to async_client_callback and async_client_context. (linux_nat_close): Adjust. * record-btrace.c (record_btrace_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_btrace_resume): Adjust. * record-full.c (record_full_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. (record_full_resume, record_full_core_resume): Adjust. * remote.c (struct remote_state) <async_client_callback, async_client_context>: Delete fields. (remote_start_remote, extended_remote_attach_1, remote_resume) (extended_remote_create_inferior): Adjust. (remote_async_serial_handler): Call inferior_event_handler directly. (remote_async): Replace 'callback' and 'context' parameters with boolean 'enable' parameter. Adjust. * top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper): Adjust. * target-delegates.c: Regenerate.
2015-03-25Associate target_ops with target_fileio file descriptorsGary Benson2-52/+132
Various target_fileio_* functions use integer file descriptors to refer to open files. File operation functions are looked up from the target stack as they are used, which causes problems if the target stack changes after the file is opened. For example, if a file is opened on a remote target and the remote target disconnects or closes the remote target will be popped off the stack. If target_fileio_close is then called on that file and "set auto-connect-native-target" is "on" (the default) then the native target's close method will be called. If the file opened on the remote happens to share the same number with a file open in GDB then that file will be closed by mistake. This commit changes target_fileio_open to store newly opened file descriptors in a table together with the target_ops used to open them. The index into the table is returned and used as the file descriptor argument to all target_fileio_* functions that accept file descriptor arguments. gdb/ChangeLog: * target.c (fileio_ft_t): New typedef, define object vector. (fileio_fhandles): New static variable. (is_closed_fileio_fh): New macro. (lowest_closed_fd): New static variable. (acquire_fileio_fd): New function. (release_fileio_fd): Likewise. (fileio_fd_to_fh): New macro. (target_fileio_open): Wrap the file descriptor on success. (target_fileio_pwrite): Updated to use wrapped file descriptor. (target_fileio_pread): Likewise. (target_fileio_close): Likewise.
2015-03-24Fix "thread apply all" with exited threadsPedro Alves4-5/+23
I noticed that "thread apply all" sometimes crashes. The problem is that thread_apply_all_command doesn take exited threads into account, and we qsort and then walk more elements than there really ever were put in the array. Valgrind shows: The current thread <Thread ID 3> has terminated. See `help thread'. (gdb) thread apply all p 1 Thread 1 (Thread 0x7ffff7fc2740 (LWP 29579)): $1 = 1 ==29576== Use of uninitialised value of size 8 ==29576== at 0x639CA8: set_thread_refcount (thread.c:1337) ==29576== by 0x5C2C7B: do_my_cleanups (cleanups.c:155) ==29576== by 0x5C2CE8: do_cleanups (cleanups.c:177) ==29576== by 0x63A191: thread_apply_all_command (thread.c:1477) ==29576== by 0x50374D: do_cfunc (cli-decode.c:105) ==29576== by 0x506865: cmd_func (cli-decode.c:1893) ==29576== by 0x7562CB: execute_command (top.c:476) ==29576== by 0x647DA4: command_handler (event-top.c:494) ==29576== by 0x648367: command_line_handler (event-top.c:692) ==29576== by 0x7BF7C9: rl_callback_read_char (callback.c:220) ==29576== by 0x64784C: rl_callback_read_char_wrapper (event-top.c:171) ==29576== by 0x647CB5: stdin_event_handler (event-top.c:432) ==29576== ... This can happen easily today as linux-nat.c/linux-thread-db.c are forgetting to purge non-current exited threads. But even with that fixed, we can always do "thread apply all" with an exited thread selected, which won't be deleted until the user switches to another thread. That's what the test added by this commit exercises. Tested on x86_64 Fedora 20. gdb/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * thread.c (thread_apply_all_command): Take exited threads into account. gdb/testsuite/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Test "thread apply all".
2015-03-24Fix switch_back_to_stepped_thread comment referencesPedro Alves2-4/+9
Whoops, switch_back_to_stepping doesn't exist... gdb/ 2015-03-24 Pedro Alves <palves@redhat.com> * infrun.c (resume, proceed): Mention switch_back_to_stepped_thread, not switch_back_to_stepping.
2015-03-24Shuffle user_visible_resume_ptidPedro Alves3-17/+29
... and move comment to declaration. gdb/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * infrun.c (user_visible_resume_ptid): Rewrite going from most-locked to unlocked instead of the opposite. Move comment ... * infrun.h (user_visible_resume_ptid): ... here.
2015-03-24Debug output tweaks in the Linux target backendsPedro Alves4-25/+73
This adds/tweaks a few debug logs I found useful recently. gdb/gdbserver/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Tweak debug log output. Also dump TRAP_TRACE. (linux_low_filter_event): In debug output, distinguish a resume_stop SIGSTOP from a delayed SIGSTOP. gdb/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_nat_resume): Output debug logs before trying to resume the event lwp. Use the lwp's ptid instead of the passed in (maybe wildcard) ptid. (stop_wait_callback): Tweak debug log output. (check_stopped_by_breakpoint): Tweak debug log output. Also dump TRAP_TRACE. (linux_nat_filter_event): In debug output, distinguish a resume_stop SIGSTOP from a delayed SIGSTOP. Output debug logs before trying to resume the lwp.
2015-03-24Do not make "prop" field of struct dynamic_prop_list a pointer.Joel Brobecker3-5/+11
struct dynamic_prop_list is declared as follow: struct dynamic_prop_list { [...] /* The dynamic property itself. */ struct dynamic_prop *prop; [...] }; In this case, the pointer indirection is unnecessary and costing us, for each dynamic property, the memory needed to store one pointer. This patch removes this pointer indirection, savin us a tiny bit of memory, as well as reduces a bit the complexity by removing the need to allocate memory for the property, as the allocation is now part of the struct itself. gdb/ChangeLog: * gdbtypes.h (struct dynamic_prop_list) <prop>: Remove pointer indirection. * gdbtypes.c (get_dyn_prop): Adjust, following change above. (add_dyn_prop, copy_dynamic_prop_list): Likewise. Tested on x86_64-linux.
2015-03-24GDB: rename DYN_ATTR_DATA_LOCATION into DYN_PROP_DATA_LOCATION.Joel Brobecker3-3/+12
The terminology we've been using is (dynamic) "property" rather than "attribute", so this patch renames an enum to use the same terminology. No behavior change. gdb/ChangeLog: * gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_DATA_LOCATION>: Renames DYN_ATTR_DATA_LOCATION. (TYPE_DATA_LOCATION): Use DYN_PROP_DATA_LOCATION instead of DYN_ATTR_DATA_LOCATION. * dwarf2read.c (set_die_type): Use DYN_PROP_DATA_LOCATION instead of DYN_ATTR_DATA_LOCATION. Tested on x86_64-linux.
2015-03-24Remove 'step' parameters from 'proceed' and 'resume'Pedro Alves8-57/+105
The "step" parameters of 'proceed' and 'resume' aren't really useful as indication of whether run control wants to single-step the target, as that information must already be retrievable from currently_stepping. In fact, if currently_stepping disagrees with whether we single-stepped the target, then things break. Thus instead of having the same information in two places, this patch removes those parameters. Setting 'step_start_function' is the only user of proceed's 'step' argument, other than passing the 'step' argument down to 'resume' and debug log output. Move that instead to set_step_frame, where we already set other related fields. clear_proceed_status keeps its "step" parameter for now because it needs to know which set of threads should have their state cleared, and is called before the "stepping_command" flag is set. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * breakpoint.c (until_break_command): Adjust call to proceed. * gdbthread.h (struct thread_control_state) <stepping_command>: New field. * infcall.c (run_inferior_call): Adjust call to proceed. * infcmd.c (run_command_1, proceed_thread_callback, continue_1): Adjust calls to proceed. (set_step_frame): Set the current thread's step_start_function here. (step_once): Adjust calls to proceed. (jump_command, signal_command, until_next_command) (finish_backward, finish_forward, proceed_after_attach_callback) (attach_command_post_wait): Adjust calls to proceed. * infrun.c (proceed_after_vfork_done): Adjust call to proceed. (do_target_resume): New function, factored out from ... (resume): ... here. Remove 'step' parameter. Instead, check currently_stepping to determine whether the thread should be single-stepped. (proceed): Remove 'step' parameter and don't set the thread's step_start_function here. Adjust call to 'resume'. (handle_inferior_event): Adjust calls to 'resume'. (switch_back_to_stepped_thread): Use do_target_resume instead of 'resume'. (keep_going): Adjust calls to 'resume'. * infrun.h (proceed): Remove 'step' parameter. (resume): Likewise. * windows-nat.c (do_initial_windows_stuff): Adjust call to 'resume'. * mi/mi-main.c (proceed_thread): Adjust call to 'proceed'.
2015-03-24Make "set scheduler-locking step" depend on user intention, onlyPedro Alves8-34/+60
Currently, "set scheduler-locking step" is a bit odd. The manual documents it as being optimized for stepping, so that focus of debugging does not change unexpectedly, but then it says that sometimes other threads may run, and thus focus may indeed change unexpectedly... A user can then be excused to get confused and wonder why does GDB behave like this. I don't think a user should have to know about details of how "next" or whatever other run control command is implemented internally to understand when does the "scheduler-locking step" setting take effect. This patch completes a transition that the code has been moving towards for a while. It makes "set scheduler-locking step" hold threads depending on whether the _command_ the user entered was a stepping command [step/stepi/next/nexti], or not. Before, GDB could end up locking threads even on "continue" if for some reason run control decides a thread needs to be single stepped (e.g., for a software watchpoint). After, if a "continue" happens to need to single-step for some reason, we won't lock threads (unless when stepping over a breakpoint, naturally). And if a stepping command wants to continue a thread for bit, like when skipping a function to a step-resume breakpoint, we'll still lock threads, so focus of debugging doesn't change. In order to make this work, we need to record in the thread structure whether what set it running was a stepping command. (A follow up patch will remove the "step" parameters of 'proceed' and 'resume') FWIW, Fedora GDB, which defaults to "scheduler-locking step" (mainline defaults to "off") carries a different patch that goes in this direction as well. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <stepping_command>: New field. * infcmd.c (step_once): Pass step=1 to clear_proceed_status. Set the thread's stepping_command field. * infrun.c (resume): Check the thread's stepping_command flag to determine which threads should be resumed. Rename 'entry_step' local to user_step. (clear_proceed_status_thread): Clear 'stepping_command'. (schedlock_applies): Change parameter type to struct thread_info pointer. Adjust. (find_thread_needs_step_over): Remove 'step' parameter. Adjust. (switch_back_to_stepped_thread): Adjust calls to 'schedlock_applies'. (_initialize_infrun): Adjust "set scheduler-locking step" help. gdb/testsuite/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * gdb.threads/schedlock.exp (test_step): No longer expect that "set scheduler-locking step" with "next" over a function call runs threads unlocked. gdb/doc/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * gdb.texinfo (test_step) <set scheduler-locking step>: No longer mention that threads may sometimes run unlocked.
2015-03-24Make step_start_function be per threadPedro Alves3-7/+17
I noticed that step_start_function is still a global, while it obviously should be a per-thread field. gdb/ChangeLog: 2015-03-24 Pedro Alves <palves@redhat.com> * infrun.c (step_start_function): Delete and ... * gdbthread.h (struct thread_control_state) <step_start_function>: ... now a field here. * infrun.c (clear_proceed_status_thread): Clear the thread's step_start_function. (proceed, process_event_stop_test, print_stop_event): Adjust.
2015-03-24No longer handle negative 'step' in 'proceed'Pedro Alves2-3/+5
Nothing ever passes a negative 'step' to proceed. Gets rid of one of the few remaining stop_after_trap references. gdb/ChangeLog 2015-03-24 Pedro Alves <palves@redhat.com> * infrun.c (proceed): No longer handle negative step.
2015-03-24Fix mi-pending.exp test output to allow stable test diffingAntoine Tremblay2-1/+5
gdb/testsuite/ChangeLog: * gdb.mi/mi-pending.exp: Fix output of breakpoint test.
2015-03-24Move duplicated Linux x86 code to nat/x86-linux.cGary Benson6-32/+41
This commit moves two identical functions from gdb/x86-linux-nat.c and gdb/gdbserver/linux-x86-low.c into the shared file gdb/nat/x86-linux.c. gdb/ChangeLog: * nat/x86-linux.h (x86_linux_new_thread): New declaration. (x86_linux_prepare_to_resume): Likewise. * x86-linux-nat.c (x86_linux_new_thread): Moved to nat/x86-linux.c. (x86_linux_prepare_to_resume): Likewise. * nat/x86-linux.c (x86_linux_new_thread): New function. (x86_linux_prepare_to_resume): Likewise. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_new_thread): Moved to nat/x86-linux.c. (x86_linux_prepare_to_resume): Likewise.
2015-03-24Move low-level Linux x86 debug register code to a shared fileGary Benson11-337/+288
This commit moves the now-identical low-level Linux x86 debug register code from gdb/x86-linux-nat.c and gdb/gdbserver/linux-x86-low.c into a new shared file gdb/nat/x86-linux-dregs.c. gdb/ChangeLog: * nat/x86-linux-dregs.h: New file. * nat/x86-linux-dregs.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add nat/x86-linux-dregs.h. (x86-linux-dregs.o): New rule. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-dregs.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * x86-linux-nat.c: Include nat/x86-linux-dregs.h. (u_debugreg_offset): Moved to nat/x86-linux-dregs.c. (x86_linux_dr_get): Likewise. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_update_debug_registers): Likewise. gdb/gdbserver/ChangeLog: * Makefile.in (x86-linux-dregs.o): New rule. * configure.srv: Add x86-linux-dregs.o to relevant targets. * linux-x86-low.c: Include nat/x86-linux-dregs.h. (u_debugreg_offset): Moved to nat/x86-linux-dregs.c. (x86_linux_dr_get): Likewise. (x86_linux_dr_set): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (x86_linux_update_debug_registers): Likewise.
2015-03-24Introduce x86_linux_update_debug_registersGary Benson4-6/+38
This commit moves the entire body of both GDB's and gdbserver's x86_linux_prepare_to_resume functions into new functions, x86_linux_update_debug_registers. This reorganisation allows all Linux x86 low-level debug register code to be placed in one shared file, separate from general Linux x86 shared code. gdb/ChangeLog: * x86-linux-nat.c (x86_linux_update_debug_registers): New function, factored out from... (x86_linux_prepare_to_resume): ...this. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_update_debug_registers): New function, factored out from... (x86_linux_prepare_to_resume): ...this.
2015-03-24Linux x86 low-level debug register comment synchronizationGary Benson4-48/+84
This commit updates comments in the low-level debug register code for Linux x86, making GDB's and gdbserver's implementations identical. gdb/ChangeLog: * x86-linux-nat.c (x86_linux_dr_get): Update comments. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_dr_get): Update comments. (x86_linux_dr_set): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (x86_linux_prepare_to_resume): Likewise.
2015-03-24Linux x86 low-level debug register code synchronizationGary Benson4-5/+18
This commit makes several small changes to the low-level debug register code for Linux x86, making the code in the GDB and gdbserver implementations identical. gdb/ChangeLog: * x86-linux-nat.c (x86_linux_dr_set_addr): Update assertion. (x86_linux_new_thread): Rename argument. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_dr_get): Add assertion. Use perror_with_name. Pass string through gettext. (x86_linux_dr_set): Likewise.
2015-03-24Rename gdbserver's low-level Linux x86 debug register accessorsGary Benson2-10/+24
This commit renames gdbserver's low-level Linux x86 debug register accessors to the same names used by GDB. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_dr_low_set_addr): Rename to... (x86_linux_dr_set_addr): ...this. (x86_dr_low_get_addr): Rename to... (x86_linux_dr_get_addr): ...this. (x86_dr_low_set_control): Rename to... (x86_linux_dr_set_control): ...this. (x86_dr_low_get_control): Rename to... (x86_linux_dr_get_control): ...this. (x86_dr_low_get_status): Rename to... (x86_linux_dr_get_status): ...this. (x86_dr_low): Update with new function names.
2015-03-24Make lwp_info.arch_private handling sharedGary Benson14-38/+198
This commit moves the code to handle lwp_info.arch_private for Linux x86 into a new shared file, nat/x86-linux.c. gdb/ChangeLog: * nat/x86-linux.h: New file. * nat/x86-linux.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add nat/x86-linux.h. (x86-linux.o): New rule. * config/i386/linux.mh (NATDEPFILES): Add x86-linux.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * nat/linux-nat.h (struct arch_lwp_info): New forward declaration. (lwp_set_arch_private_info): New declaration. (lwp_arch_private_info): Likewise. * linux-nat.c (lwp_set_arch_private_info): New function. (lwp_arch_private_info): Likewise. * x86-linux-nat.c: Include nat/x86-linux.h. (arch_lwp_info): Removed structure. (update_debug_registers_callback): Use lwp_set_debug_registers_changed. (x86_linux_prepare_to_resume): Use lwp_debug_registers_changed and lwp_set_debug_registers_changed. (x86_linux_new_thread): Use lwp_set_debug_registers_changed. gdb/gdbserver/ChangeLog: * Makefile.in (x86-linux.o): New rule. * configure.srv: Add x86-linux.o to relevant targets. * linux-low.c (lwp_set_arch_private_info): New function. (lwp_arch_private_info): Likewise. * linux-x86-low.c: Include nat/x86-linux.h. (arch_lwp_info): Removed structure. (update_debug_registers_callback): Use lwp_set_debug_registers_changed. (x86_linux_prepare_to_resume): Use lwp_debug_registers_changed and lwp_set_debug_registers_changed. (x86_linux_new_thread): Use lwp_set_debug_registers_changed.
2015-03-24Change signature of linux_target_ops.new_threadGary Benson7-14/+23
This commit changes the signature of linux_target_ops.new_thread in gdbserver to match that used in GDB's equivalent. gdb/gdbserver/ChangeLog: * linux-low.h (linux_target_ops) <new_thread>: Changed signature. * linux-arm-low.c (arm_new_thread): Likewise. * linux-aarch64-low.c (aarch64_linux_new_thread): Likewise. * linux-mips-low.c (mips_linux_new_thread): Likewise. * linux-x86-low.c (x86_linux_new_thread): Likewise. * linux-low.c (add_lwp): Update the_low_target.new_thread call.
2015-03-24Introduce basic LWP accessorsGary Benson7-10/+103
This commit introduces three accessors that shared Linux code can use to access fields of struct lwp_info. The GDB and gdbserver Linux x86 code is modified to use them. gdb/ChangeLog: * nat/linux-nat.h (ptid_of_lwp): New declaration. (lwp_is_stopped): Likewise. (lwp_stop_reason): Likewise. * linux-nat.c (ptid_of_lwp): New function. (lwp_is_stopped): Likewise. (lwp_is_stopped_by_watchpoint): Likewise. * x86-linux-nat.c (update_debug_registers_callback): Use lwp_is_stopped. (x86_linux_prepare_to_resume): Use ptid_of_lwp and lwp_stop_reason. gdb/gdbserver/ChangeLog: * linux-low.c (ptid_of_lwp): New function. (lwp_is_stopped): Likewise. (lwp_stop_reason): Likewise. * linux-x86-low.c (update_debug_registers_callback): Use lwp_is_stopped. (x86_linux_prepare_to_resume): Use ptid_of_lwp and lwp_stop_reason.
2015-03-24Make linux_stop_lwp be a shared functionGary Benson5-2/+16
Both GDB and gdbserver had linux_stop_lwp functions with identical declarations. This commit moves these to nat/linux-nat.h to allow shared code to use the function. gdb/ChangeLog: * linux-nat.h (linux_stop_lwp): Move declaration to... * nat/linux-nat.h (linux_stop_lwp): New declaration. gdb/gdbserver/ChangeLog: * linux-low.h (linux_stop_lwp): Remove declaration.
2015-03-24Add iterate_over_lwps to gdbserverGary Benson8-34/+108
This commit introduces a new function, iterate_over_lwps, that shared Linux code can use to call a function for each LWP that matches certain criteria. This function already existed in GDB and was in use by GDB's various low-level Linux x86 debug register setters. An equivalent was written for gdbserver and gdbserver's low-level Linux x86 debug register setters were modified to use it. gdb/ChangeLog: * linux-nat.h: Include nat/linux-nat.h. (iterate_over_lwps): Move declaration to nat/linux-nat.h. * nat/linux-nat.h (struct lwp_info): New forward declaration. (iterate_over_lwps_ftype): New typedef. (iterate_over_lwps): New declaration. * linux-nat.h (iterate_over_lwps): Update comment. Use iterate_over_lwps_ftype. Update callback return value check. gdb/gdbserver/ChangeLog: * linux-low.h: Include nat/linux-nat.h. * linux-low.c (iterate_over_lwps_args): New structure. (iterate_over_lwps_filter): New function. (iterate_over_lwps): Likewise. * linux-x86-low.c (update_debug_registers_callback): Update signature to what iterate_over_lwps expects. Remove PID check that iterate_over_lwps now performs. (x86_dr_low_set_addr): Use iterate_over_lwps. (x86_dr_low_set_control): Likewise.
2015-03-24Add x86_debug_reg_state to gdbserverGary Benson5-9/+27
This commit introduces a new function, x86_debug_reg_state, that shared x86 code can use to access the local mirror of a process's debug registers. This function already existed in GDB and was in use by GDB's x86_linux_prepare_to_resume. An equivalent was written for gdbserver and gdbserver's x86_linux_prepare_to_resume was modified to use it. gdb/ChangeLog: * x86-nat.h (x86_debug_reg_state): Move declaration to... * nat/x86-dregs.h (x86_debug_reg_state): New declaration. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_debug_reg_state): New function. (x86_linux_prepare_to_resume): Use the above.
2015-03-24Introduce current_lwp_ptidGary Benson7-14/+53
This commit introduces a new function, current_lwp_ptid, that shared Linux code can use to obtain the ptid of the current lightweight process. gdb/ChangeLog: * nat/linux-nat.h (current_lwp_ptid): New declaration. * linux-nat.c (current_lwp_ptid): New function. * x86-linux-nat.c: Include nat/linux-nat.h. (x86_linux_dr_get_addr): Use current_lwp_ptid. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. gdb/gdbserver/ChangeLog: * linux-low.c (current_lwp_ptid): New function. * linux-x86-low.c: Include nat/linux-nat.h. (x86_dr_low_get_addr): Use current_lwp_ptid. (x86_dr_low_get_control): Likewise. (x86_dr_low_get_status): Likewise.
2015-03-24Fix breakpoint thread condition missing with mi and a pending breakpoint.Antoine Tremblay8-25/+144
When setting a pending breakpoint with a thread condition while using the mi interface, the thread condition would be lost by gdb when the breakpoint was resolved. This patch fixes this behavior by setting the thread condition properly in the mi case. Also, this patch modifies the mi-pending test case to test for this issue and removes some unneeded code in the testcase and dependency on stdio. gdb/Changelog: PR breakpoints/16466 * breakpoint.c (create_breakpoint): Set thread on breakpoint struct. gdb/testsuite/ChangeLog: PR breakpoints/16466 * gdb.mi/Makefile.in: Add mi-pendshr2.sl to cleanup. * gdb.mi/mi-pending.c (thread_func): New function. (int main): Add threading support required. * gdb.mi/mi-pending.exp: Add tests for this issue. * gdb.mi/mi-pendshr.c (pendfunc1): Remove stdio dependency. (pendfunc2): Remove stdio dependency. * gdb.mi/mi-pendshr2.c: New file.
2015-03-23Fix indentation in ser_windows_setparity and hardwire_setparity.Joel Brobecker3-2/+7
gdb/ChangeLog: * ser-mingw.c (ser_windows_setparity): Fix indentation. * ser-unix.c (hardwire_setparity): Likewise.
2015-03-23GDB: Add set/show serial parity command.Yury Grechishchev16-4/+206
The "set serial parity" command allows the user to control which parity to use when communicating over a serial connection, rather than having the parity hardcoded to none. gdb/ChangeLog: * NEWS: Mention set/show serial parity command. * monitor.c (monitor_open): Call serial_setparity. * remote.c (remote_open_1): Likewise. * ser-base.c (ser_base_serparity): New function. * ser-base.h (ser_base_setparity): Add declaration. * ser-go32.c (dos_ops): Set "setparity" field. * ser-mingw.c (ser_windows_raw): Do not set state.fParity and state.Parity. (ser_windows_setparity): New function. (hardwire_ops): Add ser_windows_setparity. (tty_ops): Add NULL for setparity field. (pipe_ops): Add ser_base_setparity. (tcp_ops): Likewise. * ser-pipe.c (pipe_ops): Likewise. * ser-tcp.c (tcp_ops): Likewise. * ser-unix.c (hardwire_setparity): Add declaration. (hardwire_raw): Don't reset PARENB flag. (hardwire_setparity): New function. (hardwire_ops): Add hardwire_setparity. * serial.c (serial_setparity): New function. (serial_parity): New global. (parity_none, parity_odd, parity_even, parity_enums, parity): New static globals. (set_parity): New function. (_initialize_serial): Add set/show serial parity commands. * serial.h (GDBPARITY_NONE): Define. (GDBPARITY_ODD): Define. (GDBPARITY_EVEN): Define. (serial_setparity) Add declaration. (struct serial_ops): Add setparity field. * target.h (serial_parity): Add declaration. gdb/doc/ChangeLog: * gdb.texinfo (Remote configuration): Document "set/show serial parity" command.
2015-03-23Update comment of linespec_lexer_lex_keyword.Keith Seitz2-2/+5
gdb/ChangeLog * linespec.c (linespec_lexer_lex_keyword): Update comment.
2015-03-23Add missing changelog entries of last commitKeith Seitz2-0/+20
2015-03-23Expand keyword lexing intelligence in the linespec parser.Keith Seitz5-22/+153
This patch changes the heuristic the linespec lexer uses to detect a keyword in the input stream. Currently, the heuristic is: a word is a keyword if it 1) points to a string that is a keyword 2) is followed by a non-identifier character This is strictly more correct than using whitespace. For example, it allows constructs such as "break foo if(i == 1)". However, find_condition_and_thread in breakpoint.c does not support this expanded usage. It requires whitespace to follow the keyword. The proposed new heuristic is: a word is a keyword if it 1) points to a string that is a keyword 2) is followed by whitespace 3) is not followed by another keyword string followed by whitespace This additional complexity allows constructs such as "break thread thread 3" and "break thread 3". In the former case, the actual location is a symbol named "thread" to be set on thread #3. In the later case, the location is NULL, i.e., the default location, to be set on thread #3. In order to pass all the new tests added here, I've also had to add a new feature to parse_breakpoint_sals, which expands recognition of the default location to keywords other than "if", which is the only keyword currently permitted with the default (NULL) location, but there is no reason to exclude other keywords. Consequently, it will be possible to use "break thread 1" or "break task 1". In addition to all of this, it is now possible to remove the keyword_ok state from the linespec parser. gdb/ChangeLog * breakpoint.c (parse_breakpoint_sals): Use linespec_lexer_lex_keyword to ascertain if the user specified a NULL location. * linespec.c [IF_KEYWORD_INDEX]: Define. (linespec_lexer_lex_keyword): Export. (struct ls_parser) <keyword_ok>: Remove. A keyword is only a keyword if not followed by another keyword. (linespec_lexer_lex_one): Remove keyword_ok handling. Add comment explaining why the parsing stream is not advanced when a keyword is seen. (parse_linespec): Remove parser->keyword_ok. * linespec.h (linespec_lexer_lex_keyword): Add declaration. gdb/testsuite/ChangeLog * gdb.linespec/keywords.c: New file. * gdb.linespec/keywords.exp: New file.
2015-03-23PR gdb/18021 - defend against "static virtual" methodsKeith Seitz4-1/+83
This bug appears to be caused by bad debuginfo. The method causing the sefault in the reporter's test case is marked both static and virtual. This patch simply safegaurds against this case in dwarf2_add_member_fn, where the code assumes that there is a `this' pointer when a virtual method is seen (more specifically, when DW_AT_vtable_elem is seen). It previously dereferenced the first formal parameter (`this' pointer), which in this case doesn't exist. GDB consequently segfaulted dereferencing a NULL pointer. gdb/ChangeLog PR gdb/18021 * dwarf2read.c (dwarf2_add_member_fn): Issue a complaint if we find a static method with DW_AT_vtable_elem_location. gdb/testsuite/ChangeLog PR gdb/18021 * gdb.dwarf2/staticvirtual.exp: New test.
2015-03-21Fix undefined behavior in TUI's TAB expansionEli Zaretskii2-8/+14
gdb/ChangeLog: * tui/tui-io.c (tui_expand_tabs): Reinitialize the column counter before the second loop, to avoid undefined behavior. Reported by Anton Blanchard <anton@samba.org>.
2015-03-20[gdb/DWARF] Introduce linked list for dynamic attributesKeven Boell4-32/+136
This patch introduces a linked list for dynamic attributes of a type. This is a pre-work for the Fortran dynamic array support. The Fortran dynamic array support will add more dynamic attributes to a type. As only a few types will have such dynamic attributes set, a linked list is more efficient in terms of memory consumption than adding multiple attributes to main_type. gdb/ChangeLog: * gdbtypes.c (resolve_dynamic_type_internal): Adapt data_location usage to linked list. (resolve_dynamic_type_internal): Adapt data_location to linked list. (get_dyn_prop, add_dyn_prop, copy_dynamic_prop_list): New function. (copy_type_recursive, copy_type): Add copy of linked list. * gdbtypes.h (enum dynamic_prop_node_kind): New enum. (struct dynamic_prop_list): New struct. * dwarf2read.c (set_die_type): Set data_location data.
2015-03-20constify i386-sol2-tdep.c and machoread.cPedro Alves3-2/+9
/home/pedro/gdb/mygit/src/gdb/i386-sol2-tdep.c: In function ‘const char* i386_sol2_static_transform_name(const char*)’: /home/pedro/gdb/mygit/src/gdb/i386-sol2-tdep.c:93:29: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] p = strrchr (name, '.'); ^ gdb: 2015-03-20 Pedro Alves <palves@redhat.com> * i386-sol2-tdep.c (i386_sol2_static_transform_name): Move "p" to inner block and make it const. * machoread.c (get_archive_prefix_len): Make "lparen" const.
2015-03-20constify set_breakpoint_conditionPedro Alves3-2/+7
gdb: 2015-03-20 Pedro Alves <palves@redhat.com> * breakpoint.c (set_breakpoint_condition): Make argument "exp" const. * breakpoint.h (set_breakpoint_condition): Update declaration.
2015-03-20constify tui/tui-io.cPedro Alves2-1/+5
gdb: 2015-03-20 Pedro Alves <palves@redhat.com> * tui/tui-io.c (tui_expand_tabs): Make "s1" const.
2015-03-20constify xcoffread.cPedro Alves2-2/+6
/home/pedro/gdb/mygit/src/gdb/xcoffread.c: In function ‘void scan_xcoff_symtab(objfile*)’: /home/pedro/gdb/mygit/src/gdb/xcoffread.c:2644:33: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] p = strchr (namestring, ':'); ^ gdb: 2015-03-20 Pedro Alves <palves@redhat.com> * xcoffread.c (scan_xcoff_symtab): Make "p" and "q" const.
2015-03-20constify remote-m32r-sdi.cPedro Alves2-1/+6
gdb: 2015-03-20 Pedro Alves <palves@redhat.com> * remote-m32r-sdi.c (m32r_open): Make "port_str" const.
2015-03-20constify nto-tdep.cPedro Alves2-2/+9
/home/pedro/gdb/mygit/src/gdb/nto-tdep.c: In function ‘int nto_find_and_open_solib(char*, unsigned int, char**)’: /home/pedro/gdb/mygit/src/gdb/nto-tdep.c:111:14: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] endian = gdbarch_byte_order (target_gdbarch ()) ^ /home/pedro/gdb/mygit/src/gdb/nto-tdep.c: In function ‘void nto_init_solib_absolute_prefix()’: /home/pedro/gdb/mygit/src/gdb/nto-tdep.c:170:14: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] endian = gdbarch_byte_order (target_gdbarch ()) ^ gdb 2015-03-20 Pedro Alves <palves@redhat.com> * nto-tdep.c (nto_find_and_open_solib): Make "endian" const. (nto_init_solib_absolute_prefix): Likewise.
2015-03-20constify gdbserver/tracepoint.cPedro Alves2-1/+6
gdb/gdbserver/tracepoint.c:3647:7: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] gdb/gdbserver/tracepoint.c:3652:7: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] gdb/gdbserver/tracepoint.c:3657:7: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] gdb/gdbserver 2015-03-20 Pedro Alves <palves@redhat.com> * tracepoint.c (cmd_qtstatus): Make "str" const.
2015-03-20constify gdbserver/server.cPedro Alves2-1/+5
gdb/gdbserver/ 2015-03-20 Pedro Alves <palves@redhat.com> * server.c (handle_general_set): Make "req_str" const.
2015-03-20constify sparc-sol2-tdep.c and spu-tdep.cPedro Alves3-2/+7
/home/pedro/gdb/mygit/src/gdb/sparc-sol2-tdep.c: In function ‘const char* sparc_sol2_static_transform_name(const char*)’: /home/pedro/gdb/mygit/src/gdb/sparc-sol2-tdep.c:247:35: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] char *p = strrchr (name, '.'); ^ gdb: 2015-03-20 Pedro Alves <palves@redhat.com> * sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Make "p" const. * spu-tdep.c (spu_gdbarch_init): Make "name" const.