[𝘀𝗽𝗿] initial version Created using spr 1.3.7
diff --git a/docs/contributing/build-instructions.md b/docs/contributing/build-instructions.md index 627dc6f..26c30b6 100644 --- a/docs/contributing/build-instructions.md +++ b/docs/contributing/build-instructions.md
@@ -89,8 +89,7 @@ traced \ # Tracing service. traced_probes \ # Ftrace interop and /proc poller. perfetto \ # Cmdline client. - trace_processor_shell \ # Trace parsing. - traceconv # Trace conversion. + trace_processor_shell # Trace parsing and conversion. ... ``` @@ -167,8 +166,8 @@ The following targets are supported on Windows: -- `trace_processor_shell`: the trace importer and SQL query engine. -- `traceconv`: the trace conversion tool. +- `trace_processor_shell`: the trace importer, SQL query engine and trace + conversion tool. - `traced` and `perfetto`: the tracing service and cmdline client. They use an alternative implementation of the [inter-process tracing protocol](/docs/design-docs/api-and-abi.md#tracing-protocol-abi) based on a TCP socket and named shared memory. This configuration is only for @@ -362,7 +361,7 @@ In case of cross-compilation, the GN variables have the following semantic: `ar`, `cc`, `cxx`, `linker` refer to the _host_ toolchain (sometimes also called _build_ toolchain). This toolchain is used to build: (i) auxiliary tools -(e.g. the `traceconv` conversion util) and (ii) executable artifacts that are +(e.g. the `trace_processor` conversion util) and (ii) executable artifacts that are used during the rest of the build process for the target (e.g., the `protoc` compiler or the `protozero_plugin` protoc compiler plugin).
diff --git a/docs/data-sources/funcgraph.md b/docs/data-sources/funcgraph.md index 38283d9..0d6d78d 100644 --- a/docs/data-sources/funcgraph.md +++ b/docs/data-sources/funcgraph.md
@@ -26,7 +26,7 @@ up as a raw hexadecimal address. See [Symbolization: kernel symbols](/docs/learning-more/symbolization.md#ftrace) for why kernel symbols must be resolved at record time and cannot be added - afterwards with `traceconv bundle`. + afterwards with `trace_processor bundle`. - On **Android**, function graph tracing is available only on `debuggable` (userdebug/eng) builds, and was introduced in Android U. - `traced_probes` must run as root (or `kptr_restrict` lowered), both to read
diff --git a/docs/data-sources/native-heap-profiler.md b/docs/data-sources/native-heap-profiler.md index 1f110f3..5487fe5 100644 --- a/docs/data-sources/native-heap-profiler.md +++ b/docs/data-sources/native-heap-profiler.md
@@ -311,7 +311,7 @@ ## Symbolization and deobfuscation If your profile shows raw addresses or obfuscated Java/Kotlin names, run -`traceconv bundle` against the collected trace to produce an enriched +`trace_processor bundle` against the collected trace to produce an enriched archive. See [Symbolization and deobfuscation](/docs/learning-more/symbolization.md) for the full workflow, including the legacy `PERFETTO_BINARY_PATH` / `PERFETTO_PROGUARD_MAP` approach. @@ -369,7 +369,7 @@ blocks the very first `malloc` until heapprofd has fully attached, so every allocation is correctly tracked. 4. Waits for the target to exit (or `Ctrl-C` from you), then runs - `traceconv` to produce gzipped pprof files alongside the raw trace. + `trace_processor` to produce gzipped pprof files alongside the raw trace. If `-n` / `--name` is omitted, the process name defaults to the basename of the binary you passed after `--`. @@ -496,11 +496,11 @@ ## Convert to pprof -You can use [traceconv](/docs/quickstart/traceconv.md) to convert the heap +You can use [trace_processor](/docs/quickstart/traceconv.md) to convert the heap dumps in a trace into the [pprof](https://github.com/google/pprof) format: ```bash -tools/traceconv profile /tmp/profile +tools/trace_processor convert profile /tmp/profile ``` This will create a directory in `/tmp/` containing the heap dumps. Run:
diff --git a/docs/getting-started/cpu-profiling.md b/docs/getting-started/cpu-profiling.md index c2f21e3..9291459 100644 --- a/docs/getting-started/cpu-profiling.md +++ b/docs/getting-started/cpu-profiling.md
@@ -305,7 +305,7 @@ access to the debug version of the libraries (with symbol data), you can symbolise the profile on the host by following the [symbolization and deobfuscation guide](/docs/learning-more/symbolization.md). -`traceconv bundle` is the recommended entry point. +`trace_processor bundle` is the recommended entry point. TAB: Linux (command line) @@ -339,10 +339,10 @@ UI](https://ui.perfetto.dev). To convert the trace into per-process profiles in the "pprof" format, you can -use the `traceconv` script as follows: +use the `trace_processor` tool as follows: ```bash -python3 traceconv profile --perf /tmp/trace.pb +python3 trace_processor convert profile --perf /tmp/trace.pb ``` #### Missing symbols and deobfuscation @@ -351,7 +351,7 @@ access to the debug version of the libraries (with symbol data), you can symbolise the profile after the fact by following the [symbolization and deobfuscation guide](/docs/learning-more/symbolization.md). -`traceconv bundle` is the recommended entry point. +`trace_processor bundle` is the recommended entry point. </tabs?>
diff --git a/docs/getting-started/linux-cookbook.md b/docs/getting-started/linux-cookbook.md index 5de0837..8511ab3 100644 --- a/docs/getting-started/linux-cookbook.md +++ b/docs/getting-started/linux-cookbook.md
@@ -27,12 +27,12 @@ curl -LO https://get.perfetto.dev/tracebox chmod +x tracebox ``` -- **`traceconv`**: a host-side toolkit for converting and, importantly here, +- **`trace_processor`**: a host-side toolkit for converting and, importantly here, symbolizing traces. It is a thin Python wrapper that downloads the right native binary for your platform on first use. ```bash - curl -LO https://get.perfetto.dev/traceconv - chmod +x traceconv + curl -LO https://get.perfetto.dev/trace_processor + chmod +x trace_processor ``` Recording from ftrace and `perf_event_open` needs elevated privileges. The @@ -173,21 +173,21 @@ At this point **kernel** frames are already symbolized (resolved on-device from kallsyms), but **userspace** frames are still raw addresses. -**4. Bake in userspace symbols** with `traceconv bundle`. It auto-discovers the +**4. Bake in userspace symbols** with `trace_processor bundle`. It auto-discovers the binaries that were loaded (using the absolute paths recorded in the trace, which works well when you profiled on the same machine), and writes a single self-contained trace: ```bash # llvm-symbolizer must be on $PATH, e.g. `sudo apt install llvm`. -./traceconv bundle /tmp/trace.pftrace /tmp/trace.bundle +./trace_processor bundle /tmp/trace.pftrace /tmp/trace.bundle ``` If your symbols live elsewhere (a build host, a `.debug` directory, an embedded sysroot), point `bundle` at them: ```bash -./traceconv bundle \ +./trace_processor bundle \ --symbol-paths /path/to/sysroot/usr/lib/debug,/path/to/build/out \ --verbose \ /tmp/trace.pftrace /tmp/trace.bundle @@ -202,7 +202,7 @@ To instead produce aggregated [pprof](https://github.com/google/pprof) profiles: ```bash -./traceconv profile --perf /tmp/trace.pftrace +./trace_processor convert profile --perf /tmp/trace.pftrace ``` ## Recipe: Native heap (memory) profiling {#heap-profiling} @@ -277,7 +277,7 @@ requirements (`CONFIG_FUNCTION_GRAPH_TRACER`), the filtering options, and how the calls are visualised. Note that, unlike the [CPU profile](#cpu-profiling) recipe, these kernel symbols come from `symbolize_ksyms` and **cannot** be added later -with `traceconv bundle`. +with `trace_processor bundle`. ## Recipe: Finding why a thread is blocked {#blocked-thread} @@ -329,7 +329,7 @@ ``` Record and symbolize exactly as in the [CPU profiling recipe](#cpu-profiling) -(`sudo ./tracebox -c blocked.cfg --txt -o ...`, then `./traceconv bundle ...`). +(`sudo ./tracebox -c blocked.cfg --txt -o ...`, then `./trace_processor bundle ...`). For a full worked example, including filtering on both `sched_switch` and `sched_waking` and how to reason about the captured callstacks, see the
diff --git a/docs/getting-started/memory-profiling.md b/docs/getting-started/memory-profiling.md index 3593ce7..45a9063 100644 --- a/docs/getting-started/memory-profiling.md +++ b/docs/getting-started/memory-profiling.md
@@ -191,7 +191,7 @@ first `malloc` until it has attached, so every allocation is captured. When your binary exits (or you press `Ctrl-C` to stop early) the script -runs `traceconv` to produce gzipped pprof files alongside the raw trace and +runs `trace_processor` to produce gzipped pprof files alongside the raw trace and prints the output directory. A typical end-to-end run looks like this: ```text
diff --git a/docs/learning-more/symbolization.md b/docs/learning-more/symbolization.md index fbeb47d..b409de9 100644 --- a/docs/learning-more/symbolization.md +++ b/docs/learning-more/symbolization.md
@@ -18,14 +18,14 @@ Match your trace to one of the categories below and follow the link. Picking the wrong workflow is the most common reason symbols "don't work". The key rule of -thumb: **userspace** symbols are resolved offline on the host (`traceconv +thumb: **userspace** symbols are resolved offline on the host (`trace_processor bundle`), while **kernel** symbols are always resolved at record time on the device (Perfetto never stores absolute kernel addresses, to avoid disclosing [KASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization)). | Your trace contains… | Examples | What you need | | --- | --- | --- | -| **Callstacks** | Native heap profiler, `traced_perf` / Linux perf CPU sampling, Java heap dumps | [Symbolization & deobfuscation](#callstacks). Userspace frames are resolved offline (`traceconv bundle`); kernel frames are symbolized on-device automatically. | +| **Callstacks** | Native heap profiler, `traced_perf` / Linux perf CPU sampling, Java heap dumps | [Symbolization & deobfuscation](#callstacks). Userspace frames are resolved offline (`trace_processor bundle`); kernel frames are symbolized on-device automatically. | | **Kernel ftrace events** | `function_graph` tracing, `sched_blocked_reason`, kprobes | [Record-time `symbolize_ksyms`](#ftrace). These addresses **cannot** be symbolized after the fact. | | **Userspace event names** | atrace slice names, ART method tracing | [Not currently supported](#userspace-event-names) for offline deobfuscation; emit readable names at instrumentation time. | @@ -45,14 +45,14 @@ [Kernel frames in callstacks](#callstack-kernel-frames) at the end of this section. -### {#option-1-traceconv-bundle} Option 1: `traceconv bundle` (recommended) +### {#option-1-traceconv-bundle} Option 1: `trace_processor bundle` (recommended) -`traceconv bundle` is a one-shot command that takes a trace and produces an -**enriched trace**: the original trace plus all the symbol and deobfuscation +`trace_processor bundle` is a one-shot command that takes a trace and produces +an **enriched trace**: the original trace plus all the symbol and deobfuscation data needed to analyse it, packaged together in a single file. ```bash -traceconv bundle input.perfetto-trace enriched-trace +trace_processor bundle input.perfetto-trace enriched-trace ``` The enriched trace can be opened in the [Perfetto UI](https://ui.perfetto.dev) @@ -94,7 +94,7 @@ When auto-discovery isn't enough: ```bash -traceconv bundle \ +trace_processor bundle \ --symbol-paths /path/to/symbols1,/path/to/symbols2 \ --proguard-map com.example.app=/path/to/mapping.txt \ --verbose \ @@ -116,22 +116,22 @@ - `--verbose`: print every path tried and every library looked up — useful when debugging "could not find" errors. -### {#option-2-legacy-traceconv-symbolize-deobfuscate} Option 2: Legacy `traceconv symbolize` / `deobfuscate` +### {#option-2-legacy-traceconv-symbolize-deobfuscate} Option 2: Legacy `trace_processor util symbolize` / `util deobfuscate` NOTE: This flow is kept for backwards compatibility with existing scripts and CI pipelines that already depend on it. For new usage, always prefer [Option 1](#option-1-traceconv-bundle) — it is simpler, has auto-discovery, and works on non-Perfetto trace formats. -The older `traceconv symbolize` and `traceconv deobfuscate` subcommands -produce standalone symbol and deobfuscation files driven entirely by -environment variables, which must then be concatenated onto the trace by -hand. +The older `trace_processor util symbolize` and `trace_processor util +deobfuscate` subcommands produce standalone symbol and deobfuscation files +driven entirely by environment variables, which must then be concatenated onto +the trace by hand. #### Native symbolization -All tools (`traceconv`, `trace_processor_shell`, the `heap_profile` script) -honour the `PERFETTO_BINARY_PATH` environment variable: +All tools (`trace_processor`, the `heap_profile` script) honour the +`PERFETTO_BINARY_PATH` environment variable: ```bash PERFETTO_BINARY_PATH=somedir tools/heap_profile android --name ${NAME} @@ -140,7 +140,7 @@ To produce a standalone symbol file for a trace you already collected: ```bash -PERFETTO_BINARY_PATH=somedir traceconv symbolize raw-trace > symbols +PERFETTO_BINARY_PATH=somedir trace_processor util symbolize raw-trace > symbols ``` Alternatively, set `PERFETTO_SYMBOLIZER_MODE=index` and the symbolizer will @@ -161,7 +161,7 @@ ```bash PERFETTO_PROGUARD_MAP=com.example.pkg=proguard_map.txt \ - traceconv deobfuscate ${TRACE} > deobfuscation_map + trace_processor util deobfuscate ${TRACE} > deobfuscation_map ``` #### Attaching the output to a trace @@ -242,7 +242,7 @@ `readelf -n /path/to/somelib.so`. If they do not match, the copy on disk is a different build than the one on device and cannot be used. -Re-running `traceconv bundle` with `--verbose` prints every path tried, which +Re-running `trace_processor bundle` with `--verbose` prints every path tried, which usually makes it clear whether the file was missing entirely or found with the wrong Build ID. @@ -294,7 +294,7 @@ the trace. It requires that either `traced_probes` runs as root or `kptr_restrict` has been lowered manually. -WARNING: `traceconv bundle` and the offline symbolizers above **cannot** recover +WARNING: `trace_processor bundle` and the offline symbolizers above **cannot** recover kernel symbols. Perfetto deliberately does not store absolute kernel addresses in the trace, because doing so would defeat [KASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization) and
diff --git a/docs/quickstart/traceconv.md b/docs/quickstart/traceconv.md index 8872c5b..9a0c0e8 100644 --- a/docs/quickstart/traceconv.md +++ b/docs/quickstart/traceconv.md
@@ -1,31 +1,27 @@ # Converting from Perfetto to other trace formats Perfetto's native protobuf trace format can be converted to other formats using -the `traceconv` utility. `traceconv` also doubles as a toolkit for -symbolizing/deobfuscating traces and for a handful of smaller trace-editing -utilities. +the `convert` subcommand of `trace_processor`. + +> NOTE: This functionality used to live in a separate `traceconv` tool. That +> tool has been folded into `trace_processor`. The `traceconv` download still +> works as a back-compatible alias (it now fetches `trace_processor` and runs +> it in this mode), but new scripts and docs should use `trace_processor`.  +> To attach native symbols or ProGuard/R8 deobfuscation mappings to a trace, +> see [Symbolization and deobfuscation](/docs/learning-more/symbolization.md) +> instead (the `bundle` and `util` subcommands). This page covers only format +> conversion. + ## Prerequisites - A host running Linux, macOS or Windows -- Python 3 (only required if using the `traceconv` wrapper script below; on +- Python 3 (only required if using the `trace_processor` wrapper script below; on Windows this also requires `curl`, which ships with Windows 10 and later) - A Perfetto protobuf trace file -`traceconv` has three groups of modes: - -- **Format conversion** — convert a Perfetto protobuf trace into another - trace format (Chrome JSON, systrace, pprof, Firefox profiler, etc.). -- **Symbolization and deobfuscation** — attach native symbols and - ProGuard/R8 mappings to a trace. **In almost all cases you should use - `bundle`** (see below), which packages the trace and all its debug - artifacts into a single self-contained TAR — this is the recommended way - to share or archive a trace. -- **Utilities** — smaller helpers (protobuf-text ↔ binary conversion, - packet decompression). - ## Usage To use the latest binaries: @@ -35,31 +31,31 @@ TAB: Linux / macOS ```bash -curl -LO https://get.perfetto.dev/traceconv -chmod +x traceconv -./traceconv MODE [OPTIONS] [input_file] [output_file] +curl -LO https://get.perfetto.dev/trace_processor +chmod +x trace_processor +./trace_processor convert <format> [OPTIONS] [input_file] [output_file] ``` TAB: Windows ```powershell -curl.exe -LO https://get.perfetto.dev/traceconv -python traceconv MODE [OPTIONS] [input_file] [output_file] +curl.exe -LO https://get.perfetto.dev/trace_processor +python trace_processor convert <format> [OPTIONS] [input_file] [output_file] ``` </tabs?> -The `traceconv` script is a thin Python wrapper that downloads and caches -the correct native binary for your platform (including `traceconv.exe` on -Windows) under `~/.local/share/perfetto/prebuilts` on first use. +The `trace_processor` script is a thin Python wrapper that downloads and caches +the correct native binary for your platform under +`~/.local/share/perfetto/prebuilts` on first use. -`traceconv` reads from stdin and writes to stdout when the input or output -paths are omitted (or passed as `-`). Run `./traceconv` with no arguments -to print the full list of modes and options supported by your version. +`convert` reads from stdin and writes to stdout when the input or output paths +are omitted (or passed as `-`). Run `./trace_processor help convert` to print +the full list of formats and options supported by your version. ## Format conversion -| Mode | Output | +| Format | Output | | ---------- | ------------------------------------------------------------ | | `text` | protobuf text format — a text representation of the protos | | `json` | Chrome JSON format, viewable in `chrome://tracing` | @@ -71,9 +67,9 @@ Examples: ```bash -./traceconv json trace.perfetto-trace trace.json -./traceconv systrace trace.perfetto-trace trace.html -./traceconv text trace.perfetto-trace trace.textproto +./trace_processor convert json trace.perfetto-trace trace.json +./trace_processor convert systrace trace.perfetto-trace trace.html +./trace_processor convert text trace.perfetto-trace trace.textproto ``` `profile` writes one or more `.pb` files into a directory (a random tmp @@ -81,9 +77,9 @@ `--output-dir` instead of a positional output path: ```bash -./traceconv profile --output-dir ./profiles trace.perfetto-trace -./traceconv profile --java-heap --pid 1234 --output-dir ./profiles trace.perfetto-trace -./traceconv profile --perf --timestamps 1000000,2000000 --output-dir ./profiles trace.perfetto-trace +./trace_processor convert profile --output-dir ./profiles trace.perfetto-trace +./trace_processor convert profile --java-heap --pid 1234 --output-dir ./profiles trace.perfetto-trace +./trace_processor convert profile --perf --timestamps 1000000,2000000 --output-dir ./profiles trace.perfetto-trace ``` Common options: @@ -102,77 +98,13 @@ - `--output-dir DIR` (for `profile`): output directory for the generated pprof files. -## Symbolization and deobfuscation - -These modes enrich a trace with native symbols and/or ProGuard/R8 -deobfuscation mappings. For background on how Perfetto discovers symbol -files and mapping files, see the -[Symbolization](https://perfetto.dev/docs/learning-more/symbolization) -reference. - -### `bundle` (recommended) - -**`bundle` is the recommended entry point for symbolization and -deobfuscation.** It packages the trace together with its native symbols -and ProGuard/R8 mappings into a single self-contained TAR, which is the -right artifact to share with teammates, attach to bugs, or archive for -later analysis. Prefer `bundle` over `symbolize`/`deobfuscate` unless you -have a specific reason not to. - -```bash -./traceconv bundle trace.perfetto-trace trace.bundle.tar - -# Provide extra symbol search paths or explicit ProGuard maps: -./traceconv bundle \ - --symbol-paths /path/to/symbols1,/path/to/symbols2 \ - --proguard-map com.example.app=/path/to/mapping.txt \ - trace.perfetto-trace trace.bundle.tar -``` - -`bundle`-specific options: - -- `--symbol-paths PATH1,PATH2,...` — additional paths to search for - symbols (on top of the automatic discovery). -- `--no-auto-symbol-paths` — disable automatic symbol path discovery. -- `--proguard-map [pkg=]PATH` — ProGuard/R8 `mapping.txt` for Java/Kotlin - deobfuscation. May be repeated; the `pkg=` prefix scopes the map to a - specific package. -- `--no-auto-proguard-maps` — disable automatic ProGuard/R8 mapping - discovery (e.g. Gradle project layout). -- `--verbose` — print more detailed output. - -Note: `bundle` requires real file paths for both the input and the output -— it does not accept stdin/stdout. - -### `symbolize` / `deobfuscate` (advanced) - -Lower-level building blocks for pipelines that cannot use `bundle`. Each -emits a stream of packets (symbols or deobfuscation mappings) to a -separate output file: - -```bash -./traceconv symbolize trace.perfetto-trace symbols.pb -./traceconv deobfuscate trace.perfetto-trace mappings.pb -``` - -Prefer `bundle` — it produces a single self-contained TAR instead of -leaving you with loose side-car files to manage. - -## Utilities - -| Mode | What it does | -| -------------------- | ----------------------------------------------------------- | -| `binary` | Convert a protobuf text-format trace back into binary form. | -| `decompress_packets` | Decompress compressed `TracePacket`s inside a trace. | - -```bash -./traceconv binary trace.textproto trace.perfetto-trace -./traceconv decompress_packets trace.perfetto-trace trace.decompressed -``` +For the inverse of `convert text` (turning a text-format trace back into +binary) and other low-level trace helpers, see `trace_processor help util`. ## Opening in the legacy systrace UI If you just want to open a Perfetto trace with the legacy (Catapult) trace viewer, you can just navigate to [ui.perfetto.dev](https://ui.perfetto.dev), and -use the _"Open with legacy UI"_ link. This runs `traceconv` within the browser -using WebAssembly and passes the converted trace seamlessly to chrome://tracing. +use the _"Open with legacy UI"_ link. This runs the trace conversion within the +browser using WebAssembly and passes the converted trace seamlessly to +chrome://tracing.
diff --git a/docs/reference/heap_profile-cli.md b/docs/reference/heap_profile-cli.md index e0b1011..a7b6b82 100644 --- a/docs/reference/heap_profile-cli.md +++ b/docs/reference/heap_profile-cli.md
@@ -41,7 +41,7 @@ [--no-block-client] [--idle-allocations] [--dump-at-max] [--disable-fork-teardown] [--simpleperf] - [--traceconv-binary TRACECONV_BINARY] + [--trace-processor-binary TRACE_PROCESSOR_BINARY] [--no-annotations] [--print-config] [-o DIRECTORY] ``` @@ -53,7 +53,7 @@ [--block-client-timeout BLOCK_CLIENT_TIMEOUT] [--no-block-client] [--idle-allocations] [--dump-at-max] [--disable-fork-teardown] - [--traceconv-binary TRACECONV_BINARY] + [--trace-processor-binary TRACE_PROCESSOR_BINARY] [--no-annotations] [--print-config] [-o DIRECTORY] [--preload-library PRELOAD_LIBRARY] [--tracebox-binary TRACEBOX_BINARY] @@ -122,8 +122,8 @@ `--shmem-size` : Size of buffer between client and heapprofd. Default 8MiB. Needs to be a power of two multiple of 4096, at least 8192. -`--traceconv-binary` -: Path to local traceconv. For debugging. +`--trace-processor-binary` +: Path to local trace_processor. For debugging. `-h`, `--help` : Show help message and exit.
diff --git a/examples/sdk/README.md b/examples/sdk/README.md index 038ee1f..becd446 100644 --- a/examples/sdk/README.md +++ b/examples/sdk/README.md
@@ -117,11 +117,11 @@ ``` The program generates a trace file in `example_custom_data_source.perfetto-trace`, -which we can examine using Perfetto's `traceconv` tool to show the trace +which we can examine using Perfetto's `trace_processor` tool to show the trace packet written by the custom data source: ```bash -traceconv text example_custom_data_source.perfetto-trace +trace_processor convert text example_custom_data_source.perfetto-trace ... packet { trusted_uid: 0
diff --git a/python/tools/cpu_profile.py b/python/tools/cpu_profile.py index 3723ecf..c3bda91 100644 --- a/python/tools/cpu_profile.py +++ b/python/tools/cpu_profile.py
@@ -31,7 +31,7 @@ import time import uuid -from perfetto.prebuilts.manifests.traceconv import * +from perfetto.prebuilts.manifests.trace_processor_shell import * from perfetto.prebuilts.perfetto_prebuilts import * # Used for creating directories, etc. @@ -394,17 +394,18 @@ adb_check_output(['adb', 'shell', 'rm', profile_device_path]) -def get_traceconv(): - """Sets up and returns the path to `traceconv`.""" +def get_trace_processor(): + """Sets up and returns the path to `trace_processor`.""" try: - traceconv = get_perfetto_prebuilt(TRACECONV_MANIFEST, soft_fail=True) + trace_processor = get_perfetto_prebuilt( + TRACE_PROCESSOR_SHELL_MANIFEST, soft_fail=True) except Exception as error: exit_with_bug_report(error) - if traceconv is None: + if trace_processor is None: exit_with_bug_report( - "Unable to download `traceconv` for symbolizing profiles.") + "Unable to download `trace_processor` for symbolizing profiles.") - return traceconv + return trace_processor def concatenate_files(files_to_concatenate, output_file): @@ -420,12 +421,13 @@ shutil.copyfileobj(input, output) -def symbolize_trace(traceconv, profile_target): +def symbolize_trace(trace_processor, profile_target): """Attempts symbolization of the recorded trace/profile, if symbols are available. Args: - traceconv: The path to the `traceconv` binary used for symbolization. + trace_processor: The path to the `trace_processor` binary used for + symbolization. profile_target: The directory where the recorded trace was output. Returns: @@ -439,11 +441,10 @@ if binary_path is not None: try: with open(os.path.join(profile_target, 'symbols'), 'w') as symbols_file: - return_code = subprocess.call([traceconv, 'symbolize', trace_file], - env=dict( - os.environ, - PERFETTO_BINARY_PATH=binary_path), - stdout=symbols_file) + return_code = subprocess.call( + [trace_processor, 'util', 'symbolize', trace_file], + env=dict(os.environ, PERFETTO_BINARY_PATH=binary_path), + stdout=symbols_file) except IOError as error: sys.exit("Unable to write symbols to disk: {}".format(error)) if return_code == 0: @@ -461,26 +462,27 @@ return trace_file -def generate_pprof_profiles(traceconv, trace_file, args): +def generate_pprof_profiles(trace_processor, trace_file, args): """Generates pprof profiles from the recorded trace. Args: - traceconv: The path to the `traceconv` binary used for generating profiles. + trace_processor: The path to the `trace_processor` binary used for + generating profiles. trace_file: The oath to the recorded and potentially symbolized trace file. Returns: The directory where pprof profiles are output. """ try: - conversion_args = [traceconv, 'profile', '--perf'] + ( + conversion_args = [trace_processor, 'convert', 'profile', '--perf'] + ( ['--no-annotations'] if args.no_annotations else []) + [trace_file] - traceconv_output = subprocess.check_output(conversion_args) + trace_processor_output = subprocess.check_output(conversion_args) except Exception as error: exit_with_bug_report( "Unable to extract profiles from trace: {}".format(error)) profiles_output_directory = None - for word in traceconv_output.decode('utf-8').split(): + for word in trace_processor_output.decode('utf-8').split(): if 'perf_profile-' in word: profiles_output_directory = word if profiles_output_directory is None: @@ -511,10 +513,11 @@ print(trace_config) return 0 record_trace(trace_config, profile_target) - traceconv = get_traceconv() - trace_file = symbolize_trace(traceconv, profile_target) + trace_processor = get_trace_processor() + trace_file = symbolize_trace(trace_processor, profile_target) copy_profiles_to_destination( - profile_target, generate_pprof_profiles(traceconv, trace_file, args)) + profile_target, generate_pprof_profiles(trace_processor, trace_file, + args)) return 0
diff --git a/python/tools/heap_profile.py b/python/tools/heap_profile.py index 9eacbab..6e8243e 100644 --- a/python/tools/heap_profile.py +++ b/python/tools/heap_profile.py
@@ -30,7 +30,7 @@ from perfetto.prebuilts.manifests.heapprofd_glibc_preload import * from perfetto.prebuilts.manifests.tracebox import * -from perfetto.prebuilts.manifests.traceconv import * +from perfetto.prebuilts.manifests.trace_processor_shell import * from perfetto.prebuilts.perfetto_prebuilts import * NULL = open(os.devnull) @@ -147,10 +147,10 @@ return result, action.option_strings[0].strip('-') -def process_trace(trace_file, profile_target, traceconv_binary, args, +def process_trace(trace_file, profile_target, trace_processor_binary, args, android_mode): - """Convert a raw trace to pprof via traceconv. Returns an exit code.""" - if traceconv_binary is None: + """Convert a raw trace to pprof via trace_processor. Returns an exit code.""" + if trace_processor_binary is None: print('Wrote profile to {}'.format(trace_file)) print( 'This file can be opened using the Perfetto UI, https://ui.perfetto.dev' @@ -171,10 +171,10 @@ if binary_path is not None: symbols_path = os.path.join(profile_target, 'symbols') with open(symbols_path, 'w') as fd: - ret = subprocess.call([traceconv_binary, 'symbolize', trace_file], - env=dict( - os.environ, PERFETTO_BINARY_PATH=binary_path), - stdout=fd) + ret = subprocess.call( + [trace_processor_binary, 'util', 'symbolize', trace_file], + env=dict(os.environ, PERFETTO_BINARY_PATH=binary_path), + stdout=fd) if ret == 0: concat_files.append(symbols_path) else: @@ -185,11 +185,10 @@ if proguard_map is not None: deobf_path = os.path.join(profile_target, 'deobfuscation-packets') with open(deobf_path, 'w') as fd: - ret = subprocess.call([traceconv_binary, 'deobfuscate', trace_file], - env=dict( - os.environ, - PERFETTO_PROGUARD_MAP=proguard_map), - stdout=fd) + ret = subprocess.call( + [trace_processor_binary, 'util', 'deobfuscate', trace_file], + env=dict(os.environ, PERFETTO_PROGUARD_MAP=proguard_map), + stdout=fd) if ret == 0: concat_files.append(deobf_path) else: @@ -209,12 +208,12 @@ out.write(buf) trace_file = symbolized_path - conversion_args = [traceconv_binary, 'profile'] + ( + conversion_args = [trace_processor_binary, 'convert', 'profile'] + ( ['--no-annotations'] if args.no_annotations else []) + [trace_file] - traceconv_output = subprocess.check_output( + trace_processor_output = subprocess.check_output( conversion_args, stderr=subprocess.STDOUT) profile_path = None - for word in traceconv_output.decode('utf-8').split(): + for word in trace_processor_output.decode('utf-8').split(): if 'heap_profile-' in word: profile_path = word if profile_path is None: @@ -251,7 +250,7 @@ return 0 -def linux_main(args, cfg, cmd, traceconv_binary): +def linux_main(args, cfg, cmd, trace_processor_binary): """Run a local heap profile session on Linux using LD_PRELOAD.""" tracebox_binary = args.tracebox_binary if tracebox_binary is None: @@ -330,7 +329,11 @@ perfetto_proc.wait() return process_trace( - trace_output, profile_target, traceconv_binary, args, android_mode=False) + trace_output, + profile_target, + trace_processor_binary, + args, + android_mode=False) def print_options(parser): @@ -461,7 +464,8 @@ help="Get simpleperf profile of heapprofd. This is " "only for heapprofd development.") common.add_argument( - "--traceconv-binary", help="Path to local trace to text. For debugging.") + "--trace-processor-binary", + help="Path to local trace_processor. For debugging.") common.add_argument( "--no-annotations", help="Do not suffix the pprof function names with Android ART mode " @@ -603,7 +607,7 @@ parser.print_help() return 1 - traceconv_binary = args.traceconv_binary + trace_processor_binary = args.trace_processor_binary if args.continuous_dump: target_cfg += CONTINUOUS_DUMP.format(dump_interval=args.continuous_dump) @@ -620,13 +624,14 @@ print(cfg) return 0 - # Do this AFTER print_config so we do not download traceconv only to + # Do this AFTER print_config so we do not download trace_processor only to # print out the config. - if traceconv_binary is None: - traceconv_binary = get_perfetto_prebuilt(TRACECONV_MANIFEST, soft_fail=True) + if trace_processor_binary is None: + trace_processor_binary = get_perfetto_prebuilt( + TRACE_PROCESSOR_SHELL_MANIFEST, soft_fail=True) if args.subcommand == 'host': - return linux_main(args, cfg, cmd, traceconv_binary) + return linux_main(args, cfg, cmd, trace_processor_binary) # --- Android path --- @@ -731,7 +736,7 @@ return process_trace( profile_host_path, profile_target, - traceconv_binary, + trace_processor_binary, args, android_mode=True)
diff --git a/tools/cpu_profile b/tools/cpu_profile index f30bd14..d5b9efb 100755 --- a/tools/cpu_profile +++ b/tools/cpu_profile
@@ -35,19 +35,19 @@ import time import uuid -# ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/traceconv.py +# ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/trace_processor_shell.py # This file has been generated by: tools/release/roll-prebuilts v56.1 -TRACECONV_MANIFEST = [{ +TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'arch': 'mac-amd64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11839400, + 13441096, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-amd64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-amd64/trace_processor_shell', 'sha256': - '7b696e45600d03fe95121cc5710852080331874396f17297610e829887300d7f', + '99227035e8256d46660c21e35e097188a31465e95accf334e094d31cd709065b', 'platform': 'darwin', 'machine': ['x86_64'] @@ -55,13 +55,13 @@ 'arch': 'mac-arm64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 10959176, + 12421992, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-arm64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-arm64/trace_processor_shell', 'sha256': - '99dd2ebf488af5591fb5d4be0aa1d84ac173ceed62b077dd73bfa0cff8531be4', + '64180e40f94fa8bded24dee1ba62985c0f9fc8c89047cd3218be25084a4b06a2', 'platform': 'darwin', 'machine': ['arm64'] @@ -69,13 +69,13 @@ 'arch': 'linux-amd64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 12057312, + 13687824, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-amd64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-amd64/trace_processor_shell', 'sha256': - '0d91b41016b86733e56ed641b8bf88ee4192e01470e7e5d5feb1ecb00401cdbc', + 'becb22d3f2c51dc234627a3ffd5b066602575b50ad4eb082815156f1bc7cb65a', 'platform': 'linux', 'machine': ['x86_64'] @@ -83,13 +83,13 @@ 'arch': 'linux-arm', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 9103156, + 10115224, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm/trace_processor_shell', 'sha256': - 'b68f21399e4e49b81631f0e720dd1e626562020ca25b3220df4f88ba96c73eea', + '561d778f65bed8ce5c3f62043e63248d7490390a5137e4b2221893e733d43b52', 'platform': 'linux', 'machine': ['armv6l', 'armv7l', 'armv8l'] @@ -97,13 +97,13 @@ 'arch': 'linux-arm64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11435112, + 13023160, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm64/trace_processor_shell', 'sha256': - '6641337ce8fb865a85f9538c52ab563f57ed18e62b4efbe670fca484589b4c8a', + 'b0b8d7bd61120bd01db7f7e5e31636f6e476170190476b34f9013c92e604509a', 'platform': 'linux', 'machine': ['aarch64'] @@ -111,63 +111,63 @@ 'arch': 'android-arm', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 9076156, + 10079324, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm/trace_processor_shell', 'sha256': - '501ef91a96d5ff2bb49df967ad169ed6f7959f4c4c910ac782672a8bf6a25cc1' + '0a0a9c2a74282a4365d88bf681968756794e7e3dbfdb467c793b8fd4b3645e40' }, { 'arch': 'android-arm64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11292248, + 12823856, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm64/trace_processor_shell', 'sha256': - 'c0488a20b6da2533557b78d10cb69d503345c3a2660460453dee5853fe27cd08' + 'a1fe8eeff8d0fd98caf95927bbc983fb9062a944162c451cd84ada1ff86c381f' }, { 'arch': 'android-x86', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 12661180, + 14498900, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x86/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x86/trace_processor_shell', 'sha256': - '0ebd3d1a0c4c15ea32b0d15f3def3152c14967234a9ea86d6efb060a235983ed' + '0902cc9c98f3b416ab5fcb353cfbc3d63978d77a9b1ac438b223157c278f9fec' }, { 'arch': 'android-x64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11835984, + 13415352, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x64/trace_processor_shell', 'sha256': - '8242ee7c63709a170c0ca3584bc1d814a420807eb1b095b224d6d48ea5bd3c31' + '36de738cf879983a75c2fc38d3e5318fb643dcf57cf6a22bf4e015af180f2c1e' }, { 'arch': 'windows-amd64', 'file_name': - 'traceconv.exe', + 'trace_processor_shell.exe', 'file_size': - 11760640, + 13313024, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/windows-amd64/traceconv.exe', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/windows-amd64/trace_processor_shell.exe', 'sha256': - '10d420057affdfad9aaae34ade221a96740af233f03b9e5e387b7ae0f5c0ecab', + '9ac8c04ca44cc22f0aa6eff2ff8d25c3a87011b48aca554e7a10f677cbbfaaa0', 'platform': 'win32', 'machine': ['amd64'] }] -# ----- Amalgamator: end of python/perfetto/prebuilts/manifests/traceconv.py +# ----- Amalgamator: end of python/perfetto/prebuilts/manifests/trace_processor_shell.py # ----- Amalgamator: begin of python/perfetto/prebuilts/perfetto_prebuilts.py # Copyright (C) 2021 The Android Open Source Project @@ -671,17 +671,18 @@ adb_check_output(['adb', 'shell', 'rm', profile_device_path]) -def get_traceconv(): - """Sets up and returns the path to `traceconv`.""" +def get_trace_processor(): + """Sets up and returns the path to `trace_processor`.""" try: - traceconv = get_perfetto_prebuilt(TRACECONV_MANIFEST, soft_fail=True) + trace_processor = get_perfetto_prebuilt( + TRACE_PROCESSOR_SHELL_MANIFEST, soft_fail=True) except Exception as error: exit_with_bug_report(error) - if traceconv is None: + if trace_processor is None: exit_with_bug_report( - "Unable to download `traceconv` for symbolizing profiles.") + "Unable to download `trace_processor` for symbolizing profiles.") - return traceconv + return trace_processor def concatenate_files(files_to_concatenate, output_file): @@ -697,12 +698,13 @@ shutil.copyfileobj(input, output) -def symbolize_trace(traceconv, profile_target): +def symbolize_trace(trace_processor, profile_target): """Attempts symbolization of the recorded trace/profile, if symbols are available. Args: - traceconv: The path to the `traceconv` binary used for symbolization. + trace_processor: The path to the `trace_processor` binary used for + symbolization. profile_target: The directory where the recorded trace was output. Returns: @@ -716,11 +718,10 @@ if binary_path is not None: try: with open(os.path.join(profile_target, 'symbols'), 'w') as symbols_file: - return_code = subprocess.call([traceconv, 'symbolize', trace_file], - env=dict( - os.environ, - PERFETTO_BINARY_PATH=binary_path), - stdout=symbols_file) + return_code = subprocess.call( + [trace_processor, 'util', 'symbolize', trace_file], + env=dict(os.environ, PERFETTO_BINARY_PATH=binary_path), + stdout=symbols_file) except IOError as error: sys.exit("Unable to write symbols to disk: {}".format(error)) if return_code == 0: @@ -738,26 +739,27 @@ return trace_file -def generate_pprof_profiles(traceconv, trace_file, args): +def generate_pprof_profiles(trace_processor, trace_file, args): """Generates pprof profiles from the recorded trace. Args: - traceconv: The path to the `traceconv` binary used for generating profiles. + trace_processor: The path to the `trace_processor` binary used for + generating profiles. trace_file: The oath to the recorded and potentially symbolized trace file. Returns: The directory where pprof profiles are output. """ try: - conversion_args = [traceconv, 'profile', '--perf'] + ( + conversion_args = [trace_processor, 'convert', 'profile', '--perf'] + ( ['--no-annotations'] if args.no_annotations else []) + [trace_file] - traceconv_output = subprocess.check_output(conversion_args) + trace_processor_output = subprocess.check_output(conversion_args) except Exception as error: exit_with_bug_report( "Unable to extract profiles from trace: {}".format(error)) profiles_output_directory = None - for word in traceconv_output.decode('utf-8').split(): + for word in trace_processor_output.decode('utf-8').split(): if 'perf_profile-' in word: profiles_output_directory = word if profiles_output_directory is None: @@ -788,10 +790,11 @@ print(trace_config) return 0 record_trace(trace_config, profile_target) - traceconv = get_traceconv() - trace_file = symbolize_trace(traceconv, profile_target) + trace_processor = get_trace_processor() + trace_file = symbolize_trace(trace_processor, profile_target) copy_profiles_to_destination( - profile_target, generate_pprof_profiles(traceconv, trace_file, args)) + profile_target, generate_pprof_profiles(trace_processor, trace_file, + args)) return 0
diff --git a/tools/heap_profile b/tools/heap_profile index 1a8c681..27fb36a 100755 --- a/tools/heap_profile +++ b/tools/heap_profile
@@ -200,19 +200,19 @@ # ----- Amalgamator: end of python/perfetto/prebuilts/manifests/tracebox.py -# ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/traceconv.py +# ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/trace_processor_shell.py # This file has been generated by: tools/release/roll-prebuilts v56.1 -TRACECONV_MANIFEST = [{ +TRACE_PROCESSOR_SHELL_MANIFEST = [{ 'arch': 'mac-amd64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11839400, + 13441096, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-amd64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-amd64/trace_processor_shell', 'sha256': - '7b696e45600d03fe95121cc5710852080331874396f17297610e829887300d7f', + '99227035e8256d46660c21e35e097188a31465e95accf334e094d31cd709065b', 'platform': 'darwin', 'machine': ['x86_64'] @@ -220,13 +220,13 @@ 'arch': 'mac-arm64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 10959176, + 12421992, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-arm64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/mac-arm64/trace_processor_shell', 'sha256': - '99dd2ebf488af5591fb5d4be0aa1d84ac173ceed62b077dd73bfa0cff8531be4', + '64180e40f94fa8bded24dee1ba62985c0f9fc8c89047cd3218be25084a4b06a2', 'platform': 'darwin', 'machine': ['arm64'] @@ -234,13 +234,13 @@ 'arch': 'linux-amd64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 12057312, + 13687824, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-amd64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-amd64/trace_processor_shell', 'sha256': - '0d91b41016b86733e56ed641b8bf88ee4192e01470e7e5d5feb1ecb00401cdbc', + 'becb22d3f2c51dc234627a3ffd5b066602575b50ad4eb082815156f1bc7cb65a', 'platform': 'linux', 'machine': ['x86_64'] @@ -248,13 +248,13 @@ 'arch': 'linux-arm', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 9103156, + 10115224, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm/trace_processor_shell', 'sha256': - 'b68f21399e4e49b81631f0e720dd1e626562020ca25b3220df4f88ba96c73eea', + '561d778f65bed8ce5c3f62043e63248d7490390a5137e4b2221893e733d43b52', 'platform': 'linux', 'machine': ['armv6l', 'armv7l', 'armv8l'] @@ -262,13 +262,13 @@ 'arch': 'linux-arm64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11435112, + 13023160, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/linux-arm64/trace_processor_shell', 'sha256': - '6641337ce8fb865a85f9538c52ab563f57ed18e62b4efbe670fca484589b4c8a', + 'b0b8d7bd61120bd01db7f7e5e31636f6e476170190476b34f9013c92e604509a', 'platform': 'linux', 'machine': ['aarch64'] @@ -276,63 +276,63 @@ 'arch': 'android-arm', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 9076156, + 10079324, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm/trace_processor_shell', 'sha256': - '501ef91a96d5ff2bb49df967ad169ed6f7959f4c4c910ac782672a8bf6a25cc1' + '0a0a9c2a74282a4365d88bf681968756794e7e3dbfdb467c793b8fd4b3645e40' }, { 'arch': 'android-arm64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11292248, + 12823856, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-arm64/trace_processor_shell', 'sha256': - 'c0488a20b6da2533557b78d10cb69d503345c3a2660460453dee5853fe27cd08' + 'a1fe8eeff8d0fd98caf95927bbc983fb9062a944162c451cd84ada1ff86c381f' }, { 'arch': 'android-x86', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 12661180, + 14498900, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x86/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x86/trace_processor_shell', 'sha256': - '0ebd3d1a0c4c15ea32b0d15f3def3152c14967234a9ea86d6efb060a235983ed' + '0902cc9c98f3b416ab5fcb353cfbc3d63978d77a9b1ac438b223157c278f9fec' }, { 'arch': 'android-x64', 'file_name': - 'traceconv', + 'trace_processor_shell', 'file_size': - 11835984, + 13415352, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x64/traceconv', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/android-x64/trace_processor_shell', 'sha256': - '8242ee7c63709a170c0ca3584bc1d814a420807eb1b095b224d6d48ea5bd3c31' + '36de738cf879983a75c2fc38d3e5318fb643dcf57cf6a22bf4e015af180f2c1e' }, { 'arch': 'windows-amd64', 'file_name': - 'traceconv.exe', + 'trace_processor_shell.exe', 'file_size': - 11760640, + 13313024, 'url': - 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/windows-amd64/traceconv.exe', + 'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v56.1/windows-amd64/trace_processor_shell.exe', 'sha256': - '10d420057affdfad9aaae34ade221a96740af233f03b9e5e387b7ae0f5c0ecab', + '9ac8c04ca44cc22f0aa6eff2ff8d25c3a87011b48aca554e7a10f677cbbfaaa0', 'platform': 'win32', 'machine': ['amd64'] }] -# ----- Amalgamator: end of python/perfetto/prebuilts/manifests/traceconv.py +# ----- Amalgamator: end of python/perfetto/prebuilts/manifests/trace_processor_shell.py # ----- Amalgamator: begin of python/perfetto/prebuilts/perfetto_prebuilts.py # Copyright (C) 2021 The Android Open Source Project @@ -590,10 +590,10 @@ return result, action.option_strings[0].strip('-') -def process_trace(trace_file, profile_target, traceconv_binary, args, +def process_trace(trace_file, profile_target, trace_processor_binary, args, android_mode): - """Convert a raw trace to pprof via traceconv. Returns an exit code.""" - if traceconv_binary is None: + """Convert a raw trace to pprof via trace_processor. Returns an exit code.""" + if trace_processor_binary is None: print('Wrote profile to {}'.format(trace_file)) print( 'This file can be opened using the Perfetto UI, https://ui.perfetto.dev' @@ -614,10 +614,10 @@ if binary_path is not None: symbols_path = os.path.join(profile_target, 'symbols') with open(symbols_path, 'w') as fd: - ret = subprocess.call([traceconv_binary, 'symbolize', trace_file], - env=dict( - os.environ, PERFETTO_BINARY_PATH=binary_path), - stdout=fd) + ret = subprocess.call( + [trace_processor_binary, 'util', 'symbolize', trace_file], + env=dict(os.environ, PERFETTO_BINARY_PATH=binary_path), + stdout=fd) if ret == 0: concat_files.append(symbols_path) else: @@ -628,11 +628,10 @@ if proguard_map is not None: deobf_path = os.path.join(profile_target, 'deobfuscation-packets') with open(deobf_path, 'w') as fd: - ret = subprocess.call([traceconv_binary, 'deobfuscate', trace_file], - env=dict( - os.environ, - PERFETTO_PROGUARD_MAP=proguard_map), - stdout=fd) + ret = subprocess.call( + [trace_processor_binary, 'util', 'deobfuscate', trace_file], + env=dict(os.environ, PERFETTO_PROGUARD_MAP=proguard_map), + stdout=fd) if ret == 0: concat_files.append(deobf_path) else: @@ -652,12 +651,12 @@ out.write(buf) trace_file = symbolized_path - conversion_args = [traceconv_binary, 'profile'] + ( + conversion_args = [trace_processor_binary, 'convert', 'profile'] + ( ['--no-annotations'] if args.no_annotations else []) + [trace_file] - traceconv_output = subprocess.check_output( + trace_processor_output = subprocess.check_output( conversion_args, stderr=subprocess.STDOUT) profile_path = None - for word in traceconv_output.decode('utf-8').split(): + for word in trace_processor_output.decode('utf-8').split(): if 'heap_profile-' in word: profile_path = word if profile_path is None: @@ -694,7 +693,7 @@ return 0 -def linux_main(args, cfg, cmd, traceconv_binary): +def linux_main(args, cfg, cmd, trace_processor_binary): """Run a local heap profile session on Linux using LD_PRELOAD.""" tracebox_binary = args.tracebox_binary if tracebox_binary is None: @@ -773,7 +772,11 @@ perfetto_proc.wait() return process_trace( - trace_output, profile_target, traceconv_binary, args, android_mode=False) + trace_output, + profile_target, + trace_processor_binary, + args, + android_mode=False) def print_options(parser): @@ -904,7 +907,8 @@ help="Get simpleperf profile of heapprofd. This is " "only for heapprofd development.") common.add_argument( - "--traceconv-binary", help="Path to local trace to text. For debugging.") + "--trace-processor-binary", + help="Path to local trace_processor. For debugging.") common.add_argument( "--no-annotations", help="Do not suffix the pprof function names with Android ART mode " @@ -1046,7 +1050,7 @@ parser.print_help() return 1 - traceconv_binary = args.traceconv_binary + trace_processor_binary = args.trace_processor_binary if args.continuous_dump: target_cfg += CONTINUOUS_DUMP.format(dump_interval=args.continuous_dump) @@ -1063,13 +1067,14 @@ print(cfg) return 0 - # Do this AFTER print_config so we do not download traceconv only to + # Do this AFTER print_config so we do not download trace_processor only to # print out the config. - if traceconv_binary is None: - traceconv_binary = get_perfetto_prebuilt(TRACECONV_MANIFEST, soft_fail=True) + if trace_processor_binary is None: + trace_processor_binary = get_perfetto_prebuilt( + TRACE_PROCESSOR_SHELL_MANIFEST, soft_fail=True) if args.subcommand == 'host': - return linux_main(args, cfg, cmd, traceconv_binary) + return linux_main(args, cfg, cmd, trace_processor_binary) # --- Android path --- @@ -1174,7 +1179,7 @@ return process_trace( profile_host_path, profile_target, - traceconv_binary, + trace_processor_binary, args, android_mode=True)
diff --git a/tools/release/roll-prebuilts b/tools/release/roll-prebuilts index 13c969b..e63362d 100755 --- a/tools/release/roll-prebuilts +++ b/tools/release/roll-prebuilts
@@ -74,7 +74,13 @@ 'archs': ALL_ARCHS }, { + # traceconv is no longer a distinct binary: it is trace_processor_shell + # invoked under the "traceconv" name (the shell detects argv[0] and + # presents the traceconv-compatible CLI). So the manifest keeps the + # "traceconv" name and cached file_name, but downloads the + # trace_processor_shell artifact via 'source_tool'. 'tool': 'traceconv', + 'source_tool': 'trace_processor_shell', 'archs': ALL_ARCHS }, { @@ -129,14 +135,19 @@ } -def make_manifest(git_revision, tool, arch, file_name=None): +def make_manifest(git_revision, tool, arch, file_name=None, source_tool=None): + # |source_tool| lets a manifest download a differently-named GCS artifact + # while keeping its own |tool| / |file_name| (e.g. the "traceconv" manifest + # downloads the "trace_processor_shell" artifact). It defaults to |tool|. if arch == 'src': file_name = file_name or (tool + '.zip') - url = '%s/%s/sdk/%s' % (GCS_URL, git_revision, file_name) + url_file = (source_tool + '.zip') if source_tool else file_name + url = '%s/%s/sdk/%s' % (GCS_URL, git_revision, url_file) else: ext = '.exe' if arch.startswith('windows') else '' file_name = file_name or (tool + ext) - url = '%s/%s/%s/%s' % (GCS_URL, git_revision, arch, file_name) + url_file = (source_tool + ext) if source_tool else file_name + url = '%s/%s/%s/%s' % (GCS_URL, git_revision, arch, url_file) logging.info('Downloading %s', url) data = subprocess.check_output(['curl', '-fsL', '-o', '-', url]) @@ -155,11 +166,12 @@ tool_name = spec['tool'] archs = spec['archs'] file_name = spec.get('file_name', None) + source_tool = spec.get('source_tool', None) with ThreadPoolExecutor(max_workers=8) as executor: manifests = list( executor.map( - lambda arch: make_manifest(git_revision, tool_name, arch, file_name - ), archs)) + lambda arch: make_manifest(git_revision, tool_name, arch, file_name, + source_tool), archs)) out_file = os.path.join(MANIFESTS_DIR, tool_name + '.py') content = '# This file has been generated by: {script} {git_revision}\n'