CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
75 lines
2.0 KiB
Markdown
75 lines
2.0 KiB
Markdown
# Rewrite Caller
|
|
|
|
## Overview
|
|
|
|
This example provides a minimal function call chain - `main()` → `outer()` → `inner()` - designed as a test target for binary rewrite instrumentation. The functions are marked `noinline` to ensure they appear as distinct entries in the call graph after instrumentation. By counting the total calls through the chain, you can verify that binary rewriting correctly intercepts and records every function entry and exit. This is useful for validating instrumentation overhead and call graph accuracy.
|
|
|
|
## Source Files
|
|
|
|
- `rewrite-caller.cpp` - Defines `inner()` (increments a counter), `outer()` (calls `inner()`), and `main()` (calls `outer()` N times).
|
|
|
|
## Prerequisites
|
|
|
|
- CMake 3.25+
|
|
- C++ compiler
|
|
|
|
## Building
|
|
|
|
**Standalone build:**
|
|
|
|
```bash
|
|
cmake -B <build_dir> -S <project_root>/examples/rewrite-caller
|
|
cmake --build <build_dir>
|
|
```
|
|
|
|
**As part of the examples suite:**
|
|
|
|
```bash
|
|
cmake -B <build_dir> -S <project_root>/examples/
|
|
cmake --build <build_dir> --target rewrite-caller
|
|
```
|
|
|
|
**NOTE**: The target is built in Debug mode to preserve the full call chain.
|
|
|
|
## Running
|
|
|
|
```bash
|
|
# Default: 10 calls
|
|
./rewrite-caller
|
|
|
|
# Custom: 1000 calls
|
|
./rewrite-caller 1000
|
|
```
|
|
|
|
**Arguments:**
|
|
|
|
| Position | Description | Default |
|
|
| ---------- | ------------- | --------- |
|
|
| 1 | Number of calls to outer() | 10 |
|
|
|
|
## Profiling with rocprofiler-systems
|
|
|
|
This example is best used with binary rewrite instrumentation:
|
|
|
|
```bash
|
|
# Rewrite the binary
|
|
rocprof-sys-instrument -o rewrite-caller.inst -- ./rewrite-caller
|
|
|
|
# Run the instrumented binary
|
|
./rewrite-caller.inst 100
|
|
```
|
|
|
|
For runtime instrumentation:
|
|
|
|
```bash
|
|
rocprof-sys-instrument -- ./rewrite-caller 100
|
|
```
|
|
|
|
### Recommended Configuration
|
|
|
|
| Variable | Value | Purpose |
|
|
| ---------- | ------- | --------- |
|
|
| `ROCPROFSYS_TRACE` | `true` | Generate Perfetto trace showing call chain |
|
|
| `ROCPROFSYS_PROFILE` | `true` | Generate call-stack profile with call counts |
|
|
| `ROCPROFSYS_USE_SAMPLING` | `ON` | Enable sampling alongside instrumentation |
|