Skip to content

Commit

Permalink
Allow Perfetto traces without specifying an application.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuetschard committed Apr 5, 2019
1 parent 4367d9f commit 3d8bc1c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
7 changes: 4 additions & 3 deletions gapic/src/main/com/google/gapid/views/TracerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,10 @@ protected String formatTraceName(String name) {
}

public boolean isReady() {
return getSelectedDevice() != null && getSelectedApi() != null &&
!traceTarget.getText().isEmpty() && !directory.getText().isEmpty() &&
!file.getText().isEmpty();
TraceTypeCapabilities config = getSelectedApi();
return getSelectedDevice() != null && config != null &&
(!config.getRequiresApplication() || !traceTarget.getText().isEmpty()) &&
!directory.getText().isEmpty() && !file.getText().isEmpty();
}

public void addModifyListener(Listener listener) {
Expand Down
2 changes: 2 additions & 0 deletions gapis/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,8 @@ message TraceTypeCapabilities {
FeatureStatus mid_execution_capture_support = 3;
// Whether unsupported extensions can be enabled.
bool can_enable_unsupported_extensions = 4;
// Does this trace require starting an application.
bool requires_application = 6;
}

// GetTimestampsRequest is the request send to server to get the timestamps for
Expand Down
32 changes: 17 additions & 15 deletions gapis/trace/android/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,26 +449,28 @@ func (t *androidTracer) SetupTrace(ctx context.Context, o *service.TraceOptions)
match[1], match[3],
strings.Join(lines, "\n "))
}
} else {
} else if o.Type != service.TraceType_Perfetto || len(o.GetUri()) != 0 {
return ret, nil, fmt.Errorf("Could not find package matching %s", o.GetUri())
}

if !pkg.Debuggable {
err = t.b.Root(ctx)
switch err {
case nil:
case adb.ErrDeviceNotRooted:
return ret, cleanup.Invoke(ctx), err
default:
return ret, cleanup.Invoke(ctx), fmt.Errorf("Failed to restart ADB as root: %v", err)
if pkg != nil {
if !pkg.Debuggable {
err = t.b.Root(ctx)
switch err {
case nil:
case adb.ErrDeviceNotRooted:
return ret, cleanup.Invoke(ctx), err
default:
return ret, cleanup.Invoke(ctx), fmt.Errorf("Failed to restart ADB as root: %v", err)
}
log.I(ctx, "Device is rooted")
}
log.I(ctx, "Device is rooted")
}

if o.ClearCache {
log.I(ctx, "Clearing package cache")
if err := pkg.ClearCache(ctx); err != nil {
return ret, nil, err
if o.ClearCache {
log.I(ctx, "Clearing package cache")
if err := pkg.ClearCache(ctx); err != nil {
return ret, nil, err
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions gapis/trace/tracer/default_api_trace_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func VulkanTraceOptions() *service.TraceTypeCapabilities {
CanDisablePcs: false,
MidExecutionCaptureSupport: service.FeatureStatus_Supported,
CanEnableUnsupportedExtensions: true,
RequiresApplication: true,
}
}

Expand All @@ -37,6 +38,7 @@ func GLESTraceOptions() *service.TraceTypeCapabilities {
CanDisablePcs: true,
MidExecutionCaptureSupport: service.FeatureStatus_Experimental,
CanEnableUnsupportedExtensions: false,
RequiresApplication: true,
}
}

Expand All @@ -47,5 +49,6 @@ func PerfettoTraceOptions() *service.TraceTypeCapabilities {
CanDisablePcs: false,
MidExecutionCaptureSupport: service.FeatureStatus_Supported,
CanEnableUnsupportedExtensions: false,
RequiresApplication: false,
}
}

0 comments on commit 3d8bc1c

Please sign in to comment.