Commit Graph

33894 Commits

Author SHA1 Message Date
Eli Zaretskii 66af0f440b Fix MinGW compilation errors in gdbserver/.
gdb/gdbserver/Makefile.in (INCLUDE_CFLAGS): Remove trailing slash from
"-I$(srcdir)/../".  Fixes MinGW compilation errors with old GCC versions.
2014-01-13 20:54:47 +02:00
Pedro Alves f8de512932 tfile: Don't infer the PC from the tracepoint if the PC is a pseudo-register.
This PC guessing can't work when the PC is a pseudo-register.
Pseudo-register values don't end up stored in the regcache, they're
always recomputed.  And, it's actually wrong to try to write a
pseudo-register with regcache_raw_supply.  Skip it and add a comment.

gdb/
2014-01-13  Pedro Alves  <palves@redhat.com>

	* tracepoint.c (tfile_fetch_registers): Don't infer the PC from
	the tracepoint if the PC is a pseudo-register.
2014-01-13 14:56:29 +00:00
Tom Tromey fc270c357a replace XCALLOC with XCNEWVEC or XCNEW
This removes XCALLOC and replaces it either with XCNEWVEC, or, if the
number of elements being requested was 1, with XCNEW.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XCALLOC): Remove.
	* bcache.c (bcache_xmalloc): Use XCNEW, not XCALLOC.
	(print_bcache_statistics): Use XCNEWVEC, not XCALLOC.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_symfile_segments): Likewise.
	* gdbtypes.c (copy_type_recursive): Likewise.
	* i386-tdep.c (i386_gdbarch_init): Use XCNEW, not XCALLOC.
	* jit.c (jit_frame_sniffer): Use XCNEWVEC, not XCALLOC.
	* minsyms.c (prim_record_minimal_symbol_full): Use XCNEW, not
	XCALLOC.
	* mt-tdep.c (mt_gdbarch_init): Likewise.
	* opencl-lang.c (allocate_lval_closure): Use XCNEWVEC, not
	XCALLOC.
	* psymtab.c (psymbol_compare): Use XCNEW, not XCALLOC.
	* regcache.c (regcache_xmalloc_1): Use XCNEWVEC, not XCALLOC.
	* registry.c (registry_alloc_data): Likewise.
	* rs6000-tdep.c (rs6000_gdbarch_init): Use XCNEW, not XCALLOC.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* serial.c (serial_fdopen_ops): Likewise.
	* solib-aix.c (solib_aix_get_section_offsets): Use XCNEWVEC, not
	XCALLOC.
	* spu-tdep.c (spu_gdbarch_init): Use XCNEW, not XCALLOC.
	* symfile.c (default_symfile_segments): Use XCNEW and XCNEWVEC,
	not XCALLOC.
2014-01-13 07:31:29 -07:00
Tom Tromey 70ba0933ad replace XMALLOC with XNEW
This replaces XMALLOC with XNEW, and removes XMALLOC.  The only
non-mechanical bit here was remembering to edit gdbarch.sh.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XMALLOC): Remove.
	* avr-tdep.c (avr_gdbarch_init): Use XNEW, not XMALLOC.
	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
	* cli-out.c (struct ui_out *): Likewise.
	* cli/cli-dump.c (add_dump_command): Likewise.
	(add_dump_command): Likewise.
	* complaints.c (get_complaints): Likewise.
	(find_complaint): Likewise.
	* dwarf2-frame.c (execute_cfa_program): Likewise.
	* dwarf2read.c (abbrev_table_read_table): Likewise.
	* gdbarch.sh: Likewise.
	* gdbarch.c: Rebuild.
	* inf-ttrace.c (inf_ttrace_add_page): Likewise.
	* interps.c (interp_new): Likewise.
	* lm32-tdep.c (lm32_gdbarch_init): Likewise.
	* m32r-tdep.c (m32r_gdbarch_init): Likewise.
	* mi/mi-console.c (mi_console_file_new): Likewise.
	* mi/mi-interp.c (mi_interpreter_init): Likewise.
	* mi/mi-out.c (mi_out_new): Likewise.
	* mi/mi-parse.c (mi_parse): Likewise.
	* microblaze-tdep.c (microblaze_gdbarch_init): Likewise.
	* moxie-tdep.c (moxie_gdbarch_init): Likewise.
	* observer.c (xalloc_observer_list_node): Likewise.
	* regcache.c (regcache_xmalloc_1): Likewise.
	* reggroups.c (reggroup_new): Likewise.
	(_initialize_reggroup): Likewise.
	* registry.c (register_data_with_cleanup): Likewise.
	* remote.c (remote_notif_stop_alloc_reply): Likewise.
	* ser-base.c (serial_ttystate): Likewise.
	* ser-mingw.c (make_pipe_state): Likewise.
	* ser-pipe.c (pipe_open): Likewise.
	* serial.c (serial_open): Likewise.
	* sh64-tdep.c (sh64_gdbarch_init): Likewise.
	* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
	(tui_alloc_win_info): Likewise.
	(tui_add_content_elements): Likewise.
	* tui/tui-file.c (tui_file_new): Likewise.
	* tui/tui-out.c (tui_out_new): Likewise.
	* ui-file.c (mem_file_new): Likewise.
	* ui-out.c (push_level): Likewise.
	(make_cleanup_ui_out_end): Likewise.
	(append_header_to_list): Likewise.
	(ui_out_new): Likewise.
	* user-regs.c (user_reg_add_builtin): Likewise.
2014-01-13 07:31:28 -07:00
Tom Tromey 41bf6acad7 replace XZALLOC with XCNEW
This replaces XZALLOC with XCNEW and removes XZALLOC.
This change is purely mechanical.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XZALLOC): Remove.
	* ada-lang.c (get_ada_inferior_data): Use XCNEW, not XZALLOC.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* auto-load.c (get_auto_load_pspace_data): Likewise.
	* auxv.c (get_auxv_inferior_data): Likewise.
	* bfd-target.c (target_bfd_reopen): Likewise.
	* breakpoint.c (get_catch_syscall_inferior_data): Likewise.
	(deprecated_insert_raw_breakpoint): Likewise.
	* bsd-uthread.c (bsd_uthread_pid_to_str): Likewise.
	* corelow.c (core_open): Likewise.
	* darwin-nat.c (darwin_check_new_threads): Likewise.
	(darwin_attach_pid): Likewise.
	* dummy-frame.c (dummy_frame_push): Likewise.
	* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	* eval.c (ptrmath_type_p): Likewise.
	* exceptions.c (EXCEPTIONS_SIGJMP_BUF): Likewise.
	* gdbtypes.c (alloc_type_arch): Likewise.
	(alloc_type_instance): Likewise.
	* hppa-tdep.c (hppa_gdbarch_init): Likewise.
	* inf-child.c (inf_child_can_use_agent): Likewise.
	* inflow.c (get_inflow_inferior_data): Likewise.
	* infrun.c (save_infcall_suspend_state): Likewise.
	* jit.c (jit_reader_load): Likewise.
	(get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_open_impl): Likewise.
	(jit_symtab_open_impl): Likewise.
	(jit_block_open_impl): Likewise.
	(jit_frame_sniffer): Likewise.
	* linux-fork.c (add_fork): Likewise.
	* maint.c (make_command_stats_cleanup): Likewise.
	* objfiles.c (get_objfile_pspace_data): Likewise.
	* opencl-lang.c (struct lval_closure): Likewise.
	* osdata.c (osdata_start_osdata): Likewise.
	* progspace.c (new_address_space): Likewise.
	(add_program_space): Likewise.
	* remote-sim.c (get_sim_inferior_data): Likewise.
	* sh-tdep.c (sh_gdbarch_init): Likewise.
	* skip.c (Ignore): Likewise.
	(skip_delete_command): Likewise.
	* solib-aix.c (get_solib_aix_inferior_data): Likewise.
	(library_list_start_library): Likewise.
	(solib_aix_current_sos): Likewise.
	* solib-darwin.c (get_darwin_info): Likewise.
	(darwin_current_sos): Likewise.
	* solib-dsbt.c (get_dsbt_info): Likewise.
	* solib-ia64-hpux.c (new_so_list): Likewise.
	(ia64_hpux_get_solib_linkage_addr): Likewise.
	* solib-spu.c (append_ocl_sos): Likewise.
	(spu_current_sos): Likewise.
	* solib-svr4.c (get_svr4_info): Likewise.
	(svr4_keep_data_in_core): Likewise.
	(library_list_start_library): Likewise.
	(svr4_default_sos): Likewise.
	(svr4_read_so_list): Likewise.
	* solib-target.c (library_list_start_library): Likewise.
	(solib_target_current_sos): Likewise.
	* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
	* symfile-debug.c (install_symfile_debug_logging): Likewise.
	* symfile.c (default_symfile_segments): Likewise.
	* target-descriptions.c (tdesc_data_init): Likewise.
	(tdesc_create_reg): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_create_vector): Likewise.
	(tdesc_set_struct_size): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_free_feature): Likewise.
	(tdesc_create_feature): Likewise.
	* windows-nat.c (windows_add_thread): Likewise.
	(windows_make_so): Likewise.
	* xml-support.c (gdb_xml_body_text): Likewise.
	(gdb_xml_create_parser_and_cleanup): Likewise.
	(xml_process_xincludes): Likewise.
	* xml-syscall.c (allocate_syscalls_info): Likewise.
	(syscall_create_syscall_desc): Likewise.
2014-01-13 07:31:27 -07:00
Sergio Durigan Junior 5acfdbae5d Split i386_stap_parse_special_token into smaller functions
This patch reorganizes code on gdb/i386-tdep.c's SystemTap SDT probe
support functions.  Before it, the code to parse special operands on x86
lived in a single, big function.  This patch creates 2 new functions
that makes the code more organized and removes a few indentation levels
(which is always good IMO).

I haven't modified anything logical in the functions, i.e., there's still
one latent bug on i386_stap_parse_special_token_triplet now.  I will soon
post a patch to fix this, and to also improve the readability of the two
new functions.

2014-01-12  Sergio Durigan Junior  <sergiodj@redhat.com>

	* i386-tdep.c (i386_stap_parse_special_token_triplet): New
	function, with code from i386_stap_parse_special_token.
	(i386_stap_parse_special_token_three_arg_disp): Likewise.
	(i386_stap_parse_special_token): Move code to the two functions
	above; simplify it.
2014-01-12 01:32:26 -02:00
Pedro Alves 41ef2965ab [doc] Mention that "set environment" affects the shell too.
gdb/doc/
2014-01-10  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Your Program's Environment) <set environment>:
	Mention the shell, and point at 'set exec-wrapper'.
2014-01-10 15:46:59 +00:00
Andreas Arnez 52d7fb1303 Since upstream gcc has recently increased the function alignment on
S390, the dw2-dir-file-name test case fails in the first
gdb_continue_to_breakpoint.  Indeed, the breakpoint is now placed into
the alignment gap *before* the actual function.

This happens because the test case declares the respective "*_start"
symbol as a "loose" label before the function definition, and the
compiler inserts the alignment between that label and the function
itself.

The "*_start" symbols were only necessary because FUNC made the
function static.  The fix makes the functions extern instead, thus
making the "*_start" labels unnecessary.

testsuite/
2014-01-10  Andreas Arnez  <arnez@linux.vnet.ibm.com>
	    Pedro Alves <palves@redhat.com>

	* gdb.dwarf2/dw2-dir-file-name.c (FUNC): Remove "*_start" symbol.
	Make "name" extern.
	* gdb.dwarf2/dw2-dir-file-name.exp (out_cu, out_line): Replace
	references to ${name}_start by references to ${name}.
2014-01-10 15:37:36 +00:00
Joel Brobecker a2cd8cfed1 Remove path from gdb.ada/pp-rec-component.exp "source" test
gdb/testsuite/ChangeLog:

	* gdb.ada/pp-rec-component.exp: Remove path from "source" test.
2014-01-10 07:57:11 +04:00
Joel Brobecker 4e23fced81 Remove path from gdb.python/py-pp-integral.exp "source" test.
gdb/testsuite/ChangeLog:

	* gdb.python/py-pp-integral.exp: Remove path from "source" test.
