Trace subset of execution use dr_app_start

50 views
Skip to first unread message

Mahendra Tomar

unread,
Feb 10, 2023, 5:22:42 PM2/10/23
to DynamoRIO Users
Hi,
I am trying to trace a subset of code. The application compiles, and DynamoRIO statistics are displayed. But no memtrace file is generated.

Please help, how can I get the memtrace file ?

I am using DynamoRIO-Linux-9.0.1 on WSL (windows subsystem linux) Ubuntu.
The source code is:
-----------------------------------
// File name: start_stop.c
#include "stdio.h"
#include "stdlib.h"
#include "dr_api.h"

int main() {
     int set_env_result = setenv("DYNAMORIO_OPTIONS",
                    "-stderr_mask 0xc -rstats_to_stderr -client_lib ';;-offline'", 1);
    printf("Set env result %d\n", set_env_result);
    int setup_result = dr_app_setup();
    printf("dr setup result %d.\n", setup_result);
    dr_app_start();
    printf("Hello, World\n");
    dr_app_stop_and_cleanup();
    return 0;
}
-----------------------
Compile command:
-----------------------
DYNAMO_HOME = /home/ubuntu/DynamoRIO-Linux-9.0.1
TARGET = start_stop

compile:
    g++ -DX86_64 -DDR_HOST_X86 -DDR_HOST_X64 -DHAS_ZLIB \
    -DLINUX -D_LARGEFILE64_SOURCE \
    -I${DYNAMO_HOME} -I${DYNAMO_HOME}/include \
    -I${DYNAMO_HOME}/tools/include\
    -I${DYNAMO_HOME}/ext/include \
    -I${DYNAMO_HOME}/tools \
    -o $(TARGET).o \
    -c $(TARGET).c

link:
    g++ -Wl,--hash-style=both -Wl,--as-needed \
    -rdynamic  $(TARGET).o \
    -o $(TARGET)  \
    ${DYNAMO_HOME}/tools/lib64/debug/libdrmemtrace_static.a \
    ${DYNAMO_HOME}/lib64/debug/libdynamorio_static.a \
    ${DYNAMO_HOME}/lib64/libdrlibc.a \
    -ldl
---------------------------------

Thanks.


Derek Bruening

unread,
Feb 10, 2023, 6:12:10 PM2/10/23
to Mahendra Tomar, DynamoRIO Users
Nothing obvious jumps out.  I would pass -verbose 1 or higher (next to -offline) and see where it says the output dir is and whether it says it wrote out the data.

--
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 on the web visit https://groups.google.com/d/msgid/dynamorio-users/8a773e13-bf41-4ef8-acfe-e30e999495c3n%40googlegroups.com.

Mahendra Tomar

unread,
Feb 10, 2023, 7:09:47 PM2/10/23
to DynamoRIO Users
I added verbose -1, but the terminal output stays the same !

int set_env_result = setenv("DYNAMORIO_OPTIONS",
                    "-stderr_mask 0xc -rstats_to_stderr -client_lib ';;-offline -verbose 1'", 1);

Terminal output:
--------------------
Set env result 0
dr setup result 0.
Hello, World
DynamoRIO statistics:
              Peak threads under DynamoRIO control :                 1
                              Threads ever created :                 1
                   Basic block fragments generated :                75
                               Fcache exits, total :                86
             Peak fcache combined capacity (bytes) :             12288
                    Peak fcache units on live list :                 3
                    Peak fcache units on free list :                 3
                Peak special heap capacity (bytes) :             12288
                      Peak heap units on live list :                10
                      Peak heap units on free list :                 5
                       Peak stack capacity (bytes) :            147456
                        Peak heap capacity (bytes) :            262144
                 Peak total memory from OS (bytes) :            892928
              Peak vmm blocks for unreachable heap :               155
                         Peak vmm blocks for stack :                42
      Peak vmm blocks for unreachable special heap :                 5
      Peak vmm blocks for unreachable special mmap :                 3
                Peak vmm blocks for reachable heap :                24
                         Peak vmm blocks for cache :                48
        Peak vmm blocks for reachable special heap :                 6
        Peak vmm blocks for reachable special mmap :                 7
            Peak vmm virtual memory in use (bytes) :           1187840
-------------------------

What should I try next ?

Derek Bruening

unread,
Feb 11, 2023, 11:11:22 AM2/11/23
to Mahendra Tomar, DynamoRIO Users
It's not finding the client.  You're building with custom flags: I would try with the supported CMake and see what the difference is.  Maybe because you're not adding what DynamoRIO_force_static_link() does in the CMake: the whole-archive flags to prevent the linker from throwing out code it thinks is not directly referenced.  Probably it's throwing out the whole memtrace client.

On Fri, Feb 10, 2023 at 5:22 PM Mahendra Tomar <mahendra...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages