Fix several "set remote foo-packet on/off" commands.

For several RSP packets, there's a corresponding "set remote
foo-packet on/off/auto" command that one can use do bypass
auto-detection of support for the packet or feature.  However, I
noticed that setting several of these commands to 'on' or 'off'
doesn't actually have any effect.  These are, at least:

 set remote breakpoint-commands-packet
 set remote conditional-breakpoints-packet
 set remote fast-tracepoints-packet
 set remote static-tracepoints-packet
 set remote install-in-trace-packet

These are commands that control a remote protocol feature that doesn't
have a corresponding regular packet, and because of that we cache the
knowledge of the remote side support as returned by the qSupported
packet in the remote_state object.

E.g., in the case of the 'set remote breakpoint-commands-packet'
command, whether the feature is supported is recorded in the
'breakpoint_commands' field of the remote_state object.

Whether to bypass packet support auto-detection or not is controlled
by the 'detect' field of the corresponding packet's packet_config
structure.  That field is the variable associated directly with the
"set remote foo-packet" command.  Actual remote stub support for the
packet (or feature) is recorded in the 'support' field of the same
structure.

However, when the user toggles the command, the 'support' field is
also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN,
discarding the knowledge of whether the target actually supports the
feature.  If one toggles back to 'auto', it's no big issue for real
packets, as they'll just end up re-probed the next time they might be
necessary.  But features whose support is only reported through
qSupported don't get their corresponding (manually added/maintained)
fields in remote_state objected updated.  As we lost the actual status
of the target support for the feature, GDB would need to probe the
qSupported features again, which GDB doesn't do.

But we can avoid that extra traffic, and clean things up, IMO.
Instead of going in that direction, this patch completely decouples
struct packet_config's 'detect' and 'support' fields.  E.g., when the
user does "set remote foo-packet off", instead of setting the packet
config's 'support' field to PACKET_DISABLE, the 'support' field is not
touched at all anymore.  That is, we end up respecting this simple
table:

| packet_config->detect | packet_config->support | should use packet/feature? |
|-----------------------+------------------------+----------------------------|
| auto                  | PACKET_ENABLE          | PACKET_ENABLE              |
| auto                  | PACKET_DISABLE         | PACKET_DISABLE             |
| auto                  | PACKET_UNKNOWN         | PACKET_UNKNOWN             |
| yes                   | don't care             | PACKET_ENABLE              |
| no                    | don't care             | PACKET_DISABLE             |

This is implemented by the new packet_support function.  With that, we
need to update this pattern throughout:

  if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE)

to do this instead:

  if (packet_support (PACKET_qAttached) == PACKET_DISABLE)

where as mentioned, the packet_support function takes struct
packet_config's 'detect' field into account, like in the table above.

As when the packet is force-disabled or force-enabled, the 'support'
field is just ignored, if the command is set back to auto, we'll
resume respecting whatever the target said it supports.  IOW, the end
result is that the 'support' field always represents whether the
target actually supports the packet or not.

After all that, the manually maintained breakpoint_commands and
equivalent fields of struct remote_state can then be eliminated, with
references replaced by checking the result of calling the
packet_support function on the corresponding packet or feature.  This
required adding new PACKET_foo enum values for several features that
didn't have it yet.  (The patch does not add corresponding "set remote
foo-packet" style commands though, focusing only on bug fixing and
laying the groundwork).

Tested on x86_64 Fedora 17, native GDBserver.  The new tests all fail
without this patch.

gdb/
2014-04-25  Pedro Alves  <palves@redhat.com>

	* remote.c (struct remote_state): Remove multi_process_aware,
	non_stop_aware, cond_tracepoints, cond_breakpoints,
	breakpoint_commands, fast_tracepoints, static_tracepoints,
	install_in_trace, disconnected_tracing,
	enable_disable_tracepoints, string_tracing, and
	augmented_libraries_svr4_read fields.
	(remote_multi_process_p): Move further below in the file.
	(struct packet_config): Add comments.
	(update_packet_config): Delete function.
	(show_packet_config_cmd): Use packet_config_support.
	(add_packet_config_cmd): Use NULL as set callback.
	(packet_ok): "set remote foo-packet"-style commands no longer
	change config->supported -- adjust.
	(PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints)
	(PACKET_BreakpointCommands, PACKET_FastTracepoints)
	(PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments.
	(PACKET_QNonStop, PACKET_multiprocess_feature)
	(PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature)
	(PACKET_DisconnectedTracing_feature)
	(PACKET_augmented_libraries_svr4_read_feature): New enum values.
	(set_remote_protocol_packet_cmd): Delete function.
	(packet_config_support, packet_support): New functions.
	(set_remote_protocol_Z_packet_cmd): Don't call
	update_packet_config.
	(remote_query_attached, remote_pass_signals)
	(remote_program_signals, remote_threads_info)
	(remote_threads_extra_info, remote_start_remote): Use
	packet_support.
	(remote_start_remote): Use packet_config_support and
	packet_support.
	(init_all_packet_configs): Set all packets to unknown support,
	instead of calling update_packet_config.
	(remote_check_symbols): Use packet_support.
	(remote_supported_packet): Unconditionally set the packet config's
	support status.
	(remote_multi_process_feature, remote_non_stop_feature)
	(remote_cond_tracepoint_feature, remote_cond_breakpoint_feature)
	(remote_breakpoint_commands_feature)
	(remote_fast_tracepoint_feature, remote_static_tracepoint_feature)
	(remote_install_in_trace_feature)
	(remote_disconnected_tracing_feature)
	(remote_enable_disable_tracepoint_feature)
	(remote_string_tracing_feature)
	(remote_augmented_libraries_svr4_read_feature): Delete functions.
	(remote_protocol_features): Adjust to use remote_supported_packet
	for "augmented-libraries-svr4-read", "multiprocess", "QNonStop",
	"ConditionalTracepoints", "ConditionalBreakpoints",
	"BreakpointCommands", "FastTracepoints", "StaticTracepoints",
	"InstallInTrace", "DisconnectedTracing", "DisconnectedTracing",
	"EnableDisableTracepoints", and "tracenz".
	(remote_query_supported): Use packet_support.
	(remote_open_1): Adjust.
	(extended_remote_attach_1): Use packet_support.  Switch on the
	result of packet_ok instead of checking whether the packet ended
	up disabled.
	(remote_vcont_resume): Use packet_support.
	(remote_resume, remote_stop_ns, fetch_register_using_p)
	(remote_prepare_to_store, store_register_using_P)
	(check_binary_download, remote_write_bytes): Use packet_support.
	(remote_vkill): Use packet_support.  Switch on the result of
	packet_ok instead of checking whether the packet ended up
	disabled.
	(extended_remote_supports_disable_randomization): Use
	packet_support.
	(extended_remote_run): Switch on the result of packet_ok instead
	of checking whether the packet ended up disabled.
	(remote_insert_breakpoint, remote_remove_breakpoint)
	(remote_insert_watchpoint, remote_remove_watchpoint)
	(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use
	packet_support.
	(remote_search_memory): Use packet_config_support.
	(remote_get_thread_local_address, remote_get_tib_address)
	(remote_hostio_send_command, remote_can_execute_reverse): Use
	packet_support.
	(remote_supports_cond_tracepoints)
	(remote_supports_cond_breakpoints)
	(remote_supports_fast_tracepoints)
	(remote_supports_static_tracepoints)
	(remote_supports_install_in_trace)
	(remote_supports_enable_disable_tracepoint)
	(remote_supports_string_tracing)
	(remote_can_run_breakpoint_commands): Rewrite, checking whether
	the packet config says the feature is enabled or disabled.
	(remote_download_tracepoint, remote_trace_set_readonly_regions)
	(remote_get_trace_status): Use packet_support.
	(remote_set_disconnected_tracing): Adjust to check whether the
	feature is enabled with packet_support.
	(remote_set_trace_buffer_size, remote_use_agent)
	(remote_can_use_agent, remote_supports_btrace): Use
	packet_support.
	(remote_enable_btrace, remote_disable_btrace, remote_read_btrace):
	Use packet_config_support.
	(remote_augmented_libraries_svr4_read): Rewrite, checking whether
	the packet config says the feature is enabled or disabled.
	(set_range_stepping): Use packet_support.

gdb/testsuite/
2014-04-25  Pedro Alves  <palves@redhat.com>

	* gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to
	user.
	(top level): Test that "set remote conditional-breakpoints-packet
	off" works as intended.
	* gdb.base/dprintf.exp: Test that "set remote
	breakpoint-commands-packet off" works as intended.
	* gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled):
	New function.
	(top level): Call it.
	* gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set
	remote fast-tracepoints-packet off" works as intended.
	* gdb.trace/qtro.exp (gdb_is_target_remote): Moved ...
	* lib/gdb.exp (gdb_is_target_remote): ... here.
This commit is contained in:
Pedro Alves 2014-04-25 18:07:02 +01:00
parent 88667baf24
commit 4082afcc3d
7 changed files with 435 additions and 374 deletions

View File

@ -1,3 +1,101 @@
2014-04-25 Pedro Alves <palves@redhat.com>
* remote.c (struct remote_state): Remove multi_process_aware,
non_stop_aware, cond_tracepoints, cond_breakpoints,
breakpoint_commands, fast_tracepoints, static_tracepoints,
install_in_trace, disconnected_tracing,
enable_disable_tracepoints, string_tracing, and
augmented_libraries_svr4_read fields.
(remote_multi_process_p): Move further below in the file.
(struct packet_config): Add comments.
(update_packet_config): Delete function.
(show_packet_config_cmd): Use packet_config_support.
(add_packet_config_cmd): Use NULL as set callback.
(packet_ok): "set remote foo-packet"-style commands no longer
change config->supported -- adjust.
(PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints)
(PACKET_BreakpointCommands, PACKET_FastTracepoints)
(PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments.
(PACKET_QNonStop, PACKET_multiprocess_feature)
(PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature)
(PACKET_DisconnectedTracing_feature)
(PACKET_augmented_libraries_svr4_read_feature): New enum values.
(set_remote_protocol_packet_cmd): Delete function.
(packet_config_support, packet_support): New functions.
(set_remote_protocol_Z_packet_cmd): Don't call
update_packet_config.
(remote_query_attached, remote_pass_signals)
(remote_program_signals, remote_threads_info)
(remote_threads_extra_info, remote_start_remote): Use
packet_support.
(remote_start_remote): Use packet_config_support and
packet_support.
(init_all_packet_configs): Set all packets to unknown support,
instead of calling update_packet_config.
(remote_check_symbols): Use packet_support.
(remote_supported_packet): Unconditionally set the packet config's
support status.
(remote_multi_process_feature, remote_non_stop_feature)
(remote_cond_tracepoint_feature, remote_cond_breakpoint_feature)
(remote_breakpoint_commands_feature)
(remote_fast_tracepoint_feature, remote_static_tracepoint_feature)
(remote_install_in_trace_feature)
(remote_disconnected_tracing_feature)
(remote_enable_disable_tracepoint_feature)
(remote_string_tracing_feature)
(remote_augmented_libraries_svr4_read_feature): Delete functions.
(remote_protocol_features): Adjust to use remote_supported_packet
for "augmented-libraries-svr4-read", "multiprocess", "QNonStop",
"ConditionalTracepoints", "ConditionalBreakpoints",
"BreakpointCommands", "FastTracepoints", "StaticTracepoints",
"InstallInTrace", "DisconnectedTracing", "DisconnectedTracing",
"EnableDisableTracepoints", and "tracenz".
(remote_query_supported): Use packet_support.
(remote_open_1): Adjust.
(extended_remote_attach_1): Use packet_support. Switch on the
result of packet_ok instead of checking whether the packet ended
up disabled.
(remote_vcont_resume): Use packet_support.
(remote_resume, remote_stop_ns, fetch_register_using_p)
(remote_prepare_to_store, store_register_using_P)
(check_binary_download, remote_write_bytes): Use packet_support.
(remote_vkill): Use packet_support. Switch on the result of
packet_ok instead of checking whether the packet ended up
disabled.
(extended_remote_supports_disable_randomization): Use
packet_support.
(extended_remote_run): Switch on the result of packet_ok instead
of checking whether the packet ended up disabled.
(remote_insert_breakpoint, remote_remove_breakpoint)
(remote_insert_watchpoint, remote_remove_watchpoint)
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use
packet_support.
(remote_search_memory): Use packet_config_support.
(remote_get_thread_local_address, remote_get_tib_address)
(remote_hostio_send_command, remote_can_execute_reverse): Use
packet_support.
(remote_supports_cond_tracepoints)
(remote_supports_cond_breakpoints)
(remote_supports_fast_tracepoints)
(remote_supports_static_tracepoints)
(remote_supports_install_in_trace)
(remote_supports_enable_disable_tracepoint)
(remote_supports_string_tracing)
(remote_can_run_breakpoint_commands): Rewrite, checking whether
the packet config says the feature is enabled or disabled.
(remote_download_tracepoint, remote_trace_set_readonly_regions)
(remote_get_trace_status): Use packet_support.
(remote_set_disconnected_tracing): Adjust to check whether the
feature is enabled with packet_support.
(remote_set_trace_buffer_size, remote_use_agent)
(remote_can_use_agent, remote_supports_btrace): Use
packet_support.
(remote_enable_btrace, remote_disable_btrace, remote_read_btrace):
Use packet_config_support.
(remote_augmented_libraries_svr4_read): Rewrite, checking whether
the packet config says the feature is enabled or disabled.
(set_range_stepping): Use packet_support.
2014-04-25 Tom Tromey <tromey@redhat.com>
* cli/cli-cmds.c (_initialize_cli_cmds): Document "quit" command's

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,19 @@
2014-04-25 Pedro Alves <palves@redhat.com>
* gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to
user.
(top level): Test that "set remote conditional-breakpoints-packet
off" works as intended.
* gdb.base/dprintf.exp: Test that "set remote
breakpoint-commands-packet off" works as intended.
* gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled):
New function.
(top level): Call it.
* gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set
remote fast-tracepoints-packet off" works as intended.
* gdb.trace/qtro.exp (gdb_is_target_remote): Moved ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
2014-04-24 David Blaikie <dblaikie@gmail.com>
* gdb.base/catch-syscall.c: Make unreferenced statics non-static to

View File

@ -35,10 +35,10 @@ gdb_test_no_output $test_auto
# If target-side condition evaluation is not supported, this warning will be
# displayed.
set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n"
set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead."
gdb_test_multiple $test_target $test_target {
-re "$warning$gdb_prompt $" {
-re "$warning\r\n$gdb_prompt $" {
unsupported $test_target
return -1
}
@ -48,6 +48,20 @@ gdb_test_multiple $test_target $test_target {
}
}
# We now know that the target supports target-side conditional
# evaluation. Now make sure we can force-disable the
# ConditionalBreakpoints RSP feature.
if [gdb_is_target_remote] {
gdb_test_no_output "set remote conditional-breakpoints-packet off"
gdb_test $test_target "$warning" \
"set breakpoint condition-evaluation target, with support disabled"
# Confirm we can re-enable it.
gdb_test_no_output "set remote conditional-breakpoints-packet on"
gdb_test_no_output $test_target "restore $test_target"
}
# Test setting a condition in a breakpoint. BREAK_COMMAND is the
# break/hwatch command to test.
#

View File

@ -153,3 +153,13 @@ if $target_can_dprintf {
gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \
"Set dprintf style to an unrecognized type"
# Test that force-disabling the BreakpointCommands RSP feature works
# as expected. dprintf relies on support for target-side breakpoint
# commands --- use it as proxy.
if [gdb_is_target_remote] {
gdb_test_no_output "set remote breakpoint-commands-packet off"
gdb_test "set dprintf-style agent" \
"warning: Target cannot run dprintf commands.*" \
"set dprintf-style agent, with feature disabled"
}

View File

@ -282,8 +282,71 @@ proc tracepoint_change_loc_2 { trace_type } {
}
}
# Test that setting a tracepoint while the trace experiment is ongoing
# doesn't work when we force-disable the InstallInTrace RSP feature.
proc tracepoint_install_in_trace_disabled { trace_type } {
with_test_prefix "InstallInTrace disabled: $trace_type" {
global testfile
global srcfile
global pcreg
global gdb_prompt
clean_restart ${testfile}
if ![runto_main] {
fail "Can't run to main"
return -1
}
# This test only makes sense with the remote target.
if ![gdb_is_target_remote] {
return
}
gdb_test_no_output "delete break 1"
# Set a tracepoint we'll never meet. Just to avoid the
# complain after `tstart' later.
gdb_test "next" ".*"
gdb_test "trace main" \
"Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
"set tracepoint on main"
gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
"breakpoint on marker"
gdb_test_no_output "tstart"
# Force-disable the InstallInTrace RSP feature.
gdb_test_no_output "set remote install-in-trace-packet off"
# Set a tracepoint while a trace experiment is ongoing.
gdb_test "${trace_type} set_tracepoint" \
"racepoint .* at .* set_tracepoint.*" \
"set tracepoint on set_tracepoint"
gdb_trace_setactions "set action for tracepoint" "" \
"collect \$$pcreg" "^$"
# Make sure the tracepoint is _not_ installed on the target.
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*installed on target.*\<MULTIPLE\>.*4\.1.* in func4.*not installed on target.*4\.2.* in func4.*not installed on target.*" \
"tracepoint is not installed"
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
"continue to marker"
gdb_test_no_output "tstop"
# Nothing should have been collected.
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
}
}
tracepoint_change_loc_1 "trace"
tracepoint_change_loc_2 "trace"
tracepoint_install_in_trace_disabled "trace"
# Re-compile test case with IPA.
set libipa [get_in_proc_agent]
@ -297,3 +360,4 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
tracepoint_change_loc_1 "ftrace"
tracepoint_change_loc_2 "ftrace"
tracepoint_install_in_trace_disabled "ftrace"

View File

@ -159,6 +159,22 @@ proc test_fast_tracepoints {} {
"look at collected local, second time"
}
# If debugging with the remote target, try force disabling the
# fast tracepoints RSP feature, and confirm fast tracepoints
# can no longer be downloaded.
set test "fast tracepoint could not be downloaded with the feature disabled"
if [gdb_is_target_remote] {
gdb_test "set remote fast-tracepoints-packet off"
gdb_test_multiple "tstart" $test {
-re "warning: Target does not support fast tracepoints, downloading .* as regular tracepoint.*\r\n$gdb_prompt $" {
pass $test
}
}
} else {
unsupported $test
}
}
}