2014-01-10 07:57:09 +04:00
Pedro Alves c6a9e42ce4 gdb.mi/mi-info-os.exp: Fix cross-debugger testing
A live target is required for `-info-os' to work in non-native
configurations.

 (gdb)
 Expecting: ^(-info-os[
 ]+)?(.*\^done,OSDataTable=.*[
 ]+[(]gdb[)]
 [ ]*)
 -info-os
 ^error,msg="Don't know how to get OS data.  Try \"help target\"."
 (gdb)
 FAIL: gdb.mi/mi-info-os.exp: -info-os

If GDB does have a native configuration included, but we're testing
remote, it'll be worse, as if we're not connected yet, -info-os will
run against the default run target, and pass, falsely giving the
impression the remote bits were exercised.

gdb/testsuite/
2014-01-09  Maciej W. Rozycki  <macro@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.mi/mi-info-os.exp: Connect to the target with
        mi_gdb_target_load.
2014-01-09 19:57:13 +00:00
Pedro Alves 0000e5ccd8 Handle the case of a remote target supporting target side commands, but not on software breakpoints.
Although we can tell upfront whether a remote target supports target
side commands, we can only tell whether the target supports that in
combination with a given breakpoint kind (software, hardware,
watchpoints, etc.) when we go and try to insert such a breakpoint kind
the first time.  It's not desirable to make remote_insert_breakpoint
simply return -1 in this case, because if the breakpoint was set in a
shared library, insert_bp_location will assume that the breakpoint
insertion failed because the library wasn't mapped in.

insert_bp_location already handles errors/exceptions thrown from the
target_insert_xxx methods, exactly so the backend can tell the user
the detailed reason the insertion of hw breakpoints failed.  But, in
the case of software breakpoints, it discards the detailed error
message.

So the patch makes insert_bp_location use the error's message for SW
breakpoints too, and, introduces a NOT_SUPPORTED_ERROR error code so
that insert_bp_location doesn't confuse the error for failure due to a
shared library disappearing.

The result is:

(gdb) c
Warning:
Cannot insert breakpoint 2: Target doesn't support breakpoints that have target side commands.

2014-01-09  Pedro Alves  <palves@redhat.com>
	    Hui Zhu  <hui@codesourcery.com>

	PR gdb/16101
	* breakpoint.c (insert_bp_location): Rename hw_bp_err_string to
	bp_err_string.  Don't mark the location shlib_disabled if the
	error thrown wasn't a generic or memory error.  Catch errors
	thrown while inserting breakpoints in overlayed code.  Output
	error message of software breakpoints.
	* remote.c (remote_insert_breakpoint): If this breakpoint has
	target-side commands but this stub doesn't support Z0 packets,
	throw NOT_SUPPORTED_ERROR error.
	* exceptions.h (enum errors) <NOT_SUPPORTED_ERROR>: New error.
	* target.h (target_insert_breakpoint): Extend comment.
	(target_insert_hw_breakpoint): Add comment.
2014-01-09 18:33:45 +00:00
Pedro Alves 9939e1314f GDBserver: Discard previous queued events when GDB disconnects.
... not when a new GDB connection sends the status packet ('?').
Mainly just a cleanup/simplification, as GDB always sends '?' first.

Tested on x86_64 Fedora 17.

2014-01-08  Pedro Alves  <palves@redhat.com>

	* server.c (handle_status): Don't discard previous queued stop
	replies or thread's pending status here.
	(main) <disconnection>: Do it here instead.
2014-01-08 20:34:26 +00:00
Pedro Alves b7ea362b02 [remote/gdbserver] Don't lose signals when reconnecting.
Currently, when GDB connects in all-stop mode, GDBserver always
responds to the status packet with a GDB_SIGNAL_TRAP, even if the
program is actually stopped for some other signal.

 (gdb) tar rem ...
 ...
 (gdb) c
 Program received signal SIGUSR1, User defined signal 1.
 (gdb) disconnect
 (gdb) tar rem ...
 (gdb) c

(Or a GDB crash instead of an explicit disconnect.)

This results in the program losing that signal on that last continue,
because gdb will tell the target to resume with no signal (to suppress
the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will
actually suppress the real signal the program had stopped for
(SIGUSR1).  To fix that, I think we should make GDBserver report the
real signal the thread had stopped for in response to the status
packet:

 @item ?
 @cindex @samp{?} packet
 Indicate the reason the target halted.  The reply is the same as for
 step and continue.

But, that raises the question -- which thread are we reporting the
status for?  Due to how the RSP in all-stop works, we can only report
one status.  The status packet's response is a stop reply packet, so
it includes the thread identifier, so it's not a problem packet-wise.
However, GDBserver is currently always reporting the status for first
thread in the thread list, even though that may well not be the thread
that got the signal that caused the program to stop.  So the next
logical step would be to report the status for the
last_ptid/last_status thread (the last event reported to gdb), if it's
still around; and if not, fallback to some other thread.

There's an issue on the GDB side with that, though...

GDB currently always adds the thread reported in response to the
status query as the first thread in its list.  That means that if we
start with e.g.,

 (gdb) info threads
   3 Thread 1003 ...
 * 2 Thread 1002 ...
   1 Thread 1001 ...

And reconnect:

 (gdb) disconnect
 (gdb) tar rem ...

We end up with:

 (gdb) info threads
   3 Thread 1003 ...
   2 Thread 1001 ...
 * 1 Thread 1002 ...

Not a real big issue, but it's reasonably fixable, by having GDB
fetch/sync the thread list before fetching the status/'?', and then
using the status to select the right thread as current on the GDB
side.  Holes in the thread numbers are squashed before/after
reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved,
which I think is both good, and good enough.

However (yes, there's more...), the previous GDB that was connected
might have had gdbserver running in non-stop mode, or could have left
gdbserver doing disconnected tracing (which also forces non-stop), and
if the new gdb/connection is in all-stop mode, we can end up with more
than one thread with a signal to report back to gdb.  As we can only
report one thread/status (in the all-stop RSP variant; the non-stop
variant doesn't have this issue), we get to do what we do at every
other place we have this situation -- leave events we can't report
right now as pending, so that the next resume picks them up.

Note all this ammounts to a QoI change, within the existing framework.
There's really no RSP change here.

The only user visible change (other than that the signal is program is
stopped at isn't lost / is passed to the program), is in "info
program", that now can show the signal the program stopped for.  Of
course, the next resume will respect the pass/nopass setting for the
signal in question.  It'd be reasonable to have the initial connection
tell the user the program was stopped with a signal, similar to when
we load a core to debug, but I'm leaving that out for a future change.
I think we'll need to either change how handle_inferior_event & co
handle stop_soon, or maybe bypass them completely (like
fork-child.c:startup_inferior) for that.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (struct thread_info) <status_pending_p>: New field.
	* server.c (visit_actioned_threads, handle_pending_status): New
	function.
	(handle_v_cont): Factor out parts to ...
	(resume): ... this new function.  If in all-stop, and a thread
	being resumed has a pending status, report it without actually
	resuming.
	(myresume): Adjust to use the new 'resume' function.
	(clear_pending_status_callback, set_pending_status_callback)
	(find_status_pending_thread_callback): New functions.
	(handle_status): Handle the case of multiple threads having
	interesting statuses to report.  Report threads' real last signal
	instead of always reporting GDB_SIGNAL_TRAP.  Look for a thread
	with an interesting thread to report the status for, instead of
	always reporting the status of the first thread.

gdb/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_add_thread): Add threads silently if starting
	up.
	(remote_notice_new_inferior): If in all-stop, and starting up,
	don't call notice_new_inferior.
	(get_current_thread): New function, factored out from ...
	(add_current_inferior_and_thread): ... this.  Adjust.
	(remote_start_remote) <all-stop>: Fetch the thread list.  If we
	found any thread, then select the remote's current thread as GDB's
	current thread too.

gdb/testsuite/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* gdb.threads/reconnect-signal.c: New file.
	* gdb.threads/reconnect-signal.exp: New file.
2014-01-08 18:55:51 +00:00
Joel Brobecker b7bba00155 Update NEWS post GDB 7.7 branch creation.
gdb/ChangeLog:

	* NEWS: Create a new section for the next release branch.
	Rename the section of the current branch, now that it has
	been cut.
2014-01-08 13:41:03 +04:00
Joel Brobecker 16dfbded4c Bump version to 7.7.50.DATE-cvs.
Now that the GDB 7.7 branch has been created, we can
bump the version number.

gdb/ChangeLog:

	GDB 7.7 branch created (79301218fa):
	* version.in: Bump version to 7.7.50.DATE-cvs.
2014-01-08 13:25:28 +04:00
Joel Brobecker 79301218fa Add missing ChangeLog entries. 2014-01-08 13:16:32 +04:00
Yao Qi 22c90ac1cd Fix pointer assignment with different signedness
This patch fixes these errors below:

../../binutils-gdb/gdb/spu-linux-nat.c: In function ‘spu_symbol_file_add_from_memory’:
../../binutils-gdb/gdb/spu-linux-nat.c:368:3: error: pointer targets in passing argument 2 of ‘spu_proc_xfer_spu’ differ in signedness [-Werror=pointer-sign]
../../binutils-gdb/gdb/spu-linux-nat.c:232:1: note: expected ‘gdb_byte *’ but argument is of type ‘char *’
../../binutils-gdb/gdb/spu-linux-nat.c: In function ‘spu_xfer_partial’:
../../binutils-gdb/gdb/spu-linux-nat.c:598:7: error: pointer targets in passing argument 1 of ‘strtoulst’ differ in signedness [-Werror=pointer-sign]
In file included from ../../binutils-gdb/gdb/defs.h:769:0,
                 from ../../binutils-gdb/gdb/spu-linux-nat.c:21:
../../binutils-gdb/gdb/utils.h:43:15: note: expected ‘const char *’ but argument is of type ‘gdb_byte *’

gdb:

2014-01-08  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (spu_symbol_file_add_from_memory): Change
	type of 'id' to gdb_byte.  Cast 'id' to 'const char *'.
	(spu_xfer_partial): Cast 'buf' to 'const char *'.
2014-01-08 10:44:32 +08:00
Yao Qi d64ad97c6b Pass name to symbol_file_add_from_bfd
This patch fixes the following build error:

../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 2 of ‘symbol_file_add_from_bfd’ makes pointer from integer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘const char *’ but argument is of type ‘int’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 3 of ‘symbol_file_add_from_bfd’ makes integer from pointer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘int’ but argument is of type ‘void *’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 5 of ‘symbol_file_add_from_bfd’ makes integer from pointer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘int’ but argument is of type ‘void *’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: too few arguments to function ‘symbol_file_add_from_bfd’

Argument 'name' was added to function symbol_file_add_from_bfd by this patch

  [patchv4 4/5] Keep objfile original filename
  https://sourceware.org/ml/gdb-patches/2013-09/msg00683.html

but caller of symbol_file_add_from_bfd in spu-linux-nat.c wasn't updated.

This patch fixes the build error.

gdb:

2014-01-08  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (spu_symbol_file_add_from_memory): Pass
	return value of bfd_get_filename to symbol_file_add_from_bfd.
2014-01-08 10:44:20 +08:00
Pierre Muller f93ba80c98 Fix PR16201.
* coff-pe-read.c (struct read_pe_section_data): Add index field.
	(add_pe_exported_sym): Use SECTION_DATA->INDEX for call
	to prim_record_mininal_symbol_and_info.
	(add_pe_forwarded_sym): Use known section number of forwarded symbol
	in call to prim_record_minimal_symbol_and_info.
	(read_pe_exported_syms): Set index field of section_data.
2014-01-08 00:31:50 +01:00
Andrew Pinski a4d9ba85ec AARCH64: Change cpsr type to be 64bit.
2013-12-18  Andrew Pinski  <apinski@cavium.com>

	* features/aarch64-core.xml (cpsr): Change to be 64bit.
	* features/aarch64.c: Regenerate.
2014-01-07 14:31:55 -08:00
Andreas Schwab 1b67eb0273 Use correct default for target functions that return pointer
* target.c (return_null): Define.
	(update_current_target): Use it instead of return_zero for
	functions that return a pointer.
2014-01-07 22:58:31 +01:00
Edjunior Barbosa Machado 5e3f4fab9a Fix dir command for duplicated paths and add a new testcase.
gdb/ChangeLog:
2014-01-07  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* source.c (add_path): Fix check for duplicated paths in the previously
	included paths.

gdb/testsuite/ChangeLog:
2014-01-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/source-dir.exp: New file.
2014-01-07 17:03:06 -02:00
Honggyu Kim e261678878 Remove duplicated #include's from GDB
This patch simply removes duplicated #include statements in the gdb/
directory.  If there are two duplicated #include statements, this patch
keeps the first #include and removes the second.

Those duplicates have been found by using the checkincludes.pl tool from
the Linux kernel and double checked manually once again if the #include
statements are affected by #ifdef macros.

2014-01-06  Honggyu Kim  <hong.gyu.kim@lge.com>

	* ada-lang.c: Remove duplicated include statements.
	* alphabsd-nat.c: Ditto.
	* amd64-darwin-tdep.c: Ditto.
	* amd64fbsd-nat.c: Ditto.
	* auto-load.c: Ditto.
	* ax-gdb.c: Ditto.
	* breakpoint.c: Ditto.
	* dbxread.c: Ditto.
	* fork-child.c: Ditto.
	* gdb_usleep.c: Ditto.
	* i386-darwin-tdep.c: Ditto.
	* i386fbsd-nat.c: Ditto.
	* infcmd.c: Ditto.
	* inferior.c: Ditto.
	* jv-lang.c: Ditto.
	* linux-nat.c: Ditto.
	* linux-tdep.c: Ditto.
	* m68kbsd-nat.c: Ditto.
	* m68klinux-nat.c: Ditto.
	* microblaze-tdep.c: Ditto.
	* mips-linux-tdep.c: Ditto.
	* mn10300-tdep.c: Ditto.
	* nto-tdep.c: Ditto.
	* opencl-lang.c: Ditto.
	* osdata.c: Ditto.
	* printcmd.c: Ditto.
	* regcache.c: Ditto.
	* remote-m32r-sdi.c: Ditto.
	* remote.c: Ditto.
	* symfile.c: Ditto.
	* symtab.c: Ditto.
	* tilegx-linux-nat.c: Ditto.
	* tilegx-tdep.c: Ditto.
	* tracepoint.c: Ditto.
	* valops.c: Ditto.
	* vaxbsd-nat.c: Ditto.
	* windows-nat.c: Ditto.
	* xtensa-tdep.c: Ditto.
2014-01-07 14:14:30 -02:00
Yao Qi bd1f77885b Fix missing-prototypes error for '_initialize_spu_nat'
This patch fixes this build error below:

../../binutils-gdb/gdb/spu-linux-nat.c:616:1: error: no previous prototype for ‘_initialize_spu_nat’ [-Werror=missing-prototypes]

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (_initialize_spu_nat): Declare.
2014-01-07 21:47:14 +08:00
Yao Qi 3b631e3720 Cast to uintptr_t when calling ptrace32 on aix
When I verify my changes to target.h doesn't break build on aix, I get
the following build error on a clean GDB checkout.

../../binutils-gdb/gdb/aix-thread.c: In function 'pdc_read_regs':
../../binutils-gdb/gdb/aix-thread.c:366:4: error: passing argument 3 of 'ptrace32' makes integer from pointer without a cast [-Werror]
    if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
    ^
../../binutils-gdb/gdb/aix-thread.c:263:1: note: expected 'long long int' but argument is of type 'uint32_t *'
 ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 ^

../../binutils-gdb/gdb/aix-thread.c:375:42: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
       if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
                                          ^

../../binutils-gdb/gdb/aix-thread.c:392:39: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
    if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))

GCC uses -maix32 in default, so the 'long long' is 64 bit and address
is 32 bit.  Such warnings should go away if -maix64 is used.

In this patch, I cast the parameter to uintptr_t first, and then cast
to addr_ptr.

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>
	    Joel Brobecker  <brobecker@adacore.com>

	* aix-thread.c (pdc_read_regs): Cast parameter to uintptr_t.
	(pdc_write_regs): Likewise.
	(fetch_regs_kernel_thread): Likewise.
	(store_regs_kernel_thread): Likewise.
2014-01-07 14:29:25 +04:00
Joel Brobecker f30b8b38d4 varobj/Ada: Missing children for interface-wide tagged types
Consider the following code:

   type Element is abstract tagged null record;
   type GADataType is interface;
   type Data_Type is new Element and GADataType with record
      I : Integer := 42;
   end record;
   Result1 : Data_Type;
   GGG1    : GADataType'Class := GADataType'Class (Result1);

When trying to create a varobj for variable ggg1, GDB currently
returns an object which has no child:

    -var-create ggg1 * ggg1
    ^done,name="ggg1",numchild="0",[...]

This is incorrect, it should return an object which has one child
(field "i"). This is because tagged-type objects are dynamic, and
we need to apply a small transformation in order to get their actual
type. This is already done on the GDB/CLI side in ada-valprint,
and it needs to be done on the ada-varobj side as well.

gdb/ChangeLog:

        * ada-varobj.c (ada_varobj_adjust_for_child_access): Convert
        tagged type objects to their actual type.

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_interface: New testcase.
2014-01-07 08:29:04 +04:00
Joel Brobecker 8e355c5d24 Ada: Fix missing call to pretty-printer for fields of records.
Consider the following types:

   type Time_T is record
      Secs : Integer;
   end record;
   Before : Time_T := (Secs => 1384395743);

In this example, we assume that type Time_T is the number of seconds
since Epoch, and so added a Python pretty-printer, to print this
type in a more human-friendly way. For instance:

    (gdb) print before
    $1 = Thu Nov 14 02:22:23 2013 (1384395743)

However, we've noticed that things stop working when this type is
embedded inside another record, and we try to print that record.
For instance, with the following declarations:

   type Composite is record
      Id : Integer;
      T : Time_T;
   end record;
   Afternoon : Composite := (Id => 1, T => (Secs => 1384395865));

    (gdb) print afternoon
    $2 = (id => 1, t => (secs => 1384395865))

We expected instead:

    (gdb) print afternoon
    $2 = (id => 1, t => Thu Nov 14 02:24:25 2013 (1384395865))

This patch fixes the problem by making sure that we try to print
each field via a call to val_print, rather than calling ada_val_print
directly. We need to go through val_print, as the val_print
handles all language-independent features such as calling the
pretty-printer, knowing that ada_val_print will get called eventually
if actual Ada-specific printing is required (which should be the
most common scenario).

And because val_print takes the language as parameter, we enhanced
the print_field_values and print_variant_part to also take a language.
As a bonus, this allows us to remove a couple of references to
current_language.

gdb/ChangeLog:

        * ada-valprint.c (print_field_values): Add "language" parameter.
        Update calls to print_field_values and print_variant_part.
        Pass new parameter "language" in call to val_print instead
        of "current_language".  Replace call to ada_val_print by call
        to val_print.
        (print_variant_part): Add "language" parameter.
        (ada_val_print_struct_union): Update call to print_field_values.

gdb/testsuite/ChangeLog:

        * gdb.ada/pp-rec-component.exp, gdb.ada/pp-rec-component.py,
        gdb.ada/pp-rec-component/foo.adb, gdb.ada/pp-rec-component/pck.adb,
        gdb.ada/pp-rec-component/pck.ads: New files.
2014-01-07 08:17:40 +04:00
Joel Brobecker 4fbf5aa5f4 ada_print_floating: Remove use of statically sized buffer.
ada_print_floating declares a char buffer with a size that we're hoping
to always be large enough to hold any string representation of a float
value.  But that's not really necessary, and also forces us to create
a small wrapper (ui_memcpy) to perform the extraction from a temporary
stream into this buffer.  This patches fixes both issues by relying on
ui_file_xstrdup.  This forces us to make a few adjustments that are
minor in nature, as we now need to defer the cleanup to the end of
the function.

gdb/ChangeLog:

        * ada-valprint.c (ui_memcpy): Delete.
        (ada_print_floating): Update documentation.  Add empty line
        between between function documentation and implementation.
        Delete variable "buffer".  Use ui_file_xstrdup in place of
        ui_file_put.  Minor adjustments following this change.
2014-01-07 08:17:40 +04:00
Joel Brobecker 71855601a5 Extract string-printing out of ada_val_print_array
This patch creates a new function called "ada_val_print_string"
whose code is directly extracted out of ada_val_print_array.
The extracted code is then replaced by a call to this new function,
followed by a "return". The return avoids the need for an "else"
branch, with the associated block nesting. The latter is not really
terrible in this case, but it seems more readable this way.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_string): New function,
        extracted from ada_val_print_array.
        (ada_val_print_array): Replace extracted code by call
        to ada_val_print_string followed by a return.  Move
        "else" branch to the function's top block.
2014-01-07 08:17:39 +04:00
Joel Brobecker 4eb27a304c move ada_val_print_array down within other ada_val_print* functions
This patch moves ada_val_print_array to group it with the other
ada_val_print_* function which are being called by ada_val_print_1.
Since this function is in the same situation, it is more logical
to move it within that group.

It also rationalizes the function's prototype to match the prototype
of the other ada_val_print_* routines.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_array): Move implementation
        down.  Rename parameter "offset" and "val" into "offset_aligned"
        and "original_value" respectively.  Add parameter "offset".
2014-01-07 08:17:39 +04:00
Joel Brobecker 34b2795054 rewrite ada_val_print_ref to reduce if/else block nesting depth
The logic as currently implemented in this function was a little
difficult to follow, due to the nested of if/else conditions,
but most of the time, the "else" block was very simple. So this
patch re-organizes the code to use fewer levels of nesting by
using return statements, and writing the code as a sequence of
"if something simple, then handle it and return" blocks.

While touching this code, this patch changes the cryptic "???"
printed when trying to print a reference pointing to an undefined
type. This should only ever happen if the debugging information
was corrupted or improperly read. But in case that happens, we now
print "<ref to undefined type>" instead. This is more in line
with how we print other conditions such as optimized out pieces,
or synthetic pointers.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_ref): Rewrite by mostly
        re-organizing the code. Change the "???" message printed
        when target type is a TYPE_CODE_UNDEF into
        "<ref to undefined type>".
2014-01-07 08:17:39 +04:00
Joel Brobecker 079e459161 ada-valprint.c: Inline print_record inside ada_val_print_struct_union
The function print_record is a fairly small and straightforward
function which is only called from one location. So this patch
inlines the code at the point of call.

One small advantage is that the context of use of this patch has
now become such that we can assume that TYPE is not a typedef,
nor an enum. So thhe call to ada_check_typedef is unnecessary,
and this patch removes it.

gdb/ChangeLog:

        * ada-valprint.c (print_record): Delete, implementation inlined...
        (ada_val_print_struct_union): ... here.  Remove call to
        ada_check_typedef in inlined implementation.
2014-01-07 08:17:39 +04:00
Joel Brobecker 8004dfd1cf Split ada_val_print_1 into smaller functions
The idea of this patch is that it's hard to have a global view of
ada_val_print_1 because its body spans over too many lines. Also,
each individual "case" block within the giant "switch" can be hard
to isolate if spanning over multiple pages as well.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_gnat_array): New function,
        extracted from ada_val_print_1;
        (ada_val_print_ptr, ada_val_print_num, ada_val_print_enum)
        (ada_val_print_flt, ada_val_print_struct_union)
        (ada_val_print_ref): Likewise.
        (ada_val_print_1): Delete variables i and elttype.
        Replace extracted-out code by call to corresponding
        new functions.
2014-01-07 08:17:38 +04:00
Joel Brobecker 760a2db02f Remove call to gdb_flush at end of ada_val_print_1
I am not sure why this function was called in the first place, but
it disrupts the printing flow when in GDB/MI mode, ending the current
console stream output, and starting a new one. It's not clear whether,
with the code as currently written, the problem is actually visible
or only latent. But, it becomes visible when we replace one of the
"return" statements in the "switch" block just above by a "break"
statement (this is something I'd like to do, and what made me realize
the problem). With the gdb_flush call (after having replaced the
"return" statement as explained above), we get:

        % gdb -q -i=mi ada_prg
        (gdb)
        print 1
        &"print 1\n"
  !! -> ~"$1 = 1"
  !! -> ~"\n"
        ^done

With the gdb_flush call removed, we now get the entire output into
a single stream.

        (gdb)
        print 1
        &"print 1\n"
        ~"$1 = 1"
        ~"\n"
        ^done

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Remove call to gdb_flush.
2014-01-07 08:17:38 +04:00
Joel Brobecker 3a92c861bb ada_val_print_1: Go through val_print instead of recursive call to self.
This is to standardize a little bit how printing is done, and in
particular make sure that everyone goes through val_print when
printing sub-objects.  This helps making sure that standard features
handled by val_print get activated when expected.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Replace calls to
        ada_val_print_1 by calls to val_print.
2014-01-07 08:17:38 +04:00
Joel Brobecker cd1630f983 ada_val_print_1: Add language parameter
This is to help calling val_print.  We would like to be more systematic
in calling val_print when printing, because it allows us to make sure
we take advantage of the standard features such as pretty-printing
which are handled by val_print.

gdb/ChangeLog:

        * ada-valprint.c (ada_val_print_1): Add parameter "language".
        Update calls to self accordingly.  Replace calls to c_val_print
        by calls to val_print.
2014-01-07 08:17:38 +04:00
Joel Brobecker bdf779a0c5 ada-valprint.c: Reorder functions to reduce advance declarations.
Advance function declarations add to the maintenance cost, since
any update to the function prototype needs to be made twice.
For static functions, this is not necessary, and this patch
reorders the function so as to reduce the use of such advanche
declarations.

gdb/ChangeLog:

        * ada-valprint.c (print_record): Delete declaration.
        (adjust_type_signedness, ada_val_print_1): Likewise.
        (ada_val_print): Move function implementation down.
        (print_variant_part, print_field_values, print_record):
        Move function implementation up.
2014-01-07 08:17:37 +04:00
Joel Brobecker c0d4881122 [python] Add gdb.Type.name attribute.
Consider the following declarations:

    typedef long our_time_t;
    our_time_t current_time = 1384395743;

The purpose of this patch is to allow the use of a pretty-printer
for variables of type our_time_t.  Normally, pretty-printing sniffers
use the tag name in order to determine which, if any, pretty-printer
should be used. But in the case above, the tag name is not set, since
it does not apply to integral types.

This patch extends the gdb.Type list of attributes to also include
the name of the type, thus allowing the sniffer to match against
that name. With that change, I was able to write a pretty-printer
which displays our variable as follow:

    (gdb) print current_time
    $1 = Thu Nov 14 02:22:23 2013 (1384395743)

gdb/ChangeLog:

        * python/py-type.c (typy_get_name): New function.
        (type_object_getset): Add entry for attribute "name".
        * NEWS: Add entry mentioning this new attribute.

gdb/doc/ChangeLog:

        * gdb.texinfo (Types In Python): Document new attribute Types.name.

gdb/testsuite:

        * gdb.python/py-pp-integral.c: New file.
        * gdb.python/py-pp-integral.py: New file.
        * gdb.python/py-pp-integral.exp: New file.

Tested on x86_64-linux.
2014-01-07 07:11:17 +04:00
Yao Qi c26e9cbb0c Remove an empty-body 'if' statement
This patch removes the if statement and the comments together.

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (set_exceptions_cmd): Remove an empty body 'if'
	statement.
2014-01-07 11:01:55 +08:00
Yao Qi 0cc6f43dae Add qualifier 'const' to argument args
This patch fixes the following error.

../../../git/gdb/gnu-nat.c: In function 'info_port_rights':
../../../git/gdb/gnu-nat.c:3083:11: error: passing argument 1 of 'parse_to_comma_and_eval' from incompatible pointer type [-Werror]
In file included from ../../../git/gdb/breakpoint.h:23:0,
                 from ../../../git/gdb/inferior.h:37,
                 from ../../../git/gdb/gnu-nat.c:55:
../../../git/gdb/value.h:763:22: note: expected 'const char **' but argument is of type 'char **'

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (info_port_rights): Add qualifier const to
	argument args.
2014-01-07 11:01:48 +08:00
Yao Qi eec03155c2 Use void for empty argument list in trace_me
This patch fixes the following error:

../../../git/gdb/gnu-nat.c: In function 'trace_me':
../../../git/gdb/gnu-nat.c:2106:8: error: old-style function definition [-Werror=old-style-definition]

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (trace_me): Use 'void' for empty argument list.
2014-01-07 11:01:42 +08:00
Yao Qi f04a82ef62 Make functions static.
gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (make_inf) Update declaration.
	(make_inf): Make it static.
	(inf_set_traced): Likewise.
	(inf_port_to_thread, inf_task_died_status): Likewise.
2014-01-07 11:01:37 +08:00
Yao Qi d57dda0ab3 Remove declaration of inf_tid_to_proc
inf_tid_to_proc is not defined at all.  This patch is to remove its
declaration.
gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (inf_tid_to_proc): Remove declaration.
2014-01-07 11:01:33 +08:00
Yao Qi 3aa8c9698a Fix no previous prototype for '_initialize_gnu_nat' [-Werror=missing-prototypes]
This patch fixes this error below by declaring _initialize_gnu_nat.

../../../git/gdb/gnu-nat.c:3447:1: error: no previous prototype for '_initialize_gnu_nat' [-Werror=missing-prototypes]

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gnu-nat.c (_initialize_gnu_nat): Declare.
2014-01-07 11:01:27 +08:00
Yao Qi 94123b4f91 Use enum bfd_endian in gdbarch.sh
This patch changes the return type of gdbarch_byte_order and
gdbarch_byte_order_for_code, from 'int' to 'enum bfd_endian'.

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* gdbarch.sh (byte_order, byte_order_for_code): Change type to
	'enum bfd_endian'.
	(struct gdbarch_info) <byte_order>: Change type to
	'enum bfd_endian'.
	<byte_order_for_code>: Likewise.
	* gdbarch.c, gdbarch.h: Regenerated.
2014-01-07 10:28:06 +08:00
Tom Tromey dc81d70a97 fix JIT reader path creation
2014-01-06  Sasha Smundak  <asmundak@google.com>

	* jit.c: (jit_reader_load_command): Fix JIT reader path creation.
2014-01-06 14:57:59 -07:00
Tom Tromey cc2f3c3582 convert CONST to const
This removes the last uses of the obsolete CONST macro from the tree.
I'm checking this in.  Tested by rebuilding.

2014-01-06  Tom Tromey  <tromey@redhat.com>

	* doublest.c (convert_doublest_to_floatformat): Use const, not
	CONST.
	* somread.c (som_symtab_read): Likewise.
2014-01-06 12:06:40 -07:00
Hui Zhu 78f47043ff Fix a error of my previous commit. 2014-01-07 00:28:55 +08:00
Hui Zhu adcf2eed05 Remove gdb_bfd_stash_filename to fix crash with fix of binutils/11983
https://sourceware.org/ml/gdb-patches/2014-01/msg00029.html
https://sourceware.org/ml/gdb-patches/2014-01/msg00053.html

2014-01-07  Hui Zhu  <hui@codesourcery.com>

	* gdb_bfd.c (gdb_bfd_stash_filename): Removed.
	(gdb_bfd_open): Removed gdb_bfd_stash_filename.
	(gdb_bfd_fopen): Ditto.
	(gdb_bfd_openr): Ditto.
	(gdb_bfd_openw): Ditto.
	(gdb_bfd_openr_iovec): Ditto.
	(gdb_bfd_fdopenr): Ditto.
	* gdb_bfd.h (gdb_bfd_stash_filename): Removed.
	* solib-aix.c (solib_aix_bfd_open): Alloc object_bfd->filename
	with xstrdup.
	* solib-darwin.c (darwin_bfd_open): Alloc res->filename
	with xstrdup.
	* symfile-mem.c (symbol_file_add_from_memory): Removed
	gdb_bfd_stash_filename.
2014-01-07 00:24:41 +08:00
Doug Evans 5072219825 * nat/linux-waitpid.c (linux_debug): Remove extraneous \n from output. 2014-01-03 14:34:45 -08:00
Joel Brobecker 2fa4b86204 Add gdb/ChangeLog entry for previous change.
I forgot to add that entry when I checked in the "copyright year range"
update for GDB files.
2014-01-01 07:57:03 +04:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Joel Brobecker 28498c4207 Update copyright year in gdb/gdbserver/gdbreplay version output.
gdb/ChangeLog:

        * top.c (print_gdb_version): Set copyright year to 2014.

gdb/gdbserver/ChangeLog:

        * gdbserver.c (gdbserver_version): Set copyright year to 2014.
        * gdbreplay.c (gdbreplay_version): Likewise.
2014-01-01 07:43:51 +04:00
Joel Brobecker 7b6e104658 Add gdb/ChangeLog-2013 entry in fnchange.lst. 2014-01-01 07:34:22 +04:00
Joel Brobecker df96af5539 New Year - GDB ChangeLog rotation. 2014-01-01 07:31:51 +04:00
Joel Brobecker 5fba4c0ff5 Clarify documentation of the gdb.Field.bitpos attribute
gdb/doc/ChangeLog:

        * gdb.texinfo (Types In Python): Clarify the documentation
        of attribute gdb.Field.bitpos.
2013-12-30 06:52:43 +04:00
Sergio Durigan Junior c248fc1d26 Add comment describing arm_stap_is_single_operand
2013-12-29  Sergio Durigan Junior  <sergiodj@redhat.com>

	* arm-linux-tdep.c (arm_stap_is_single_operand): Add comment
	describing function.
2013-12-29 18:55:11 -02:00
Sergio Durigan Junior 8d85bacb91 Extend handling of immediates on ARM's SystemTap SDT probe support
Continuing my series of fixes on the SystemTap SDT support for the
ARM/AArch64 architectures, this patch now extends how ARM's SDT specific
parser handles literal numbers (immediates).

Currently, it only accepts "#" as the prefix.  However, according to
"info '(as) ARM-Chars'", expressions can also have "$" and nothing as a
prefix.  This patch extends the parser to accept those options.

2013-12-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	* arm-linux-tdep.c (arm_stap_is_single_operand): Accept "$" as a
	literal prefix.  Also accept no prefix at all.
	(arm_stap_parse_special_token): Likewise.
	(arm_linux_init_abi): Likewise.
2013-12-28 19:20:58 -02:00
Sergio Durigan Junior 08248ca9fe Implement SystemTap SDT probe support for AArch64
This commit implements the needed bits for SystemTap SDT probe support
on AArch64 architectures.

First, I started by looking at AArch64 assembly specification and
filling the necessary options on gdbarch's stap machinery in order to
make the generic asm parser (implemented in stap-probe.c) recognize
AArch64's asm.

After my last patch for the SystemTap SDT API, which extends it in order
to accept multiple prefixes and suffixes, this patch became simpler.  I
also followed Marcus suggestion and did not shared code between 32- and
64-bit ARM.

Tom asked me in a previous message how I did my tests.  I believe I
replied that, but just in case: I ran the tests on
gdb.base/stap-probe.exp by hand.  I also managed to run the tests on
real hardware, and they pass without regressions.

2013-12-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR tdep/15653
	* NEWS: Mention SystemTap SDT probe support for AArch64 GNU/Linux.
	* aarch64-linux-tdep.c: Include necessary headers for parsing of
	SystemTap SDT probes.
	(aarch64_stap_is_single_operand): New function.
	(aarch64_stap_parse_special_token): Likewise.
	(aarch64_linux_init_abi): Declare SystemTap SDT probe argument
	prefixes and suffixes.  Initialize gdbarch with them.
2013-12-28 14:14:11 -02:00
Joel Brobecker 0809504b5e Fix gdb.Field attributes documentation for enum types.
The following patch ...

    | commit 14e75d8ea4
    | Date:   Wed Apr 18 06:46:47 2012 +0000
    |
    |     gdb/
    |         PR symtab/7259:
    | [...]

... discussed under ...

    [PATCH] Allow 64-bit enum values
    http://www.sourceware.org/ml/gdb-patches/2012-03/msg00772.html

... introduced a change in the gdb.Fields API without documenting it:

    | I took a separate approach from the one I took in:
    |
    | http://sourceware.org/ml/gdb-patches/2012-02/msg00403.html
    |
    | and removed the overloaded meaning of the bitpos location variable to
    | fix PR symtab/7259. In the following patch, I introduce a separate
    | field_location union member 'enumval' which can accept LONGEST and
    | hence expand enum values to 64-bit signed values. With this change,
    | bitpos now only is used for (non-negative) offsets into structures,
    | since the other overload of bitpos (range bounds) were already
    | separated into struct range_bound.

This patch updates the documentation to reflect that change.

gdb/doc/ChangeLog:

        * gdb.texinfo (Types In Python): Fix the documentation of
        attribute "bitpos" in class gdb.Field for enum types.  Add
        documentation for attribute "enumval" in that same class.
2013-12-28 07:19:07 +04:00
Joel Brobecker edef60002f Turn -list-feature @table into @ftable.
This is to make it easier to discover the various options displayed
by the -list-features command.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Support Commands): Change @table into
        @ftable.
2013-12-28 07:08:30 +04:00
Doug Evans 71b8c8455f Reorganize extension language auto-loading docs.
* gdb.texinfo (Auto-loading): Move menu up.  Move discussion of
	auto-loaded objfile scripts and .debug_gdb_scripts section to their
	corresponding section in Extending GDB.
	(Extending GDB): Move menu up.  New menu item "Auto-loading
	extensions".
	(Sequences): New menu item "Auto-loading sequences".
	(Auto-loading sequences): New node.
	(Python): Rename section from Scripting GDB to Extending GDB.
	(Python Auto-loading): Update xref, refer to "Auto-loading extensions".
	Move docs on ways to auto-load extensions to ...
	(Auto-loading extensions): ... here.  New node.
2013-12-23 21:01:17 -08:00
Sterling Augustine e617b0692b 2013-12-17 Sterling Augustine <saugustine@google.com>
* linespec.c (add_sal_to_sals): Use "<unknown>" when a symbol
	isn't found.
2013-12-23 15:14:39 -08:00
Sergio Durigan Junior 97c2dca091 Some cleanups on stap-probe.c
This patch does some basic cleanups on the SystemTap SDT probes API.  It
removes spurious newlines, brackets, reindents some code, and do
explicit checks for NULL, NUL, and 0 where applicable.

2013-12-23  Sergio Durigan JUnior  <sergiodj@redhat.com>

	* stap-probe.c (struct stap_probe) <args_parsed>: Add comment.
	(stap_is_generic_prefix): Delete extra brackets.  Reindent.
	(stap_parse_register_operand): Remove spurious newlines.  Simplify
	code to parse special token.
	(stap_parse_argument_conditionally): Add gdb_assert.
	(stap_parse_argument_1): Likewise.  Explicitly check for NULL and
	NUL.
	(stap_parse_probe_arguments): Likewise.
	(handle_stap_probe): Likewise.  Reindent code.
	(get_stap_base_address): Explicitly check for NULL.
	(stap_get_probes): Likewise.  Reindent code.
	(stap_relocate): Explicitly check for 0.
	(stap_gen_info_probes_table_values): Likewise.
2013-12-23 20:48:08 -02:00
Joel Brobecker d192b37306 Move GDB/MI commands related to support-query to their own @node.
A number of commands provide the capability to query the debugger
about support for various features, and one of them in particular
(-list-features), is expected to grow as new features get added.
-list-target-features should also grow a bit over time, but probably
slower.

These commands deserve their own section and @node.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI): Add "GDB/MI Support Commands" entry
        in menu.
        (GDB/MI Variable Objects): Adjust reference to "-list-features"
        command, now in a new node.
        (GDB/MI Support Commands): New node, with its contents being
        extracted from the "GDB/MI Miscellaneous Commands" node.
        A small paragraph introducing the section is also added at
        the start.
        (GDB/MI Miscellaneous Commands): Delete the description of the
        -info-gdb-mi-command, -list-features and -list-target-features
        commands, now hosted in the "GDB/MI Support Commands" node.
2013-12-23 04:58:02 +04:00
Chung-Lin Tang 21986715b1 2013-12-20 Chung-Lin Tang <cltang@codesourcery.com>
* nios2-linux-tdep.c (nios2_linux_sigreturn_init): Remove.
	(nios2_linux_sigreturn_tramp_frame): Remove.
	(nios2_linux_rt_sigreturn_tramp_frame): Update rt_sigreturn syscall
	number.
	(nios2_linux_syscall_next_pc): Likewise. Remove sigreturn case.
	(nios2_linux_init_abi): Remove registration of
	nios2_linux_sigreturn_tramp_frame.
2013-12-20 20:53:53 +08:00
H.J. Lu f9fda3f571 Mask out PREFIX_ADDR when adding prefix to opcode
PREFIX_ADDR isn't a prefix to opcode.  This patch masks out PREFIX_ADDR
when adding prefix to opcode.

	PR gdb/16305
	* i386-tdep.c (i386_process_record): Mask out PREFIX_ADDR when
	adding prefix to opcode.
2013-12-19 14:28:18 -08:00
H.J. Lu 1e87984a63 Properly decode MODRM byte for 64-bit
64-bit mode doesn't use 16-bit address.  We should always check SIB byte
for address in 64-bit mode.

	PR gdb/16304
	* i386-tdep.c (i386_record_lea_modrm_addr): Don't use 16-bit
	address in 64-bit mode.
2013-12-19 14:24:34 -08:00
H.J. Lu e85596e021 Zero-extend address from 32-bit to 64-bit for ADDR32 prefix
When there is ADDR32 prefix in 64-bit mode, we should zero-extend
address from 32-bit to 64-bit.

	PR gdb/16304
	* i386-tdep.c (i386_record_lea_modrm_addr): Zero-extend 32-bit
	address to 64-bit in 64-bit mode.
2013-12-19 14:22:30 -08:00
H.J. Lu 8ee5199a42 Add amd64_x32_linux_record_tdep and amd64_x32_sys
X32 Linux system calls are diffferent from amd64 Linux system calls in
system call numbers as well as parameter types/values.  This patch adds
amd64_x32_linux_record_tdep and amd64_x32_syscall for x32.

	PR gdb/16304
	* amd64-linux-tdep.c (amd64_canonicalize_syscall): Handle x32
	system calls.
	(amd64_x32_linux_record_tdep): New.
	(amd64_linux_syscall_record_common): New function.
	(amd64_linux_syscall_record): Call
	amd64_linux_syscall_record_common with amd64_linux_record_tdep.
	(amd64_x32_linux_syscall_record): Call
	amd64_linux_syscall_record_common with
	amd64_x32_linux_record_tdep.
	(amd64_linux_init_abi_common): Move amd64_linux_record_tdep
	initialization and tdep->i386_syscall_record setup to ...
	(amd64_linux_init_abi): Here.
	(amd64_x32_linux_init_abi): Initialize
	amd64_x32_linux_record_tdep.  Set tdep->i386_syscall_record to
	amd64_x32_linux_syscall_record.
	* amd64-linux-tdep.h (amd64_x32_syscall): New enum.
2013-12-19 14:17:48 -08:00
Sergio Durigan Junior 05c0465e16 Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments.  It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).

I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.

This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec).  And AArch64 will also need this, for the same
reason.

This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64).  No regressions were found.

2013-12-19  Sergio Durigan Junior  <sergiodj@redhat.com>

	* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
	argument prefixes and suffixes.  Initialize gdbarch with them.
	* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
	(stap_register_prefix, stap_register_suffix)
	(stap_register_indirection_prefix)
	(stap_register_indirection_suffix): Declare as "const char *const
	*" instead of "const char *".  Adjust printing function.  Rename
	all of the variables to the plural.
	(pstring_list): New function.
	* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
	argument prefixes and suffixes.  Initialize gdbarch with them.
	* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
	* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* stap-probe.c (stap_is_generic_prefix): New function.
	(stap_is_register_prefix): Likewise.
	(stap_is_register_indirection_prefix): Likewise.
	(stap_is_integer_prefix): Likewise.
	(stap_generic_check_suffix): Likewise.
	(stap_check_integer_suffix): Likewise.
	(stap_check_register_suffix): Likewise.
	(stap_check_register_indirection_suffix): Likewise.
	(stap_parse_register_operand): Remove unecessary declarations for
	variables holding prefix and suffix information.  Use the new
	functions listed above for checking for prefixes and suffixes.
	(stap_parse_single_operand): Likewise.
2013-12-19 18:53:40 -02:00
Gabriel Krisman Bertazi 4924df7977 Fix PR breakpoints/16297: catch syscall with syscall 0
Code rationale
==============
by: Gabriel Krisman Bertazi

This is a fix for bug 16297. The problem occurs when the user attempts
to catch any syscall 0 (such as syscall read on Linux/x86_64). GDB was
not able to catch the syscall and was missing the breakpoint.

Now, breakpoint_hit_catch_syscall returns immediately when it finds the
correct syscall number, avoiding a following check for the end of the
search vector, that returns a no hit if the syscall number was zero.

Testcase rationale
==================
by: Sergio Durigan Junior

This testcase is a little difficult to write.  By doing a quick
inspection at the Linux source, one can see that, in many targets, the
syscall number 0 is restart_syscall, which is forbidden to be called
from userspace.  Therefore, on many targets, there's just no way to test
this safely.

My decision was to take the simpler route and just adds the "read"
syscall on the default test.  Its number on x86_64 is zero, which is
"good enough" since many people here do their tests on x86_64 anyway and
it is a popular architecture.

However, there was another little gotcha.  When using "read" passing 0
as the third parameter (i.e., asking it to read 0 bytes), current libc
implementations could choose not to effectively call the syscall.
Therefore, the best solution was to create a temporary pipe, write 1
byte into it, and then read this byte from it.

gdb/ChangeLog
2013-12-19  Gabriel Krisman Bertazi  <gabriel@krisman.be>

	PR breakpoints/16297
	* breakpoint.c (breakpoint_hit_catch_syscall): Return immediately
	when expected syscall is hit.

gdb/testsuite/ChangeLog
2013-12-19  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR breakpoints/16297
	* gdb.base/catch-syscall.c (read_syscall, pipe_syscall)
	(write_syscall): New variables.
	(main): Create a pipe, write 1 byte in it, and read 1 byte from
	it.
	* gdb.base/catch-syscall.exp (all_syscalls): Include "pipe,
	"write" and "read" syscalls.
	(fill_all_syscalls_numbers): Improve the way to obtain syscalls
	numbers.
2013-12-19 17:01:49 -02:00
Tom Tromey 12e8c7d7c2 don't allocate serial_ops
Now that struct serial_ops is const everywhere, we can easily turn the
instances into globals.  This patch implements this idea.

On the one hand I think this is nicer since it makes a bit more data
readonly and slightly reduces allocations.  On the other hand it
reduces readability somewhat.

If the readability is a concern to anyone I was thinking I could write
a macro that conditionally uses GCC's designated initializer
extension.

Tested by rebuilding on x86-64 Fedora 18, both natively and using the
mingw cross tools.

2013-12-19  Tom Tromey  <tromey@redhat.com>

	* ser-unix.c (hardwire_ops): New global.
	(_initialize_ser_hardwire): Use it.
	* ser-tcp.c (tcp_ops): New global.
	(_initialize_ser_tcp): Use it.
	* ser-pipe.c (pipe_ops): New global.
	(_initialize_ser_pipe): Use it.
	* ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): New
	globals.
	(_initialize_ser_windows): Use them.
2013-12-19 08:50:48 -07:00
Tom Tromey fcd488ca4e make serial_ops const
I noticed that the serial_ops vtable is not const, but really it ought
to be.

This patch constifies it, removing the only mutable field in the
process.

Tested by rebuilding on x86-64 Fedora 18, both natively and using the
mingw cross tools.

2013-12-19  Tom Tromey  <tromey@redhat.com>

	* serial.c (serial_ops_p): New typedef.
	(serial_ops_list): Now a VEC.
	(serial_interface_lookup): Return const.  Use VEC_iterate.
	(serial_add_interface): Make parameter const.
	(serial_open): Update.
	(serial_fdopen_ops): Make 'ops' const.
	(serial_pipe): Update.
	* ser-tcp.c (_initialize_ser_tcp): Update.
	* ser-pipe.c (_initialize_ser_pipe): Update.
	* ser-unix.c (_initialize_ser_hardwire): Update.
	* ser-mingw.c (_initialize_ser_windows): Update.
	* ser-go32.c (dos_ops): Now const.  Update.
	* serial.h (struct serial) <ops>: Now const.
	(struct serial_ops) <next>: Remove.
	(serial_add_interface): Make parameter const.
2013-12-19 08:50:46 -07:00
Keven Boell 530e8392d7 fortran: enable ptype/whatis for modules.
Added new domain MODULE_DOMAIN for fortran modules to avoid
issues with sharing namespaces (e.g. when a variable currently
in scope has the same name as a module).

	(gdb) ptype modname
	old> No symbol "modname" in current context.
	new> type = module modname

This fixes PR 15209 and also addresses the issue
with sharing namespaces:
https://sourceware.org/ml/gdb-patches/2013-02/msg00643.html

2013-11-19  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* cp-namespace.c (cp_lookup_nested_symbol): Enable
	nested lookups for fortran modules.
	* dwarf2read.c (read_module): Add fortran module to
	the symbol table.
	(add_partial_symbol, add_partial_module): Add fortran
	module to the partial symbol table.
	(new_symbol_full): Create full symbol for fortran module.
	* f-exp.y (yylex): Add new module domain to be parsed.
	* symtab.h: New domain for fortran modules.

testsuite/

	* gdb.fortran/module.exp: Completion matches fortran module
	names as well. ptype/whatis on modules return a proper type.
	Add new check for having the correct scope.
2013-12-19 13:18:21 +01:00
Keven Boell 7f9b20bb35 fortran: enable ptype/whatis for user defined types.
(gdb) ptype type
	old> No symbol "type" in current context.
	new> type = Type type
	     integer(kind=4) :: t_i
	     End Type type

2013-11-19  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* f-exp.y (yylex): Add domain array to enable lookup
	in multiple domains. Loop over lookup domains and try
	to find requested symbol. Add STRUCT_DOMAIN to lookup
	domains to be able to query for user defined types.

testsuite/
	* gdb.fortran/type.f90: New file.
	* gdb.fortran/whatis_type.f90: New file.
2013-12-19 13:18:11 +01:00
Sergio Durigan Junior 2e0d821f2d Improve and fix catch-syscall.exp
While fixing another bug, I found that the current
gdb.base/catch-syscall.exp is kind of messy, could use some
improvements, and is not correctly testing some things.

I've made the following patch to address all the issues I found.  On the
organization side, it does a cleanup and removes unecessary imports of
gdb_prompt, uses prepare_for_testing and clean_restart where needed, and
fixes some comments.  The testcase was also not correctly testing
catching syscalls using only numbers, or catching many syscalls at
once.  I fixed that.

The patch also uses a new method for obtaining the syscalls numbers: it
relies on the C source file to get them, via <sys/syscall.h> and SYS_*
macros.  This makes the .exp file simpler because there is no need to
include target conditionals there.

I tested this on x86_64 Fedora 18.

gdb/testsuite/ChangeLog:
2013-12-18  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/catch-syscall.c: Include <sys/syscall.h>.
	(close_syscall, chroot_syscall, exit_group_syscall): New
	variables.
	* gdb.base/catch-syscall.exp: Replace gdb_compile by
	prepare_for_testing.  Call fill_all_syscalls_numbers before
	starting.  Replace gdb_exit, gdb_start, gdb_reinitialize_dir and
	gdb_load by clean_restart.
	(check_info_bp_any_syscall, check_info_bp_specific_syscall)
	(check_info_bp_many_syscalls): Remove global gdb_prompt.
	(check_call_to_syscall): Likewise.  Add global decimal.  Improve
	testing regex.
	(check_return_from_syscall): Likewise.
	(check_continue, insert_catch_syscall_with_arg): Remove global
	gdb_prompt.
	(insert_catch_syscall_with_many_args): Likewise.  Add global
	decimal.  Fix $filter_str.  Improve testing regex.
	(check_for_program_end): Remove global gdb_prompt.
	(test_catch_syscall_without_args): Likewise.  Add global decimal.
	Improve testing regex.
	(test_catch_syscall_with_args, test_catch_syscall_with_many_args)
	(test_catch_syscall_with_wrong_args)
	(test_catch_syscall_restarting_inferior)
	(test_catch_syscall_fail_nodatadir): Remove global gdb_prompt.
	(do_syscall_tests): Likewise.  Remove global srcdir.
	(test_catch_syscall_without_args_noxml): Remove global gdb_prompt.
	Add global last_syscall_number.  Test for the exact syscall number
	to be caught.
	(test_catch_syscall_with_args_noxml): Remove global gdb_prompt.
	Add global all_syscalls_numbers.  Test each syscall number to be
	caught, instead of only testing "close".
	(test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt.
	(do_syscall_tests_without_xml): Likewise.  Remove global srcdir.
	Remove stale comment.
	(fill_all_syscalls_numbers): Add global last_syscall_number.  Fill
	the correct syscall numbers using information from the inferior.
2013-12-18 20:19:01 -02:00
Yufeng Zhang f45c82da38 gdb/
* aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Set
	iov.iov_len with the real length in use.

gdb/gdbserver/

	* linux-aarch64-low.c (aarch64_linux_set_debug_regs): Set
	iov.iov_len with the real length in use.
2013-12-18 16:47:33 +00:00
Yao Qi 4ac248ca0b Add target_xfer_partial_ftype
This patch adds a typedef target_xfer_partial_ftype.  When we change
the signature of xfer_partial functions (for example, adding a new
parameter), we don't have to modify all of their declarations.

This patch also updates the type of parameters of target_xfer_partial
from "void *" to "gdb_byte *".

gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

	* target.h (target_xfer_partial_ftype): New typedef.
	(target_xfer_partial): Update declaration.
	* auxv.h (memory_xfer_auxv): Likewise.
	* ia64-hpux-nat.c (super_xfer_partial): Likewise.
	* ia64-linux-nat.c (super_xfer_partial): Likewise.
	* linux-nat.c (super_xfer_partial): Likewise.
	* procfs.c (procfs_xfer_partial): Likewise.
	* record-full.c (record_full_beneath_to_xfer_partial):
	(tmp_to_xfer_partial): Likewise.
	* sparc-nat.c (inf_ptrace_xfer_partial): Likewise.
	* target.c (default_xfer_partial): Likewise.
	(current_xfer_partial): Likewise.
	(target_xfer_partial): Change parameter type to 'gdb_byte *'.
2013-12-18 11:47:03 +08:00
Yao Qi cde33bf103 Replace sprintf with xsnprintf
gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

	* linux-nat.c (linux_proc_xfer_partial): Call xsnprintf instead
	of sprintf.
	(linux_nat_detach, linux_child_pid_to_exec_file): Likewise.
	(linux_proc_pending_signals): Likewise.
2013-12-18 11:46:56 +08:00
Yao Qi 230de03ab4 Fix the format of one ChangeLog entry
I notice that two lines of a recent changelog entry are not prefixed
with tab.  They are prefixed with a space and a tab.  This patch
is to remove the space.

gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

	* ChangeLog: Fix the format of one entry.
2013-12-18 11:30:54 +08:00
Joel Brobecker 64c46ce4ac ARI fix in value.c::value_entirely_unavailable
gdb/ChangeLog:

        * value.c (value_entirely_unavailable): ARI fix: Move trailing
        binary operator to the next line.  No actual code change.
2013-12-18 06:45:49 +04:00
Pedro Alves 5ce0145de7 "tfind" across unavailable-stack frames.
Like when stepping, the current stack frame location is expected to be
printed as result of tfind command, if that results in moving to a
different function.  In tfind_1 we see:

  if (from_tty
      && (has_stack_frames () || traceframe_number >= 0))
    {
      enum print_what print_what;

      /* NOTE: in imitation of the step command, try to determine
         whether we have made a transition from one function to
         another.  If so, we'll print the "stack frame" (ie. the new
         function and it's arguments) -- otherwise we'll just show the
         new source line.  */

      if (frame_id_eq (old_frame_id,
                       get_frame_id (get_current_frame ())))
        print_what = SRC_LINE;
      else
        print_what = SRC_AND_LOC;

      print_stack_frame (get_selected_frame (NULL), 1, print_what, 1);
      do_displays ();
    }

However, when we haven't collected any registers in the tracepoint
(collect $regs), that doesn't actually work:

 (gdb) tstart
 (gdb) info tracepoints
 Num     Type           Disp Enb Address    What
 1       tracepoint     keep y   0x080483b7 in func0
                                            at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28
         collect testload
     installed on target
 2       tracepoint     keep y   0x080483bc in func1
                                            at ../.././../git/gdb/testsuite/gdb.trace/circ.c:32
         collect testload
     installed on target
 (gdb) c
 Continuing.

 Breakpoint 3, end () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:72
 72    }
 (gdb) tstop
 (gdb) tfind start
 Found trace frame 0, tracepoint 1
 #0  func0 () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28
 28    }
 (gdb) tfind
 Found trace frame 1, tracepoint 2
 32    }
 (gdb)

When we don't have info about the stack available
(UNWIND_UNAVAILABLE), frames end up with outer_frame_id as frame ID.
And in the scenario above, the issue is that both frames before and
after the second tfind (the frames for func0 an func1) have the same
id (outer_frame_id), so the frame_id_eq check returns false, even
though the frames were of different functions.  GDB knows that,
because the PC is inferred from the tracepoint's address, even if no
registers were collected.

To fix this, this patch adds support for frame ids with a valid code
address, but <unavailable> stack address, and then makes the unwinders
use that instead of the catch-all outer_frame_id for such frames.  The
frame_id_eq check in tfind_1 then automatically does the right thing
as expected.

I tested with --directory=gdb.trace/ , before/after the patch, and
compared the resulting gdb.logs, then adjusted the tests to expect the
extra output that came out.  Turns out that was only circ.exp, the
original test that actually brought this issue to light.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-12-17  Pedro Alves  <palves@redhat.com>

	* frame.h (enum frame_id_stack_status): New enum.
	(struct frame_id) <stack_addr>: Adjust comment.
	<stack_addr_p>: Delete field, replaced with ...
	<stack_status>: ... this new field.
	(frame_id_build_unavailable_stack): Declare.
	* frame.c (frame_addr_hash, fprint_field, outer_frame_id)
	(frame_id_build_special): Adjust.
	(frame_id_build_unavailable_stack): New function.
	(frame_id_build, frame_id_build_wild): Adjust.
	(frame_id_p, frame_id_eq, frame_id_inner): Adjust to take into
	account frames with unavailable stack.

	* amd64-tdep.c (amd64_frame_this_id)
	(amd64_sigtramp_frame_this_id, amd64_epilogue_frame_this_id): Use
	frame_id_build_unavailable_stack.
	* dwarf2-frame.c (dwarf2_frame_this_id): Likewise.
	* i386-tdep.c (i386_frame_this_id, i386_epilogue_frame_this_id)
	(i386_sigtramp_frame_this_id):  Likewise.

gdb/testsuite/
2013-12-17  Pedro Alves  <palves@redhat.com>

	* gdb.trace/circ.exp: Expect frame info to be printed when
	switching between frames with unavailable stack, but different
	functions.
2013-12-17 20:47:36 +00:00
Andrew Burgess bdf2220615 Convert the unavailable vector to be bit, not byte, based.
https://sourceware.org/ml/gdb-patches/2013-12/msg00144.html

The vector of unavailable parts of a value is currently byte based.  Given
that we can model a value down to the bit level, we can potentially loose
information with the current implementation.  After this patch we model the
unavailable information in bits.

gdb/ChangeLog

	* dwarf2loc.c (read_pieced_value): Mark bits, not bytes
	unavailable, use correct bit length.
	* value.c (struct value): Extend comment on unavailable to
	indicate that it is bit based.
	(value_bits_available): New function.
	(value_bytes_available): Call value_bits_available.
	(value_entirely_available): Check against the bit length, not byte
	length.
	(mark_value_bits_unavailable): New function.
	(mark_value_bytes_unavailable): Move contents to
	mark_value_bits_unavailable, call to same.
	(memcmp_with_bit_offsets): New function.
	(value_available_contents_bits_eq): New function, takes the
	functionality from value_available_contents_eq but uses
	memcmp_with_bit_offsets now, and is bit not byte based.
	(value_available_contents_eq): Move implementation into
	value_available_contents_bits_eq, call to same.
	(value_contents_copy_raw): Work on bits, not bytes.
	(unpack_value_bits_as_long_1): Check availability in bits, not
	bytes.
	* value.h (value_bits_available): Declare new function.
	(mark_value_bits_unavailable): Declare new function.

gdb/testsuite/ChangeLog

	* gdb.trace/unavailable-dwarf-piece.c: New file.
	* gdb.trace/unavailable-dwarf-piece.exp: New file.
2013-12-17 17:24:15 +00:00
Pierre Muller 774f74c220 Fix compilation error for cygwin native build.
* windows-nat.c (windows_ensure_ntdll_loaded) [__USEWIDE]:
        Call wcstombs.
2013-12-16 23:44:43 +01:00
Pedro Alves 9a362b9a32 PR 16329: remote debugging broken on Solaris.
Like on GNU/Linux (linux-thread-db.c), the Solaris solaris-threads
target (handles libthread_db.so) shouldn't be pushed when remote
debugging.

This uses the same predicate used by linux-thread-db.c.

gdb/
2013-12-16  Pedro Alves  <palves@redhat.com>

	PR 16329
	* sol-thread.c (check_for_thread_db): If the target can't run or
	isn't a core, return without pushing.
2013-12-16 14:04:52 +00:00
Joel Brobecker b030cf11d6 Revert "Do not overwrite so_list's so_name in solib_map_sections"
This reverts commit 07293be448, as it
causes an unintended change of behavior with GDB/MI's =library-loaded
events: The host-name="<path>" part of the event is now showing the
target-side path instead of the host-side path.

This revert affects Darwin and AIX systems, however, where the BFD
is either artificial or icomplete, leading to the outputt of
"info shared" not containing the information we'd like. For instance,
on Darwin, we would see:

    (top-gdb) info shared
    From                To                  Syms Read   Shared Object Library
    0x00007fff8d060de4  0x00007fff8d09ce1f  Yes (*)     i386:x86-64
    0x00007fff8af08b10  0x00007fff8b1c6f73  Yes (*)     i386:x86-64

To compensate for that, we overwrite the filename of the associated bfd.

gdb/ChangeLog:

	Revert the following commit:
	* solib.c (solib_map_sections): Remove code overwriting
	SO->SO_NAME with the bfd's filename.

	Make the following changes required after the revert above:
	* solib-aix.c (solib_aix_bfd_open): Set the filename of the
	returned bfd to a copy of the synthetic pathname.
	* solib-darwin.c (darwin_bfd_open): Set the filename of the
	returned bfd to a copy of PATHNAME.
2013-12-15 10:59:18 +01:00
Yao Qi 07d100d43e Perf test case: skip-prologue
This patch add a perf test case on skip-prologue by inserting
breakpoints on two functions many times, in order to exercise
skip-prologue.

gdb/testsuite:

2013-12-15  Yao Qi  <yao@codesourcery.com>

	* gdb.perf/skip-prologue.c: New.
	* gdb.perf/skip-prologue.exp: New.
	* gdb.perf/skip-prologue.py: New.
2013-12-15 16:16:10 +08:00
Joel Brobecker 379a5e2d36 nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing
This is the gdbserver-equivalent of the change made in GDB to handle
the case, in x64 windows version 2012, where the kernel produces
a LOAD_DLL_DEBUG_EVENT where the name of the associated DLL cannot
be determined at that time, and thus has to be processed later.

The visible symptom is that ntdll.dll is missing from the list of
shared libraries known to be mapped by the inferior, with other
side-effects such as failure to unwind through code provided by
that DLL (such as exception handling routines).

gdb/gdbserver/ChangeLog:

	* Makefile.in (safe-ctype.o, lbasename.o): New rules.
	* configure.srv: Add safe-ctype.o and lbasename.o to srv_tgtobj
	for all targets that use win32-low.c.
	* win32-low.c (win32_ensure_ntdll_loaded): New function.
	(do_initial_child_stuff): Add call to win32_ensure_ntdll_loaded.
2013-12-13 16:42:54 +01:00
Pedro Alves 4210d83ee6 Do the target-waiting within do_initial_child_stuff on Windows.
This is a preparatory patch that achieves two goals:

  . Makes the initial event handling more similar to GDB's;
  . Opens the door for implementing post-inititial-handling
    operations.

At the moment, this is only done on Windows, where the
post-initial-handling is going to be needed (in the context of
Windows 2012). And because we're close to creating the gdb 7.7
branch, making that change for all platforms is a little more
risk that we'd like. So the change is currently implemented
on Windows.

gdb/gdbserver/ChangeLog:

        * target.c (mywait): Set OURSTATUS->KIND to TARGET_WAITKIND_STOPPED
        if equal to TARGET_WAITKIND_LOADED.
        * win32-low.c (cached_status): New static global.
        (win32_wait): Add declaration.
        (do_initial_child_stuff): Flush all initial pending debug events
        up to the initial breakpoint.
        (win32_wait): If CACHED_STATUS was set, return that instead
        of doing a real wait.  Remove the code resuming the execution
        of the inferior after receiving a TARGET_WAITKIND_LOADED event
        during the initial phase.  Also remove the code changing
        OURSTATUS->KIND from TARGET_WAITKIND_LOADED to
        TARGET_WAITKIND_STOPPED.
2013-12-13 16:42:08 +01:00
Joel Brobecker 8a48ac9579 wrong dimension found in ada-lang.c:ada_array_bound_from_type
This function has the following code:

  elt_type = type;
  for (i = n; i > 1; i--)
    elt_type = TYPE_TARGET_TYPE (type);

For multi-dimension arrays, the code above tries to find the array
type corresponding to the dimension we're trying to inspect.
The problem is that, past the second dimension, the loop does
nothing other than repeat the first iteration. There is a little
thinko where it got the TYPE_TARGET_TYPE of TYPE instead of ELT_TYPE!

To my surprise, I was unable to produce an Ada exemple that demonstrated
the problem.  That's because the examples I created all trigger a parallel
___XA type which we then use in place of the ELT_TYPE in order to
determine the bounds - see the code that immediately follows our
loop above:

    index_type_desc = ada_find_parallel_type (type, "___XA");
    ada_fixup_array_indexes_type (index_type_desc);
    if (index_type_desc != NULL)
    [...]

So, in order to avoid depending on an Ada example where the compiler
can potentially decide one way or the other, I decided to use an
artificial example, written in C. With ...

  int multi[1][2][3];

... forcing the language to Ada, and trying to print the 'last,
we get:

    (gdb) p multi'last(1)
    $1 = 0
    (gdb) p multi'last(2)
    $2 = 1
    (gdb) p multi'last(3)
    $3 = 1   <<<---  This should be 2!

Additionally, I noticed that a couple of check_typedef's were missing.
This patch adds them. And since the variable in question only gets
used within an "else" block, I moved the variable declaration and
use inside that block - making it clear what the scope of the variable
is.

gdb/ChangeLog:

        * ada-lang.c (ada_array_bound_from_type): Move the declaration
        and assignment of variable "elt_type" inside the else block
        where it is used.  Add two missing check_typedef calls.
        Fix bug where we got TYPE's TYPE_TARGET_TYPE, where in fact
        we really wanted to get ELT_TYPE's TYPE_TARGET_TYPE.

gdb/testsuite/ChangeLog:

        * gdb.ada/arraydim: New testcase.
2013-12-13 09:55:24 +01:00
Joel Brobecker fb5e3d5c69 Small style violation fix in ada_array_bound_from_type
gdb/ChangeLog:

        * ada-lang.c (ada_array_bound_from_type): Remove unwanted space
        between 'struct type *' and 'arr_type'.
2013-12-13 09:48:35 +01:00
Siva Chandra a16b0e220d 2013-12-12 Siva Chandra Reddy <sivachandra@google.com>
PR python/16113
	* NEWS (Python Scripting): Add entry for the new feature and the
	new attribute of gdb.Field objects.
	* python/py-type.c (gdbpy_is_field): New function
	(convert_field): Add 'parent_type' attribute to gdb.Field
	objects.
	* python/py-value.c (valpy_getitem): Allow subscript value to be
	a gdb.Field object.
	(value_has_field): New function
	(get_field_flag): New function
	* python/python-internal.h (gdbpy_is_field): Add declaration.

	testsuite/
	* gdb.python/py-value-cc.cc: Improve test case.
	* gdb.python/py-value-cc.exp: Add new tests to test usage of
	gdb.Field objects as subscripts on gdb.Value objects.

	doc/
	* gdb.texinfo (Values From Inferior): Add a note about using
	gdb.Field objects as subscripts on gdb.Value objects.
	(Types In Python): Add description about the new attribute
	"parent_type" of gdb.Field objects.
2013-12-12 15:21:53 -08:00
Joel Brobecker 9b26f0fbe4 Add @cindex for section documenting the -list-features GDB/MI command.
gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Add @cindex
        entry for section docuumenting the -list-features GDB/MI command.
2013-12-12 16:54:48 +01:00
Pedro Alves b15e5c540f breakpoint.c:insert_bp_location: Constify local.
gdb/
2013-12-12  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (insert_bp_location): Make 'hw_bp_err_string' local
	const, and remove casts.
2013-12-12 10:44:42 +00:00
Pedro Alves f23981e991 Eliminate UNSUPPORTED_ERROR.
I have a case that could use an exception for "unsupported feature".
I found UNSUPPORTED_ERROR, but looking deeper, I think as is, reusing
it for other things would be fragile.  E.g., if the Python script
sourced by source_script_from_stream triggers any other missing
functionality that would result in UNSUPPORTED_ERROR being propagated
out to source_script_from_stream, that would confuse the error for
Python not being built into GDB.

This patch thus redoes things a little.  Instead of using an exception
for the "No Python" scenario, check whether Python is configured in
before actually trying to source the file.  It adds a new function
instead of using #ifdef HAVE_PYTHON directly, as that is better at
avoiding bitrot, as both Python and !Python paths are visible to the
compiler this way.

Tested on Fedora 17, with and without Python.

gdb/
2013-12-12  Pedro Alves  <palves@redhat.com>

	* cli/cli-cmds.c (source_script_from_stream) Use have_python
	instead of catching UNSUPPORTED_ERROR.
	* exceptions.h (UNSUPPORTED_ERROR): Delete.
	* python/python.c (source_python_script) [!HAVE_PYTHON]: Internal
	error if called.
	* python/python.h (have_python): New static inline function.
2013-12-12 10:15:48 +00:00
Doug Evans 43942612f4 * dwarf2read.c (lookup_dwo_cutu): Include name of dwp file in
"can't find DWO" warning.
2013-12-11 15:52:12 -08:00
Sergio Durigan Junior 08a6411c71 Sanitize access to gdbarch on the SDT probe API (and fix ARM bug)
This patch sanitizes the access to gdbarch made by various functions of
the SDT probe API.  Before this patch, gdbarch was being accessed via
the probe's objfile; however, this proved to cause a bug on 32-bit ARM
targets because during the parsing of the probe's arguments the code
needed to access some pseudo-registers of the architecture, and this
information is not fully correct on the objfile's gdbarch.

Basically, the approach taken was to instead pass the current/selected
frame to the parsing and evaluation functions, so that they can extract
the gdbarch directly from the frame.  It solved the ARM bug reported
above, and also contributed to make the API cleaner.

Tested on x86_64 and 32-bit ARM.

2013-12-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Pass selected frame
	to get_probe_argument_count and evaluate_probe_argument.
	* probe.c (get_probe_argument_count): Adjust declaration to accept
	frame.  Pass frame to probe_ops's get_probe_argument_count.
	(evaluate_probe_argument): Likewise, for evaluate_probe_argument.
	(probe_safe_evaluate_at_pc): Pass frame to
	get_probe_argument_count and evaluate_probe_argument.
	* probe.h (struct probe_ops) <get_probe_argument_count,
	evaluate_probe_argument>: Adjust declarations to accept frame.
	(get_probe_argument_count, evaluate_probe_argument): Likewise.
	* solib-svr4.c (solib_event_probe_action): Get current frame.
	Pass it to get_probe_argument_count.
	(svr4_handle_solib_event): Get current frame.  Pass it to
	get_probe_argument_count and evaluate_probe_argument.
	* stap-probe.c (stap_parse_probe_arguments): Adjust declaration to
	accept gdbarch.  Do not obtain it from the probe's objfile.
	(stap_get_probe_argument_count): Adjust declaration to accept
	frame.  Obtain gdbarch from the frame.  Call generic
	can_evaluate_probe_arguments.  Pass gdbarch to
	stap_parse_probe_arguments.
	(stap_get_arg): Adjust declaration to accept gdbarch.  Pass it to
	stap_parse_probe_arguments.
	(stap_evaluate_probe_argument): Adjust declaration to accept
	frame.  Obtain gdbarch from the frame.  Pass gdbarch to
	stap_get_arg.
	(stap_compile_to_ax): Pass agent_expr's gdbarch to stap_get_arg.
	(compute_probe_arg): Obtain gdbarch from frame.  Pass frame to
	get_probe_argument_count and evaluate_probe_argument.
2013-12-10 23:59:00 -02:00
Yao Qi e7f0d979dd Fix a bug in matching notifications.
Due to copy-n-paste, the problem caused PR remote/15974 also exists
in gdbserver.  This patch fixes it in the same way.  Patch to fix
remote/15974 can be found:

  https://sourceware.org/ml/gdb-patches/2013-12/msg00014.html

gdb/gdbserver:

2013-12-11  Yao Qi  <yao@codesourcery.com>

	* notif.c (handle_notif_ack): Return 0 if no notification
	matches.
2013-12-11 09:38:58 +08:00
Doug Evans 7b3fd68b73 add missing PR# to previous entry 2013-12-10 16:21:41 -08:00
Doug Evans 0987cf3512 PR 16286
* c-lang.c (c_get_string): Ignore the declared size of the object
	if a specific length is requested.

	testsuite/
	* gdb.python/py-value.c: #include stdlib.h, string.h.
	(str): New struct.
	(main): New local xstr.
	* gdb.python/py-value.exp (test_value_in_inferior): Add test to
	fetch a value as a string with a length beyond the declared length
	of the array.
2013-12-10 16:20:08 -08:00
Doug Evans 34dc884e17 Delete interp_exec_p.
* interps.h (interp_exec_p): Delete.
    	* interps.c (interp_exec_p): Delete.
    	(interp_exec): Update.  Assert interp->procs->exec_proc != NULL.
    	* mi/mi-interp.c (mi_cmd_interpreter_exec): Update.
2013-12-10 16:06:53 -08:00
Andrew Burgess 409d8f4815 Add call to get_compiler_info to gdb_compile_shlib.
https://sourceware.org/ml/gdb-patches/2013-12/msg00374.html

gdb/testsuite/ChangeLog

	* lib/gdb.exp (gdb_compile_shlib): Add call to get_compiler_info,
	update comment.
2013-12-10 17:04:17 +00:00
Yao Qi bae8a07ab1 Use target_read_code in skip_prologue (amd64)
gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* amd64-tdep.c (amd64_analyze_stack_align): Call
	target_read_code instead of target_read_memory.
	(amd64_analyze_prologue): Call read_code_unsigned_integer
	instead of read_memory_unsigned_integer.  Call read_code
	instead of read_memory.
	(amd64_skip_xmm_prologue): Likewise.
2013-12-10 20:27:56 +08:00
Yao Qi 0865b04a4d Use target_read_code in skip_prologue (i386)
GDB is able to cache memory accesses requested in target_read_code,
so target_read_code is more efficient than general target_read_memory.

This patch uses target_read_code and its variants to read target
memory in the functions related to i386_skip_prologue.  It improves
the performance when doing 'b foo' (foo is a function) in remote
debugging.

Nowadays, when we set a breakpoint on function f1, GDB will fetch the
code in f1 to determine the start of the function body (say skip the
prologue), it requests read from target many times.  With this patch
applied, the number of RSP 'm' packets are reduced.

gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* corefile.c (read_code): New function.
	(read_code_integer): New function.
	(read_code_unsigned_integer): New function.
	* gdbcore.h (read_code): Declare.
	(read_code_integer): Declare.
	(read_code_unsigned_integer): Declare.
	* i386-tdep.c (i386_follow_jump): Call target_read_code instead
	of target_read_memory.  Call read_code_unsigned_integer instead
	of read_memory_unsigned_integer.
	(i386_analyze_struct_return): Likewise.
	(i386_skip_probe): Likewise.
	(i386_analyze_stack_align): Likewise.
	(i386_match_pattern): Likewise.
	(i386_skip_noop): Likewise.
	(i386_analyze_frame_setup): Likewise.
	(i386_analyze_register_saves): Likewise.
	(i386_skip_prologue): Likewise.
	(i386_skip_main_prologue): Likewise.
	(i386_frame_cache_1): Likewise.
2013-12-10 20:27:49 +08:00
Yao Qi f15cb84a84 Invalidate target cache before starting to handle event.
gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* infrun.c: Include "target-dcache.h".
	(prepare_for_detach): Call target_dcache_invalidate.
	(wait_for_inferior): Likewise.
	(fetch_inferior_event): Likewise.
	(infrun_thread_stop_requested_callback): Likewise.  Set
	overlay_cache_invalid to 1.
2013-12-10 19:57:20 +08:00
Joel Brobecker 036e93dfda Set language for Ada minimal symbols.
This helps with the following issue: Given an Ada program defining
a global variable:

    package Pck is
       Watch : Integer := 1974;
    end Pck;

When printing the address of this variable, GDB also tries to print
the associated symbol name:

    (gdb) p watch'address
    $1 = (access integer) 0x6139d8 <pck__watch>
                                       ^^
                                       ||

The problem is that GDB prints the variable's linkage name, instead
of its natural name. This is because the language of the associated
minimal symbol never really gets set.

This patch adds handling for Ada symbols in symbol_find_demangled_name.
After this patch, we now get:

    (gdb) p watch'address
    $1 = (access integer) 0x6139d8 <pck.watch>
                                       ^
                                       |

gdb/ChangeLog:

        * symtab.c (symbol_find_demangled_name): Add handling of
        Ada symbols.

gdb/testsuite/ChangeLog:

        * gdb.ada/int_deref.exp: Add test verifying that we print
        the decoded symbol name when printing the address of Ada
        symbols.
2013-12-10 12:16:47 +01:00
Joel Brobecker 72bfa06c56 GDB/MI: Document support for -exec-run --start in -list-features
This adds "exec-run-start-option" in the output of the -list-features
commands, allowing front-ends to easily determine whether -exec-run
supports the --start option.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): add "exec-run-start-option".
        * NEWS: Expand the entry documenting the new -exec-run --start
        option to mention the corresponding new entry in the output of
        "-list-features".

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new
	"exec-run-start-option" entry in the output of the "-list-features"
	command.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-start.exp: Add test verifying that -list-features
        contains "exec-run-start-option".
2013-12-10 12:12:14 +01:00
Joel Brobecker 94481b8c8f nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing
We observed on Windows 2012 that we were unable to unwind past
exception handlers. For instance, with any Ada program raising
an exception that does not get handled:

    % gnatmake -g a -bargs -shared
    % gdb a
    (gdb) start
    (gdb) catch exception unhandled
    Catchpoint 2: unhandled Ada exceptions
    (gdb) c
    Catchpoint 2, unhandled CONSTRAINT_ERROR at <__gnat_unhandled_exception> (
        e=0x645ff820 <constraint_error>) at s-excdeb.adb:53
    53      s-excdeb.adb: No such file or directory.

At this point, we can already see that something went wrong, since
the frame selected by the debugger corresponds to a runtime function
rather than the function in the user code that caused the exception
to be raised (in our case procedure A).

This is further confirmed by the fact that we are unable to unwind
all the way to procedure A:

    (gdb) bt
    #0  <__gnat_unhandled_exception> (e=0x645ff820 <constraint_error>)
        at s-excdeb.adb:53
    #1  0x000000006444e9a3 in <__gnat_notify_unhandled_exception> (excep=0x284d2
+0)
        at a-exextr.adb:144
    #2  0x00000000645f106a in __gnat_personality_imp ()
       from C:\[...]\libgnat-7.3.dll
    #3  0x000000006144d1b7 in _GCC_specific_handler (ms_exc=0x242fab0,
        this_frame=0x242fe60, ms_orig_context=0x242f5c0, ms_disp=0x242ef70,
        gcc_per=0x645f0960 <__gnat_personality_imp>)
        at ../../../src/libgcc/unwind-seh.c:289
    #4  0x00000000645f1211 in __gnat_personality_seh0 ()
       from C:\[...]\libgnat-7.3.dll
    #5  0x000007fad3879f4d in ?? ()
    Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that the unwinder has been doing its job flawlessly
up until frame #5. The address in frame #5 is correct, but GDB
is not able to associate it with any symbol or unwind record.

And this is because this address is inside ntdll.dll, and when
we received the LOAD_DLL_DEBUG_EVENT for that DLL, the system
was not able to tell us the name of the library, thus causing us
to silently ignoring the event. Because GDB does not know about
ntdll.dll, it is unable to access the unwind information from it.
And because the function at that address does not use a frame
pointer, the unwinding becomes impossible.

This patch helps recovering ntdll.dll at the end of the "run/attach"
phase, simply by trying to locate that specific DLL again.

In terms of our medium to long term planning, it seems to me that
we should be able to simplify the code by ignoring LOAD_DLL_DEBUG_EVENT
during the startup phase, and modify windows_ensure_ntdll_loaded
to then detect and report all shared libraries after we've finished
inferior creation.  But for a change just before 7.7 branch creation,
I thought it was safest to just handle ntdll.dll specifically. This
is less intrusive, and ntdll is the only DLL affected by the problem
I know so far.

gdb/ChangeLog:

	* windows-nat.c (handle_load_dll): Add comments.
        (windows_ensure_ntdll_loaded): New function.
	(do_initial_windows_stuff): Use windows_ensure_ntdll_loaded.
        Add FIXME comment.
2013-12-10 11:02:56 +01:00
Joel Brobecker ebeec1e942 Fix gdb/ChangeLog date in last entry. 2013-12-08 12:28:10 +04:00
Yao Qi 11ec596510 Use gdb_produce_source
We added a new proc gdb_produce_source recently, and it can be used
more widely in lib/gdb.exp to generate source file.

gdb/testsuite:

2013-12-08  Yao Qi  <yao@codesourcery.com>

	* lib/gdb.exp (support_complex_tests): Use gdb_produce_source.
	(is_elf_target, is_ilp32_target, is_ilp64_target): Likewise.
	(is_64_target, is_amd64_regs_target): Likewise.
	(skip_altivec_tests, skip_vsx_tests, skip_btrace_tests): Likewise.
2013-12-08 15:20:18 +08:00
Joel Brobecker 0c2242c192 Document the GDB 7.6.2 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 7.6.2 released.
2013-12-08 08:40:37 +04:00
Yao Qi e5e6f788e4 Avoid "may be used uninitialized" warning
Hi,
I see such warning below on one compiler I am using.

cc1: warnings being treated as errors
../../workspace/gdb/stack.c: In function 'frame_info':
../../workspace/gdb/stack.c:1519:20: error: 'caller_pc' may be used uninitialized in this function

Go through the gdb-patches archives and find the "canonical" way to
fix this warning is to initialize the variable.

gdb:

2013-12-08  Yao Qi  <yao@codesourcery.com>

	* stack.c (frame_info): Initialize variable caller_pc.
2013-12-08 10:34:34 +08:00
Mike Frysinger 594d8fa8e9 strip off +x bits on non-executable/script files
These files are source files and have no business being +x.  We couldn't
easily fix it in CVS (you need login+write access to the raw rcs files),
but we can fix this w/git.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-07 02:03:03 -05:00
Mike Frysinger d9a196da2e gdb: testsuite: fix ksh shebang to use sh
These scripts use /bin/ksh, but they're dirt simple and can be used with
/bin/sh, so just change the shebang.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-07 01:59:26 -05:00
Pedro Alves 782d47dfbd Fix "info frame" in the outermost frame.
Doing "info frame" in the outermost frame, when that was indicated by
the next frame saying the unwound PC is undefined/not saved, results
in error and incomplete output:

 (gdb) bt
 #0  thread_function0 (arg=0x0) at threads.c:63
 #1  0x00000034cf407d14 in start_thread (arg=0x7ffff7fcb700) at pthread_create.c:309
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

 (gdb) frame 2
 #2  0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
 115             call    *%rax

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip Register 16 was not saved
 (gdb)

Not saved register values are treated as optimized out values
internally throughout.  stack.c:frame_info is handing unvailable
values, but not optimized out ones.  The patch deletes the
frame_unwind_caller_pc_if_available wrapper function and instead lets
errors propagate to frame_info (it's only user).

As frame_unwind_pc now needs to be able to handle and cache two
different error scenarios, the prev_pc.p variable is replaced with an
enumeration.

(FWIW, I looked into making gdbarch_unwind_pc or a variant return
struct value's instead, but it results in lots of boxing and unboxing
for no real gain -- e.g., the mips and arm implementations need to do
computation on the unboxed PC value.  Might as well throw an error on
first attempt to get at invalid contents.)

After the patch, we get:

 (gdb) info frame
 Stack level 2, frame at 0x0:
  rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip = <not saved>
  Outermost frame: outermost
  caller of frame at 0x7ffff7fcafc0
  source language asm.
  Arglist at 0x7ffff7fcafb8, args:
  Locals at 0x7ffff7fcafb8, Previous frame's sp is 0x7ffff7fcafc8
 (gdb)

A new test is added.  It's based off dw2-reg-undefined.exp, and tweaked to
mark the return address (rip) of "stop_frame" as undefined.

Tested on x86_64 Fedora 17.

gdb/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* frame.c (enum cached_copy_status): New enum.
	(struct frame_info) <prev_pc.p>: Change type to enum
	cached_copy_status.
	(fprint_frame): Handle not saved and unavailable prev_pc values.
	(frame_unwind_pc_if_available): Delete and merge contents into ...
	(frame_unwind_pc): ... here.  Handle OPTIMIZED_OUT_ERROR.  Adjust
	to use enum cached_copy_status.
	(frame_unwind_caller_pc_if_available): Delete.
	(create_new_frame): Adjust.
	* frame.h (frame_unwind_caller_pc_if_available): Delete
	declaration.
	* stack.c (frame_info): Use frame_unwind_caller_pc instead of
	frame_unwind_caller_pc_if_available, and handle
	NOT_AVAILABLE_ERROR and OPTIMIZED_OUT_ERROR errors.
	* valprint.c (val_print_optimized_out): Use val_print_not_saved.
	(val_print_not_saved): New function.
	* valprint.h (val_print_not_saved): Declare.

gdb/testsuite/
2013-12-06  Pedro Alves  <palves@redhat.com>

	* gdb.dwarf2/dw2-undefined-ret-addr.S: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.c: New file.
	* gdb.dwarf2/dw2-undefined-ret-addr.exp: New file.
2013-12-06 19:50:10 +00:00
Pedro Alves 710409a221 New OPTIMIZED_OUT_ERROR error code.
In order to catch <optimized out> errors like we catch <unavailable>
errors, this adds a new OPTIMIZED_OUT_ERROR error code, and throws it
in various places.

gdb/ChangeLog
2013-12-06  Andrew Burgess  <aburgess@broadcom.com>
	    Pedro Alves  <palves@redhat.com>

	* exceptions.h (errors): Add OPTIMIZED_OUT_ERROR.
	* dwarf2loc.c (write_pieced_value): Throw OPTIMIZED_OUT_ERROR.
	* frame.c (frame_unwind_register): Throw OPTIMIZED_OUT_ERROR.
	* spu-tdep.c (spu_software_single_step): Throw
	OPTIMIZED_OUT_ERROR.
	* valops.c (value_assign): Throw OPTIMIZED_OUT_ERROR.
2013-12-06 19:48:54 +00:00
Tom Tromey 7580e91767 update free_objfile comment
The introductory comment to free_objfile is obsolete.
This patch fixes it by removing all the obsolete bits.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* objfiles.c (free_objfile): Update comment.
2013-12-06 12:14:03 -07:00
Tom Tromey 53e0e56d64 remove objfile_to_front
I happened to notice that nothing uses objfile_to_front.
This patch removes it.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* objfiles.h (objfile_to_front): Remove.
	* objfiles.c (objfile_to_front): Remove.
2013-12-06 12:13:59 -07:00
Tom Tromey 830f7a41e3 remove unnecessary declaration
This removes an unnecessary declaration from minsyms.c.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* minsyms.c (get_symbol_leading_char): Remove unnecessary
	declaration.
2013-12-06 12:13:55 -07:00
Tom Tromey e1b06ae220 pack partial_symtab for space
This improves the packing of struct partial_symtab.  I noticed with
pahole that were were a couple of holes.  This consolidates the holes
without, I think, affecting readability -- it just moves the "user"
field a bit earlier in the struct.  This change saves a small amount
of memory.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* psympriv.h (struct partial_symtab) <user>: Move earlier.
2013-12-06 12:13:51 -07:00
Tom Tromey 2b69941d0d fix a couple of FIXMEs
This fixes a couple of old "32x64" FIXME comments by using paddress
with current_gdbarch rather than hex_string and a cast to long.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* cli/cli-cmds.c (edit_command): Use paddress, not hex_string.
	(list_command): Likewise.
2013-12-06 12:13:47 -07:00
Tom Tromey bf121224c7 put the psymtab filename in the filename bcache
This puts the psymtab filename in the filename bcache.
This saves a small amount of memory.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* psymtab.c (allocate_psymtab): Put the filename in the filename
	bcache.
2013-12-06 12:13:42 -07:00
Tom Tromey 8e96694e31 make symtab::dirname const
This makes symtab::dirname const and updates one spot to avoid an
intermediate constless result.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* buildsym.c (end_symtab_from_static_block): Use obstack_copy0.
	* symtab.h (struct symtab) <dirname>: Now const.
2013-12-06 12:13:37 -07:00
Tom Tromey 21ea9eece7 make symtab::filename const
This makes symtab::filename const and removes a newly unnecessary
cast.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* symfile.c (allocate_symtab): Remove cast.
	* symtab.h (struct symtab) <filename>: Now const.
2013-12-06 12:13:31 -07:00
Doug Evans 399d6e3089 * gdb.base/break.exp: Fix setting of $baz. 2013-12-06 10:19:01 -08:00
Tom Tromey 37fbcad0be remove some sym_probe_fns methods
While looking into the probe API, it seemed to me that there were a
number of methods in sym_probe_fns that were not needed.  This patch
removes them.

Specifically, it seems to me that sym_probe_fns ought to be concerned
with the API for constructing the probes.  Any method relating to some
aspect of an individual probe can be handled via the probe's own
vtable.  That is, the double indirection here doesn't seem useful --
it certainly isn't in fact used, but also I couldn't think of a
potential use.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use
	get_probe_argument_count and evaluate_probe_argument.
	* elfread.c (elf_get_probe_argument_count)
	(elf_can_evaluate_probe_arguments, elf_evaluate_probe_argument)
	(elf_compile_to_ax): Remove.
	(elf_probe_fns): Update.
	* probe.c (get_probe_argument_count, can_evaluate_probe_arguments)
	(evaluate_probe_argument): Call method on probe, not via sym
	functions.
	* stap-probe.c (compute_probe_arg): Use get_probe_argument_count,
	evaluate_probe_argument.
	(compile_probe_arg): Use get_probe_argument_count.  Call method on
	probe, not via sym functions.
	* symfile-debug.c (debug_sym_get_probe_argument_count)
	(debug_can_evaluate_probe_arguments)
	(debug_sym_evaluate_probe_argument, debug_sym_compile_to_ax):
	Remove.
	(debug_sym_probe_fns): Remove.
	* symfile.h (struct sym_probe_fns) <sym_get_probe_argument_count,
	can_evaluate_probe_arguments, sym_evaluate_probe_argument,
	sym_compile_to_ax>: Remove fields.
2013-12-06 08:57:55 -07:00
Andrew Burgess 16b5a7cbae Add support for DW_OP_bit_piece and DW_OP_plus_uconst to DWARF assembler.
https://sourceware.org/ml/gdb-patches/2013-12/msg00143.html

gdb/testsuite/ChangeLog

	* lib/dwarf.exp: (Dwarf::_location): Handle DW_OP_bit_piece and
	DW_OP_plus_uconst.
2013-12-06 13:27:24 +00:00
Keven Boell f84bc21877 testsuite: introduce index in varobj child eval.
In some languages, e.g. fortran, arrays start with index 1
instead 0. This patch changes the MI library to support testing
varobj children of fortran arrays.

2013-11-21  Keven Boell  <keven.boell@intel.com>

testsuite/

	* lib/mi-support.exp (mi_list_varobj_children_range): Add
	call to mi_list_array_varobj_children_with_index.
	(mi_list_array_varobj_children_with_index): New function.
	Add parameter to specify array start.
2013-12-06 10:02:16 +01:00
Pierre Muller 8662d51346 Fix completion for pascal language.
* p-exp.y (exp : field_exp name): Do not call mark_struct_expression.
       (exp : field_exp name COMPLETE): New rule.
       (exp : SIZEOF): Set correct current_type.
       (last_was_structop): Remove static variable.
       (yylex): Remove saw_structop local variable.
       Adapt code to removal of variables above.
2013-12-06 09:37:35 +01:00
Joel Brobecker da361ebd2d Uninitialized variable "this_id" in frame.c:get_prev_frame_1.
With a simple Ada program where I have 3 functions, one just calling
the next, the backtrace is currently broken when GDB is compiled
at -O2:

   #0  hello.first () at hello.adb:5
   #1  0x0000000100001475 in hello.second () at hello.adb:10
   Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that a recent patch deleted the assignment of variable
this_id, making it an unitialized variable:

        * frame-unwind.c (default_frame_unwind_stop_reason): Return
        UNWIND_OUTERMOST if the frame's ID is outer_frame_id.
        * frame.c (get_prev_frame_1): Remove outer_frame_id check.

The hunk in question starts with:

-  /* Check that this frame is not the outermost.  If it is, don't try
-     to unwind to the prev frame.  */
-  this_id = get_frame_id (this_frame);
-  if (frame_id_eq (this_id, outer_frame_id))

(the code was removed as redundant - but removing the assignment
was in fact not intentional).

There is no other code in this function that sets the variable.
Instead of re-adding the statement in the lone section where it is
actually used, I inlined it, and then got rid of the variable
altogether.  This way, and until we start needing this frame ID
in another location within that function, we dont' have to worry
about the variable's validity/lifetime.

gdb/ChangeLog:

        * frame.c (get_prev_frame_1): Delete variable "this_id".
        Replace its use by a call to get_frame_id.
2013-12-06 08:51:15 +04:00
Anthony Green 6ed1ff02f3 Add software single step support to moxie port 2013-12-05 10:25:03 -05:00
Doug Evans 39d7494aad fix date in previous entry 2013-12-04 22:12:54 -08:00
Doug Evans c47cf54742 * auto-load.c (load_auto_scripts_for_objfile): Add some comments. 2013-12-04 22:08:38 -08:00
Joel Brobecker 170d82c951 Allow Windows UNWIND_INFO version 2.
We've observed in Windows 2012 that ntdll.dll contains some unwind
records with the version field set to 2.  This patch adjusts the
decoder to accept records flagged with this version as well.

Version 2 appears to still be largely undocumented at this stage.
However, apart from a mysterious opcode 6, everything else still
seems to remain the same. So this patch also changes the decoder
to ignore those opcodes; before this change, the debugger would
silently stop the decoding, and let the frame unwinder make do
with what it the decoder managed to decode up to that point.

It's unclear at this point what we're losing by not being able to
decode that opcode. But the information does not appear to be critical,
at least as far as call unwinding is concerned.

gdb/ChangeLog:

	(from Tristan Gingold  <gingold@adacore.com>)
	(from Joel Brobecker  <brobecker@adacore.com>)
	* amd64-windows-tdep.c (amd64_windows_frame_decode_insns):
	Accept version 2.  Ignore operations using opcode 6.
2013-12-05 07:41:31 +04:00
Joel Brobecker a5e619ec1f Minor coding-style fixes in ada-lex.l:find_dot_all.
gdb/ChangeLog:

        * ada-lex.l (find_dot_all): Fix coding style violations.
2013-12-05 07:38:49 +04:00
Eli Zaretskii 22f25c9dd6 Fix the manual more thoroughly. 2013-12-04 19:44:30 +02:00
Eli Zaretskii 3ea8680f84 doc/gdb.texinfo (i386): Fix yesterday's commit. 2013-12-04 18:12:16 +02:00
Tom Tromey 1a4f73eb8a add @kindex for catchpoints
I wanted to find the docs for "catch load" the other day, and I found
out that this isn't in the index.  It seems to me that each command
ought to be in the index for quick reference like this, so this patch
adds an @kindex (chosen because it seems to be what the rest of the
manual does) for each "catch" subcommand.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Set Catchpoints): Add @kindex for each command
	documented here.
2013-12-03 13:04:16 -07:00
Tom Tromey 6cb999f8df add "dir" menu item for gdbserver
I happened to notice that the gdbserver program doesn't appear in the
top-level "dir" file.  This adds an entry for it to the gdb manual.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (@direntry): Add menu item for gdbserver.
2013-12-03 13:02:48 -07:00
Walfred Tedeschi ca8941bbd0 Documentation for MPX.
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* NEWS:  Add section for Intel(R) Architecture Instructions
	Extesions mentioning MPX.
doc/
	* gdb.texinfo (i386 Features): Add MPX feature registers.
	(x86 Specific featuresx86 Architecture-specific Issues): Adds
	a subsubsection for MPX and describes the display of the
	boundary registers.


Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2013-12-03 13:31:03 +00:00
Jose E. Marchesi 489e41ddf4 Fixed typo in date in testsuite/ChangeLog entry 2013-12-03 04:41:30 -08:00
Jose E. Marchesi f130030056 testsuite: handle SIGLOST/SIGPWR conflict in sparc64-*-linux-gnu targets.
2013-10-03  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.base/sigall.exp (test_one_sig): gdb identifies SIGLOST as a
	SIGPWR in sparc64.

	* gdb.base/sigall.c (main): In some targets SIGLOST and SIGPWR
	have the same signal number.  Handle this situation.
2013-12-03 04:34:48 -08:00
Joel Brobecker 7fb1b8b13f Ada: Reserved word "all" should not need to be spelled in lowercase.
Consider the following code:

   type Ptr is access all Integer;
   IP : Ptr := new Integer'(123);

IP is the Ada exception of a pointer to an integer. To dereference
the pointer and get its value, the user uses the reserved word "all"
as follow:

    (gdb) p ip.all
    $1 = 123

Ada being a case-insensitive language, the casing should not matter.
Unfortunately, for the reserved word "all", things don't work. For
instance:

    (gdb) p ip.ALL
    Type integer is not a structure or union type

This patch fixes the problem.

gdb/ChangeLog:

	* ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp.

gdb/testsuite/ChangeLog:

        * gdb.ada/dot_all: New testcase.
2013-12-03 16:04:26 +04:00
Joel Brobecker 849f2b52ec crash evaluating bogus exception condition expression (sparc-solaris)
With a program raising an exception, trying to debug that program
in GDB/MI mode can yield a crash:

    % gdb -i=mi foo
    (gdb)
    -catch-exception -e "Program_Error"
    ^done,bkptno="2",bkpt={number="2",type="breakpoint",[...]
    (gdb)
    -exec-continue
    ^running
    *running,thread-id="all"
    (gdb)
    =library-loaded,id=[...]
    &"warning: failed to reevaluate internal exception condition for catchpoint 2: Error in expression, near `'.\n"
    zsh: 22956 bus error (core dumped)  gdb -q -i=mi foo

