aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2014-05-21* scm-breakpoint.c (breakpoint_functions): Fix typo.Doug Evans2-1/+5
2014-05-21Make exception throwers have void result. Delete unused ↵Doug Evans4-24/+20
gdbscm_scm_to_target_string_unsafe. * scm-exception.c (gdbscm_invalid_object_error): Make result is void. (gdbscm_out_of_range_error): Ditto. (gdbscm_memory_error): Ditto. * scm-string.c (gdbscm_scm_to_target_string_unsafe): Delete. * guile-internal.h (gdbscm_invalid_object_error): Update. (gdbscm_out_of_range_error): Update. (gdbscm_memory_error): Update. (gdbscm_scm_to_target_string_unsafe): Delete.
2014-05-21Allow making GDB not automatically connect to the native target.Pedro Alves20-47/+574
Sometimes it's useful to be able to disable the automatic connection to the native target. E.g., sometimes GDB disconnects from the extended-remote target I was debugging, without me noticing it, and then I do "run". That starts the program locally, and only after a little head scratch session do I figure out the program is running locally instead of remotely as intended. Same thing with "attach", "info os", etc. With the patch, we now can have this instead: (gdb) set auto-connect-native-target off (gdb) target extended-remote :9999 ... *gdb disconnects* (gdb) run Don't know how to run. Try "help target". To still be able to connect to the native target with auto-connect-native-target set to off, I've made "target native" work instead of erroring out as today. Before: (gdb) target native Use the "run" command to start a native process. After: (gdb) target native Done. Use the "run" command to start a process. (gdb) maint print target-stack The current target stack is: - native (Native process) - exec (Local exec file) - None (None) (gdb) run Starting program: ./a.out ... I've also wanted this for the testsuite, when running against the native-extended-gdbserver.exp board (runs against gdbserver in extended-remote mode). With a non-native-target board, it's always a bug to launch a program with the native target. Turns out we still have one such case this patch catches: (gdb) break main Breakpoint 1 at 0x4009e5: file ../../../src/gdb/testsuite/gdb.base/coremaker.c, line 138. (gdb) run Don't know how to run. Try "help target". (gdb) FAIL: gdb.base/corefile.exp: run: with core On the patch itself, probably the least obvious bit is the need to go through all targets, and move the unpush_target call to after the generic_mourn_inferior call instead of before. This is what inf-ptrace.c does too, ever since multi-process support was added. The reason inf-ptrace.c does things in that order is that in the current multi-process/single-target model, we shouldn't unpush the target if there are still other live inferiors being debugged. The check for that is "have_inferiors ()" (a misnomer nowadays...), which does: have_inferiors (void) { for (inf = inferior_list; inf; inf = inf->next) if (inf->pid != 0) return 1; It's generic_mourn_inferior that ends up clearing inf->pid, so we need to call it before the have_inferiors check. To make all native targets behave the same WRT to explicit "target native", I've added an inf_child_maybe_unpush_target function that targets call instead of calling unpush_target directly, and as that includes the have_inferiors check, I needed to adjust the targets. Tested on x86_64 Fedora 20, native, and also with the extended-gdbserver board. Confirmed a cross build of djgpp gdb still builds. Smoke tested a cross build of Windows gdb under Wine. Untested otherwise. gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * inf-child.c (inf_child_ops, inf_child_explicitly_opened): New globals. (inf_child_open_target): New function. (inf_child_open): Use inf_child_open_target to push the target instead of erroring out. (inf_child_disconnect, inf_child_close) (inf_child_maybe_unpush_target): New functions. (inf_child_target): Install inf_child_disconnect and inf_child_close. Store a pointer to the returned object. * inf-child.h (inf_child_open_target, inf_child_maybe_unpush): New declarations. * target.c (auto_connect_native_target): New global. (show_default_run_target): New function. (find_default_run_target): Return NULL if automatically connecting to the native target is disabled. (_initialize_target): Install set/show auto-connect-native-target. * NEWS: Mention "set auto-connect-native-target", and "target native". * linux-nat.c (super_close): New global. (linux_nat_close): Call super_close. (linux_nat_add_target): Store a pointer to the base class's to_close method. * inf-ptrace.c (inf_ptrace_mourn_inferior, inf_ptrace_detach): Use inf_child_maybe_unpush. * inf-ttrace.c (inf_ttrace_him): Don't push the target if it is already pushed. (inf_ttrace_mourn_inferior): Only unpush the target after mourning the inferior. Use inf_child_maybe_unpush_target. (inf_ttrace_attach): Don't push the target if it is already pushed. (inf_ttrace_detach): Use inf_child_maybe_unpush_target. * darwin-nat.c (darwin_mourn_inferior): Only unpush the target after mourning the inferior. Use inf_child_maybe_unpush_target. (darwin_attach_pid): Don't push the target if it is already pushed. * gnu-nat.c (gnu_mourn_inferior): Only unpush the target after mourning the inferior. Use inf_child_maybe_unpush_target. (gnu_detach): Use inf_child_maybe_unpush_target. * go32-nat.c (go32_create_inferior): Don't push the target if it is already pushed. (go32_mourn_inferior): Use inf_child_maybe_unpush_target. * nto-procfs.c (procfs_is_nto_target): Adjust comment. (procfs_open): Rename to ... (procfs_open_1): ... this. Add target_ops parameter. Adjust comments. Can target_preopen before changing node. Call inf_child_open_target to push the target explicitly. (procfs_attach): Don't push the target if it is already pushed. (procfs_detach): Use inf_child_maybe_unpush_target. (procfs_create_inferior): Don't push the target if it is already pushed. (nto_native_ops): New global. (procfs_open): Reimplement. (procfs_native_open): New function. (init_procfs_targets): Install procfs_native_open as to_open of "target native". Store a pointer to the "native" target in nto_native_ops. * procfs.c (procfs_attach): Don't push the target if it is already pushed. (procfs_detach): Use inf_child_maybe_unpush_target. (procfs_mourn_inferior): Only unpush the target after mourning the inferior. Use inf_child_maybe_unpush_target. (procfs_init_inferior): Don't push the target if it is already pushed. * windows-nat.c (do_initial_windows_stuff): Don't push the target if it is already pushed. (windows_detach): Use inf_child_maybe_unpush_target. (windows_mourn_inferior): Only unpush the target after mourning the inferior. Use inf_child_maybe_unpush_target. gdb/doc/ 2014-05-21 Pedro Alves <palves@redhat.com> * gdb.texinfo (Starting): Document "set/show auto-connect-native-target". (Target Commands): Document "target native". gdb/testsuite/ 2014-05-21 Pedro Alves <palves@redhat.com> * boards/gdbserver-base.exp (GDBFLAGS): Set to "set auto-connect-native-target off". * gdb.base/auto-connect-native-target.c: New file. * gdb.base/auto-connect-native-target.exp: New file.
2014-05-21NEWS: Mention native target renames.Pedro Alves2-0/+16
gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * NEWS: Mention that the "child", "GNU, "djgpp", "darwin-child" and "procfs" targets are now called "native" instead.
2014-05-21go32-nat.c: Don't override to_open.Pedro Alves2-7/+5
Although the string says "Done.", nothing is pushing the target as is. Removing the method override let's us fall through to the the base to_open implemention in inf-child.c, which will push the target in reaction to "target native" in a follow up patch. gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * go32-nat.c (go32_open): Delete. (go32_target): Don't override the to_open method.
2014-05-21nto-procfs.c: Add "target native".Pedro Alves2-12/+41
This makes QNX/NTO end up with two targets. It preserves "target procfs <node>", and adds a "native" target to be like other native ports. Not tested. gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * nto-procfs.c (procfs_can_run): New function. (nto_procfs_ops): New global. (init_procfs_targets): New, based on procfs_target. Install "target native" in addition to "target procfs". (_initialize_procfs): Call init_procfs_targets instead of adding the target here.
2014-05-21Windows: Rename "target child" -> "target native"Pedro Alves2-3/+5
To be like other native targets. Leave to_shortname, to_longname, to_doc as inf-child.c sets them: t->to_shortname = "native"; t->to_longname = "Native process"; t->to_doc = "Native process (started by the \"run\" command)."; gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * windows-nat.c (windows_target): Don't override to_shortname, to_longname or to_doc.
2014-05-21Rename "target GNU" -> "target native"Pedro Alves2-4/+5
To be like other native targets. Leave to_shortname, to_longname, to_doc as inf-child.c sets them: t->to_shortname = "native"; t->to_longname = "Native process"; t->to_doc = "Native process (started by the \"run\" command)."; gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * gnu-nat.c (gnu): Don't override to_shortname, to_longname or to_doc.
2014-05-21Rename "target darwin-child" -> "target native"Pedro Alves2-4/+5
To be like other native targets. Leave to_shortname, to_longname, to_doc as inf-child.c sets them: t->to_shortname = "native"; t->to_longname = "Native process"; t->to_doc = "Native process (started by the \"run\" command)."; gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * darwin-nat.c (_initialize_darwin_inferior): Don't override to_shortname, to_longname or to_doc.
2014-05-21Rename "target djgpp" -> "target native"Pedro Alves2-4/+5
To be like other native targets. Leave to_shortname, to_longname, to_doc as inf-child.c sets them: t->to_shortname = "native"; t->to_longname = "Native process"; t->to_doc = "Native process (started by the \"run\" command)."; gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * go32-nat.c (go32_target): Don't override to_shortname, to_longname or to_doc.
2014-05-21Rename "target child" to "target native".Pedro Alves4-6/+16
I had been pondering renaming "target child" to something else. "child" is a little lie in case of "attach", and not exactly very clear to users, IMO. By best suggestion is "target native". If I were to explain what "target child" is, I'd just start out with "it's the native target" anyway. I was worrying a little that "native" might be a lie too if some port comes up with a default target that can run but is not really native, but I think that's a very minor issue - we can consider that "native" really means the default built in target that GDB supports, instead of saying that's the target that debugs host native processes, if it turns out necessary. This change doesn't affect users much, because "target child" results in error today: (gdb) target child Use the "run" command to start a child process. Other places "child" is visible: (gdb) help target ... List of target subcommands: target child -- Child process (started by the "run" command) target core -- Use a core file as a target target exec -- Use an executable file as a target ... (gdb) info target Symbols from "/home/pedro/gdb/mygit/build/gdb/gdb". Child process: Using the running image of child Thread 0x7ffff7fc9740 (LWP 4818). While running this, GDB does not access memory from... ... These places will say "native" instead. I think that's a good thing. gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * inf-child.c (inf_child_open): Remove mention of "child". (inf_child_target): Rename target to "native" instead of "child". gdb/testsuite/ 2014-05-21 Pedro Alves <palves@redhat.com> * gdb.base/default.exp: Test "target native" instead of "target child".
2014-05-21Drop regset_alloc().Andreas Arnez4-56/+9
Now that all invocations of regset_alloc() have been removed, the function is dropped. Since regset_alloc() was the only function provided by regset.c, this source file is removed as well.
2014-05-21SPARC: Replace regset_alloc() invocations by static regset structures.Andreas Arnez8-21/+105
2014-05-21SPARC: Rename register maps from "*regset" to "*regmap"Andreas Arnez22-179/+275
Clear the naming confusion about "regset" versus "sparc*regset". The latter was used to represent the *map* of a register set, not the register set itself, and is thus renamed accordingly. The following identifiers are renamed: sparc32_bsd_fpregset => sparc32_bsd_fpregmap sparc32_linux_core_gregset => sparc32_linux_core_gregmap sparc32_sol2_fpregset => sparc32_sol2_fpregmap sparc32_sol2_gregset => sparc32_sol2_gregmap sparc32_sunos4_fpregset => sparc32_sunos4_fpregmap sparc32_sunos4_gregset => sparc32_sunos4_gregmap sparc32nbsd_gregset => sparc32nbsd_gregmap sparc64_bsd_fpregset => sparc64_bsd_fpregmap sparc64_linux_core_gregset => sparc64_linux_core_gregmap sparc64_linux_ptrace_gregset => sparc64_linux_ptrace_gregmap sparc64_sol2_fpregset => sparc64_sol2_fpregmap sparc64_sol2_gregset => sparc64_sol2_gregmap sparc64fbsd_gregset => sparc64fbsd_gregmap sparc64nbsd_gregset => sparc64nbsd_gregmap sparc64obsd_core_gregset => sparc64obsd_core_gregmap sparc64obsd_gregset => sparc64obsd_gregmap sparc_fpregset => sparc_fpregmap sparc_gregset => sparc_gregmap sparc_sol2_fpregset => sparc_sol2_fpregmap sparc_sol2_gregset => sparc_sol2_gregmap Also, all local variables 'gregset' and 'fpregset' are renamed to 'gregmap' and 'fpregmap', respectively.
2014-05-21SCORE: Replace regset_alloc() invocation by a static regset structure.Andreas Arnez3-20/+17
Since this changes makes the only member of the tdep structure obsolete, the tdep structure is removed.
2014-05-21MN10300: Replace regset_alloc() invocations by static regset structures.Andreas Arnez2-9/+19
On this architecture the change may fix a small memory leak.
2014-05-21MIPS: Replace regset_alloc() invocations by static regset structures.Andreas Arnez4-41/+36
After removal of the regset_alloc invocations, the appropriate tdep fields become obsolete and are thus removed.
2014-05-21X86: Replace regset_alloc() invocations by static regset structures.Andreas Arnez8-77/+80
After removal of the regset_alloc invocations, the appropriate tdep fields become obsolete and are thus removed.
2014-05-21ARM: Replace regset_alloc() invocations by static regset structures.Andreas Arnez3-23/+27
After removal of the regset_alloc invocations, the appropriate tdep fields become obsolete and are thus removed.
2014-05-21AARCH64: Replace regset_alloc() invocations by static regset structures.Andreas Arnez3-18/+24
After removal of the regset_alloc invocations, the tdep fields 'gregset' and 'fpregset' become obsolete and are thus removed.
2014-05-21Remove 'arch' field from regset structure.Andreas Arnez10-27/+41
Removes the 'arch' field from the regset structure, since it represents the only "dynamic" data in a regset. It was referenced in some regset supply- and collect routines, to get access to the gdbarch associated with the regset. Naturally, the affected routines always have access to the regcache to be supplied to or collected from. Thus the gdbarch associated with that regcache can be used instead.
2014-05-21Constify regset structures.Andreas Arnez25-39/+71
2014-05-21gdb/testsuite: Handle underlying type in gdb.cp/var-tag.exp.Mark Wielaard2-3/+13
* gdb.cp/var-tag.exp (do_global_tests): Handle underlying type.
2014-05-21Fix TLS access for -static -pthreadJan Kratochvil9-32/+131
I have posted: TLS variables access for -static -lpthread executables https://sourceware.org/ml/libc-help/2014-03/msg00024.html and the GDB patch below has been confirmed as OK for current glibcs. Further work should be done for newer glibcs: Improve TLS variables glibc compatibility https://sourceware.org/bugzilla/show_bug.cgi?id=16954 Still the patch below implements the feature in a fully functional way backward compatible with current glibcs, it depends on the following glibc source line: csu/libc-tls.c main_map->l_tls_modid = 1; gdb/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * linux-thread-db.c (struct thread_db_info): Add td_thr_tlsbase_p. (try_thread_db_load_1): Initialize it. (thread_db_get_thread_local_address): Call it if LM is zero. * target.c (target_translate_tls_address): Remove LM_ADDR zero check. * target.h (struct target_ops) (to_get_thread_local_address): Add load_module_addr comment. gdb/gdbserver/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdbserver/thread-db.c (struct thread_db): Add td_thr_tlsbase_p. (thread_db_get_tls_address): Call it if LOAD_MODULE is zero. (thread_db_load_search, try_thread_db_load_1): Initialize it. gdb/testsuite/ 2014-05-21 Jan Kratochvil <jan.kratochvil@redhat.com> Fix TLS access for -static -pthread. * gdb.threads/staticthreads.c <HAVE_TLS> (tlsvar): New. <HAVE_TLS> (thread_function, main): Initialize it. * gdb.threads/staticthreads.exp: Try gdb_compile_pthreads for $have_tls. Add clean_restart. <$have_tls != "">: Check TLSVAR. Message-ID: <20140410115204.GB16411@host2.jankratochvil.net>
2014-05-21Make the dcache (code/stack cache) handle line reading errors betterPedro Alves5-2/+190
The dcache (code/stack cache) is supposed to be transparent, but it's actually not in one case. dcache tries to read chunks (cache lines) at a time off of the target. This may end up trying to read unaccessible or unavailable memory. Currently the caller gets an xfer error in this case. But if the specific bits of memory the caller actually wanted are available and accessible, then the caller should get the memory it wanted, not an error. gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * dcache.c (dcache_read_memory_partial): If reading the cache line fails, fallback to reading just the memory the caller wanted. gdb/testsuite/ 2014-05-21 Pedro Alves <palves@redhat.com> * gdb.base/dcache-line-read-error.c: New. * gdb.base/dcache-line-read-error.exp: New.
2014-05-21daily updateAlan Modra1-1/+1
2014-05-20Add ChangeLog from previous MIPS .module commitmfortune2-0/+51
2014-05-20Add MIPS .module directivemfortune12-284/+376
gas/ * config/tc-mips.c (file_mips_opts_checked): New static global. (s_module): New static function. (file_ase): Remove. (mips_pseudo_table): Add .module handler. (mips_set_ase): Add opts argument and use instead of mips_opts. (md_assemble): Use file_mips_check_options. (md_parse_option): Update to use file_mips_opts instead of mips_opts. (mips_set_architecture): Delete function. Moved to... (mips_after_parse_args): Here. All logic now applies to file_mips_opts first and then copies the final state to mips_opts. Move error checking and defaults inference to mips_check_options and file_mips_check_options. (mips_check_options): New static function. Common option checking for command line, .module and .set. Use .module values in error messages instead of refering to command line options. (file_mips_check_options): New static function. A wrapper for mips_check_options with file_mips_opts. Updates BFD arch based on final options. (s_mipsset): Split into s_mipsset and parse_code_option. Settings supported by both .set and .module are moved to parse_code_option. Warnings and errors are kept in s_mipsset because when parse_code_option is used with s_module the warnings are deferred until code is generated. Any setting supporting 'default' value is kept in s_mipsset as it is not applicable to s_module. Inferred settings are also kept in s_mipsset as s_module does not infer any settings. Use mips_check_options. (parse_code_option): New static function derived from s_mipsset. (s_module): New static function that implements .module. Allows file level settings to be changed until code is generated. (s_cpload, s_cpsetup, s_cplocal): Use file_mips_check_options. (s_cprestore, s_cpreturn, s_cpadd, mips_address_bytes): Likewise. (mips_elf_final_processing): Update file_ase to file_mips_opts.ase. (md_mips_end): Use file_mips_check_options. * doc/c-mips.texi: Document .module. gas/testsuite * gas/mips/mips.exp: Add new tests. Use 64-bit ABI for relax-bc1any. Fix micromips arch definition to use mips64r2 consistently. * gas/mips/module-defer-warn1.s: New. * gas/mips/module-defer-warn1.d: New. * gas/mips/module-defer-warn2.s: New. * gas/mips/module-defer-warn2.l: New. * gas/mips/module-override.d: New. * gas/mips/module-override.s: New. * gas/mips/mips-gp32-fp64.l: Update expected output. * gas/mips/mips-gp64-fp32-pic.l: Update expected output. * gas/mips/mips-gp64-fp32.l: Update expected output.
2014-05-20Remove newly introduced whitespace from warnings.mfortune2-3/+8
* messages.c (as_warn_internal): Remove extra whitespace from warning messages.
2014-05-20Mark MSA as requiring FP64mfortune5-124/+114
gas/ * config/tc-mips.c (FP64_ASES): Add ASE_MSA. (mips_after_parse_args): Do not select ASE_MSA without -mfp64. gas/testsuite/ * gas/mips/micromips@msa-branch.d: Rework expected output for fp64. * gas/mips/msa-branch.d: Likewise.
2014-05-20ld: Add missing eelf32mbel_linux.c to ALL_EMULATION_SOURCES.Hans-Peter Nilsson3-0/+8
ld: * Makefile.am (ALL_EMULATION_SOURCES): Add missing eelf32mbel_linux.c. * Makefile.in: Regenerate.
2014-05-20Fix gdb.multi/base.exp failures.Doug Evans2-1/+15
UNRESOLVED: gdb.multi/base.exp: remove-inferiors 2-3 UNRESOLVED: gdb.multi/base.exp: check remove-inferiors gdb is crashing because it's accessing/freeing already freed memory. ==16368== Invalid read of size 4 ==16368== at 0x660A9D: find_pc_section (binutils-gdb/gdb/objfiles.c:1349) ==16368== by 0x663ECB: lookup_minimal_symbol_by_pc_section (binutils-gdb/gdb/minsyms.c:734) ==16368== by 0x5D987A: find_pc_sect_symtab (binutils-gdb/gdb/symtab.c:2153) ==16368== by 0x5D4D77: blockvector_for_pc_sect (binutils-gdb/gdb/block.c:168) ==16368== by 0x5D4F59: block_for_pc_sect (binutils-gdb/gdb/block.c:246) ==16368== by 0x5D4F9B: block_for_pc (binutils-gdb/gdb/block.c:258) ==16368== by 0x734C5D: inline_frame_sniffer (binutils-gdb/gdb/inline-frame.c:218) ==16368== by 0x732104: frame_unwind_try_unwinder (binutils-gdb/gdb/frame-unwind.c:108) ==16368== by 0x73223F: frame_unwind_find_by_frame (binutils-gdb/gdb/frame-unwind.c:159) ==16368== by 0x72D5AA: compute_frame_id (binutils-gdb/gdb/frame.c:453) ==16368== by 0x7300EC: get_prev_frame_if_no_cycle (binutils-gdb/gdb/frame.c:1758) ==16368== by 0x73079A: get_prev_frame_always (binutils-gdb/gdb/frame.c:1931) ==16368== Address 0x5b13500 is 16 bytes inside a block of size 24 free'd ==16368== at 0x403072E: free (valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c:445) ==16368== by 0x762134: xfree (binutils-gdb/gdb/common/common-utils.c:108) ==16368== by 0x65DACF: objfiles_pspace_data_cleanup (binutils-gdb/gdb/objfiles.c:91) ==16368== by 0x75E546: program_spaceregistry_callback_adaptor (binutils-gdb/gdb/progspace.c:45) ==16368== by 0x7644F6: registry_clear_data (binutils-gdb/gdb/registry.c:82) ==16368== by 0x7645AB: registry_container_free_data (binutils-gdb/gdb/registry.c:95) ==16368== by 0x75E5B4: program_space_free_data (binutils-gdb/gdb/progspace.c:45) ==16368== by 0x75E9BA: release_program_space (binutils-gdb/gdb/progspace.c:167) ==16368== by 0x75EB9B: prune_program_spaces (binutils-gdb/gdb/progspace.c:269) ==16368== by 0x75303D: remove_inferior_command (binutils-gdb/gdb/inferior.c:792) ==16368== by 0x50B5FD: do_cfunc (binutils-gdb/gdb/cli/cli-decode.c:107) ==16368== by 0x50E6F2: cmd_func (binutils-gdb/gdb/cli/cli-decode.c:1886) The problem originates from the get_current_arch call in py-progspace.c:py_free_pspace. The inferior associated with the pspace is gone, and the current inferior is a different one and is running. Therefore get_current_arch tries to read the current frame which causes reads of data in the current program space which we've just deleted. * python/py-progspace.c (py_free_pspace): Call target_gdbarch instead of get_current_arch.
2014-05-20 * messages.c (as_warn_internal): Ensure we don't interleave outputMike Stump2-10/+14
within a single line when make -j is used. (as_bad_internal): Likewise.
2014-05-20* elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.DJ Delorie2-4/+9
2014-05-20Make compare-sections work against all targets; add compare-sections [-r] tests.Pedro Alves11-40/+316
This does two things: 1. Adds a test. Recently compare-sections got a new "-r" switch, but given no test existed for compare-sections, the patch was allowed in with no testsuite addition. This now adds a test for both compare-sections and compare-sections -r. 2. Makes the compare-sections command work against all targets. Currently, compare-sections only works with remote targets, and only those that support the qCRC packet. The patch makes it so that if the target doesn't support accelerating memory verification, then GDB falls back to comparing memory itself. This is of course slower, but it's better than nothing, IMO. While testing against extended-remote GDBserver I noticed that we send the qCRC request to the target if we're connected, but not yet running a program. That can't work of course -- the patch fixes that. This all also goes in the direction of bridging the local/remote parity gap. I didn't decouple 1. from 2., because that would mean that the test would need to handle the case of the target not supporting the command. Tested on x86_64 Fedora 17, native, remote GDBserver, and extended-remote GDBserver. I also hack-disabled qCRC support to make sure the fallback paths in remote.c work. gdb/doc/ 2014-05-20 Pedro Alves <palves@redhat.com> * gdb.texinfo (Memory) <compare-sections>: Generalize comments to not be remote specific. Add cross reference to the qCRC packet. (Separate Debug Files): Update cross reference to the qCRC packet. (General Query Packets) <qCRC packet>: Add anchor. gdb/ 2014-05-20 Pedro Alves <palves@redhat.com> * NEWS: Mention that compare-sections now works with all targets. * remote.c (PACKET_qCRC): New enum value. (remote_verify_memory): Don't send qCRC if the target has no execution. Use packet_support/packet_ok. If the target doesn't support the qCRC packet, fallback to a deep memory copy. (compare_sections_command): Say "target image" instead of "remote executable". (_initialize_remote): Add PACKET_qCRC to the list of config packets that have no associated command. Extend comment. * target.c (simple_verify_memory, default_verify_memory): New function. * target.h (struct target_ops) <to_verify_memory>: Default to default_verify_memory. (simple_verify_memory): New declaration. * target-delegates.c: Regenerate. gdb/testsuite/ 2014-05-20 Pedro Alves <palves@redhat.com> * gdb.base/compare-sections.c: New file. * gdb.base/compare-sections.exp: New file.
2014-05-20gas/Richard Sandiford3-0/+67
* config/obj-elf.h (obj_elf_seen_attribute): Declare. * config/obj-elf.c (recorded_attribute_info): New structure. (recorded_attributes): New variable. (record_attribute, obj_elf_seen_attribute): New functions. (obj_elf_vendor_attribute): Record which attributes have been seen.
2014-05-20[GDBserver] Make Zx/zx packet handling idempotent.Pedro Alves25-411/+1300
This patch fixes hardware breakpoint regressions exposed by my fix for "PR breakpoints/7143 - Watchpoint does not trigger when first set", at https://sourceware.org/ml/gdb-patches/2014-03/msg00167.html The testsuite caught them on Linux/x86_64, at least. gdb.sum: gdb.sum: FAIL: gdb.base/hbreak2.exp: next over recursive call FAIL: gdb.base/hbreak2.exp: backtrace from factorial(5.1) FAIL: gdb.base/hbreak2.exp: continue until exit at recursive next test gdb.log: (gdb) next Program received signal SIGTRAP, Trace/breakpoint trap. factorial (value=4) at ../../../src/gdb/testsuite/gdb.base/break.c:113 113 if (value > 1) { /* set breakpoint 7 here */ (gdb) FAIL: gdb.base/hbreak2.exp: next over recursive call Actually, that patch just exposed a latent issue to "breakpoints always-inserted off" mode, not really caused it. After that patch, GDB no longer removes breakpoints at each internal event, thus making some scenarios behave like breakpoint always-inserted on. The bug is easy to trigger with always-inserted on. The issue is that since the target-side breakpoint conditions support, if the stub/server supports evaluating breakpoint conditions on the target side, then GDB is sending duplicate Zx packets to the target without removing them before, and GDBserver is not really expecting that for Z packets other than Z0/z0. E.g., with "set breakpoint always-inserted on" and "set debug remote 1": (gdb) b main Sending packet: $m410943,1#ff...Packet received: 48 Breakpoint 4 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028. Sending packet: $Z0,410943,1#48...Packet received: OK ^^^^^^^^^^^^ (gdb) b main Note: breakpoint 4 also set at pc 0x410943. Sending packet: $m410943,1#ff...Packet received: 48 Breakpoint 5 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028. Sending packet: $Z0,410943,1#48...Packet received: OK ^^^^^^^^^^^^ (gdb) b main Note: breakpoints 4 and 5 also set at pc 0x410943. Sending packet: $m410943,1#ff...Packet received: 48 Breakpoint 6 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028. Sending packet: $Z0,410943,1#48...Packet received: OK ^^^^^^^^^^^^ (gdb) del Delete all breakpoints? (y or n) y Sending packet: $Z0,410943,1#48...Packet received: OK Sending packet: $Z0,410943,1#48...Packet received: OK Sending packet: $z0,410943,1#68...Packet received: OK And for Z1, similarly: (gdb) hbreak main Sending packet: $m410943,1#ff...Packet received: 48 Hardware assisted breakpoint 4 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028. Sending packet: $Z1,410943,1#49...Packet received: OK ^^^^^^^^^^^^ Packet Z1 (hardware-breakpoint) is supported (gdb) hbreak main Note: breakpoint 4 also set at pc 0x410943. Sending packet: $m410943,1#ff...Packet received: 48 Hardware assisted breakpoint 5 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028. Sending packet: $Z1,410943,1#49...Packet received: OK ^^^^^^^^^^^^ (gdb) hbreak main Note: breakpoints 4 and 5 also set at pc 0x410943. Sending packet: $m410943,1#ff...Packet received: 48 Hardware assisted breakpoint 6 at 0x410943: file ../../../src/gdb/gdbserver/server.c, line 3028. Sending packet: $Z1,410943,1#49...Packet received: OK ^^^^^^^^^^^^ (gdb) del Delete all breakpoints? (y or n) y Sending packet: $Z1,410943,1#49...Packet received: OK ^^^^^^^^^^^^ Sending packet: $Z1,410943,1#49...Packet received: OK ^^^^^^^^^^^^ Sending packet: $z1,410943,1#69...Packet received: OK ^^^^^^^^^^^^ So GDB sent a bunch of Z1 packets, and then when finally removing the breakpoint, only one z1 packet was sent. On the GDBserver side (with monitor set debug-hw-points 1), in the Z1 case, we see: $ ./gdbserver :9999 ./gdbserver Process ./gdbserver created; pid = 8629 Listening on port 9999 Remote debugging from host 127.0.0.1 insert_watchpoint (addr=410943, len=1, type=instruction-execute): CONTROL (DR7): 00000101 STATUS (DR6): 00000000 DR0: addr=0x410943, ref.count=1 DR1: addr=0x0, ref.count=0 DR2: addr=0x0, ref.count=0 DR3: addr=0x0, ref.count=0 insert_watchpoint (addr=410943, len=1, type=instruction-execute): CONTROL (DR7): 00000101 STATUS (DR6): 00000000 DR0: addr=0x410943, ref.count=2 DR1: addr=0x0, ref.count=0 DR2: addr=0x0, ref.count=0 DR3: addr=0x0, ref.count=0 insert_watchpoint (addr=410943, len=1, type=instruction-execute): CONTROL (DR7): 00000101 STATUS (DR6): 00000000 DR0: addr=0x410943, ref.count=3 DR1: addr=0x0, ref.count=0 DR2: addr=0x0, ref.count=0 DR3: addr=0x0, ref.count=0 insert_watchpoint (addr=410943, len=1, type=instruction-execute): CONTROL (DR7): 00000101 STATUS (DR6): 00000000 DR0: addr=0x410943, ref.count=4 DR1: addr=0x0, ref.count=0 DR2: addr=0x0, ref.count=0 DR3: addr=0x0, ref.count=0 insert_watchpoint (addr=410943, len=1, type=instruction-execute): CONTROL (DR7): 00000101 STATUS (DR6): 00000000 DR0: addr=0x410943, ref.count=5 DR1: addr=0x0, ref.count=0 DR2: addr=0x0, ref.count=0 DR3: addr=0x0, ref.count=0 remove_watchpoint (addr=410943, len=1, type=instruction-execute): CONTROL (DR7): 00000101 STATUS (DR6): 00000000 DR0: addr=0x410943, ref.count=4 DR1: addr=0x0, ref.count=0 DR2: addr=0x0, ref.count=0 DR3: addr=0x0, ref.count=0 That's one insert_watchpoint call for each Z1 packet, and then one remove_watchpoint call for the z1 packet. Notice how ref.count increased for each insert_watchpoint call, and then in the end, after GDB told GDBserver to forget about the hardware breakpoint, GDBserver ends with the the first debug register still with ref.count=4! IOW, the hardware breakpoint is left armed on the target, while on the GDB end it's gone. If the program happens to execute 0x410943 afterwards, then the CPU traps, GDBserver reports the trap to GDB, and GDB not having a breakpoint set at that address anymore, reports to the user a spurious SIGTRAP. This is exactly what is happening in the hbreak2.exp test, though in that case, it's a shared library event that triggers a breakpoint_re_set, when breakpoints are still inserted (because nowadays GDB doesn't remove breakpoints while handling internal events), and that recreates breakpoint locations, which likewise forces breakpoint reinsertion and Zx packet resends... That is a lot of bogus Zx duplication that should possibly be addressed on the GDB side. GDB resends Zx packets because the way to change the target-side condition, is to resend the breakpoint to the server with the new condition. (That's an option in the packet: e.g., "Z1,410943,1;X3,220027" for "hbreak main if 0". The packets in the examples above are shorter because the breakpoints don't have conditions attached). GDB doesn't remove the breakpoint first before reinserting it because that'd be bad for non-stop, as it'd open a window where the inferior could miss the breakpoint. The conditions actually haven't changed between the resends, but GDB isn't smart enough to realize that. (TBC, if the target doesn't support target-side conditions, then GDB doesn't trigger these resends (init_bp_location calls mark_breakpoint_location_modified, and that does nothing if condition evaluation is on the host side. The resends are caused by the 'loc->condition_changed = condition_modified.' line.) But, even if GDB was made smarter, GDBserver should really still handle the resends anyway. So target-side conditions also aren't really to blame. The documentation of the Z/z packets says: "To avoid potential problems with duplicate packets, the operations should be implemented in an idempotent way." As such, we may want to fix GDB, but we should definitely fix GDBserver. The fix is a prerequisite for target-side conditions on hardware breakpoints anyway (and while at it, on watchpoints too). GDBserver indeed already treats duplicate Z0 packets in an idempotent way. mem-break.c has the concept of high-level and low-level breakpoints, somewhat similar to GDB's split of breakpoints vs breakpoint locations, and keeps track of multiple breakpoints referencing the same address/location, for the case of an internal GDBserver breakpoint or a tracepoint being set at the same address as a GDB breakpoint. But, it only allows GDB to ever contribute one reference to a software breakpoint location. IOW, if gdbserver sees a Z0 packet for the same address where it already had a GDB breakpoint set, then GDBserver won't create another high-level GDB breakpoint. However, mem-break.c only tracks GDB Z0 breakpoints. The same logic should apply to all kinds of Zx packets. Currently, gdbserver passes down each duplicate Zx (other than Z0) request directly to the target->insert_point routine. The x86 watchpoint support itself refcounts watchpoint / hw breakpoint requests, to handle overlapping watchpoints, and save debug registers. But that code doesn't (and really shouldn't) handle the duplicate requests, assuming that for each insert there will be a corresponding remove. So the fix is to generalize mem-break.c to track all kinds of Zx breakpoints, and filter out duplicates. As mentioned, this ends up adding support for target-side conditions on hardware breakpoints and watchpoints too (though GDB itself doesn't support the latter yet). Probably the least obvious change in the patch is that it kind of turns the breakpoint insert/remove APIs inside out. Before, the target methods were only called for GDB breakpoints. The internal breakpoint set/delete methods inserted memory breakpoints directly bypassing the insert/remove target methods. That's not good when the target should use a debug API to set software breakpoints, instead of relying on GDBserver patching memory with breakpoint instructions, as is the case of NTO. Now removal/insertion of all kinds of breakpoints/watchpoints, either internal, or from GDB, always go through the target methods. The insert_point/remove_point methods no longer get passed a Z packet type, but an internal/raw breakpoint type. They're also passed a pointer to the raw breakpoint itself (note that's still opaque outside mem-break.c), so that insert_memory_breakpoint / remove_memory_breakpoint have access to the breakpoint's shadow buffer. I first tried passing down a new structure based on GDB's "struct bp_target_info" (actually with that name exactly), but then decided against it as unnecessary complication. As software/memory breakpoints work by poking at memory, when setting a GDB Z0 breakpoint (but not internal breakpoints, as those can assume the conditions are already right), we need to tell the target to prepare to access memory (which on Linux means stop threads). If that operation fails, we need to return error to GDB. Seeing an error, if this is the first breakpoint of that type that GDB tries to insert, GDB would then assume the breakpoint type is supported, but it may actually not be. So we need to check whether the type is supported at all before preparing to access memory. And to solve that, the patch adds a new target->supports_z_point_type method that is called before actually trying to insert the breakpoint. Other than that, hopefully the change is more or less obvious. New test added that exercises the hbreak2.exp regression in a more direct way, without relying on a breakpoint re-set happening before main is reached. Tested by building GDBserver for: aarch64-linux-gnu arm-linux-gnueabihf i686-pc-linux-gnu i686-w64-mingw32 m68k-linux-gnu mips-linux-gnu mips-uclinux nios2-linux-gnu powerpc-linux-gnu sh-linux-gnu tilegx-unknown-linux-gnu x86_64-redhat-linux x86_64-w64-mingw32 And also regression tested on x86_64 Fedora 20. gdb/gdbserver/ 2014-05-20 Pedro Alves <palves@redhat.com> * linux-aarch64-low.c (aarch64_insert_point) (aarch64_remove_point): No longer check whether the type is supported here. Adjust to new interface. (the_low_target): Install aarch64_supports_z_point_type as supports_z_point_type method. * linux-arm-low.c (raw_bkpt_type_to_arm_hwbp_type): New function. (arm_linux_hw_point_initialize): Take an enum raw_bkpt_type instead of a Z packet char. Adjust. (arm_supports_z_point_type): New function. (arm_insert_point, arm_remove_point): Adjust to new interface. (the_low_target): Install arm_supports_z_point_type. * linux-crisv32-low.c (cris_supports_z_point_type): New function. (cris_insert_point, cris_remove_point): Adjust to new interface. Don't check whether the type is supported here. (the_low_target): Install cris_supports_z_point_type. * linux-low.c (linux_supports_z_point_type): New function. (linux_insert_point, linux_remove_point): Adjust to new interface. * linux-low.h (struct linux_target_ops) <insert_point, remove_point>: Take an enum raw_bkpt_type instead of a char. Add raw_breakpoint pointer parameter. <supports_z_point_type>: New method. * linux-mips-low.c (mips_supports_z_point_type): New function. (mips_insert_point, mips_remove_point): Adjust to new interface. Use mips_supports_z_point_type. (the_low_target): Install mips_supports_z_point_type. * linux-ppc-low.c (the_low_target): Install NULL as supports_z_point_type method. * linux-s390-low.c (the_low_target): Install NULL as supports_z_point_type method. * linux-sparc-low.c (the_low_target): Install NULL as supports_z_point_type method. * linux-x86-low.c (x86_supports_z_point_type): New function. (x86_insert_point): Adjust to new insert_point interface. Use insert_memory_breakpoint. Adjust to new i386_low_insert_watchpoint interface. (x86_remove_point): Adjust to remove_point interface. Use remove_memory_breakpoint. Adjust to new i386_low_remove_watchpoint interface. (the_low_target): Install x86_supports_z_point_type. * lynx-low.c (lynx_target_ops): Install NULL as supports_z_point_type callback. * nto-low.c (nto_supports_z_point_type): New. (nto_insert_point, nto_remove_point): Adjust to new interface. (nto_target_ops): Install nto_supports_z_point_type. * mem-break.c: Adjust intro comment. (struct raw_breakpoint) <raw_type, size>: New fields. <inserted>: Update comment. <shlib_disabled>: Delete field. (enum bkpt_type) <gdb_breakpoint>: Delete value. <gdb_breakpoint_Z0, gdb_breakpoint_Z1, gdb_breakpoint_Z2, gdb_breakpoint_Z3, gdb_breakpoint_Z4>: New values. (raw_bkpt_type_to_target_hw_bp_type): New function. (find_enabled_raw_code_breakpoint_at): New function. (find_raw_breakpoint_at): New type and size parameters. Use them. (insert_memory_breakpoint): New function, based off set_raw_breakpoint_at. (remove_memory_breakpoint): New function. (set_raw_breakpoint_at): Reimplement. (set_breakpoint): New, based on set_breakpoint_at. (set_breakpoint_at): Reimplement. (delete_raw_breakpoint): Go through the_target->remove_point instead of assuming memory breakpoints. (find_gdb_breakpoint_at): Delete. (Z_packet_to_bkpt_type, Z_packet_to_raw_bkpt_type): New functions. (find_gdb_breakpoint): New function. (set_gdb_breakpoint_at): Delete. (z_type_supported): New function. (set_gdb_breakpoint_1): New function, loosely based off set_gdb_breakpoint_at. (check_gdb_bp_preconditions, set_gdb_breakpoint): New functions. (delete_gdb_breakpoint_at): Delete. (delete_gdb_breakpoint_1): New function, loosely based off delete_gdb_breakpoint_at. (delete_gdb_breakpoint): New function. (clear_gdb_breakpoint_conditions): Rename to ... (clear_breakpoint_conditions): ... this. Don't handle a NULL breakpoint. (add_condition_to_breakpoint): Make static. (add_breakpoint_condition): Take a struct breakpoint pointer instead of an address. Adjust. (gdb_condition_true_at_breakpoint): Rename to ... (gdb_condition_true_at_breakpoint_z_type): ... this, and add z_type parameter. (gdb_condition_true_at_breakpoint): Reimplement. (add_breakpoint_commands): Take a struct breakpoint pointer instead of an address. Adjust. (gdb_no_commands_at_breakpoint): Rename to ... (gdb_no_commands_at_breakpoint_z_type): ... this. Add z_type parameter. Return true if no breakpoint was found. Change debug output. (gdb_no_commands_at_breakpoint): Reimplement. (run_breakpoint_commands): Rename to ... (run_breakpoint_commands_z_type): ... this. Add z_type parameter, and change return type to boolean. (run_breakpoint_commands): New function. (gdb_breakpoint_here): Also check for Z1 breakpoints. (uninsert_raw_breakpoint): Don't try to reinsert a disabled breakpoint. Go through the_target->remove_point instead of assuming memory breakpoint. (uninsert_breakpoints_at, uninsert_all_breakpoints): Uninsert software and hardware breakpoints. (reinsert_raw_breakpoint): Go through the_target->insert_point instead of assuming memory breakpoint. (reinsert_breakpoints_at, reinsert_all_breakpoints): Reinsert software and hardware breakpoints. (check_breakpoints, breakpoint_here, breakpoint_inserted_here): Check both software and hardware breakpoints. (validate_inserted_breakpoint): Assert the breakpoint is a software breakpoint. Set the inserted flag to -1 instead of setting shlib_disabled. (delete_disabled_breakpoints): Adjust. (validate_breakpoints): Only validate software breakpoints. Adjust to inserted flag change. (check_mem_read, check_mem_write): Skip breakpoint types other than software breakpoints. Adjust to inserted flag change. * mem-break.h (enum raw_bkpt_type): New enum. (raw_breakpoint, struct process_info): Forward declare. (Z_packet_to_target_hw_bp_type): Delete declaration. (raw_bkpt_type_to_target_hw_bp_type, Z_packet_to_raw_bkpt_type) (set_gdb_breakpoint, delete_gdb_breakpoint) (clear_breakpoint_conditions): New declarations. (set_gdb_breakpoint_at, clear_gdb_breakpoint_conditions): Delete. (breakpoint_inserted_here): Update comment. (add_breakpoint_condition, add_breakpoint_commands): Replace address parameter with a breakpoint pointer parameter. (gdb_breakpoint_here): Update comment. (delete_gdb_breakpoint_at): Delete. (insert_memory_breakpoint, remove_memory_breakpoint): Declare. * server.c (process_point_options): Take a struct breakpoint pointer instead of an address. Adjust. (process_serial_event) <Z/z packets>: Use set_gdb_breakpoint and delete_gdb_breakpoint. * spu-low.c (spu_target_ops): Install NULL as supports_z_point_type method. * target.h: Include mem-break.h. (struct target_ops) <prepare_to_access_memory>: Update comment. <supports_z_point_type>: New field. <insert_point, remove_point>: Take an enum raw_bkpt_type argument instead of a char. Also take a raw breakpoint pointer. * win32-arm-low.c (the_low_target): Install NULL as supports_z_point_type. * win32-i386-low.c (i386_supports_z_point_type): New function. (i386_insert_point, i386_remove_point): Adjust to new interface. (the_low_target): Install i386_supports_z_point_type. * win32-low.c (win32_supports_z_point_type): New function. (win32_insert_point, win32_remove_point): Adjust to new interface. (win32_target_ops): Install win32_supports_z_point_type. * win32-low.h (struct win32_target_ops): <supports_z_point_type>: New method. <insert_point, remove_point>: Take an enum raw_bkpt_type argument instead of a char. Also take a raw breakpoint pointer. gdb/testsuite/ 2014-05-20 Pedro Alves <palves@redhat.com> * gdb.base/break-idempotent.c: New file. * gdb.base/break-idempotent.exp: New file.
2014-05-20[GDBserver] Move Z packet defines and type convertion routines to shared code.Pedro Alves9-81/+62
The Aarch64, MIPS and x86 Linux backends all have Z packet number defines and corresponding protocol number to internal type convertion routines. Factor them all out to gdbserver's core code, so we only have one shared copy. Tested on x86_64 Fedora 20, and also cross built for aarch64-linux-gnu and mips-linux-gnu. gdb/gdbserver/ 2014-05-20 Pedro Alves <palves@redhat.com> * mem-break.h: Include break-common.h. (Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP) (Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): New defines. (Z_packet_to_target_hw_bp_type): New declaration. * mem-break.c (Z_packet_to_target_hw_bp_type): New function. * i386-low.c (Z_PACKET_HW_BP, Z_PACKET_WRITE_WP, Z_PACKET_READ_WP) (Z_PACKET_ACCESS_WP): Delete macros. (Z_packet_to_hw_type): Delete function. * i386-low.h: Don't include break-common.h here. (Z_packet_to_hw_type): Delete declaration. * linux-x86-low.c (x86_insert_point, x86_insert_point): Call Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type. * win32-i386-low.c (i386_insert_point, i386_remove_point): Call Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type. * linux-aarch64-low.c: Don't include break-common.h here. (Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP) (Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): Delete macros. (Z_packet_to_target_hw_bp_type): Delete function. * linux-mips-low.c (rsp_bp_type_to_target_hw_bp_type): Delete function. (mips_insert_point, mips_remove_point): Use Z_packet_to_target_hw_bp_type.
2014-05-20[GDBserver][AArch64] Make watchpoint support use target_hw_bp_type.Pedro Alves2-39/+82
This makes linux-aarch64-low.c use target_hw_bp_type, like gdb's aarch64-linux-nat.c. The original motivation is decoupling insert_point/remove_point from Z packet numbers, but I think making the files a little bit more similar is a good thing on its own right. Ideally we'd merge these files even... The aarch64_point_encode_ctrl_reg change is taken straight from GDB's copy. I confirmed with a cross compiler that this builds, but it's otherwise untested. gdb/gdbserver/ 2014-05-20 Pedro Alves <palves@redhat.com> * linux-aarch64-low.c: Include break-common.h. (enum target_point_type): Delete. (Z_packet_to_point_type): Rename to ... (Z_packet_to_target_hw_bp_type): ... this, and return a target_hw_bp_type instead. (aarch64_show_debug_reg_state): Take an enum target_hw_bp_type instead of an enum target_point_type. (aarch64_point_encode_ctrl_reg): Likewise. Compute type mask from breakpoint type. (aarch64_dr_state_insert_one_point) (aarch64_dr_state_remove_one_point, aarch64_handle_breakpoint) (aarch64_handle_aligned_watchpoint) (aarch64_handle_unaligned_watchpoint, aarch64_handle_watchpoint): Take an enum target_hw_bp_type instead of an enum target_point_type. (aarch64_supports_z_point_type): New function. (aarch64_insert_point, aarch64_remove_point): Use it. Adjust to use Z_packet_to_target_hw_bp_type.
2014-05-20Do not build gdbserver with -Werror by default if development=falseJoel Brobecker3-4/+10
On GDB release branches, we change $development in gdb/development.sh to false, in order to build the GDB release without -Werror by default, thus avoiding harmless compiler warnings from breaking the build of someone who's only interested in building GDB rather than working on it. This patch implements the same strategy for gdbserver, using the exact same method. gdb/gdbserver/ChangeLog: * configure.ac: Only use -Werror by default when DEVELOPMENT is true. * configure: Regenerate. Tested on x86_64-linux, by rebuilding GDBserver first with development set to true, and then doing it again with development set to false. Werror was used in the first case, but not in the second.
2014-05-20btrace: no replay without historyMarkus Metzger4-0/+58
When using a reverse execution command without execution history, GDB might end up in a state where replaying has been started but remains at the current instruction. This state is illegal. Do not step if there is no execution history to avoid this. 2014-05-20 Markus Metzger <markus.t.metzger@intel.com> * record-btrace.c (record_btrace_step_thread): Check for empty history. testsuite/ * gdb.btrace/nohist.exp: New.
2014-05-20Fix MSP430 assembler to support #hi(<symbol>).Nick Clifton8-29/+73
* config/tc-msp430.c (CHECK_RELOC_MSP430): Add OP parameter. Generate BFD_RELOC_MSP430_ABS_HI16 if vshift is 1. (msp430_srcoperand): Store vshift value in operand. * msp430.h (struct msp430_operand_s): Add vshift field. * gas/elf/struct.d: Expect extra output from some toolchains. * gas/symver/symver0.d: Likewise. * gas/symver/symver1.d: Likewise.
2014-05-20ld/aarch64: xfail non-PIC shared object tests on aarch64Will Newton2-0/+8
aarch64 does not support building non-PIC shared objects, so mark tests for these as xfail. ld/testsuite/ChangeLog: 2014-05-20 Will Newton <will.newton@linaro.org> * ld-shared/shared.exp: Mark non-PIC shared object tests as xfail on aarch64.
2014-05-20Set timeout for gdb.reverse/*.exp test casesYao Qi3-0/+21
Hi, This patch is to add a new board setting gdb_reverse_timeout, which is used to set timeout for all gdb.reverse test cases, which are usually very slow and cause some TIMEOUT failures, for example, on some arm boards. We have some alternatives to this approach, but I am not satisfied with them: - Increase the timeout value. This is the global change, and it may cause some delay where actual failures happen. - Set timeout by gdb_reverse_timeout in every gdb.reverse/*.exp. Then, we have to touch every file under gdb.reverse. In this patch, we choose a central place to set timeout for all tests in gdb.reverse, which is convenient. gdb/testsuite: 2014-05-20 Yao Qi <yao@codesourcery.com> * lib/gdb.exp (gdb_init): Set timeout if test file is under gdb.reverse directory and gdb_reverse_timeout exists in board setting. * README: Document gdb_reverse_timeout.
2014-05-20gdb_init argument ARGS is a string rather than a listYao Qi2-10/+12
The argument ARGS of gdb_init is passed from dejagnu is a string, the test file name. In dejagnu/runtest.exp: proc runtest { test_file_name } { .... .... if [info exists tool] { if { [info procs "${tool}_init"] != "" } { ${tool}_init $test_file_name; } } .... } but inn default_gdb_init (callee of gdb_init), we have set gdb_test_file_name [file rootname [file tail [lindex $args 0]]] In tcl, all actual arguments are combined to a list and assigned to args. This code here isn't wrong, but unnecessary, because its caller (proc runtest) only passes one string to it, and IMO, we don't need such tricky tcl "args". I doubt that "[lindex $args 0]" is to be backward compatible with old dejagnu, but dejagnu-1.4 release started to pass $test_file_name to ${too}_init, as I showed above. dejagnu-1.4 was released in 2001, and it should be old enough. I also tried to check whether gdb testusite works with dejagnu-1.3 or not, but failed to build dejagnu-1.3 on my machine. Supposing GDB testsuite requires at least dejagnu-1.4, this change should be safe. This patch is update default_gdb_init to treat ARGS as a string instead of a list. Then, 'args' sounds like a list, and this patch also renames it by 'test_file_name', to align with dejagnu. gdb/testsuite: 2014-05-20 Yao Qi <yao@codesourcery.com> * lib/gdb.exp (default_gdb_init): Rename argument 'args' by 'test_file_name'. Treat args as a string instead of a list. (gdb_init): Rename argument 'args' by 'test_file_name'.
2014-05-20Fix issue #15778: GDB Aarch64 signal frame unwinder issueHui Zhu2-29/+41
The root cause of this issue is unwinder of "#3 <signal handler called>" doesn't supply right values of registers. When GDB want to get the previous frame of "#3 <signal handler called>", it will call cache init function of unwinder "aarch64_linux_sigframe_init". The address or the value of the registers is get from this function. So the bug is inside thie function. I check the asm code of "#3 <signal handler called>": (gdb) frame 3 (gdb) p $pc $1 = (void (*)()) 0x7f931fa4d0 (gdb) disassemble $pc, +10 Dump of assembler code from 0x7f931fa4d0 to 0x7f931fa4da: => 0x0000007f931fa4d0: mov x8, #0x8b // #139 0x0000007f931fa4d4: svc #0x0 0x0000007f931fa4d8: nop This is the syscall sys_rt_sigreturn, Linux kernel function "restore_sigframe" will set the frame: for (i = 0; i < 31; i++) __get_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], err); __get_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); __get_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); The struct of uc_mcontext is: struct sigcontext { __u64 fault_address; /* AArch64 registers */ __u64 regs[31]; __u64 sp; __u64 pc; __u64 pstate; /* 4K reserved for FP/SIMD state and future expansion */ __u8 __reserved[4096] __attribute__((__aligned__(16))); }; But in GDB function "aarch64_linux_sigframe_init", the code the get address of registers is: for (i = 0; i < 31; i++) { trad_frame_set_reg_addr (this_cache, AARCH64_X0_REGNUM + i, sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET + i * AARCH64_SIGCONTEXT_REG_SIZE); } trad_frame_set_reg_addr (this_cache, AARCH64_FP_REGNUM, fp); trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM, fp + 8); trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, fp + 8); The code that get pc and sp is not right, so I change the code according to Linux kernel code: trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM, sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET + 31 * AARCH64_SIGCONTEXT_REG_SIZE); trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM, sigcontext_addr + AARCH64_SIGCONTEXT_XO_OFFSET + 32 * AARCH64_SIGCONTEXT_REG_SIZE); The issue was fixed by this change, and I did the regression test. It also fixed a lot of other XFAIL and FAIL. 2014-05-20 Hui Zhu <hui@codesourcery.com> Yao Qi <yao@codesourcery.com> PR backtrace/16558 * aarch64-linux-tdep.c (aarch64_linux_sigframe_init): Update comments and change address of sp and pc.
2014-05-20Remove unnecessary header from m68k-dis.cAlan Modra2-2/+4
* m68k-dis.c: Don't include setjmp.h.
2014-05-20Rewrite ppc32 backend .sdata and .sdata2 handlingAlan Modra7-118/+150
1) _SDA_BASE_ and _SDA2_BASE_ and defined automatically, in a similar manner to the way _GLOBAL_OFFSET_TABLE_ is handled. It's a little more complicated to remove the symbols because _SDA_BASE_ needs to be there if either .sdata or .sbss is present, and similarly for _SDA2_BASE. 2) The linker created .sdata and .sdata2 sections used for R_PPC_EMB_SDAI16 and R_PPC_EMB_SDA2I16 pointers are created early. Nowadays we strip unneeded sections from the output, so it isn't necessary to delay creating the sections. 3) The output section for targets of various SDA relocs is now checked as per the ABI(s). We previously allowed .sdata.foo and similar, most likely because at some stage we were checking input sections. Also, the patch fixes a long-standing bug in size_input_sections that affects the values of symbols defined in stripped input sections. PR 16952 bfd/ * elf32-ppc.c (ppc_elf_create_linker_section): Move earlier. Remove redundant setting of htab->elf.dynobj. Don't align. Define .sdata symbols using _bfd_elf_define_linkage_sym. (ppc_elf_create_glink): Call ppc_elf_create_linker_section. (create_sdata_sym): Delete. (elf_allocate_pointer_linker_section): Rename from elf_create_pointer_linker_section. Align section. (ppc_elf_check_relocs): Don't call ppc_elf_creat_linker_section directly here, or create_sdata_sym. Set ref_regular on _SDA_BASE_ and _SDA2_BASE_. (ppc_elf_size_dynamic_sections): Remove ATTRIBUTE_UNUSED on param. Remove unnecessary tests on _SDA_BASE_ sym. (maybe_strip_sdasym, ppc_elf_maybe_strip_sdata_syms): New functions. (ppc_elf_relocate_section): Tighten SDA reloc symbol section checks. * elf32-ppc.h (ppc_elf_set_sdata_syms): Delete. (ppc_elf_maybe_strip_sdata_syms): Declare. ld/ * emulparams/elf32ppccommon.sh (_SDA_BASE_, _SDA2_BASE_): Delete. * emultempl/ppc32elf.em (ppc_before_allocation): Call ppc_elf_maybe_strip_sdata_syms. * ldlang.c (size_input_section): Correct output_offset value for excluded input sections.
2014-05-20daily updateAlan Modra1-1/+1
2014-05-19build_type_unit_groups and moved closer to only caller and renamedDoug Evans2-158/+164
* dwarf2read.c (build_type_psymtabs_1): Renamed from build_type_unit_groups and moved closer to only caller. Remove arguments. All references updated. Remove outdated .gdb_index comment. (struct tu_abbrev_offset, sort_tu_by_abbrev_offset): Move with build_type_psymtabs_1.