Using start-stop interface for third party library calls

23 views
Skip to first unread message

Niklas Bartelheimer

unread,
Jul 17, 2025, 10:34:49 AMJul 17
to DynamoRIO Users
Hi there,

I'm trying to get a memory trace for only some calls to a third party library like OpenMPI in my application.  
Therefore, I would like to use the start-stop interface as suggested in the documentation, but for some reason im not able to get it going.
I also looked at the burst_static.cpp code and its corresponding CMake build instructions.

In order to test the build process, I created a simple example that looks like this running on aarch64:

```
#include <stdlib.h>
#include <stdio.h>
#include "dr_api.h"

int main(int argc, char *argv[]){

int *a = (int*)malloc(10 * sizeof(int));
dr_app_setup_and_start();
for(int i = 0; i < 10; ++i)
a[i] = i + 1;
dr_app_stop_and_cleanup();
volatile int p = a[2];
printf("p: %d\n",p);
free(a);
return 0;
}
```

and the CMakeLists.txt:

```
project(test)
cmake_minimum_required(VERSION 3.20)
find_package(DynamoRIO REQUIRED)
add_executable(test.bin "burst_static.cpp")
configure_DynamoRIO_static(test.bin)
use_DynamoRIO_static_client(test.bin drmemtrace_static)
target_compile_options(test.bin PUBLIC "-fPIC")
```
The build process fails with: /usr/bin/ld: cannot find -ldrmemtrace_static, thus I'm linking manually against drmemtrace_static.a.

Then the app runs fine, but no memory traces are generated. At this point, I'm thinking that I'm doing something fundamentally wrong but cannot figure out what. I would appreciate any pointers towards a solution.

Best,
Niklas

Derek Bruening

unread,
Jul 17, 2025, 11:09:08 AMJul 17
to Niklas Bartelheimer, DynamoRIO Users
The default mode for drmemtrace is online analysis, sending data over a pipe.  To write it to a file you need to specify the -offline option.  This is why all the *burst* tests setenv DYNAMORIO_OPTIONS to something like "-client_lib ';;-offline'" (no path needed for static linked client).

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dynamorio-users/a57d48b8-aef3-4b4e-91f8-01f0740ee4c6n%40googlegroups.com.

Derek Bruening

unread,
Jul 17, 2025, 11:20:16 AMJul 17
to Niklas Bartelheimer, DynamoRIO Users
Adding a reminder to the docs in https://github.com/DynamoRIO/dynamorio/pull/7557.

Niklas

unread,
Jul 18, 2025, 11:37:20 AMJul 18
to DynamoRIO Users
Hi Derek,
thank you for your fast reply. I was kind of aware of the need of DYNAMORIO_OPTIONS but this does not change the results I'm seeing. I might run into the same issue you pointed out here: "https://groups.google.com/g/dynamorio-users/c/ZREI8kgq_Ew/m/DK7E5KEaAwAJ"
Since the Makefile generated by CMake does not run through completely (cannot find -ldrmemtrace_static), I tried to manually apply the same linker flags as in DynamoRIO_force_static_link(), resulting in more linking problems.
Any suggestion on how to proceed?

Derek Bruening

unread,
Jul 21, 2025, 9:40:40 PMJul 21
to Niklas, DynamoRIO Users
I believe the drmemtrace tracer libraries are not being exported.  I filed https://github.com/DynamoRIO/dynamorio/issues/7560 and have a PR https://github.com/DynamoRIO/dynamorio/pull/7561 to solve.

Niklas

unread,
Jul 28, 2025, 9:59:08 AMJul 28
to DynamoRIO Users
Sorry for the late reply, was temporary unavailable.

Thanks for your help and the PR. Works like a charm now!

Reply all
Reply to author
Forward
0 new messages