The problem is triggered by a problem in the compiler which causes
EXP in the following TRY_CATCH block to change unexpectedly when
parse_exp_1 throws an error :

   |      TRY_CATCH (e, RETURN_MASK_ERROR)
   |        {
   |          exp = parse_exp_1 (&s, bl->address,
   |                             block_for_pc (bl->address), 0);
   |        }

In ada-lang.c:create_excep_cond_exprs, EXP is initialized to NULL,
and is expected to remain NULL if parse_exp_1 throws.  Instead,
its value gets changed to something invalid.  This later crashes
the debugger, when trying to evaluate the bogus expression.

This patch works around the issue by simply forcing EXP back to NULL
when an exception was thrown. A comment explaining why, and the sort
of timeline we're looking at for a fix, is also added.

gdb/ChangeLog:

        * ada-lang.c (create_excep_cond_exprs): Force EXP to NULL
        when parse_exp_1 threw an error.  Add comment.
2013-12-03 15:42:48 +04:00
Joel Brobecker 4e35e8085e NEWS: Extend documentation of the new GDB/MI --language option.
This patch extends a bit the news entry we added which documents
general support of the --language option, to add a small reference
to the associated entry which was also added to the "-list-features"
command output.

gdb/ChangeLog:

        * NEWS: Mention "-list-features" in the entry documenting
        the support for the "--language" option.
