Commit 7cf8b99a authored by Karel Král's avatar Karel Král Committed by Commit Bot

Trace mojo async response parameters

Implement tracing of mojo async response parameters. Add a
|parameter_group| argument to |trace_event| macro to provide more
flexibility when naming the traced parameters.

Thus provide debugging information for asynchronous response parameters
as well.

Bug: 1103623
Change-Id: I7e38d8cc53ba8eff30c207defc0467674be50f3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339632
Commit-Queue: Karel Král <karelkral@google.com>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797271}
parent b773b788
...@@ -121,8 +121,10 @@ bool {{proxy_name}}::{{method.name}}( ...@@ -121,8 +121,10 @@ bool {{proxy_name}}::{{method.name}}(
#if BUILDFLAG(MOJO_TRACE_ENABLED) #if BUILDFLAG(MOJO_TRACE_ENABLED)
{%- set qualified_method_name = "%s::%s::%s" % (namespace_as_string, {%- set qualified_method_name = "%s::%s::%s" % (namespace_as_string,
class_name, method.name) %} class_name, method.name) %}
{{interface_macros.trace_event("param_", method.parameters, {{interface_macros.trace_event(prefix="param_",
qualified_method_name, method_parameters=method.parameters,
method_name=qualified_method_name,
parameter_group="input_parameters",
trace_event_type='_BEGIN')}} trace_event_type='_BEGIN')}}
#endif #endif
const bool kExpectsResponse = true; const bool kExpectsResponse = true;
...@@ -156,8 +158,10 @@ bool {{proxy_name}}::{{method.name}}( ...@@ -156,8 +158,10 @@ bool {{proxy_name}}::{{method.name}}(
{%- endfor %})); {%- endfor %}));
ignore_result(receiver_->AcceptWithResponder(&message, std::move(responder))); ignore_result(receiver_->AcceptWithResponder(&message, std::move(responder)));
#if BUILDFLAG(MOJO_TRACE_ENABLED) #if BUILDFLAG(MOJO_TRACE_ENABLED)
{{interface_macros.trace_event("out_param_", method.response_parameters, {{interface_macros.trace_event(prefix="out_param_",
qualified_method_name, method_parameters=method.response_parameters,
method_name=qualified_method_name,
parameter_group="sync_response_parameters",
trace_event_type='_END', trace_event_type='_END',
dereference_parameters=True)}} dereference_parameters=True)}}
#endif #endif
...@@ -170,8 +174,10 @@ void {{proxy_name}}::{{method.name}}( ...@@ -170,8 +174,10 @@ void {{proxy_name}}::{{method.name}}(
#if BUILDFLAG(MOJO_TRACE_ENABLED) #if BUILDFLAG(MOJO_TRACE_ENABLED)
{%- set qualified_method_name = "%s::%s::%s" % (namespace_as_string, class_name, {%- set qualified_method_name = "%s::%s::%s" % (namespace_as_string, class_name,
method.name) %} method.name) %}
{{interface_macros.trace_event("in_", method.parameters, {{interface_macros.trace_event(prefix="in_",
qualified_method_name)}} method_parameters=method.parameters,
method_name=qualified_method_name,
parameter_group="input_parameters")}}
#endif #endif
{%- if method.response_parameters != None %} {%- if method.response_parameters != None %}
const bool kExpectsResponse = true; const bool kExpectsResponse = true;
...@@ -327,6 +333,16 @@ bool {{class_name}}_{{method.name}}_ForwardToCallback::Accept( ...@@ -327,6 +333,16 @@ bool {{class_name}}_{{method.name}}_ForwardToCallback::Accept(
void {{class_name}}_{{method.name}}_ProxyToResponder::Run( void {{class_name}}_{{method.name}}_ProxyToResponder::Run(
{{interface_macros.declare_params("in_", method.response_parameters)}}) { {{interface_macros.declare_params("in_", method.response_parameters)}}) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
{%- set qualified_method_name = "(Impl)%s::%s::%sCallback"
% (namespace_as_string, class_name, method.name) %}
{{interface_macros.trace_event(prefix="in_",
method_parameters=method.response_parameters,
method_name=qualified_method_name,
parameter_group="async_response_parameters",
trace_event_type='_BEGIN',
dereference_parameters=False)}}
#endif
{%- if method|method_supports_lazy_serialization %} {%- if method|method_supports_lazy_serialization %}
const bool kSerialize = responder_->PrefersSerializedMessages(); const bool kSerialize = responder_->PrefersSerializedMessages();
auto message = {{response_message_typename}}::Build(kSerialize, is_sync_ auto message = {{response_message_typename}}::Build(kSerialize, is_sync_
...@@ -341,8 +357,8 @@ void {{class_name}}_{{method.name}}_ProxyToResponder::Run( ...@@ -341,8 +357,8 @@ void {{class_name}}_{{method.name}}_ProxyToResponder::Run(
{%- endif %} {%- endif %}
#if BUILDFLAG(MOJO_TRACE_ENABLED) #if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1("mojom", "(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}Callback", TRACE_EVENT_END1("mojom", "{{qualified_method_name}}", "message",
"message", message.name()); message.name());
#endif #endif
#if defined(ENABLE_IPC_FUZZER) #if defined(ENABLE_IPC_FUZZER)
......
...@@ -24,7 +24,7 @@ base::OnceCallback<void( ...@@ -24,7 +24,7 @@ base::OnceCallback<void(
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{%- macro trace_event(prefix, method_parameters, qualified_method_name, {%- macro trace_event(prefix, method_parameters, method_name, parameter_group,
trace_event_type='', dereference_parameters=False) -%} trace_event_type='', dereference_parameters=False) -%}
{#- This macro assumes that the argument names are the ones declared by -#} {#- This macro assumes that the argument names are the ones declared by -#}
{#- |declare_request_params/declare_sync_method_params|. Namely the |prefix| -#} {#- |declare_request_params/declare_sync_method_params|. Namely the |prefix| -#}
...@@ -40,12 +40,7 @@ base::OnceCallback<void( ...@@ -40,12 +40,7 @@ base::OnceCallback<void(
{#- |dereference_parameters| the parameters type is actually |kind*|. -#} {#- |dereference_parameters| the parameters type is actually |kind*|. -#}
{%- if method_parameters -%} {%- if method_parameters -%}
TRACE_EVENT{{trace_event_type}}1( TRACE_EVENT{{trace_event_type}}1(
{%- if trace_event_type=='' or trace_event_type=='_BEGIN' -%} "mojom", "{{method_name}}", "{{parameter_group}}",
{%- set parameter_group = 'input_parameters' -%}
{%- else -%}
{%- set parameter_group = 'response_parameters' -%}
{%- endif %}
"mojom", "{{qualified_method_name}}", "{{parameter_group}}",
[&](){ [&](){
auto value = std::make_unique<base::trace_event::TracedValue>(); auto value = std::make_unique<base::trace_event::TracedValue>();
base::trace_event::TracedValue* raw_value = value.get(); base::trace_event::TracedValue* raw_value = value.get();
...@@ -75,7 +70,7 @@ base::OnceCallback<void( ...@@ -75,7 +70,7 @@ base::OnceCallback<void(
return value; return value;
}()); }());
{%- else -%} {#- if method_parameters -#} {%- else -%} {#- if method_parameters -#}
TRACE_EVENT{{trace_event_type}}0("mojom", "{{qualified_method_name}}"); TRACE_EVENT{{trace_event_type}}0("mojom", "{{method_name}}");
{%- endif %} {#- if method_parameters #} {%- endif %} {#- if method_parameters #}
{%- endmacro -%} {%- endmacro -%}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment