aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2015-10-20[nto] Implement TARGET_OBJECT_AUXV.Aleksandar Ristovski4-0/+127
Fix 'info auxv' for nto. gdb/ChangeLog: * nto-procfs.c (sys/auxv.h): Include. (procfs_xfer_partial): Implement TARGET_OBJECT_AUXV. * nto-tdep.c (nto_read_auxv_from_initial_stack): New function. * nto-tdep.h (nto_read_auxv_from_initial_stack): New declaration.
2015-10-20[nto] Fixes for nto procfs.Aleksandar Ristovski2-25/+50
Fix errnoeus construction of procfs path. The issue is, after the first info pidlist or first run, the path for local node (the most common node) will be reset to empty which makes subsequent queries and runs impossible. gdb/ChangeLog: * nto-procfs.c (nto_procfs_path): Rename to... (nodestr): ... this, and change type. (nto_node): Use new variable and logic accordingly. (procfs_open_1): Use new variable name. Use local buffer to construct procfrs path. (procfs_pidlist): Use NODESTR to construct procfs path. (procfs_files_info): Use NODESTR to output meaningful text. (do_attach): Construct procfs using NODESTR. (procfs_create_inferior): Compare pointer to NULL.
2015-10-19gdb: Improve syscall entry/return tracking on LinuxJosh Stone5-23/+171
The existing logic was simply to flip syscall entry/return state when a syscall trap was seen, and even then only with active 'catch syscall'. That can get out of sync if 'catch syscall' is toggled at odd times. This patch updates the entry/return state for all syscall traps, regardless of catching state, and also updates known syscall state for other kinds of traps. Almost all PTRACE_EVENT stops are delivered from the middle of a syscall, so this can act like an entry. Every other kind of ptrace stop is only delivered outside of syscall event pairs, so marking them ignored ensures the next syscall trap looks like an entry. Three new test scenarios are added to catch-syscall.exp: - Disable 'catch syscall' from an entry to deliberately miss the return event, then re-enable to make sure a new entry is recognized. - Enable 'catch syscall' for the first time from a vfork event, which is a PTRACE_EVENT_VFORK in the middle of the syscall. Make sure the next syscall event is recognized as the return. - Make sure entry and return are recognized for an ENOSYS syscall. This is to defeat a common x86 hack that uses the pre-filled ENOSYS return value as a sign of being on the entry side. gdb/ChangeLog: 2015-10-19 Josh Stone <jistone@redhat.com> * linux-nat.c (linux_handle_syscall_trap): Always update entry/ return state, even when not actively catching syscalls at all. (linux_handle_extended_wait): Mark syscall_state like an entry. (wait_lwp): Set syscall_state ignored for other traps. (linux_nat_filter_event): Likewise. gdb/testsuite/ChangeLog: 2015-10-19 Josh Stone <jistone@redhat.com> * gdb.base/catch-syscall.c: Include <sched.h>. (unknown_syscall): New variable. (main): Trigger a vfork and an unknown syscall. * gdb.base/catch-syscall.exp (vfork_syscalls): New variable. (unknown_syscall_number): Likewise. (check_call_to_syscall): Accept an optional syscall pattern. (check_return_from_syscall): Likewise. (check_continue): Likewise. (test_catch_syscall_without_args): Check for vfork and ENOSYS. (test_catch_syscall_skipping_return): New test toggling off 'catch syscall' to step over the syscall return, then toggling back on. (test_catch_syscall_mid_vfork): New test turning on 'catch syscall' during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall. (do_syscall_tests): Call test_catch_syscall_without_args and test_catch_syscall_mid_vfork. (test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS. (fill_all_syscalls_numbers): Initialize unknown_syscall_number.
2015-10-19Make GDB wait for events after handling target File-I/OLuis Machado2-14/+14
_ftext () at arm-vector.S:25 25 ldr pc, [pc, #24] @ reset (gdb) load Loading section .text, size 0xc01c lma 0x0 Loading section .eh_frame, size 0x48 lma 0xc01c Loading section .ARM.exidx, size 0x8 lma 0xc064 Loading section .rodata, size 0x398 lma 0xc070 Loading section .data, size 0x8e0 lma 0xc408 Start address 0x40, load size 52452 Transfer rate: 17074 KB/sec, 1748 bytes/write. (gdb) c Continuing. infrun: clear_proceed_status_thread (Thread 1) infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 1] at 0x40 Sending packet: $vCont?#49...Ack Packet received: Packet vCont (verbose-resume) is NOT supported Sending packet: $Hc0#db...Ack Packet received: OK Sending packet: $c#63...Ack infrun: infrun_async(1) infrun: prepare_to_wait infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [Thread 0], infrun: status->kind = ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait Packet received: Ffstat,00000001,07fffdb0 Sending packet: $M7fffdb0,40:000000000000000000002080000000010000c336000001180000000000000000000000000000000000000200000000000000000055dfb11b55dfb11b55dfb11b#5a...Ack Packet received: OK Sending packet: $F0#76...Ack infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [Thread 0], infrun: status->kind = ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [Thread 0], infrun: status->kind = no-resumed infrun: TARGET_WAITKIND_NO_RESUMED infrun: stop_waiting infrun: clear_step_over_info Sending packet: $qfThreadInfo#bb...Ack Packet received: m1 Sending packet: $qsThreadInfo#c8...Ack Packet received: l No unwaited-for children left. infrun: infrun_async(0) (gdb) c Continuing. Cannot execute this command while the selected thread is running. (gdb) Continuing. Cannot execute this command while the selected thread is running. This behavior shows up whenever GDB is in all-stop mode and is handling target-initiated File-I/O requests, in the middle of, say, a continue request. When GDB is done handling the File-I/O request, it doesn't set rs->waiting_for_stop_reply back to 1, meaning GDB should wait for further target events. This seems to be a latent bug, because in the past this didn't really cause any issues. But it seems to have been uncovered by commit 567420d10895611e03d5ee65e6b24c16a69a6e99, which explicitly checks for rs->waiting_for_stop_reply == 0, triggering the failures above. The following patch fixes this by reorganizing the setting of rs->waiting_for_stop_reply. infrun: prepare_to_wait Packet received: Ffstat,00000001,07fffdb0 Sending packet: $M7fffdb0,40:000000000000000000002080000000010000c336000001180000000000000000000000000000000000000200000000000000000055dfb19e55dfb19e55dfb19e#7b...Ack Packet received: OK Sending packet: $F0#76...Ack infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [Thread 0], infrun: status->kind = ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait Packet received: Fisatty,00000001 Sending packet: $F1#77...Ack infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [Thread 0], infrun: status->kind = ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait Packet received: Fwrite,00000001,0000d098,00000004 Sending packet: $md098,4#d2...Ack Packet received: 3732300a 720 Sending packet: $F4#7a...Ack infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [Thread 0], infrun: status->kind = ignore infrun: TARGET_WAITKIND_IGNORE infrun: prepare_to_wait Packet received: Fwrite,00000001,07ffffac,00000011 Sending packet: $m7ffffac,11#8e...Ack Packet received: 0a2a2a2a204558495420636f646520300a *** EXIT code 0 Regression-tested on Ubuntu x86-64 and qemu-system-based debugging for arm eabi. gdb/ChangeLog: 2015-10-16 Luis Machado <lgustavo@codesourcery.com> * remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to 0 when handling 'E', 'T', 'S', 'X' and 'W' packets. Do not set rs->waiting_for_stop_reply back to 1.
2015-10-19Fixup comments oops in last commit.Andrew Stubbs1-4/+4
2015-10-19Robustify inherit.exp and virtbase.exp.Andrew Stubbs3-3/+34
2015-10-19 Andrew Stubbs <ams@codesourcery.com> gdb/testsuite/ * gdb.cp/inherit.exp (print g_vB, print g_vC, print g_vD, print g_vE): Add new pass patterns. * gdb.cp/virtbase.exp (print *this, print *(D *) e): Allow GDB to print various symbol names for vptr fields.
2015-10-16[nto] Fix nto build.Aleksandar Ristovski4-16/+29
gdb/gdbserver/ChangeLog: * gdbserver/nto-low.c (nto_insert_point, nto_remove_point): Fix variable name. gdb/ChangeLog: * nto-procfs.c (common/filestuff.h): Include. (procfs_can_use_hw_breakpoint): Fix enum name. (procfs_open_1): Fix compiler warning. (procfs_pidlist): Make static. (procfs_meminfo): Make static, fix type name, add missing argument. (procfs_store_registers): Make static. (procfs_thread_info): Remove unused function. (_initialize_procfs): Forward declare.
2015-10-16gdbserver: Reset current_thread when the thread is removed.Aleksandar Ristovski1-0/+7
Reset current_thread and make sure 'remove_process' is used after all associated threads have been removed first. gdb/gdbserver/ChangeLog: * inferiors.c (thread_pid_matches_callback): New function. (find_thread_process): New function. (remove_thread): Reset current_thread. (remove_process): Assert threads have been removed first.
2015-10-16gdbserver: Reset current_thread when the thread is removed.Aleksandar Ristovski1-0/+24
Reset current_thread and make sure 'remove_process' is used after all associated threads have been removed first. gdb/gdbserver/ChangeLog: * inferiors.c (thread_pid_matches_callback): New function. (find_thread_process): New function. (remove_thread): Reset current_thread. (remove_process): Assert threads have been removed first.
2015-10-16MAINTAINERS: Fix my inconsistent email addressYao Qi2-3/+7
Hi, This patch fixes inconsistency in my email address. 2015-10-16 Yao Qi <yao.qi@arm.com> * MAINTAINERS: Update my email address.
2015-10-15aarch64 multi-arch part 6: HW breakpoint on unaligned addressYao Qi8-11/+87
Nowadays, both aarch64 GDB and linux kernel assumes that address for setting breakpoint should be 4-byte aligned. However that is not true after we support multi-arch, because thumb instruction can be at 2-byte aligned address. Patch http://lists.infradead.org/pipermail/linux-arm-kernel/2015-October/375141.html to linux kernel is to teach kernel to handle 2-byte aligned address for HW breakpoint, while this patch is to teach aarch64 GDB handle 2-byte aligned address. First of all, we call gdbarch_breakpoint_from_pc to get the instruction length rather than using hard-coded 4. Secondly, in GDBserver, we set length back to 2 if it is 3, because GDB encode 3 in it to indicate it is a 32-bit thumb breakpoint. Then we relax the address alignment check from 4-byte aligned to 2-byte aligned. This patch enables some tests (such as gdb.base/break-idempotent.exp, gdb.base/cond-eval-mode.exp, gdb.base/watchpoint-reuse-slot.exp,) and fixes many fails (such as gdb.base/hbreak2.exp) when the program is compiled in thumb mode on aarch64. Regression tested on aarch64-linux, both native and gdbserver. This is the last patch of multi-arch work. gdb: 2015-10-15 Yao Qi <yao.qi@linaro.org> * aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Call gdbarch_breakpoint_from_pc to instruction length. (aarch64_linux_remove_hw_breakpoint): Likewise. * common/common-regcache.h (regcache_register_size): Declare. * nat/aarch64-linux-hw-point.c: Include "common-regcache.h". (aarch64_point_is_aligned): Set alignment to 2 for breakpoint if the process is 32bit, otherwise set alignment to 4. (aarch64_handle_breakpoint): Update comments. * regcache.c (regcache_register_size): New function. gdb/gdbserver: 2015-10-15 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_insert_point): Set len to 2 if it is 3. (aarch64_remove_point): Likewise. * regcache.c (regcache_register_size): New function.
2015-10-15Normalize my (personal) email address in ChangeLogSimon Marchi1-2/+2
2015-10-15Remove core_regset_sectionAleksandar Ristovski3-2/+5
gdb/ChangeLog: * gdbarch.sh (core_regset_section): Remove. * gdbarch.h: Regenerate.
2015-10-14Define enum out of structYao Qi2-6/+15
This patch moves the definition of enum out of the scope of struct aarch64_memory_operand, otherwise it breaks GDB build in c++ mode. gdb: 2015-10-14 Yao Qi <yao.qi@linaro.org> * arch/aarch64-insn.h (struct aarch64_memory_operand): Move enum out of it. (enum aarch64_memory_operand_type): New.
2015-10-13Recognize a few more AIX XCOFF DWARF sections.David Edelsohn2-3/+10
gdb/ChangeLog: * xcoffread.c (dwarf2_xcoff_names): Add .dwmac and .dwpbtyp.
2015-10-13More char constificationPedro Alves14-22/+42
Trivial constifications flagged by G++. E.g.: src/gdb/c-varobj.c: In function ‘void c_describe_child(const varobj*, int, char**, value**, type**, char**)’: src/gdb/c-varobj.c:373:33: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] char *join = was_ptr ? "->" : "."; ^ gdb/ChangeLog: 2015-10-13 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_enum_name): Constify local. * ada-typeprint.c (print_range_bound): Constify locals. * c-varobj.c (c_describe_child): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * dwarf2read.c (find_file_and_directory): Likewise. (anonymous_struct_prefix, dwarf2_name): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-lang.c (unpack_mangled_go_symbol): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * ser-tcp.c (net_open): Likewise. * symfile.c (deduce_language_from_filename): Likewise. * symtab.c (gdb_mangle_name): Likewise. * tui/tui-io.c (tui_redisplay_readline): Likewise.
2015-10-13Fix execution_direction's typePedro Alves3-6/+25
This fixes a few build errors like these in C++ mode: src/gdb/reverse.c: In function ‘void exec_reverse_once(char*, char*, int)’: src/gdb/reverse.c:49:34: error: invalid conversion from ‘int’ to ‘exec_direction_kind’ [-fpermissive] enum exec_direction_kind dir = execution_direction; ^ make: *** [reverse.o] Error 1 gdb/ChangeLog: 2015-10-13 Pedro Alves <palves@redhat.com> * infrun.c (restore_execution_direction): New function. (fetch_inferior_event): Use it instead of make_cleanup_restore_integer. (execution_direction): Change type to enum exec_direction_kind. * infrun.h (execution_direction): Likewise.
2015-10-13ada-lang.c:ada_value_primitive_packed_val: const correctnessPedro Alves2-8/+15
gdb/ChangeLog: 2015-10-13 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_value_primitive_packed_val): Constify locals. Use value_contents_writeable. Remove casts.
2015-10-13ada-lang.c: malloc/alloca casts for C++Pedro Alves2-2/+7
gdb/ChangeLog: 2015-10-13 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_value_primitive_packed_val): Add casts to malloc and alloca calls.
2015-10-13lm32: Replace call to write_memory with write_memory_unsigned_integerSimon Marchi2-1/+7
Fixes this error: /home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c: In function ‘CORE_ADDR lm32_push_dummy_call(gdbarch*, value*, regcache*, CORE_ADDR, int, value**, CORE_ADDR, int, CORE_ADDR)’: /home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c:292:59: error: invalid conversion from ‘void*’ to ‘const gdb_byte* {aka const unsigned char*}’ [-fpermissive] write_memory (sp, (void *) &val, TYPE_LENGTH (arg_type)); ^ In file included from /home/emaisin/src/binutils-gdb/gdb/lm32-tdep.c:29:0: /home/emaisin/src/binutils-gdb/gdb/gdbcore.h:107:13: error: initializing argument 2 of ‘void write_memory(CORE_ADDR, const gdb_byte*, ssize_t)’ [-fpermissive] extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ^ gdb/ChangeLog: * lm32-tdep.c (lm32_push_dummy_call): Replace call to write_memory with write_memory_unsigned_integer.
2015-10-13Constify arguments of gdb_bfd_lookup_symbol and related functionsSimon Marchi6-15/+30
Fixes this error: /home/pedro/gdb/mygit/src/gdb/solib-frv.c: In function ‘int enable_break2()’: /home/pedro/gdb/mygit/src/gdb/solib-frv.c:622:72: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive] addr = gdb_bfd_lookup_symbol (tmp_bfd, cmp_name, "_dl_debug_addr"); ^ In file included from /home/pedro/gdb/mygit/src/gdb/solib-frv.c:23:0: /home/pedro/gdb/mygit/src/gdb/solib.h:82:18: error: initializing argument 3 of ‘CORE_ADDR gdb_bfd_lookup_symbol(bfd*, int (*)(asymbol*, void*), void*)’ [-fpermissive] extern CORE_ADDR gdb_bfd_lookup_symbol (bfd *abfd, ^ The call in question is: addr = gdb_bfd_lookup_symbol (tmp_bfd, cmp_name, "_dl_debug_addr"); gdb/ChangeLog: * solib-dsbt.c (cmp_name): Constify arguments. * solib-frv.c (cmp_name): Likewise. * solib-svr4.c (svr4_create_solib_event_breakpoints): Likewise. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Likewise. (bfd_lookup_symbol_from_dyn_symtab): Likewise. (gdb_bfd_lookup_symbol): Likewise. * solib.h (gdb_bfd_lookup_symbol): Likewise. (gdb_bfd_lookup_symbol_from_symtab): Likewise.
2015-10-12gdb: Simplify parse_frame_specification.Andrew Burgess2-10/+16
Remove an unneeded parameter from parse_frame_specification, replace with a fixed string within parse_frame_specification. The message was the same in every place that parse_frame_specification was used anyway. gdb/ChangeLog: * stack.c (parse_frame_specification): Remove message parameter, replace with fixed string in function body, update function comment. (frame_info): Remove message to parse_frame_specification. (select_frame_command): Likewise.
2015-10-12gdb: Avoid unneeded calls to parse_frame_specification.Andrew Burgess2-14/+19
Within the stack command there are a couple of places where fixed strings are passed into functions that are really intended for processing user input. These fixed strings are then processed and the result returned. Given that the input strings in these cases are fixed, and are always "0", then the result will always be the same, the current frame. By switching to using get_current_frame instead the code can be simplified, and the intention of the code is clearer. gdb/ChangeLog: * stack.c (parse_frame_specification): Delete. (parse_frame_specification_1): Rename to parse_frame_specification. (frame_info): Use parse_frame_specification. (select_frame_command): Likewise. (return_command): Use select_frame and print_stack_frame rather than frame_command and select_frame_command. (func_command): Use get_current_frame rather than parse_frame_specification.
2015-10-12gdb: Fix bug with dbx style func command.Andrew Burgess4-6/+12
The func command, available when starting gdb in dbx mode, is supposed to take a function name and locate the frame for that function in the stack. This has been broken for a while due to an invalid check of the arguments within the worker function. Fixed in this commit. gdb/ChangeLog: * stack.c (func_command): Return early when there is no ARG string. gdb/testsuite/ChangeLog: * gdb.base/dbx.exp (test_func): Remove xfails, update expected results.
2015-10-12gdb/doc: Restructure frame command documentation.Andrew Burgess2-160/+157
The 'frame' command is documented in two places. The 'select-frame' command is only mentioned in one of these places. Of the two places, having the description of 'frame' and 'select-frame' in the section 'Selecting a Frame' seems like the most obvious choice, which is where things like 'up' and 'down' are also documented. This commit moves the documentation of 'frame' and 'select-frame' into the 'Selecting a Frame' section, and removes the duplicate documentation of the 'frame' command. At the same time I have reordered the sections in the 'Examining the Stack' chapter, moving the discussion of frame filters to the end of the chapter; it feels odd that we talk about frame filters before such basic things like navigating the stack, or examining stack frames in general. gdb/doc/ChangeLog: * gdb.texinfo (Frames): Remove 'frame' and 'select-frame' description. (Frame Filter Management): Move to later in the 'Examining the Stack' chapter. (Selection): Add entry for 'select-frame'.
2015-10-12gdb: Make use of safe-ctype.h header.Andrew Burgess2-3/+9
In stack.c switch to using safe-ctype.h instead of ctype.h, update code as required. gdb/ChangeLog: * stack.c: Include safe-ctype.h not ctype.h. (parse_frame_specification): Use ISSPACE not isspace. (backtrace_command): Use TOLOWER not tolower.
2015-10-12mep: Add cast for int to enum conversionSimon Marchi2-2/+10
Taken directly from Pedro's branch. gdb/ChangeLog: * mep-tdep.c (current_me_module): Add cast. (mep_gdbarch_init): Likewise.
2015-10-12m32c: Split m32c_move_reg_t in read/write variantsSimon Marchi2-62/+89
This allows to avoid casting away the const qualification in m32c_pseudo_register_write (which is the entry points for all other register read/write functions). Also, use gdb_byte* instead of void* to avoid casts when calling gdb common memory functions. It also allows to remove those "For adderss arithmetic" local variables. gdb/ChangeLog: * m32c-tdep.c (m32c_move_reg_t): Replace with... (m32c_write_reg_t): ...this and... (m32c_read_reg_t): ...this. (struct m32c_reg): Update types of read and write. (m32c_raw_read): Change declaration type to m32c_read_reg_t and adjust definition. (m32c_banked_read): Likewise. (m32c_sb_read): Likewise. (m32c_part_read): Likewise. (m32c_cat_read): Likewise. (m32c_r3r2r1r0_read): Likewise. (m32c_raw_write): Change declaration type to m32c_write_reg_t and adjust definition. (m32c_banked_write): Likewise. (m32c_sb_write): Likewise. (m32c_part_write): Likewise. (m32c_cat_write): Likewise. (m32c_r3r2r1r0_write): Likewise.
2015-10-12aarch64: Add cast for integer to enum castSimon Marchi2-1/+6
/home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c: In function ‘int aarch64_linux_syscall_record(regcache*, long unsigned int)’: /home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c:904:57: error: invalid conversion from ‘long unsigned int’ to ‘aarch64_syscall’ [-fpermissive] syscall_gdb = aarch64_canonicalize_syscall (svc_number); ^ /home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c:645:1: note: initializing argument 1 of ‘gdb_syscall aarch64_canonicalize_syscall(aarch64_syscall)’ aarch64_canonicalize_syscall (enum aarch64_syscall syscall_number) ^ gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_linux_syscall_record): Add cast.
2015-10-12aarch64: Use gdb_sys_no_syscall enum instead of -1Simon Marchi2-1/+6
Fixes: /home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c: In function "gdb_syscall aarch64_canonicalize_syscall(aarch64_syscall)": /home/simark/src/binutils-gdb/gdb/aarch64-linux-tdep.c:874:13: error: invalid conversion from "int" to "gdb_syscall" [-fpermissive] return -1; ^ gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_canonicalize_syscall): Return gdb_sys_no_syscall instead of -1.
2015-10-12Mention the change in NEWSYao Qi2-0/+6
gdb: 2015-10-12 Yao Qi <yao.qi@linaro.org> * NEWS: Mention the change.
2015-10-12Rename emit_load_store to aarch64_emit_load_storeYao Qi5-15/+25
Likewise, this patch renames emit_load_store to aarch64_emit_load_store. gdb: 2015-10-12 Yao Qi <yao.qi@linaro.org> * arch/aarch64-insn.c (emit_load_store): Rename to ... (aarch64_emit_load_store): ... it. All callers updated. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c: Update all callers as emit_load_store is renamed to aarch64_emit_load_store.
2015-10-12Rename emit_insn to aarch64_emit_insnYao Qi6-72/+85
As emit_insn becomes extern, the prefix "aarch64_" is needed. This patch renames emit_insn to aarch64_emit_insn. gdb: 2015-10-12 Yao Qi <yao.qi@linaro.org> * arch/aarch64-insn.c (emit_insn): Rename to ... (aarch64_emit_insn): ... it. All callers updated. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c: Update all callers of function renaming from emit_insn to aarch64_emit_insn.
2015-10-12New test case gdb.arch/disp-step-insn-reloc.expYao Qi2-0/+88
This patch adds a new test case which uses gdb.arch/insn-reloc.c too to test displaced stepping. Nowadays, tests are for x86, x86_64 and aarch64. gdb/testsuite: 2015-10-12 Yao Qi <yao.qi@linaro.org> * gdb.arch/disp-step-insn-reloc.exp: New test case.
2015-10-12Support displaced stepping in support_displaced_stepping for aarch64*-*-linux*Yao Qi2-1/+7
gdb/testsuite: 2015-10-12 Yao Qi <yao.qi@linaro.org> * lib/gdb.exp (support_displaced_stepping): Return 1 if target is aarch64*-*-linux*.
2015-10-12Support displaced stepping in aarch64-linuxYao Qi8-320/+711
This patch is to support displaced stepping in aarch64-linux. A visitor is implemented for displaced stepping, and used to record information to fixup pc after displaced stepping if needed. Some emit_* functions are converted to macros, and moved to arch/aarch64-insn.{c,h} so that they can be shared. gdb: 2015-10-12 Yao Qi <yao.qi@linaro.org> * aarch64-linux-tdep.c: Include arch-utils.h. (aarch64_linux_init_abi): Call set_gdbarch_max_insn_length, set_gdbarch_displaced_step_copy_insn, set_gdbarch_displaced_step_fixup, set_gdbarch_displaced_step_free_closure, set_gdbarch_displaced_step_location, and set_gdbarch_displaced_step_hw_singlestep. * aarch64-tdep.c (struct displaced_step_closure): New. (struct aarch64_displaced_step_data): New. (aarch64_displaced_step_b): New function. (aarch64_displaced_step_b_cond): Likewise. (aarch64_register): Likewise. (aarch64_displaced_step_cb): Likewise. (aarch64_displaced_step_tb): Likewise. (aarch64_displaced_step_adr): Likewise. (aarch64_displaced_step_ldr_literal): Likewise. (aarch64_displaced_step_others): Likewise. (aarch64_displaced_step_copy_insn): Likewise. (aarch64_displaced_step_fixup): Likewise. (aarch64_displaced_step_hw_singlestep): Likewise. * aarch64-tdep.h (DISPLACED_MODIFIED_INSNS): New macro. (aarch64_displaced_step_copy_insn): Declare. (aarch64_displaced_step_fixup): Declare. (aarch64_displaced_step_hw_singlestep): Declare. * arch/aarch64-insn.c (emit_insn): Moved from gdbserver/linux-aarch64-low.c. (emit_load_store): Likewise. * arch/aarch64-insn.h (enum aarch64_opcodes): Moved from gdbserver/linux-aarch64-low.c. (struct aarch64_register): Likewise. (struct aarch64_memory_operand): Likewise. (ENCODE): Likewise. (can_encode_int32): New macro. (emit_b, emit_bcond, emit_cb, emit_ldr, emit_ldrsw): Likewise. (emit_tb, emit_nop): Likewise. (emit_insn): Declare. (emit_load_store): Declare. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (enum aarch64_opcodes): Move to arch/aarch64-insn.h. (struct aarch64_memory_operand): Likewise. (ENCODE): Likewise. (emit_insn): Move to arch/aarch64-insn.c. (emit_b, emit_bcond, emit_cb, emit_tb): Remove. (emit_load_store): Move to arch/aarch64-insn.c. (emit_ldr, emit_ldrb, emit_ldrsw, emit_nop): Remove. (can_encode_int32): Remove.
2015-10-12Move aarch64_relocate_instruction to arch/aarch64-insn.cYao Qi5-155/+162
This patch moves aarch64_relocate_instruction and visitor class to arch/aarch64-insn.c, so that both GDB and GDBserver can use it. gdb: 2015-10-12 Yao Qi <yao.qi@linaro.org> * arch/aarch64-insn.c (aarch64_decode_ldr_literal): Moved from gdbserver/linux-aarch64-low.c. (aarch64_relocate_instruction): Likewise. * arch/aarch64-insn.h (aarch64_decode_ldr_literal): Declare. (struct aarch64_insn_data): Moved from gdbserver/linux-aarch64-low.c. (struct aarch64_insn_visitor): Likewise. (aarch64_relocate_instruction): Declare. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (extract_signed_bitfield): Remove. (aarch64_decode_ldr_literal): Move to gdb/arch/aarch64-insn.c. (aarch64_relocate_instruction): Likewise. (struct aarch64_insn_data): Move to gdb/arch/aarch64-insn.h. (struct aarch64_insn_visitor): Likewise.
2015-10-12Use visitor in aarch64_relocate_instructionYao Qi2-143/+314
Nowadays, the instruction decodings and handling are mixed together inside aarch64_relocate_instruction. The patch decouples instruction decoding and instruction handling by using visitor pattern. That is, aarch64_relocate_instruction decode instructions and visit each instruction by different visitor methods. Each visitor defines the concrete things to different instructions. Fast tracepoint instruction relocation and displaced stepping can define their own visitors, sub-class of struct aarch64_insn_data. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (struct aarch64_insn_data): New. (struct aarch64_insn_visitor): New. (struct aarch64_insn_relocation_data): New. (aarch64_ftrace_insn_reloc_b): New function. (aarch64_ftrace_insn_reloc_b_cond): Likewise. (aarch64_ftrace_insn_reloc_cb): Likewise. (aarch64_ftrace_insn_reloc_tb): Likewise. (aarch64_ftrace_insn_reloc_adr): Likewise. (aarch64_ftrace_insn_reloc_ldr_literal): Likewise. (aarch64_ftrace_insn_reloc_others): Likewise. (visitor): New. (aarch64_relocate_instruction): Use visitor.
2015-10-12Move append_insns out of aarch64_relocate_instructionYao Qi2-18/+26
aarch64_relocate_instruction should only decode instructions, and other operations should be done out side of it. This patch moves append_insns out of aarch64_relocate_instruction, to its caller. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_relocate_instruction): Return int. Add argument buf. (aarch64_install_fast_tracepoint_jump_pad): Pass buf to aarch64_relocate_instruction.
2015-10-12Move target_read_uint32 out of aarch64_relocate_instructionYao Qi2-7/+14
This patch is to move target_read_uint32 out of aarch64_relocate_instruction and pass INSN to aarch64_relocate_instruction, so that it is cleaner, only decode instructions. gdb/gdbserver: 2015-10-12 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_relocate_instruction): Add argument insn. Remove local variable insn. Don't call target_read_uint32. (aarch64_install_fast_tracepoint_jump_pad): Call target_read_uint32.
2015-10-12More tests in gdb.arch/insn-reloc.cYao Qi2-3/+57
This patch adds more tests in gdb.arch/insn-reloc.c to cover instruction BL and cover B.CON when CON is false. These new added tests can be used for displaced stepping too. gdb/testsuite: 2015-10-12 Yao Qi <yao.qi@linaro.org> * gdb.arch/insn-reloc.c (can_relocate_bcond): Rename to ... (can_relocate_bcond_true): ... it. (can_relocate_bcond_false): New function. (foo): Likewise. (can_relocate_bl): Likewise. (testcases) [__aarch64__]: Add can_relocate_bcond_false and can_relocate_bl.
2015-10-12Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCTPierre-Marie de Rodat5-1/+81
Assume foo_array is a pointer to a C structure. GDB must evaluate the following expression properly, but it does not currently: (gdb) print 1 && &foo_array[1].a Attempt to take address of value not located in memory. The problem is that in EVAL_AVOID_SIDE_EFFECTS mode, eval.c:evaluate_subexp_standard always returns a not_lval value as the result for a STRUCTOP_STRUCT operation. As a consequence, the rest of the code believes that one cannot take the address of the returned value. This patch fixes STRUCTOP_STRUCT handling so that the VALUE_LVAL attribute for the returned value is properly initialized. After this change, the above session becomes: (gdb) print 1 && &foo_array[1].a $1 = 1 gdb/ChangeLog: * eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT>: If EVAL_AVOID_SIDE_EFFECTS mode, forward the VALUE_LVAL attribute to the returned value. gdb/testsuite/ChangeLog: * gdb.base/nested-addr.c: New file. * gdb.base/nested-addr.exp: New testcase. Tested on x86_64-linux, no regression.
2015-10-09[Ada] ada_unpack_from_contents: Error if target buffer not large enoughJoel Brobecker2-1/+15
This adds a guard that the size of the "unpacked" buffer is large enough to contain at least BIT_SIZE bits. If not, report an error. This is to guard this routine from doing buffer overflows when called incorrectly. gdb/ChangeLog: * ada-lang.c (ada_unpack_from_contents): Add guard that unpacked is large enough for BIT_SIZE. Update function comment.
2015-10-09[Ada] Buffer overflow in ada_unpack_from_contentsJoel Brobecker2-1/+19
This patch fixes a buffer overflow in ada_unpack_from_contents caused by one of the previous commits. This happens when trying to print the value of an array of variant records. The overflow happens while trying to print one element of the array. Because the size of each element in the array is variable, the array has a DWARF byte_stride attribute, which makes us treat the array as if it was packed. And during the extraction of each array element, we try to unpack an object using the array's byte stride as the size, into an element whose size is actually less than the stride. This patch fixes the issue by overriding the byte-stride with the actual element's length. gdb/ChangeLog: * ada-lang.c (ada_value_primitive_packed_val): Move src_len variable to local block where used. Override BIT_SIZE if bigger than size of resolved type.
2015-10-09make is_scalar_type non-static and use it in ada-lang.cJoel Brobecker4-14/+11
Just a small cleanup, to avoid code duplication... gdb/ChangeLog: * gdbtypes.h (is_scalar_type): Add extern declaration. * gdbtypes.c (is_scalar_type): Make non-static. * ada-lang.c (ada_value_primitive_packed_val): Use is_scalar_type to compute IS_SCALAR instead of doing it ourselves.
2015-10-09[Ada] Better handling of dynamic types in ada_value_primitive_packed_valJoel Brobecker2-29/+57
There is some partial handling for dynamic types in ada_value_primitive_packed_val, but this support was added in a fairly ad hoc way, and actually only covered the situation where OBJ is not NULL and its contents had not been fetched yet. In addition, even in the cases that it does cover, it doesn't make much sense. In particular, it was adjusting BIT_SIZE and SRC_LEN, which are properties of the data to be extracted _from_, based on TYPE's length once resolved, which is a property of the data we want to extract _to_. This patch hopefully adjust this function to handle dynamic types correctly, and in all cases. It does so by unpacking the data into a temporary buffer in order to use that buffer to resolve the type. And _then_ creates the resulting value from that resolved type. gdb/ChangeLog: * ada-lang.c (ada_value_primitive_packed_val): Rework handling of case where TYPE is dynamic.
2015-10-09[Ada] split data unpacking code out of ada_value_primitive_packed_val.Joel Brobecker2-91/+133
This patch is just preparation work which splits the function ada_value_primitive_packed_val into two function: one which unpacks the data, and the other which now uses it to implement ada_value_primitive_packed_val. This simplifies a bit ada_value_primitive_packed_val, but will also allow us to use the new function to unpack data without actually creating a struct value as a result. gdb/ChangeLog: * ada-lang.c (ada_unpack_from_contents): New function, extracted from ada_value_primitive_packed_val. (ada_value_primitive_packed_val): Replace extracted out code by call to ada_unpack_from_contents.
2015-10-09Reorder variable declarations in ada_value_primitive_packed_valJoel Brobecker2-9/+18
This patch just changes the order in which local variables are declared so as to group the logically-related variables together. No code change otherwise. gdb/ChangeLog: * ada-lang.c (ada_value_primitive_packed_val): Reorder local variable declarations.
2015-10-09use gdb_byte in ada-lang.c::ada_value_primitive_packed_val...Joel Brobecker2-5/+11
... instead of "unsigned char". gdb/Changelog: * ada-lang.c (ada_value_primitive_packed_val): Change the type of local variables src and unpacked to "gdb_type *" instead of "unsigned char *".
2015-10-09More explicit local variable names in ada_value_primitive_packed_valJoel Brobecker2-30/+37
A number of local variables declared in ada_value_primitive_packed_val have a name that could, IMO, be improved to, either: Be more explicit about what the variable is about (Eg: "src" is an index, so rename it to "src_idx"); or be more consistent with other variables that they relate to: for instance, several variables refer to the source via "src" (Eg: srcBitsLeft, nsrc), but the buffer they refer to is called "bytes", so patch renames "bytes" to "src". This should help read and understand a little more easily the code inside this function. No real code change otherwise. gdb/ChangeLog: * ada-lang.c (ada_value_primitive_packed_val): Make the name of various local variables more explicit and consistent. No real code change otherwise.