2013-12-03 14:20:18 +04:00
Samuel Bronson caf26be91a Resurrect gdb-add-index as a contrib script
This includes changes made in Fedora's gdb packaging[1], Doug's
robustness patch[2] from before gdb-add-index was dropped, some
corrections, and some more changes Doug accumulated in the
meantime[3].

[1]: http://pkgs.fedoraproject.org/cgit/gdb.git/log/gdb-gdb-add-index-script.patch?id=fe74423b0812bae6d7bb027584e401a2ac37d24d
[2]: https://sourceware.org/ml/gdb-patches/2010-09/msg00130.html
[3]: https://sourceware.org/ml/gdb-patches/2013-11/msg00297.html

It would be a good idea to mention the existance of this script
in (info "(gdb) Index Files"), but I'm boycotting invariant
sections/cover texts because non-free docs are a PITA, so somebody
else would need to do that.

Summary of previous activity:

97924a9 Actual removal
c29c521 Attempted removal (accidentally left gdb-add-index.sh in place)
c2bbed2 Addition
2013-12-03 00:17:59 -05:00
Samuel Bronson 34a4fb3a70 MAINTAINERS (Write After Approval): Add myself to the list. 2013-12-03 00:17:57 -05:00
Joel Brobecker 688981c916 Remove "ada-exceptions" from -list-features output.
Now that the -info-gdb-mi-command is available, there is no need for
this entry. The entry and associated new commands were added recently
enough that no front-end out there should be depending on it yet.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): Remove "ada-exceptions".

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Remove the
        documentation of the "ada-exceptions" entry.
2013-12-03 08:53:11 +04:00
Joel Brobecker c1244769eb Remove all trailing spaces in mi/mi-main.c.
No code change, just a mechanical cleanup.

gdb/ChangeLog:

        * mi/mi-main.c: Remove trailing spaces throughout.
2013-12-03 08:53:11 +04:00
Joel Brobecker 2ea126fa78 Add "undefined-command" error code at end of ^error result...
... when trying to execute an undefined GDB/MI command. When trying
to execute a GDB/MI command which does not exist, the current error
result record looks like this:

    -unsupported
    ^error,msg="Undefined MI command: unsupported"

The only indication that the command does not exist is the error
message. It would be a little fragile for a consumer to rely solely
on the contents of the error message in order to determine whether
a command exists or not.

This patch improves the situation by adding concept of error
code, starting with one well-defined error code ("undefined-command")
identifying errors due to a non-existant command. Here is the new
output:

    -unsupported
    ^error,msg="Undefined MI command: unsupported",code="undefined-command"

This error code is only displayed when the corresponding error
condition is met. Otherwise, the error record remains unchanged.
For instance:

    -symbol-list-lines foo.adb
    ^error,msg="-symbol-list-lines: Unknown source file name."

For frontends to be able to know whether they can rely on this
variable, a new entry "undefined-command-error-code" has been
added to the "-list-features" command.  Another option would be
to always generate an error="..." variable (for the default case,
we could decide for instance that the error code is the empty string).
But it seems more efficient to provide that info in "-list-features"
and then only add the error code when meaningful.

