aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2015-11-23darwin-nat: rewrite darwin_read_write_inferiorTristan Gingold2-61/+93
This is a little bit more efficient.
2015-11-22target.h: #include <sys/types.h>.Doug Evans2-0/+5
For musl.
2015-11-20Fix '-data-read-memory-bytes' typo/assertionDon Breazeal2-2/+8
This patch fixes a typo in target.c:read_memory_robust, where it calls read_whatever_is_readable with the function arguments in the wrong order. Depending on the address being read, it can cause an xmalloc with a huge size, resulting in an assertion failure, or just read something other than what was requested. The problem only arises when GDB is handling an MI "-data-read-memory-bytes" request and the initial target_read returns an error status. Note that read_memory_robust is only called from the MI code. gdb/ChangeLog: * gdb/target.c (read_memory_robust): Call read_whatever_is_readable with arguments in the correct order.
2015-11-20callfuncs.exp: avoid spurious register differences in sparc64 targets.Jose E. Marchesi2-0/+16
The Linux kernel disables the FPU upon returning to userland. This introduces spurious failures in the register preservation tests in callfuncs.exp, since the pstate.PEF bit gets cleared after system calls. This patch filters out the pstate register in sparc64-*-linux-gnu targets, so the relevant tests are no longer fooled and pass. gdb/testsuite/ChangeLog: 2015-11-20 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.base/callfuncs.exp (fetch_all_registers): Filter out the pstate register when comparing registers values in sparc64-*-linux-gnu targets to avoid spurious differences.
2015-11-20sparc: fix build of gdb/testsuite/gdb.arch/sparc-sysstep.cJose E. Marchesi2-0/+5
This patch adds a missing include that makes the test program to not be built (--Wimplicit-function-declaration). gdb/testsuite/ChangeLog: 2015-11-20 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.arch/sparc-sysstep.c: Include unistd.h for getpid.
2015-11-19Fix think-o in calls to gdb_compile.Sandra Loosemore4-3/+10
2015-11-19 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/nested-subp1.exp: Pass executable, not executable name, as type argument to gdb_compile. * gdb.base/nested-subp2.exp: Likewise. * gdb.base/nested-subp3.exp: Likewise.
2015-11-19gdbserver: Fix qSupported:xmlRegisters=i386;UnknownFeature+ handlingPedro Alves6-24/+53
The target_process_qsupported method is called for each qSupported feature that the common code does not recognize. The only current implementation, for x86 Linux (x86_linux_process_qsupported), assumes that it either is called with the "xmlRegisters=i386" feature, or that it is isn't called at all, indicating the connected GDB predates x86 XML descriptions. That's a bad assumption however. If GDB sends in a new/unknown (to core gdbserver) feature after "xmlRegisters=i386", say, something like qSupported:xmlRegisters=i386;UnknownFeature+, then when target_process_qsupported is called for "UnknownFeature+", x86_linux_process_qsupported clears the 'use_xml' global and calls x86_linux_update_xmltarget, and gdbserver ends up _not_ reporting a XML description... This commit changes the target_process_qsupported API to instead pass down a vector of unprocessed qSupported features in one go. (There's an early call to target_process_qsupported(NULL) that indicates "starting qSupported processing". There's no matching call to mark the end of processing, though. I first fixed this by passing (char *)-1 to indicate that, and adjusted the x86 backend to only clear 'use_xml' when qSupported processing starts, and then only call x86_linux_update_xmltarget() when (char *)-1 was passed. However, I wasn't that happy with the hack and came up this alternative version.) gdb/gdbserver/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_process_qsupported): Change prototype. Adjust. * linux-low.h (struct linux_target_ops) <process_qsupported>: Change prototype. * linux-x86-low.c (x86_linux_process_qsupported): Change prototype and adjust to loop over all features. * server.c (handle_query) <qSupported>: Adjust to call target_process_qsupported once, passing it a vector of unprocessed features. * target.h (struct target_ops) <process_qsupported>: Change prototype. (target_process_qsupported): Adjust.
2015-11-19gdb: Workaround bad gdbserver qSupported:xmlRegisters=i386;UnknwnFeat+ handlingPedro Alves2-3/+10
gdbserver's target_process_qsupported is called for each feature that the gdbserver common code does not recognize. The only current implementation, for x86 Linux, does this: static void x86_linux_process_qsupported (const char *query) { /* Return if gdb doesn't support XML. If gdb sends "xmlRegisters=" with "i386" in qSupported query, it supports x86 XML target descriptions. */ use_xml = 0; if (query != NULL && startswith (query, "xmlRegisters=")) { char *copy = xstrdup (query + 13); char *p; for (p = strtok (copy, ","); p != NULL; p = strtok (NULL, ",")) { if (strcmp (p, "i386") == 0) { use_xml = 1; break; } } free (copy); } x86_linux_update_xmltarget (); } Notice that this clears use_xml and calls x86_linux_update_xmltarget each time target_process_qsupported is called. So if gdb sends in any unknown feature after "xmlRegisters=i386", like e.g., "xmlRegisters=i386;UnknownFeature+" gdbserver ends up not reporting a XML description... Work around this by having GDB send the "xmlRegisters=" feature last. gdb/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * remote.c (remote_query_supported): Send the "xmlRegisters=" feature last.
2015-11-19Fix iov_len calculation in aarch64_linux_set_debug_regsSimon Marchi2-2/+7
There is this build failure when building in C++: /home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c: In function ‘void aarch64_linux_set_debug_regs(const aarch64_debug_reg_state*, int, int)’: /home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:564:64: error: ‘count’ cannot appear in a constant-expression iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1]) ^ We can simplify the computation and make g++ happy at the same time by formulating as: size of fixed part + size of variable part thus... size of fixed part + count * size of one variable part element thus... offsetof (struct user_hwdebug_state, dbg_regs) + count * sizeof (regs.dbg_reg[0]); gdb/ChangeLog: * nat/aarch64-linux-hw-point.c (aarch64_linux_set_debug_regs): Change form of iov_len computation.
2015-11-19[C++] Default to -Werror in C++ mode tooPedro Alves6-14/+18
Both x86_64 GNU/Linux and x86_64 mingw-w64 build cleanly with --enable-targets=all. This enables -Werror by default in C++ mode too, in order to let the buildbot catch C++ build regressions for us. gdb/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * configure.ac (ERROR_ON_WARNING): Don't check whether in C++ mode. * configure: Regenerate. gdb/gdbserver/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * configure.ac (ERROR_ON_WARNING): Don't check whether in C++ mode. * configure: Regenerate.
2015-11-19[C++] Drop -fpermissive hackPedro Alves5-6/+12
Both x86_64 GNU/Linux and x86_64 mingw-w64 build cleanly with --enable-targets=all. Let's drop the -fpermissive hack, in order to let the buildbot catch C++ build regressions for us. gdb/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Remove -fpermissive. * configure: Regenerate. gdb/gdbserver/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * configure: Regenerate.
2015-11-19[C++] breakpoint.c: "no memory" software watchpoints and enum castsPedro Alves2-13/+44
Fixes: src/gdb/breakpoint.c: In function ‘void update_watchpoint(watchpoint*, int)’: src/gdb/breakpoint.c:2147:31: error: invalid conversion from ‘int’ to ‘target_hw_bp_type’ [-fpermissive] base->loc->watchpoint_type = -1; ^ Seems better to rely on "address == -1 && length == -1" than on a enum value that's not really part of the set of supposedly valid enum values. Also, factor that out to separate functions for better localization of the concept. gdb/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * breakpoint.c (software_watchpoint_add_no_memory_location) (is_no_memory_software_watchpoint): New functions. (update_watchpoint): Use software_watchpoint_add_memoryless_location. (breakpoint_address_bits): Use is_no_memory_software_watchpoint.
2015-11-19[C++] s390: Fix enum gdb_syscall conversionSimon Marchi2-17/+30
Fixes: src/gdb/s390-linux-tdep.c: In function ‘gdb_syscall s390_canonicalize_syscall(int, s390_abi_kind)’: src/gdb/s390-linux-tdep.c:2622:16: error: invalid conversion from ‘int’ to ‘gdb_syscall’ [-fpermissive] return syscall; ^ src/gdb/s390-linux-tdep.c:2722:16: error: invalid conversion from ‘int’ to ‘gdb_syscall’ [-fpermissive] return syscall; ^ src/gdb/s390-linux-tdep.c:2725:24: error: invalid conversion from ‘int’ to ‘gdb_syscall’ [-fpermissive] return syscall + 2; ^ src/gdb/s390-linux-tdep.c:2728:24: error: invalid conversion from ‘int’ to ‘gdb_syscall’ [-fpermissive] return syscall + 5; ^ src/gdb/s390-linux-tdep.c:2731:24: error: invalid conversion from ‘int’ to ‘gdb_syscall’ [-fpermissive] return syscall + 6; ^ src/gdb/s390-linux-tdep.c:2734:24: error: invalid conversion from ‘int’ to ‘gdb_syscall’ [-fpermissive] return syscall + 7; ^ gdb/ChangeLog: 2015-11-19 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> * s390-linux-tdep.c (s390_canonicalize_syscall): Add casts and intermediate 'int' variable.
2015-11-19[C++] linux-thread-db.c: dladdr castPedro Alves2-1/+5
Fixes: src/gdb/linux-thread-db.c: In function ‘int try_thread_db_load_1(thread_db_info*)’: src/gdb/linux-thread-db.c:769:53: error: invalid conversion from ‘td_err_e (*)(ps_prochandle*, td_thragent_t**) {aka td_err_e (*)(ps_prochandle*, td_thragent**)}’ to ‘const void*’ [-fpermissive] library = dladdr_to_soname (*info->td_ta_new_p); ^ src/gdb/linux-thread-db.c:637:1: error: initializing argument 1 of ‘const char* dladdr_to_soname(const void*)’ [-fpermissive] dladdr_to_soname (const void *addr) ^ gdb/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * linux-thread-db.c (try_thread_db_load_1): Add cast.
2015-11-19[C++] remote.c: Avoid enum arithmeticPedro Alves4-12/+40
Fixes: src/gdb/remote.c: In function ‘void remote_unpush_target()’: src/gdb/remote.c:4610:45: error: invalid conversion from ‘int’ to ‘strata’ [-fpermissive] pop_all_targets_above (process_stratum - 1); ^ In file included from src/gdb/inferior.h:38:0, from src/gdb/remote.c:25: src/gdb/target.h:2299:13: error: initializing argument 1 of ‘void pop_all_targets_above(strata)’ [-fpermissive] extern void pop_all_targets_above (enum strata above_stratum); ^ I used to carry a patch in the C++ branch that just did: - pop_all_targets_above (process_stratum - 1); + pop_all_targets_above ((enum strata) (process_stratum - 1)); But then thought that maybe adding a routine that does exactly what we need results in clearer code. This is the result. gdb/ChangeLog: 2015-11-19 Pedro Alves <palves@redhat.com> * remote.c (remote_unpush_target): Use pop_all_targets_at_and_above instead of pop_all_targets_above. * target.c (unpush_target_and_assert): New function, factored out from ... (pop_all_targets_above): ... here. (pop_all_targets_at_and_above): New function. * target.h (pop_all_targets_at_and_above): Declare.
2015-11-19Change argument opcode type from enum aarch64_opcodes to uint32_tYao Qi2-1/+6
The patch fixes the following errors in C++ build, gdb/gdbserver/linux-aarch64-low.c: In function 'int emit_data_processing(uint32_t*, aarch64_opcodes, aarch64_register, aarch64_register, aarch64_operand)': gdb/gdbserver/linux-aarch64-low.c:1071:52: error: invalid conversion from 'unsigned int' to 'aarch64_opcodes' [-fpermissive] return emit_data_processing_reg (buf, opcode | operand_opcode, rd, ^ gdb/gdbserver: 2015-11-19 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (emit_data_processing_reg): Change opcode type to uint32_t.
2015-11-19Define enum out of the scope of structYao Qi2-5/+13
This patch moves the enum definition out of the scope of struct, and fixes the following error. gdb/gdbserver/linux-aarch64-low.c:681:18: error: 'OPERAND_REGISTER' was not declared in this scope operand.type = OPERAND_REGISTER; ^ gdb/gdbserver: 2015-11-19 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (enum aarch64_operand_type): New. (struct aarch64_operand): Move enum out.
2015-11-19Cast void * to user_fpsimd_state *.Yao Qi2-2/+9
This patch fixes the following build error in GDBserver, gdb/gdbserver/linux-aarch64-low.c: In function 'void aarch64_fill_fpregset(regcache*, void*)': gdb/gdbserver/linux-aarch64-low.c:134:38: error: invalid conversion from 'void*' to 'user_fpsimd_state*' [-fpermissive] struct user_fpsimd_state *regset = buf; ^ gdb/gdbserver/linux-aarch64-low.c: In function 'void aarch64_store_fpregset(regcache*, const void*)': gdb/gdbserver/linux-aarch64-low.c:146:44: error: invalid conversion from 'const void*' to 'const user_fpsimd_state*' [-fpermissive] const struct user_fpsimd_state *regset = buf; ^ gdb/gdbserver: 2015-11-19 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_fill_fpregset): Cast buf to struct user_fpsimd_state *. (aarch64_store_fpregset): Likewise.
2015-11-19Cast void * to struct user_pt_regs *Yao Qi2-2/+8
This patch fixes the following GDBserver build errors in C++. gdb/gdbserver/linux-aarch64-low.c:108:33: error: invalid conversion from 'void*' to 'user_pt_regs*' [-fpermissive] struct user_pt_regs *regset = buf; ^ gdb/gdbserver/linux-aarch64-low.c: In function 'void aarch64_store_gregset(regcache*, const void*)': gdb/gdbserver/linux-aarch64-low.c:121:39: error: invalid conversion from 'const void*' to 'const user_pt_regs*' [-fpermissive] const struct user_pt_regs *regset = buf; gdb/gdbserver: 2015-11-19 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_fill_gregset): Cast buf to struct user_pt_regs *. (aarch64_store_gregset): Likewise.
2015-11-18Constify value_stringSimon Marchi3-2/+7
If we constify value_cstring, we might as well constify this one. gdb/ChangeLog: * valops.c (value_string): Constify 'ptr' parameter. * value.h (value_string): Constify 'ptr' parameter.
2015-11-18[C++] Add casts to obstack_base callsSimon Marchi8-12/+24
The recent libiberty import of upstream obstack.h (314dee8ea9be) makes obstack_base return a 'void *', with the consequence that a few places in gdb need a (char *) cast. gdb/ChangeLog: 2015-11-18 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> * break-catch-sig.c (signal_catchpoint_print_one): Add cast. * c-exp.y (parse_string_or_char, yylex): Add casts. * c-lang.c (evaluate_subexp_c): Add casts. * d-exp.y (parse_string_or_char, yylex): Add casts. * go-exp.y (parse_string_or_char, build_packaged_name): Add casts. * p-valprint.c (pascal_object_print_value_fields): Add casts. * valprint.c (generic_emit_char, generic_printstr): Add casts.
2015-11-18Constify value_cstringSimon Marchi3-2/+7
gdb/ChangeLog: 2015-11-18 Simon Marchi <simon.marchi@ericsson.com> * valops.c (value_cstring): Constify 'ptr' parameter. * value.h (value_cstring): Constify 'ptr' parameter.
2015-11-18[gdbserver/ipa] Fix build dependenciesPedro Alves2-1/+5
Commit 91ee7171d088 (MinGW and attribute format(printf/gnu_printf)) made common/common-defs.h depend on gnulib's substitute headers. Turns out that that broke the gdbserver/ipa build (as the buildbots discovered) because nothing is making sure that gnulib is built before the ipa is. gdb/gdbserver/ChangeLog: 2015-11-18 Pedro Alves <palves@redhat.com> * Makefile.in (all_object_files): Add $IPA_OBJS.
2015-11-18Fix out of boundary access in pass_in_vYao Qi2-4/+18
Hi, I build GDB with -fsanitize=address, and run testsuite. In gdb.base/callfuncs.exp, I see the following error, p t_float_values(0.0,0.0) ================================================================= ==8088==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000cb650 at pc 0x6e195c bp 0x7fff164f9770 sp 0x7fff164f9768 READ of size 16 at 0x6020000cb650 thread T0^ #0 0x6e195b in regcache_raw_write /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:912 #1 0x6e1e52 in regcache_cooked_write /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:945 #2 0x466d69 in pass_in_v /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1101 #3 0x467512 in pass_in_v_or_stack /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1196 #4 0x467d7d in aarch64_push_dummy_call /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1335 The code in pass_in_v read contents from V registers (128 bit), but the data passed through V registers can be less than 128 bit. In this case, float is passed. So writing V registers contents into contents buff will cause overflow. In this patch, we add an array reg[V_REGISTER_SIZE], which is to hold the contents from V registers, and then copy useful bits to buf. gdb: 2015-11-18 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (pass_in_v): Add argument len. Add local array reg. Callers updated.
2015-11-17Fix gdb.threads/multiple-step-overs.exp fails on armYao Qi2-6/+14
Hi, Some tests in gdb.threads/multiple-step-overs.exp fail on arm target when the displaced stepping on, but they pass when displaced stepping is off. FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: step: step FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: next: next FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: continue: continue FAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr1: continue to sigusr1_handler when displaced stepping is on, Sending packet: $vCont;c#a8...infrun: infrun_async(1)^M <--- [1] infrun: prepare_to_wait^M infrun: target_wait (-1.0.0, status) =^M infrun: -1.0.0 [Thread 0],^M infrun: status->kind = ignore^M infrun: TARGET_WAITKIND_IGNORE^M infrun: prepare_to_wait^M Packet received: T05swbreak:;0b:f8faffbe;0d:409ee7b6;0f:d0880000;thread:p635.636;core:0;^M infrun: target_wait (-1.0.0, status) =^M infrun: 1589.1590.0 [Thread 1590],^M infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP^M infrun: TARGET_WAITKIND_STOPPED^M infrun: stop_pc = 0x88d0^M infrun: context switch^M infrun: Switching context from Thread 1591 to Thread 1590^ GDB resumes the whole process (all threads) rather than the specific thread for which GDB wants to step over the breakpoint (as shown in [1]). That is wrong because we resume a single thread and leave others stopped when doing a normal step over where we temporarily remove the breakpoint, single-step, reinsert the breakpoint, is that if we let other threads run in the period while the breakpoint is removed, then these other threads could miss the breakpoint. Since with displaced stepping, we don't ever remove the breakpoint, it should be fine to let other threads run. However, there's another reason that we should not let other threads run: that is the case where some of those threads are also stopped for a breakpoint that itself needs to be stepped over. If we just let those threads run, then they immediately re-trap their breakpoint again. when displaced stepping is off, GDB behaves correctly, only resumes the specific thread (as shown in [2]). Sending packet: $vCont;c:p611.613#b2...infrun: infrun_async(1)^M <-- [2] infrun: prepare_to_wait^M infrun: target_wait (-1.0.0, status) =^M infrun: -1.0.0 [Thread 0],^M infrun: status->kind = ignore^M infrun: TARGET_WAITKIND_IGNORE^M infrun: prepare_to_wait^M Packet received: T05swbreak:;0b:f8faffbe;0d:409e67b6;0f:48880000;thread:p611.613;core:1;^M infrun: target_wait (-1.0.0, status) =^M infrun: 1553.1555.0 [Thread 1555],^M infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP^M infrun: TARGET_WAITKIND_STOPPED^M infrun: clear_step_over_info^M infrun: stop_pc = 0x8848 The current logic in GDB on deciding the set of threads to resume is: /* Decide the set of threads to ask the target to resume. */ if ((step || thread_has_single_step_breakpoints_set (tp)) && tp->control.trap_expected) { /* We're allowing a thread to run past a breakpoint it has hit, by single-stepping the thread with the breakpoint removed. In which case, we need to single-step only this thread, and keep others stopped, as they can miss this breakpoint if allowed to run. */ resume_ptid = inferior_ptid; } else resume_ptid = internal_resume_ptid (user_step); it doesn't handle the case correctly that GDB continue (instead of single step) the thread for displaced stepping. I also update the comment below to reflect the code. I remove the "with the breakpoint removed" comment, because GDB doesn't remove breakpoints in displaced stepping, so we don't have to worry that other threads may miss the breakpoint. Patch is regression tested on both x86_64-linux and arm-linux. gdb: 2015-11-17 Yao Qi <yao.qi@linaro.org> * infrun.c (resume): Check control.trap_expected only when deciding the set of threads to resume.
2015-11-17Introduce null_block_symbolPedro Alves5-12/+31
... in the spirit of null_ptid, null_frame_id, etc. Fixes two instances of: /root/binutils-gdb/gdb/cp-namespace.c: In function 'block_symbol cp_lookup_nested_symbol(type*, const char*, const block*, domain_enum)': /root/binutils-gdb/gdb/cp-namespace.c:1010: warning: jump to case label /root/binutils-gdb/gdb/cp-namespace.c:1008: error: crosses initialization of 'block_symbol <anonymous>' Compiler info: Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.8/4.2.1/specs Target: amd64-unknown-openbsd5.8 Configured with: OpenBSD/amd64 system compiler Thread model: posix gcc version 4.2.1 20070719 gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * cp-namespace.c (cp_lookup_bare_symbol) (cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports) (cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1) (cp_lookup_nested_symbol): Use null_block_symbol. * d-namespace.c (d_lookup_symbol, d_lookup_nested_symbol) (d_lookup_symbol_imports, d_lookup_symbol_module): Use null_block_symbol. * symtab.c (null_block_symbol): New global. * symtab.h (null_block_symbol): Declare.
2015-11-17[C++] Always use setjmp/longjmp for exceptionsPedro Alves3-16/+41
We currently throw exceptions from signal handlers (e.g., for Quit/ctrl-c). But throwing C++ exceptions from signal handlers is undefined. (That doesn't restore signal masks, like siglongjmp does, and, because asynchronous signals can arrive at any instruction, we'd have to build _everything_ with -fasync-unwind-tables to make it reliable.) It happens to work on x86_64 GNU/Linux at least, but it's likely broken on other ports. Until we stop throwing from signal handlers, use setjmp/longjmp based exceptions in C++ mode as well. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY) (GDB_XCPT_RAW_TRY, GDB_XCPT): Define. Replace __cplusplus checks with GDB_XCPT checks throughout. * common/common-exceptions.c: Replace __cplusplus checks with GDB_XCPT checks throughout.
2015-11-17MinGW and attribute format(printf/gnu_printf)Pedro Alves2-0/+14
Cross building gdbserver for --host=x86_64-w64-mingw32 with gcc 4.8.4 20141219 (Fedora MinGW 4.8.4-1.fc20), I get: src/gdb/gdbserver/tracepoint.c: In function 'cmd_qtdp': src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=] trace_debug ("Defined %stracepoint %d at 0x%s, " ^ src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=] src/gdb/gdbserver/tracepoint.c:2577:7: error: too many arguments for format [-Werror=format-extra-args] src/gdb/gdbserver/tracepoint.c: In function 'stop_tracing': src/gdb/gdbserver/tracepoint.c:3447:7: error: unknown conversion type character 'l' in format [-Werror=format=] trace_debug ("Stopping the trace because " ^ src/gdb/gdbserver/tracepoint.c:3447:7: error: too many arguments for format [-Werror=format-extra-args] src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_tracepoint': src/gdb/gdbserver/tracepoint.c:4651:3: error: unknown conversion type character 'l' in format [-Werror=format=] trace_debug ("Making new traceframe for tracepoint %d at 0x%s, hit %" PRIu64, ^ src/gdb/gdbserver/tracepoint.c:4651:3: error: too many arguments for format [-Werror=format-extra-args] src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_step': src/gdb/gdbserver/tracepoint.c:4687:3: error: unknown conversion type character 'l' in format [-Werror=format=] trace_debug ("Making new step traceframe for " ^ trace_debug is a macro that calls: static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2); The calls that fail checking use PRIu64, etc., like: trace_debug ("Defined %stracepoint %d at 0x%s, " "enabled %d step %" PRIu64 " pass %" PRIu64, tpoint->type == fast_tracepoint ? "fast " : tpoint->type == static_tracepoint ? "static " : "", tpoint->number, paddress (tpoint->address), tpoint->enabled, tpoint->step_count, tpoint->pass_count); gnulib's stdio/printf module replacements may make %llu, etc. work on mingw, instead of the MS-specific %I64u, and thus may make PRIu64 expand to %llu. However, gcc isn't aware of that, because libiberty's ansidecl.h defines ATTRIBUTE_PRINTF as using attribute format(printf). But, with that format, gcc checks for MS-style format strings (%I64u). In order to have gcc expect gnu/standard formats, we need to use gnu_printf format instead. Which version to use (printf/gnu_printf) depends on msvcrt and mingw version, and so gnulib has a configure-time check, and defines _GL_ATTRIBUTE_FORMAT_PRINTF accordingly. Since _GL_ATTRIBUTE_FORMAT_PRINTF is compatible with ATTRIBUTE_PRINTF, the fix is simply to make use of the former. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * common/common-defs.h (ATTRIBUTE_PRINTF): Redefine in terms of _GL_ATTRIBUTE_FORMAT_PRINTF after including ansidecl.h.
2015-11-17[C++] Define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS for stdint.hPedro Alves2-0/+21
With some toolchains, building in C++ mode stumbles on many instances of: In file included from ../../src/gdb/../include/splay-tree.h:43:0, from ../../src/gdb/dcache.c:26: build-gnulib/import/inttypes.h:61:3: error: #error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>." # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>." ^ make: *** [dcache.o] Error 1 That's: #if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX) # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>." #endif I see it when cross building for --host=x86_64-w64-mingw32 using Fedora 20's g++ (gcc version 4.8.4 20141219 (Fedora MinGW 4.8.4-1.fc20)), Simon reports seeing this on several cross compilers too. The issue is that on some hosts that predate C++11, when using C++ one must define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS to make visible the definitions of INTMAX_C / INTMAX_MAX etc. This was a C99 requirement that later C++11 -- the first to define stdint.h -- removed, and then C11 removed it as well. https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html says that gnulib's stdint.h fixes this, but because we run gnulib's configure tests with a C compiler, gnulib determines that mingw's stdint.h is C99-compliant, and doesn't actually replace it. Actually, even though configuring gnulib with a C++ compiler does result in gnulib replacing stdint.h, the resulting replacement is broken for mingw, because it defines uintptr_t incorrectly. I sent a gnulib patch upstream to fix that, here: https://lists.gnu.org/archive/html/bug-gnulib/2015-11/msg00004.html but then even with that, gnulib still stumbles on other configured-with-C++-compiler problems. So for now, until gnulib + C++ is fixed upstream and then gdb's copy is updated, which may take a while, I think it's best to keep configuring gnulib in C, and define __STDC_LIMIT_MACROS/__STDC_CONSTANT_MACROS ourselves, just like C99 intended. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * common/common-defs.h (__STDC_CONSTANT_MACROS) (__STDC_LIMIT_MACROS): Define before including stdint.h.
2015-11-17[C++/mingw] Simplify first chance exception handlingPedro Alves2-18/+12
Building in C++ errors out with: ../../src/gdb/windows-nat.c: In function 'int get_windows_debug_event(target_ops*, int, target_waitstatus*)': ../../src/gdb/windows-nat.c:1503:13: warning: invalid conversion from 'int' to 'gdb_signal' [-fpermissive] last_sig = 1; ^ ../../src/gdb/windows-nat.c:1533:43: warning: invalid conversion from 'int' to 'gdb_signal' [-fpermissive] windows_resume (ops, minus_one_ptid, 0, 1); ^ ../../src/gdb/windows-nat.c:1228:1: warning: initializing argument 4 of 'void windows_resume(target_ops*, ptid_t, int, gdb_signal)' [-fpermissive] windows_resume (struct target_ops *ops, ^ Looking at the code, I can't figure out why we treat first chance exceptions any different here. AFAICS, we set last_sig to 1, and then call windows_resume passing signal==1, so the DBG_EXCEPTION_NOT_HANDLED code path in win32_resume is taken: ~~~ if (sig != GDB_SIGNAL_0) { if (current_event.dwDebugEventCode != EXCEPTION_DEBUG_EVENT) { OUTMSG (("Cannot continue with signal %d here.\n", sig)); } else if (sig == last_sig) continue_status = DBG_EXCEPTION_NOT_HANDLED; else OUTMSG (("Can only continue with recieved signal %d.\n", last_sig)); } ~~~ Fix this by removing this special casing. gdbserver also goes straight to continuing with DBG_EXCEPTION_NOT_HANDLED, AFAICS. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * windows-nat.c (handle_exception): Return 0 for first chance exceptions. (get_windows_debug_event): Adjust.
2015-11-17[C++/mingw] gdbserver: gdb/host signal mixupPedro Alves2-4/+11
Building in C++ caught a buglet here: ../../../src/gdb/gdbserver/win32-low.c: In function 'void win32_resume(thread_resume*, size_t)': ../../../src/gdb/gdbserver/win32-low.c:929:11: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive] sig = resume_info[0].sig; ^ ../../../src/gdb/gdbserver/win32-low.c:934:11: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive] sig = 0; ^ Signals in the "struct thread_resume" structure are host signals, not gdb signals. The current code happens to work because the only signals that the Windows port supports have the same number as the gdb equivalent (see handle_exception for the win32 exception -> gdb signal mapping). gdb/gdbserver/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * win32-low.c (win32_resume): Use gdb_signal_from_host, GDB_SIGNAL_0 and gdb_signal_to_string.
2015-11-17[C++/mingw] Fix windows-nat.c::xlatePedro Alves2-1/+6
Fixes: ../../src/gdb/windows-nat.c:287:11: error: invalid conversion from 'int' to 'gdb_signal' [-fpermissive] {-1, -1}}; ^ The signal number here doesn't really matter. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * windows-nat.c (xslate): Use GDB_SIGNAL_UNKNOWN instead of -1 as signal number for terminator.
2015-11-17[C++/mingw] handle_output_debug_stringPedro Alves2-6/+11
Fixes: ../../../src/gdb/gdbserver/win32-low.c: In function 'int win32_kill(int)': ../../../src/gdb/gdbserver/win32-low.c:823:46: error: invalid conversion from 'int' to 'target_waitkind' [-fpermissive] struct target_waitstatus our_status = { 0 }; ^ handle_output_debug_string doesn't use the parameter for anything (it's an output parameter in the gdb version), so just remove it. gdb/gdbserver/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * win32-low.c (handle_output_debug_string): Remove parameter. (win32_kill): Remove our_status local and adjust call to handle_output_debug_string. (get_child_debug_event): Adjust call to handle_output_debug_string.
2015-11-17[C++/mingw] ser-tcp.c castsPedro Alves2-6/+17
Fixes a few errors like these: ../../src/gdb/ser-tcp.c: In function 'int net_open(serial*, const char*)': ../../src/gdb/ser-tcp.c:286:73: error: invalid conversion from 'void*' to 'char*' [-fpermissive] res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len); ^ gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * ser-tcp.c (net_open) : Cast getsockopt argument to char * instead of void *. Update comment. (net_read_prim): Cast recv argument to char * instead of void *. (net_write_prim): Cast send argument to char *. Add comment.
2015-11-17[C++/mingw] gdbserver castsPedro Alves3-11/+23
A set of obviously-needed C++ casts. gdb/gdbserver/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * win32-i386-low.c (update_debug_registers_callback) (win32_get_current_dr): Add cast. * win32-low.c (thread_rec, delete_thread_info) (continue_one_thread): Add casts. (strwinerror): Cast FormatMessage argument to LPTSTR instead of LPVOID. (win32_create_inferior, suspend_one_thread): Add casts.
2015-11-17[C++/mingw] windows-nat.c castsPedro Alves2-38/+74
Fixes a set of errors like: ../../src/gdb/windows-nat.c: In function 'void _initialize_loadable()': ../../src/gdb/windows-nat.c:2778:30: error: invalid conversion from 'void*' to 'BOOL (*)(DWORD) {aka int (*)(long unsigned int)}' [-fpermissive] DebugActiveProcessStop = (void *) ^ gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * windows-nat.c (AdjustTokenPrivileges_ftype) (DebugActiveProcessStop_ftype, DebugBreakProcess_ftype) (DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype) (GetCurrentConsoleFont_ftype, GetModuleInformation_ftype) (LookupPrivilegeValueA_ftype, OpenProcessToken_ftype) (GetConsoleFontSize_ftype): New typedefs. (AdjustTokenPrivileges, DebugActiveProcessStop) (DebugBreakProcess, DebugSetProcessKillOnExit, EnumProcessModules) (GetConsoleFontSize, GetCurrentConsoleFont, GetModuleInformation) (LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize): Adjust. (GetModuleFileNameEx_ftype): New typedef. (GetModuleFileNameEx): Use it. (_initialize_loadable): Define GPA macro and use it.
2015-11-17[C++/mingw] gdb-dlfcn.c castsPedro Alves2-2/+7
Fixes: ../../src/gdb/gdb-dlfcn.c: In function 'void* gdb_dlsym(void*, const char*)': ../../src/gdb/gdb-dlfcn.c:105:49: error: invalid conversion from 'void*' to 'HMODULE {aka HINSTANCE__*}' [-fpermissive] return (void *) GetProcAddress (handle, symbol); ^ gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * gdb-dlfcn.c (gdb_dlsym, gdb_dlclose) [__MINGW32__]: Add casts to HMODULE.
2015-11-17[C++/mingw] Misc alloca castsPedro Alves5-8/+15
gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * exec.c (exec_file_attach, symfile_bfd_open) [__GO32__ || _WIN32 || __CYGWIN__]: Add casts. * utils.c (gdb_filename_fnmatch): Add cast. * windows-nat.c (windows_create_inferior): Add cast.
2015-11-17[C++/mingw] ser-mingw.c castsPedro Alves2-25/+42
2015-11-17 Pedro Alves <palves@redhat.com> * ser-mingw.c (CancelIo_ftype): New typedef. (CancelIo): Use CancelIo_ftype. (ser_windows_close, ser_windows_wait_handle) (ser_windows_read_prim, stop_select_thread) (console_select_thread, pipe_select_thread, file_select_thread) (ser_console_wait_handle, ser_console_done_wait_handle) (ser_console_close, cleanup_pipe_state, pipe_windows_close) (pipe_windows_write, pipe_wait_handle, pipe_done_wait_handle) (net_windows_socket_check_pending, net_windows_select_thread) (net_windows_wait_handle, net_windows_done_wait_handle) (net_windows_close): Add casts. (_initialize_ser_windows): Cast to CancelIo_ftype* instead of void*.
2015-11-17Convert c_string_type to an enum flags typeSimon Marchi4-13/+31
c_string_type contains values meant to be OR'ed together (even though some bits are mutually exclusive), so it makes sense to make it an enum flags type. gdb/ChangeLog: 2015-11-17 Simon Marchi <simon.marchi@ericsson.com> * c-exp.y (exp): Adjust, change enum c_string_type to c_string_type. (parse_string_or_char): Likewise. * c-lang.c (charset_for_string_type): Likewise. (classify_type): Likewise. (c_printchar): Likewise. (c_printstr): Likewise. (evaluate_subexp_c): Likewise. And change cast to enum c_string_type_values. * c-lang.h: Include "common/enum_flags.h". (enum c_string_type): Rename to... (enum c_string_type_values): ...this. (c_string_type): Define new enum flags type.
2015-11-17Type-safe wrapper for enum flagsPedro Alves14-37/+349
This patch fixes C++ build errors like this: /home/pedro/gdb/mygit/cxx-convertion/src/gdb/linux-tdep.c:1126:35: error: invalid conversion from ‘int’ to ‘filterflags’ [-fpermissive] | COREFILTER_HUGETLB_PRIVATE); ^ This is a case of enums used as bit flags. Unlike "regular" enums, these values are supposed to be or'ed together. However, in C++, the type of "(ENUM1 | ENUM2)" is int, and you then can't assign an int to an enum variable without a cast. That means that this: enum foo_flags flags = 0; if (...) flags |= FOO_FLAG1; if (...) flags |= FOO_FLAG2; ... would have to be written as: enum foo_flags flags = (enum foo_flags) 0; if (...) flags = (enum foo_flags) (flags | FOO_FLAG1); if (...) flags = (enum foo_flags) (flags | FOO_FLAG2); which is ... ugly. Alternatively, we'd have to use an int for the variable's type, which isn't ideal either. This patch instead adds an "enum flags" class. "enum flags" are exactly the enums where the values are bits that are meant to be ORed together. This allows writing code like the below, while with raw enums this would fail to compile without casts to enum type at the assignments to 'f': enum some_flag { flag_val1 = 1 << 1, flag_val2 = 1 << 2, flag_val3 = 1 << 3, flag_val4 = 1 << 4, }; DEF_ENUM_FLAGS_TYPE(enum some_flag, some_flags) some_flags f = flag_val1 | flag_val2; f |= flag_val3; It's also possible to assign literal zero to an enum flags variable (meaning, no flags), dispensing either adding an awkward explicit "no value" value to the enumeration or the cast to assignments from 0. For example: some_flags f = 0; f |= flag_val3 | flag_val4; Note that literal integers other than zero do fail to compile: some_flags f = 1; // error C is still supported -- DEF_ENUM_FLAGS_TYPE is just a typedef in that case. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * btrace.h: Include common/enum-flags.h. (btrace_insn_flags): Define. (struct btrace_insn) <flags>: Change type. (btrace_function_flags): Define. (struct btrace_function) <flags>: Change type. (btrace_thread_flags): Define. (struct btrace_thread_info) <flags>: Change type. * c-exp.y (token_flags): Rename to ... (token_flag): ... this. (token_flags): Define. (struct token) <flags>: Change type. * common/enum-flags.h: New file. * compile/compile-c-types.c (convert_qualified): Change type of 'quals' local. * compile/compile-internal.h: Include "common/enum-flags.h". (gcc_qualifiers_flags): Define. * completer.c (enum reg_completer_targets): Rename to ... (enum reg_completer_target): ... this. (reg_completer_targets): Define. (reg_or_group_completer_1): Change type of 'targets' parameter. * disasm.c (do_mixed_source_and_assembly_deprecated): Change type of 'psl_flags' local. (do_mixed_source_and_assembly): Change type of 'psl_flags' local. * infrun.c: Include "common/enum-flags.h". (enum step_over_what): Rename to ... (enum step_over_what_flag): ... this. (step_over_what): Change type. (start_step_over): Change type of 'step_what' local. (thread_still_needs_step_over): Now returns a step_over_what. Adjust. (keep_going_pass_signal): Change type of 'step_what' local. * linux-tdep.c: Include "common/enum-flags.h". (enum filterflags): Rename to ... (enum filter_flag): ... this. (filter_flags): Define. (dump_mapping_p): Change type of 'filterflags' parameter. (linux_find_memory_regions_full): Change type of 'filterflags' local. (linux_find_memory_regions_full): Pass the address of an unsigned int to sscanf instead of the address of an enum. * record-btrace.c (btrace_print_lines): Change type of local 'psl_flags'. (btrace_call_history): Replace 'flags' parameter with 'int_flags' parameter. Adjust. (record_btrace_call_history, record_btrace_call_history_range) (record_btrace_call_history_from): Rename 'flags' parameter to 'int_flags'. Use record_print_flags. * record.h: Include "common/enum-flags.h". (record_print_flags): Define. * source.c: Include "common/enum-flags.h". (print_source_lines_base, print_source_lines): Change type of flags parameter. * symtab.h: Include "common/enum-flags.h". (enum print_source_lines_flags): Rename to ... (enum print_source_lines_flag): ... this. (print_source_lines_flags): Define. (print_source_lines): Change prototype.
2015-11-17guile disassembly hardcode TARGET_XFER_E_IOPedro Alves2-4/+10
Instead of adding a cast at the memory_error call, as needed for C++, and have the reader understand the indirection, make it simple and hardcode the generic memory error at the memory_error call site. gdb/ChangeLog: 2015-11-17 Pedro Alves <palves@redhat.com> * guile/scm-disasm.c (gdbscm_disasm_read_memory): Return -1 on error instead of TARGET_XFER_E_IO. (gdbscm_disasm_memory_error): Always pass TARGET_XFER_E_IO to memory_error.
2015-11-17gdb/testsuite: Fix left shift of negative value.Dominik Vogt3-2/+7
This patch fixes all occurences of left-shifting negative constants in C cod which is undefined by the C standard. gdb/testsuite/ChangeLog: * lib/dwarf.exp (_note): Fix left shift of negative value. * gdb.trace/trace-condition.exp: Likewise.
2015-11-17gdb: Fix left shift of negative value.Dominik Vogt3-5/+12
This patch fixes all occurences of left-shifting negative constants in C cod which is undefined by the C standard. gdb/ChangeLog: * hppa-tdep.c (hppa_sign_extend, hppa_low_hppa_sign_extend) (prologue_inst_adjust_sp, hppa_frame_cache): Fix left shift of negative value. * dwarf2read.c (read_subrange_type): Likewise.
2015-11-16Fix stack buffer overflow in aarch64_extract_return_valueYao Qi2-1/+6
Hi, I build GDB with -fsanitize=address, and run testsuite. In gdb.base/callfuncs.exp, I see the following error, p/c fun1() =================================================================^M ==9601==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffee858530 at pc 0x6df079 bp 0x7fffee8583a0 sp 0x7fffee858398 WRITE of size 16 at 0x7fffee858530 thread T0 #0 0x6df078 in regcache_raw_read /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:673 #1 0x6dfe1e in regcache_cooked_read /home/yao/SourceCode/gnu/gdb/git/gdb/regcache.c:751 #2 0x4696a3 in aarch64_extract_return_value /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1708 #3 0x46ae57 in aarch64_return_value /home/yao/SourceCode/gnu/gdb/git/gdb/aarch64-tdep.c:1918 We are extracting return value from V registers (128 bit), but only allocate X_REGISTER_SIZE-byte array, which isn't sufficient. This patch changes the array to V_REGISTER_SIZE. gdb: 2015-11-16 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_extract_return_value): Change array buf's length to V_REGISTER_SIZE.
2015-11-16Pass value * instead of bfd_byte * to pass_* functions in aarch64-tdep.cYao Qi2-22/+27
This patch changes the last argument of functions pass_in_x_or_stack, pass_in_v_or_stack, pass_on_stack, and pass_in_x to type value *. gdb: 2015-11-16 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (pass_in_x_or_stack): Change argument type from bfd_byte * to value *. Caller updated. (pass_in_x): Likewise. (pass_in_v_or_stack): Likewise. (pass_on_stack): Likewise.
2015-11-16Use value_contents instead of value_contents_writeableYao Qi3-2/+8
Both aarch64_push_dummy_call and bfin_push_dummy_call only use args[i] contents but then never write to them, so that we can use value_contents instead. gdb: 2015-11-16 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_push_dummy_call): Call value_contents instead of value_contents_writeable. * bfin-tdep.c (bfin_push_dummy_call): Likewise.
2015-11-16Fix bug in arm_push_dummy_call by -fsanitize=addressYao Qi2-3/+13
When I build GDB with -fsanitize=address, and run testsuite, some gdb.base/*.exp test triggers the ERROR below, ================================================================= ==7646==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000242810 at pc 0x487844 bp 0x7fffe32e84e0 sp 0x7fffe32e84d8 READ of size 4 at 0x603000242810 thread T0 #0 0x487843 in push_stack_item /home/yao/SourceCode/gnu/gdb/git/gdb/arm-tdep.c:3405 #1 0x48998a in arm_push_dummy_call /home/yao/SourceCode/gnu/gdb/git/gdb/arm-tdep.c:3960 In that path, GDB passes value on stack, in an INT_REGISTER_SIZE slot, but the value contents' length can be less than INT_REGISTER_SIZE, so the contents will be accessed out of the bound. This patch adds an array buf[INT_REGISTER_SIZE], and copy val to buf before writing them to stack. gdb: 2015-11-16 Yao Qi <yao.qi@linaro.org> * arm-tdep.c (arm_push_dummy_call): New array buf. Store regval to buf. Pass buf instead of val to push_stack_item.
2015-11-13PR 19051: support of inferior call with gnu vector support on ARMYao Qi2-14/+63
This patch teaches GDB to support gnu vector in inferior calls. As a result, fails in gdb.base/gnu_vector.exp are fixed. The calling convention of gnu vector isn't documented in the AAPCS, because it is the GCC extension. I checked the gcc/config/arm/arm.c, understand how GCC pass arguments and return values, and do the same in GDB side. The patch is tested with both hard float and soft float on arm-linux. gdb: 2015-11-13 Yao Qi <yao.qi@linaro.org> PR tdep/19051 * arm-tdep.c (arm_type_align): Return the right alignment value for vector. (arm_vfp_cprc_sub_candidate): Return true for 64-bit and 128-bit vector types. (arm_return_in_memory): Handel vector type.
2015-11-13Refactor arm_return_in_memoryYao Qi2-78/+90
Current arm_return_in_memory isn't friendly to adding new things in it. Moreover, a lot of stuff are about APCS, which is not used nowadays (AAPCS is being used). This patch is to refactor arm_return_in_memory, so that some code can be shared for both APCS and AAPCS at the beginning of arm_return_in_memory, and then each ABI (APCS and AAPCS) are processed separately. gdb: 2015-11-13 Yao Qi <yao.qi@linaro.org> * arm-tdep.c (arm_return_in_memory): Rewrite it. (arm_return_value): Call arm_return_in_memory for TYPE_CODE_COMPLEX.