@@ -37,49 +37,60 @@ static const std::array<std::string, 2> EXIT_REGION_WHITELIST = {
3737#endif
3838};
3939
40+ static region_handle create_user_region (const std::string& region_name, const CString module ,
41+ const CString file_name, const std::uint64_t line_number)
42+ {
43+ region_handle handle;
44+ SCOREP_User_RegionInit (&handle.value , NULL , NULL , region_name.c_str (),
45+ SCOREP_USER_REGION_TYPE_FUNCTION, file_name.c_str (), line_number);
46+
47+ // Extract main module name if module is like "mainmodule.submodule.subsubmodule"
48+ const char * dot_pos = module .find (' .' );
49+ if (dot_pos)
50+ {
51+ const std::string main_module (module .c_str (), dot_pos);
52+ SCOREP_User_RegionSetGroup (handle.value , main_module.c_str ());
53+ }
54+ else
55+ {
56+ SCOREP_User_RegionSetGroup (handle.value , module .c_str ());
57+ }
58+ return handle;
59+ }
60+
4061// Used for regions, that have an identifier, aka a code object id. (instrumenter regions and
4162// some decorated regions)
42- void region_begin (const std::string& function_name, const std::string& module ,
43- const std::string& file_name, const std::uint64_t line_number,
44- const std::uintptr_t & identifier)
63+ void region_begin (const CString function_name, const CString module , const CString file_name,
64+ const std::uint64_t line_number, const std::uintptr_t & identifier)
4565{
4666 auto & region_handle = regions[identifier];
4767
4868 if (region_handle == uninitialised_region_handle)
4969 {
50- auto & region_name = make_region_name (module , function_name);
51- SCOREP_User_RegionInit (®ion_handle.value , NULL , NULL , region_name.c_str (),
52- SCOREP_USER_REGION_TYPE_FUNCTION, file_name.c_str (), line_number);
53-
54- SCOREP_User_RegionSetGroup (region_handle.value ,
55- std::string (module , 0 , module .find (' .' )).c_str ());
70+ const auto & region_name = make_region_name (module , function_name);
71+ region_handle = create_user_region (region_name, module , file_name, line_number);
5672 }
5773 SCOREP_User_RegionEnter (region_handle.value );
5874}
5975
6076// Used for regions, that only have a function name, a module, a file and a line number (user
6177// regions)
62- void region_begin (const std::string& function_name, const std::string& module ,
63- const std::string& file_name, const std:: uint64_t line_number)
78+ void region_begin (const CString function_name, const CString module , const CString file_name ,
79+ const std::uint64_t line_number)
6480{
6581 const auto & region_name = make_region_name (module , function_name);
6682 auto & region_handle = user_regions[region_name];
6783
6884 if (region_handle == uninitialised_region_handle)
6985 {
70- SCOREP_User_RegionInit (®ion_handle.value , NULL , NULL , region_name.c_str (),
71- SCOREP_USER_REGION_TYPE_FUNCTION, file_name.c_str (), line_number);
72-
73- SCOREP_User_RegionSetGroup (region_handle.value ,
74- std::string (module , 0 , module .find (' .' )).c_str ());
86+ region_handle = create_user_region (region_name, module , file_name, line_number);
7587 }
7688 SCOREP_User_RegionEnter (region_handle.value );
7789}
7890
7991// Used for regions, that have an identifier, aka a code object id. (instrumenter regions and
8092// some decorated regions)
81- void region_end (const std::string& function_name, const std::string& module ,
82- const std::uintptr_t & identifier)
93+ void region_end (const CString function_name, const CString module , const std::uintptr_t & identifier)
8394{
8495 const auto it_region = regions.find (identifier);
8596 if (it_region != regions.end ())
@@ -94,7 +105,7 @@ void region_end(const std::string& function_name, const std::string& module,
94105}
95106
96107// Used for regions, that only have a function name, a module (user regions)
97- void region_end (const std::string& function_name, const std::string& module )
108+ void region_end (const CString function_name, const CString module )
98109{
99110 auto & region_name = make_region_name (module , function_name);
100111 const auto it_region = user_regions.find (region_name);
0 commit comments