gdb/ChangeLog:

        (from Pedro Alves  <palves@redhat.com>)
        (from Joel Brobecker  <brobecker@adacore.com>)
        * exceptions.h (enum_errors) <UNDEFINED_COMMAND_ERROR>: New enum.
        * mi/mi-parse.c (mi_parse): Throw UNDEFINED_COMMAND_ERROR instead
        of a regular error when the GDB/MI command does not exist.
        * mi/mi-main.c (mi_cmd_list_features): Add
        "undefined-command-error-code".
        (mi_print_exception): Print an "undefined-command"
        error code if EXCEPTION.ERROR is UNDEFINED_COMMAND_ERROR.
        * NEWS: Add entry documenting the new "code" variable in
        "^error" result records.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Result Records): Fix the syntax of the
        "^error" result record concerning the error message.  Document
        the error code that may also be part of that result record.
        (GDB/MI Miscellaneous Commands): Document the
        "undefined-command-error-code" element in the output of
        the "-list-features" GDB/MI command.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-undefined-cmd.exp: New testcase.
2013-12-03 08:01:01 +04:00
Joel Brobecker 6b7cbff192 New GDB/MI command "-info-gdb-mi-command"
This patch adds a new GDB/MI command meant for graphical frontends
trying to determine whether a given GDB/MI command exists or not.

Examples:

    -info-gdb-mi-command unsupported-command
    ^done,command={exists="false"}
    (gdb)
    -info-gdb-mi-command symbol-list-lines
    ^done,command={exists="true"}
    (gdb)

At the moment, this is the only piece of information that this
command returns.

Eventually, and if needed, we can extend it to provide
command-specific pieces of information, such as updates to
the command's syntax since inception.  This could become,
for instance:

    -info-gdb-mi-command symbol-list-lines
    ^done,command={exists="true",features=[]}
    (gdb)
    -info-gdb-mi-command catch-assert
    ^done,command={exists="true",features=["conditions"]}

In the first case, it would mean that no extra features,
while in the second, it announces that the -catch-assert
command in this version of the debugger supports a feature
called "condition" - exact semantics to be documented with
combined with the rest of the queried command's documentation.

But for now, we start small, and only worry about existance.
And to bootstrap the process, I have added an entry in the
output of the -list-features command as well ("info-gdb-mi-command"),
allowing the graphical frontends to go through the following process:

  1. Send -list-features, collect info from there as before;
  2. Check if the output contains "info-gdb-mi-command".
     If it does, then support for various commands can be
     queried though -info-gdb-mi-command. Newer commands
     will be expected to always be checked via this new
     -info-gdb-mi-command.

gdb/ChangeLog:

        * mi/mi-cmds.h (mi_cmd_info_gdb_mi_command): Declare.
        * mi/mi-cmd-info.c (mi_cmd_info_gdb_mi_command): New function.
        * mi/mi-cmds.c (mi_cmds): Add -info-gdb-mi-command command.
        * mi/mi-main.c (mi_cmd_list_features): Add "info-gdb-mi-command"
        field to output of "-list-features".

        * NEWS: Add entry for new -info-gdb-mi-command.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Miscellaneous Commands): Document
        the new -info-gdb-mi-command GDB/MI command.  Document
        the meaning of "-info-gdb-mi-command" in the output of
        -list-features.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-i-cmd.exp: New file.
2013-12-03 07:57:24 +04:00
Jan Kratochvil 04affae3ef Record objfile->original_name as an absolute path
gdb/
2013-12-02  Doug Evans  <dje@google.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* objfiles.c (allocate_objfile): Save original_name as an absolute
	path.
	* objfiles.h (struct objfile): Expand comment on original_name.
	* source.c (openp): Call gdb_abspath.
	* utils.c (gdb_abspath): New function.
	* utils.h (gdb_abspath): Declare.

gdb/testsuite/
2013-12-02  Doug Evans  <dje@google.com>

	* gdb.dwarf/dwp-symlink.c: Fake out gdb to not load debug info
	at start.
	* gdb.dwarf/dwp-symlink.exp: Test trying to load dwp when the binary
	has been specified with a relative path and we have chdir'd before
	accessing the debug info.
2013-12-02 22:24:32 +01:00
Pedro Alves aee4bf8505 Add new target_read_raw_memory function, and consolidate comments.
Tested on x86_64 Fedora 17.

gdb/
2013-12-02  Pedro Alves  <palves@redhat.com>

	* dcache.c (dcache_read_line): Use target_read_raw_memory.
	* target.c (target_read_raw_memory): New function.
	(target_read_stack, target_write_memory, target_write_raw_memory):
	Update comment.
	(target_read_code): Add comment.
	* target.h (target_read_raw_memory): Declare.
2013-12-02 11:10:20 +00:00
Pedro Alves 840207d8ee gnulib's sys/stat.h always defines S_IRGRP, S_IXGRP, S_IXOTH.
Confirmed that cross building a mingw gdb still works, and also made
sure it was gnulib's sys/stat.h that was defining the values, by
hacking the header with #errors where the macros are defined.

gdb/
2013-12-02  Pedro Alves  <palves@redhat.com>

	* ctf.c (ctf_start): Use S_IRGRP, S_IXGRP, S_IXOTH
	unconditionally.
2013-12-02 11:09:24 +00:00
Pedro Alves 0fdf84ca4b Handle 'k' packet TARGET_CLOSE_ERROR gracefully.
Remote servers may cut the connection abruptly since they are not
required to reply to a 'k' (Kill) packet sent from GDB.

This patch addresses any issues arising from such scenario, which
leads to a GDB internal error due to an attempt to pop the target more
than once.  With the patch, this failure is handled gracefully.

Here's the GDB backtrace Maciej got running the testsuite against
QEMU.  Full paths edited out for brevity.

#0  0x55573430 in __kernel_vsyscall ()
#1  0x557a2951 in raise () from /lib32/libc.so.6
#2  0x557a5d82 in abort () from /lib32/libc.so.6
#3  0x0826e2e4 in dump_core ()
    at .../gdb/utils.c:635
#4  0x0826e5b6 in internal_vproblem (problem=0x85200c0,
    file=0x8416be8 ".../gdb/target.c", line=2861,
    fmt=0x84174ac "could not find a target to follow mourn inferior",
    ap=0xffa4796c "\f")
    at .../gdb/utils.c:804
#5  0x0826e5fb in internal_verror (
    file=0x8416be8 ".../gdb/target.c", line=2861,
    fmt=0x84174ac "could not find a target to follow mourn inferior",
    ap=0xffa4796c "\f")
    at .../gdb/utils.c:820
#6  0x0826e633 in internal_error (
    file=0x8416be8 ".../gdb/target.c", line=2861,
    string=0x84174ac "could not find a target to follow mourn inferior")
    at .../gdb/utils.c:830
#7  0x081b4ad0 in target_mourn_inferior ()
    at .../gdb/target.c:2861
#8  0x08082283 in remote_kill (ops=0x85245e0)
    at .../gdb/remote.c:7840
#9  0x081b06d1 in target_kill ()
    at .../gdb/target.c:486
#10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0)
    at .../gdb/target.c:2570
#11 0x08290cfc in iterate_over_inferiors (
    callback=0x81b42af <dispose_inferior>, data=0x0)
    at .../gdb/inferior.c:396
#12 0x081b435a in target_preopen (from_tty=1)
    at .../gdb/target.c:2591
#13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1,
    target=0x85245e0, extended_p=0)
    at .../gdb/remote.c:4292
#14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1)
    at .../gdb/remote.c:3655
#15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237",
    from_tty=1)
    at .../gdb/cli/cli-decode.c:107
#16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237",
    from_tty=1)
    at .../gdb/cli/cli-decode.c:1882
#17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1)
    at .../gdb/top.c:467
#18 0x08193f2d in command_handler (command=0xa5538a8 "")
    at .../gdb/event-top.c:435
#19 0x08194463 in command_line_handler (
    rl=0xa778198 "target remote localhost:1237")
    at .../gdb/event-top.c:633
#20 0x082ba92b in rl_callback_read_char ()
    at .../readline/callback.c:220
#21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0)
    at .../gdb/event-top.c:164
#22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0)
    at .../gdb/event-top.c:375
#23 0x08192f29 in handle_file_event (data=...)
    at .../gdb/event-loop.c:768
#24 0x0819266a in process_event ()
    at .../gdb/event-loop.c:342
#25 0x08192708 in gdb_do_one_event ()
    at .../gdb/event-loop.c:394
#26 0x08192781 in start_event_loop ()
    at .../gdb/event-loop.c:431
#27 0x08193b08 in cli_command_loop (data=0x0)
    at .../gdb/event-top.c:179
#28 0x0818bc26 in current_interp_command_loop ()
    at .../gdb/interps.c:327
#29 0x0818c4e5 in captured_command_loop (data=0x0)
    at .../gdb/main.c:267
#30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>,
    func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL)
    at .../gdb/exceptions.c:524
#31 0x0818d736 in captured_main (data=0xffa47f10)
    at .../gdb/main.c:1067
#32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>,
    func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL)
    at .../gdb/exceptions.c:524
#33 0x0818d76c in gdb_main (args=0xffa47f10)
    at .../gdb/main.c:1076
#34 0x0804dd1b in main (argc=5, argv=0xffa47fd4)
    at .../gdb/gdb.c:34

The corresponding gdb.log excerpt:

(gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9)
cont
Continuing.

Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44
44	}
(gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9
print flags
$10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'}
(gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc)
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break break2
Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48.
(gdb) entering gdb_reload
target remote localhost:1235
A program is being debugged already.  Kill it? (y or n) y
Remote connection closed
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) ^Ccontinue
Please answer y or n.
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) Resyncing due to internal error.
n
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y
Command aborted.
(gdb) print/x flags
$11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0}
(gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1
cont
The program is not being run.
(gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running)
print/x flags
$12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0}
(gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break break3
Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52.
(gdb) entering gdb_reload
target remote localhost:1236
Remote debugging using localhost:1236
Reading symbols from .../lib/ld-linux.so.3...done.
Loaded symbols for .../lib/ld-linux.so.3
0x41001b80 in _start () from .../lib/ld-linux.so.3
(gdb) continue
Continuing.

Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52
52	}
(gdb) print flags
$13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'}
(gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges

gdb/
2013-12-02  Pedro Alves  <pedro@codesourcery.com>
            Maciej W. Rozycki  <macro@codesourcery.com>

	* remote.c (putpkt_for_catch_errors): Remove function.
	(remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet
	gracefully.
2013-12-02 10:42:02 +00:00
Yao Qi 62972e0b66 Fix PR remote/15974
In remote-notif.c:handle_notification, we have a loop,

  for (i = 0; i < ARRAY_SIZE (notifs); i++)
    {
      nc = notifs[i];
      if (strncmp (buf, nc->name, strlen (nc->name)) == 0
	  && buf[strlen (nc->name)] == ':')
	break;
    }

  /* We ignore notifications we don't recognize, for compatibility
     with newer stubs.  */
  if (nc == NULL)
    return;

If the notification is not in the list 'notifs', the last entry is
used, which is wrong.  It should be NULL.  This patch fixes it.

gdb:

2013-12-02  Pedro Alves  <palves@redhat.com>

	PR remote/15974
	* remote-notif.c (handle_notification): Return early if no
	notification is found.
2013-12-02 14:44:14 +08:00
Joel Brobecker f9b0da3d58 Fix filestuff.c build error if RLIMIT_NOFILE not defined.
Not all systems supporting getrlimit also support RLIMIT_NOFILE
(Eg. All LynxOS systems appear to be lacking support for this).
So check its existance before using it.

gdb/ChangeLog:

        * common/filestuff.c (fdwalk): Add "defined(RLIMIT_NOFILE)"
        preprocessor check.
2013-12-02 07:14:10 +04:00
Joel Brobecker 2dd4d4224a Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_dirent.h".
This file no longer exists.

gdb/ChangeLog:

	* Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_dirent.h".
2013-12-02 07:10:29 +04:00
Joel Brobecker e72eff80bf Remove last traces of gdb_stat.h.
This file no longer exists.

gdb/ChangeLog:

        * Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_stat.h".
        * ctf.c (ctf_start): Remove obsolete comment.
2013-12-02 07:05:10 +04:00
Joel Brobecker 844ad0054a Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_string.h".
This file no longer exists...

gdb/ChangeLog:

	* Makefile.in (HFILES_NO_SRCDIR): Remove "common/gdb_string.h".
2013-12-02 06:57:38 +04:00
Doug Evans 5b2bf9471f Move .debug_gdb_script processing to auto-load.c.
Simplify handling of auto-loaded objfile scripts.

.debug_gdb_scripts was always intended to handle more than just python,
thus the rightful home for the code that processes it is not in py-foo.c.
This is just a cleanup to move the code to a better place.

This also simplifies the handling of the ${objfile}-${suffix} auto-loaded
scripts.  There's no need for each of the the handlers to do is-safe-to-load
checking, or call maybe_add_script.  Doing it in the caller removes the
duplication.

	* auto-load.h (script_language): New members name, auto_load_enabled.
	Add missing comments on struct members.
	(auto_load_objfile_script): Delete.
	* auto-load.c: #include "cli/cli-cmds.h".
	(auto_load_gdb_scripts_enabled): New function.
	(script_language_gdb): Update, add new members.
	(source_gdb_script_for_objfile): Simplify, auto-load safe-checking
	and call to maybe_add_script moved to caller.
	(auto_load_objfile_script_1): Auto-load safe-checking and
	call to maybe_add_script moved here.
	(auto_load_objfile_script): Make static.  Early exit if support for
	scripting language hasn't been compiled in, or auto-loading has been
	disabled.
	(source_section_scripts): Argument "source_name" renamed to
	"section_name".  All uses updated.  Replace uses of AUTO_SECTION_NAME
	with section_name.  Skip loading script if support for scripting
	language hasn't been compiled in, or auto-loading has been disabled.
	Call language->source_script_for_objfile instead of calling
	source_python_script_for_objfile directly.
	(load_auto_scripts_for_objfile): Update.
	* python/py-auto-load.c: Delete #include "cli/cli-cmds.h".
	(gdbpy_load_auto_script_for_objfile): Delete.
	(auto_load_python_scripts_enabled): New function.
	(script_language_python): Update, add new members.
	(gdbpy_script_language_defn): New function.
	* python/python.h (gdbpy_load_auto_scripts_for_objfile): Delete.
	(gdbpy_script_language_defn): Declare.

	* auto-load.c (AUTO_SECTION_NAME): Moved here and renamed from
	py-auto-load.c, GDBPY_AUTO_SECTION_NAME.
	(source_section_scripts): Moved here from py-auto-load.c.
	(auto_load_section_scripts): Ditto.
	* python/py-auto-load.c (GDBPY_AUTO_SECTION_NAME): Moved to
	auto-load.c, renamed AUTO_SECTION_NAME.
	(source_section_scripts, auto_load_section_scripts): Moved to
	auto-load.c.
2013-11-29 21:29:26 -08:00
Yao Qi d9c4392818 Fix typo "checksm"
Fix typo "checksm".

gdb:

2013-11-30  Yao Qi  <yao@codesourcery.com>

	* remote.c (getpkt_or_notif_sane_1): Fix typo "checksm".
2013-11-30 11:17:16 +08:00
Sergio Durigan Junior e7b1239280 Remove gdb_string.h from gdbarch.sh
This commit removes the "#include gdb_string.h" from gdbarch.sh, fixing
a small nit caused by Tom's commit
0e9f083f4c.

Checked-in as obvious.

2013-11-29  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdbarch.sh: Remove include of "gdb_string.h", replace by
	<string.h>.
2013-11-29 20:28:16 -02:00
Doug Evans 7b2d3abff9 * python/py-auto-load.c (source_section_scripts): Move comment to
more relevant location.
2013-11-29 12:34:32 -08:00
Doug Evans 256458bc0e Remove trailing whitespace.
Whitespace cleanup.
	* python/py-breakpoint.c: Remove trailing whitespace.
	* python/py-cmd.c: Ditto.
	* python/py-evts.c: Ditto.
	* python/py-finishbreakpoint.c: Ditto.
	* python/py-frame.c: Ditto.
	* python/py-function.c: Ditto.
	* python/py-inferior.c: Ditto.
	* python/py-infthread.c: Ditto.
	* python/py-param.c: Ditto.
	* python/py-prettyprint.c: Ditto.
	* python/py-symbol.c: Ditto.
	* python/py-type.c: Ditto.
	* python/py-utils.c: Ditto.
	* python/py-value.c: Ditto.
	* python/python-internal.h: Ditto.
	* python/python.c: Ditto.
2013-11-29 12:00:47 -08:00
Pedro Alves 20e1ca3bc1 UNWIND_NULL_ID is no longer used anywhere. Update comments.
Unfortunately, UNWIND_NULL_ID is exported to Python as
gdb.FRAME_UNWIND_NULL_ID so we can't really eliminate it.

(I'd assume scripts just check the result of Frame.unwind_stop_reason,
and compare it to gdb.FRAME_UNWIND_NO_REASON.  That at most, they'll
pass the result of Frame.unwind_stop_reason to
gdb.frame_stop_reason_string.  I'd prefer to just get rid of it, but
because we make an API promise, we get to keep this around for
compatibility, in case a script does refer to gdb.FRAME_UNWIND_NULL_ID
directly.)

gdb/
2013-11-29  Pedro Alves  <palves@redhat.com>

	* unwind_stop_reasons.def (UNWIND_NULL_ID): Update comment.

gdb/doc/
2013-11-29  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Frames In Python) <gdb.FRAME_UNWIND_NULL_ID>:
	Update comment.
2013-11-29 15:25:46 +00:00
Pedro Alves 8b4f3082d8 Plug target side conditions and commands leaks.
The memory management of bp_location->target_info.conditions|tcommands
is currently a little fragile.  If the target reports support for
target conditions or commands, and then target side breakpoint support
is disabled, or some error is thrown before remote_add_target_side_XXX
is called, we'll leak these lists.  This patch makes us free these
lists when the locations are deleted, and also, just before recreating
the commands|conditions lists.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-11-29  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (build_target_condition_list): Release previous
	conditions.
	(build_target_command_list): Release previous commands.
	(bp_location_dtor): Release target conditions and commands.
	* remote.c (remote_add_target_side_condition): Don't release
	conditions.
	(remote_add_target_side_commands): Don't release commands.
2013-11-29 14:50:26 +00:00
Yao Qi 9f7132948d Delegate to target_ops->beneath for TARGET_OBJECT_RAW_MEMORY
GDB on x86_64-linux is unable to disassemble on core-file target.

$ ./gdb ./testsuite/gdb.base/corefile
(gdb) core-file ./testsuite/gdb.base/corefile.core
(gdb) disassemble main
Dump of assembler code for function main:
   0x0000000000400976 <+0>:	Cannot access memory at address 0x400976

However, it works if we turn code-cache off.

(gdb) set code-cache off
(gdb) disassemble main,+4
Dump of assembler code from 0x400976 to 0x40097a:
   0x0000000000400976 <main+0>:	push   %rbp
   0x0000000000400977 <main+1>:	mov    %rsp,%rbp
End of assembler dump.

When code-cache is off, GDB will iterate target_ops from top to bottom
and call to_xfer_partial.  When current_target is "core", it will call
to_xfer_partial of target "exec", which reads the contents for
disassemble.  However, dcache uses TARGET_OBJECT_RAW_MEMORY to read,
but target_xfer_partial doesn't delegate requests to beneath for
TARGET_OBJECT_RAW_MEMORY.

This patch factors out the iteration from top to bottom to a new
function, raw_memory_xfer_partial, and use it for
TARGET_OBJECT_RAW_MEMORY.

Regression tested on x86_64-linux.

gdb:

2013-11-29  Yao Qi  <yao@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	* dcache.c (dcache_read_line): Use current_target.beneath
	instead of &current_target.
	* target.c (memory_xfer_partial_1): Factor code out to ...
	(raw_memory_xfer_partial): ... it.  New function.
	(target_xfer_partial): Call raw_memory_xfer_partial if OBJECT
	is TARGET_OBJECT_RAW_MEMORY.
2013-11-29 21:32:03 +08:00
Doug Evans 4cb0213de5 Rename breakpoint_object to gdbpy_breakpoint_object.
* breakpoint.h (gdbpy_breakpoint_object): Renamed from
	breakpoint_object.  All uses updated.
	* python/python-internal.h (gdbpy_breakpoint_object): Renamed from
	breakpoint_object.  All uses updated.
	* python.c (*): All uses of breakpoint_object updated.
	* python.h (*): All uses of breakpoint_object updated.
	* python/py-breakpoint.c (*): All uses of breakpoint_object updated.
	* python/py-finishbreakpoint.c (*): Ditto.
2013-11-28 14:54:32 -08:00
Doug Evans d729aae0fd fix spelling in previous entry 2013-11-28 14:31:55 -08:00
Doug Evans d344e670e7 * configure.ac: Add comments delineating libpython and libmcheck.
* configure: Regenerate.
2013-11-28 14:30:59 -08:00
Andrew Burgess eebc056c8e Print entirely unavailable struct/union values as a single <unavailable>.
When printing an entirely optimized out structure/class/union, we
print a single <optimized out> instead of printing <optimized out> for
each field.

This patch makes an entirely unavailable structure/class/union be
likewise displayed with a single "<unavailable>" rather than the whole
object with all fields <unavailable>.

This seems good because this way the user can quickly tell whether the
whole value is unavailable, rather than having to skim all fields.
Consistency with optimized out values also seems to be a good thing to
have.

A few updates to gdb.trace/unavailable.exp where required.

Tested on x86_64 Fedora 17, native gdbserver.

gdb/
2013-11-28  Andrew Burgess  <aburgess@broadcom.com>
	    Pedro Alves  <palves@redhat.com>

	* valprint.c (value_check_printable): If the value is entirely
	unavailable, print a single "<unavailable>" instead of printing
	all subfields.

gdb/testsuite/
2013-11-28  Andrew Burgess  <aburgess@broadcom.com>

	* gdb.trace/unavailable.exp (gdb_collect_args_test): Update
	expected results.
	(gdb_collect_locals_test): Likewise.
	(gdb_collect_globals_test): Likewise.
2013-11-28 18:54:20 +00:00
Pedro Alves a730086980 get_prev_frame, stop_reason != UNWIND_NO_REASON, add frame debug output.
The stop_reason != UNWIND_NO_REASON doesn't currently have "set debug
frame" output.  This patch makes it print the stop_reason enum value
as a string.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame.c (get_prev_frame_1) <stop_reason != UNWIND_NO_REASON>:
	Add "set debug frame" output.
	(frame_stop_reason_symbol_string): New function.
2013-11-28 18:09:41 +00:00
Pedro Alves 50fd528a13 get_prev_frame, outer_frame_id and unwind->stop_reason checks are redundant.
After the previous patch, it should be clear that the
this_frame->unwind->stop_reason check is redundant with the
outer_frame_id check just below.  We can now move the frame_id_eq
comparison to the default this_frame->unwind->stop_reason callback.

Tested on x86_64 Fedora 17.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame-unwind.c (default_frame_unwind_stop_reason): Return
	UNWIND_OUTERMOST if the frame's ID is outer_frame_id.
	* frame.c (get_prev_frame_1): Remove outer_frame_id check.
2013-11-28 17:37:47 +00:00
Pedro Alves 5de5158168 get_prev_frame, UNWIND_NULL_ID -> UNWIND_OUTERMOST
- The UNWIND_NULL_ID check in get_prev_frame_1 used to really be
  against null_frame_id, back before we had outer_frame_id.  We didn't
  have UNWIND_OUTERMOST when outer_frame_id was added, but we do now,
  and it's more accurate.

- It used to be necessary to check for the sentinel frame explicitly
  because that uses null_frame_id for frame id.  Since no other frame
  can have that id nowadays (it's asserted by compute_frame_id), we
  don't need that explicit check.

Tested on x86_64 Fedora 17.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame.c (get_prev_frame_1): If the frame id is outer_frame_id,
	set the unwind stop reason to UNWIND_OUTERMOST, not
	UNWIND_NULL_ID.  Remove explicit check for sentinel frame.
2013-11-28 17:35:28 +00:00
Pedro Alves 739cb10c0e register: "optimized out" -> "not saved".
Another spot that missed the previous related text adjustments.

Tested on x86_64 Fedora 17.

gdb/
2013-11-28  Pedro Alves  <palves@redhat.com>

	* frame.c (frame_unwind_register): Say the register was "not
	saved" instead of "optimized out".
2013-11-28 17:32:26 +00:00
Pedro Alves 514c0aa6a3 Fix PR 16152's ChangeLog entry.
Mention PR 16152.  Fix formatting.  Make wording match commit log.
2013-11-28 17:27:36 +00:00
Yao Qi 8b5e6dc217 GDB perf test on disassemble
This patch adds a test case to test the performance of GDB doing
disassembly.

gdb/testsuite/

2013-11-28  Yao Qi  <yao@codesourcery.com>

	* lib/gdb.exp (with_gdb_prompt): New proc.
	* gdb.perf/disassemble.exp: New.
	* gdb.perf/disassemble.py: New.
2013-11-28 12:53:26 +08:00
Steffen Sledz 92a021debf gdb: fix cygwin check in configure script
Avoid false positives if the search pattern "lose" is found in path
descriptions in comments generated by the preprocessor.

See <https://sourceware.org/bugzilla/show_bug.cgi?id=16152>.

gdb/
2013-11-27  Steffen Sledz  <sledz@dresearch-fe.de>

	* configure.ac: Tighten Cygwin detection check.
	* configure: Rebuild.
2013-11-27 18:51:49 +00:00
Pedro Alves 908fa2aaed Fix type of not saved registers.
value_of_register_lazy uses the type of REGNUM in FRAME, but given
multi-arch, the arch of FRAME might be different from the previous
frame's arch, and therefore the type of register REGNUM should be
retrieved from the unwound arch.  This used to be correct before the
previous change.

Tested on x86_64 Fedora 17.

gdb/
2013-11-27  Pedro Alves  <palves@redhat.com>

	* frame-unwind.c (frame_unwind_got_optimized): Use the type of the
	register in the previous frame's arch.
2013-11-27 17:55:38 +00:00
Pedro Alves 6bd273ae45 Make "set debug frame 1" output print <not saved> instead of <optimized out>.
"set debug frame 1" is printing "<optimized out>" for not saved
registers.  That's because the unwinders are returning optimized out
not_lval values instead of optimized out lval_register values.  "<not
saved>" is how val_print_optimized_out prints lval_register values.

  ...
  - { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <optimized out> }
  + { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <not saved> }
  ...

Tested on x86_64 Fedora 17.

2013-11-27  Pedro Alves  <palves@redhat.com>

	* frame-unwind.c (frame_unwind_got_optimized): Return
	an lval_register value instead of a not_lval value.
2013-11-27 17:49:59 +00:00
Andrew Burgess f6c01fc515 Make "set debug frame 1" use the standard print routine for optimized out values.
...
 - { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> optimized out }
 + { frame_unwind_register_value (frame=0,regnum=7(rsp),...) -> <optimized out> }
 ...

Tested on x86_64 Fedora 17.

2013-11-27  Andrew Burgess  <aburgess@broadcom.com>

	* frame.c: Include "valprint.h".
	(frame_unwind_register_value): Use value_optimized_out.
	* value.c (value_fetch_lazy): Likewise.
2013-11-27 17:49:59 +00:00
Luis Machado 0db4ca1856 * gdb.base/callfuncs.c (main): Assign malloc's return value
and free it afterwards.
	* gdb.base/charset-malloc.c (malloc_stub): Likewise.
	* gdb.base/printcmds.c (main): Likewise.
	* gdb.base/randomize.c (main): Free "p" and change breakpoint
	marker position.
	* gdb.base/setvar.c (dummy): Assign malloc's return value
	and free it afterwards.
2013-11-27 10:39:26 -02:00
Andrew Burgess d24a9f159c Tighten regexp in gdb.base/setshow.exp
https://sourceware.org/ml/gdb-patches/2013-11/msg00817.html

gdb/testsuite/ChangeLog

	* gdb.base/setshow.exp: Add $gdb_prompt to the patterns in
	gdb_test_multiple.
2013-11-26 16:36:21 +00:00
Andrew Burgess 4f14910fa1 Mark entirely optimized out value as non-lazy.
If a value is entirely optimized out, then there's nothing for
value_fetch_lazy to fetch.  Sequences like:

 if (value_lazy (retval))
   value_fetch_lazy (retval);

End up allocating the value contents buffer, wasting memory, for no
use.

gdb/ChangeLog
2013-11-26  Andrew Burgess  <aburgess@broadcom.com>

	* value.c (allocate_optimized_out_value): Mark value as non-lazy.
2013-11-26 16:21:53 +00:00
Tom Tromey 158599681f revert patch from 2013-11-22
This reverts da2b2fdf57 and some
follow-up patches.  They were incorrect.

2013-11-26  Tom Tromey  <tromey@redhat.com>

	* dwarf2-frame.c (dwarf2_frame_cache): Revert patch from
	2013-11-22.

2013-11-26  Tom Tromey  <tromey@redhat.com>

	* gdb.dwarf2/dw2-unspecified-ret-addr.S: Remove.
	* gdb.dwarf2/dw2-unspecified-ret-addr.c: Remove.
	* gdb.dwarf2/dw2-unspecified-ret-addr.exp: Remove.
2013-11-26 07:47:56 -07:00
Walfred Tedeschi 244ec0da38 Fix PR16193 - gdbserver aborts.
The MPX patch has broken the I386_XSTATE_SIZE macro.  For AVX machines,
it ends up returning I386_XSTATE_SSE_SIZE.  Where it first reads
I386_XSTATE_AVX_SIZE, it should have read I386_XSTATE_AVX:

 #define I386_XSTATE_SIZE(XCR0) \
     (((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \
        : (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \
 -       : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \
 +       : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \
        : I386_XSTATE_SSE_SIZE)))

The patch goes a step further and improves readability of the macro,
by adding a couple other auxiliary macros.


2013-11-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* i386-xstate.h (I386_XSTATE_MPX): New Macro.
	(I386_XSTATE_MPX_MASK): Makes use of I386_XSTATE_MPX.
	(HAS_MPX): New macro.
	(HAS_AVX): New macro.
	(I386_XSTATE_SIZE): Uses HAS_MPX and HAS_AVX.
2013-11-26 08:32:16 +00:00
Keith Seitz f7e3ecae9f PR c++/14819: Explicit class:: inside class scope does not work
https://sourceware.org/ml/gdb-patches/2013-11/msg00102.html
2013-11-25 13:37:08 -08:00
Yao Qi 23e9d3b9ce GDB perf test on backtrace
gdb/testsuite/

2013-11-25  Yao Qi  <yao@codesourcery.com>

	* gdb.perf/backtrace.c: New.
	* gdb.perf/backtrace.exp: New.
	* gdb.perf/backtrace.py: New.
2013-11-25 09:12:38 +08:00
Yao Qi 283f7163ec Use target_read_code in disassemble.
This patch teaches "disassembly" use code cache mechanism to read
target code.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* disasm.c (dis_asm_read_memory): Call target_read_code
	instead of target_read_memory.
2013-11-24 14:56:51 +08:00
Yao Qi 29453a1455 set/show code-cache
Similar to stack cache, in this patch, we add
TARGET_OBJECT_CODE_MEMORY to read code from target and add a new
option "set code-cache on|off" to optimize code accesses by
using the target memory cache.

In V4:
 - Remove "without affecting correctness" from NEWS and doc.
 - Replace "ON" with "on" in doc.
 - "access" -> "accesses".

In V3:
 - Rename functions and variables.
 - Update command help, doc and NEWS entry.
 - Invalidate cache on option transitions, to align with
   the behaviour of "stack-cache".  Since cache invalidation is
   transparent to users, users don't know option "stack-cache"
   transitions cause code cache invalidation.

V2 was reviewed by Doug.  There are some changes in V3, so I post it
here.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* NEWS: Add note on new "set code-cache" option.
	* target-dcache.c (code_cache_enabled_1): New variable.
	(code_cache_enabled): New variable.
	(show_code_cache, set_code_cache): New function.
	(code_cache_enabled_p): New function.
	(_initialize_target_dcache): Register command.
	* target-dcache.h (code_cache_enabled_p): Declare.
	* target.c (memory_xfer_partial_1):Handle
	TARGET_OBJECT_CODE_MEMORY and code_cache_enabled.
	(target_read_code): New function.
	* target.h (enum target_object) <TARGET_OBJECT_CODE_MEMORY>:
	New.
	(target_read_code): Declare.

gdb/doc:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Caching Remote Data): Document new
	"set/show stack-cache" option.
2013-11-24 14:56:49 +08:00
Yao Qi 0fb14d8ffd Renaming in target-dcache.c
Hi,
This patch does some renamings on "stack-cache" related functions and
variables.

In the review to "code cache" series v2, we have some discussions on the
name of predicate function 'stack_cache_enabled', and have some options,

 1 keep it unchanged, as it is already a predicate clearly,
 2 rename it to stack_cache_enabled_p,
 3 rename it to enable_stack_cache_p,

I choose #2, because 'stack_cache_enabled' is a predicate, but
it's better to add "_p" suffix to stress this.  There are some other
similar patterns used in GDB source, such as unop_user_defined_p
and agent_loaded_p.

Then, I have to rename variable stack_cache_enabled_p to something
else.  The option is "stack-cache", so I'd like to name the variable
associated with this command as "stack_cache".  Similarly, the commands
associated with this command should be renamed to "set_stack_cache"
and "show_stack_cache" respectively.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* target-dcache.c (stack_cache_enabled_p_1): Rename to ...
	(stack_cache_enabled_1): ... this.  New variable.
	(stack_cache_enabled_p): Rename to ...
	(stack_cache_enabled): ... this.  New variable.
	(set_stack_cache_enabled_p): Rename to ...
	(set_stack_cache): ... this.  Update caller.
	(show_stack_cache_enabled_p): Rename to ...
	(show_stack_cache): ... this.  Update caller.
	(stack_cache_enabled): Rename to ...
	(stack_cache_enabled_p): ... this.  Update caller.
	(_initialize_target_dcache): Replace "data cache" with
	"target memory cache".
	* target-dcache.h (stack_cache_enabled): Remove declaration.
	(stack_cache_enabled_p): Add declaration.
2013-11-24 14:56:48 +08:00
Yao Qi 22825df749 GDB perf test on single step
gdb/testsuite:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* gdb.perf/single-step.c: New.
	* gdb.perf/single-step.exp: New.
	* gdb.perf/single-step.py: New.
2013-11-24 14:33:31 +08:00
Yao Qi 6dd315bae3 Write "ON" and "OFF" in lower case in GDB doc.
gdb/doc:

2013-11-24  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Caching Target Data): Replace "ON" with "on".
	(Maintenance Commands): Replace "ON" and "OFF" with "on" and
	"off" respectively.
2013-11-24 11:11:39 +08:00
Doug Evans c1ea7c017e * gdb.base/ena-dis-br.exp: Add missing quote to "step after continue
with ignore count".
2013-11-23 16:43:29 -08:00
Doug Evans 35720eaabd Test name tweaks for py-value.exp.
* gdb.python/py-value.exp (test_lazy_strings): Tweak test names.
	(test_subscript_regression): Ditto.
	(top level): Run test_subscript_regression for c++ with "c++" prefix.
2013-11-23 16:03:47 -08:00
Doug Evans 3cd14e4575 * gdb.python/py-type.exp (test_enums): Fix typo. 2013-11-23 15:54:05 -08:00
Doug Evans 985c818c2d * gdb.python/py-symbol.exp: Add some comments. Make all test names unique. 2013-11-23 15:45:43 -08:00