diff --git a/.gitmodules b/.gitmodules index fae0dc770e..161592f0ae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,7 +49,7 @@ url = https://github.com/pybind/pybind11.git [submodule "projects/rocprofiler-sdk/external/gotcha"] path = projects/rocprofiler-sdk/external/gotcha - url = https://jrmadsen@github.com/jrmadsen/GOTCHA + url = https://github.com/ROCm/GOTCHA [submodule "projects/rocprofiler-systems/external/timemory"] path = projects/rocprofiler-systems/external/timemory url = https://github.com/ROCm/timemory.git diff --git a/projects/rocprofiler-sdk/external/gotcha b/projects/rocprofiler-sdk/external/gotcha index 9afbaf0ae5..b944da10ff 160000 --- a/projects/rocprofiler-sdk/external/gotcha +++ b/projects/rocprofiler-sdk/external/gotcha @@ -1 +1 @@ -Subproject commit 9afbaf0ae5858098d50f79bf494b6333da17da6b +Subproject commit b944da10ff9b3364ef2e4b12e02cb2464e05dd48 diff --git a/projects/rocprofiler-sdk/source/lib/python/rocpd/__init__.py b/projects/rocprofiler-sdk/source/lib/python/rocpd/__init__.py index dc9f798560..acc6d4490c 100644 --- a/projects/rocprofiler-sdk/source/lib/python/rocpd/__init__.py +++ b/projects/rocprofiler-sdk/source/lib/python/rocpd/__init__.py @@ -32,6 +32,13 @@ try: except Exception: pass +try: + import sqlite3 + + sqlite3.connect(":memory:") # Test if sqlite3 is available +except Exception: + pass + from . import libpyrocpd from .importer import RocpdImportData diff --git a/projects/rocprofiler-sdk/source/lib/python/rocpd/source/interop.cpp b/projects/rocprofiler-sdk/source/lib/python/rocpd/source/interop.cpp index bdde41b0b9..5cb5d8cb7f 100644 --- a/projects/rocprofiler-sdk/source/lib/python/rocpd/source/interop.cpp +++ b/projects/rocprofiler-sdk/source/lib/python/rocpd/source/interop.cpp @@ -161,6 +161,22 @@ auto bindings = std::array{ void activate_gotcha_bindings() { +#if defined(GOTCHA_INIT) && GOTCHA_INIT > 0 + // initialize gotcha + gotcha_init_config_t gotcha_cfg = { + .size = sizeof(gotcha_init_config_t), .dl_open_bind = 0, .dl_sym_bind = 0}; + gotcha_init(&gotcha_cfg); +#endif + + // this ensures that the sqlite3 module is imported and the sqlite3_open_v2 and sqlite3_close_v2 + // in lib-dynload/_sqlite3.cpython-*.so are remapped to the gotcha bindings. + // this is needed to ensure that the sqlite3 connections are captured by gotcha + { + auto sqlite3_mod = py::module_::import("sqlite3"); + auto ret = sqlite3_mod.attr("connect")(":memory:"); + ret.attr("close")(); + } + // activate the gotcha wrappers auto _err = gotcha_wrap(bindings.data(), bindings.size(), "rocpd.sqlite3"); ROCP_WARNING_IF(_err != GOTCHA_SUCCESS) << "gotcha error for rocpd.sqlite3";