File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from scorep ._bindings import abspath
2+ from scorep .instrumenter import has_c_instrumenter
23
34
45def get_module_name (frame ):
@@ -11,6 +12,12 @@ def get_module_name(frame):
1112 modulename = "numpy.__array_function__"
1213 else :
1314 modulename = "unkown"
15+ typeobject = frame .f_locals .get ("self" , None )
16+ if typeobject is not None :
17+ if has_c_instrumenter ():
18+ return "." .join ([modulename , type (typeobject ).__name__ ])
19+ else :
20+ return "." .join ([modulename , typeobject .__class__ .__name__ ])
1421 return modulename
1522
1623
Original file line number Diff line number Diff line change @@ -14,11 +14,13 @@ namespace compat
1414{
1515 // / Region names that are known to have no region enter event and should not report an error
1616 // / on region exit
17- static const std::array<std::string, 2 > exit_region_whitelist = {
17+ static const std::array<std::string, 4 > exit_region_whitelist = {
1818#if PY_MAJOR_VERSION >= 3
19- " threading:_bootstrap_inner" , " threading:_bootstrap"
19+ " threading.Thread:_bootstrap_inner" , " threading.Thread:_bootstrap" ,
20+ " threading.TMonitor:_bootstrap_inner" , " threading.TMonitor:_bootstrap"
2021#else
21- " threading:__bootstrap_inner" , " threading:__bootstrap"
22+ " threading.Thread:__bootstrap_inner" , " threading.Thread:__bootstrap" ,
23+ " threading.TMonitor:__bootstrap_inner" , " threading.TMonitor:__bootstrap"
2224#endif
2325 };
2426
Original file line number Diff line number Diff line change 33#include " pathUtils.hpp"
44#include " pythoncapi_compat.h"
55
6+ #include < sstream>
67#include < stdlib.h>
78
89namespace scorepy
910{
1011std::string get_module_name (PyFrameObject& frame)
1112{
13+ const char * self_name = nullptr ;
14+ PyObject* locals = PyFrame_GetLocals (&frame);
15+ PyObject* self = PyDict_GetItemString (locals, " self" );
16+ if (self)
17+ {
18+ Py_INCREF (self);
19+ PyTypeObject* type = Py_TYPE (self);
20+ self_name = _PyType_Name (type);
21+ Py_DECREF (self);
22+ }
23+ Py_DECREF (locals);
24+
1225 PyObject* globals = PyFrame_GetGlobals (&frame);
1326 PyObject* module_name = PyDict_GetItemString (globals, " __name__" );
1427 Py_DECREF (globals);
1528 if (module_name)
16- return std::move (std::string (compat::get_string_as_utf_8 (module_name)));
29+ {
30+ std::stringstream result;
31+ result << compat::get_string_as_utf_8 (module_name);
32+ if (self_name)
33+ result << ' .' << self_name;
34+ return std::move (result).str ();
35+ }
1736
1837 // this is a NUMPY special situation, see NEP-18, and Score-P issue #63
1938 // TODO: Use string_view/C-String to avoid creating 2 std::strings
Original file line number Diff line number Diff line change @@ -309,25 +309,9 @@ def test_classes(scorep_env, instrumenter):
309309
310310 trace = OTF2_Trace (trace_path )
311311
312- region_ids = []
313- foo_count = 0
314- for line in str (trace ).split ("\n " ):
315- m = re .search ('ENTER[ ]*[0-9 ]*[0-9 ]*Region: "__main__:foo" <([0-9]*)>' , line )
316- if m is not None :
317- foo_count += 1
318- r_id = m .group (1 )
319-
320- if foo_count == 1 :
321- region_ids .append (r_id )
322- continue
323-
324- if foo_count < 4 :
325- assert region_ids [- 1 ] < r_id # check if foo regions are different
326- else :
327- assert r_id == region_ids [0 ] # check if last foo is fist foo
328- region_ids .append (r_id )
329-
330- assert len (region_ids ) == 4
312+ assert OTF2_Region ("__main__:foo" ) in trace
313+ assert OTF2_Region ("__main__.TestClass:foo" ) in trace
314+ assert OTF2_Region ("__main__.TestClass2:foo" ) in trace
331315
332316
333317def test_dummy (scorep_env ):
You can’t perform that action at this time.
0 commit comments