cmake setup for analysis tools

30 views
Skip to first unread message

Prasun Ratn

unread,
Feb 16, 2023, 3:42:48 AM2/16/23
to DynamoRIO Users
I am trying to set up cmake based build for a drmemtrace analyzer and I am following the directions from the "Creating New Analysis Tools" page https://dynamorio.org/sec_drcachesim_newtool.html

This is my CMakeLists.txt

    cmake_minimum_required(VERSION 3.10)
    project(analyzer_example)

    find_package(DynamoRIO)
    if (NOT DynamoRIO_FOUND)
        message(FATAL_ERROR "DynamoRIO package required to build")
    endif(NOT DynamoRIO_FOUND)

    set (target analyzer_example)
    add_executable (${target} ${target}.cpp)

    # The target OS:
    if (APPLE)
        set(MACOS 1)
    elseif (UNIX)
        set(LINUX 1)
    endif (APPLE)
    if (WIN32)
        set(WINDOWS 1)
    endif (WIN32)

    if (LINUX)
        target_compile_definitions(${target} PRIVATE -DLINUX -DUNIX)
    elseif (WINDOWS)
        target_compile_definitions(${target} PRIVATE WINDOWS)
    endif (LINUX)

    target_compile_definitions(${target} PRIVATE X86_64 X64)

    configure_DynamoRIO_main_headers()
    use_DynamoRIO_drmemtrace(${target})

This is my analyzer_example.cpp

    #include "analysis_tool.h"
    #include <string>

    int main()
    {
        return 0;
    }

On compiling, I get this error

    fatal error: analysis_tool.h: No such file or directory
        1 | #include "analysis_tool.h"

I also tried adding configure_DynamoRIO_main_headers() in CMakeLists.txt but it did not help.

I am able to compile if I change the include to this

    #include "drmemtrace/analysis_tool.h"

Is my CMakeLists.txt set up incorrectly?

Derek Bruening

unread,
Feb 16, 2023, 5:38:45 PM2/16/23
to Prasun Ratn, DynamoRIO Users
It looks like use_DynamoRIO_drmemtrace() adds the base include/ dir to the compiler search dirs, and the headers for drmemtrace are in the drmemtrace/ subdir of that base include/ dir, so it looks like you would be expected to use the #include "drmemtrace/analysis_tool.h"?  Probably that documentation page should explicitly say that?  I wonder if you could send a pull request making that clearer (plus anything else you found confusing on that page).

--
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/93510886-3fe0-48f4-b4ae-7c52064eeffbn%40googlegroups.com.

Prasun Ratn

unread,
Feb 17, 2023, 5:25:59 AM2/17/23
to Derek Bruening, DynamoRIO Users
Thanks. I wasn't sure if that was needed or if I was doing something wrong.

Reply all
Reply to author
Forward
0 new messages