Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,25 @@ main(int argc, char** argv)
//
//----------------------------------------------------------------------------------//

auto* main_func = find_function(app_image, main_fname.c_str());
procedure_t* main_func = nullptr;
// Fortran programs typically have a C-style "main" wrapper that calls the actual
// Fortran main. This should be prioritized as:
// 1. It contains the actual user code that should be instrumented and will not be
// treated as a subroutine.
// 2. If we instrument the C wrapper and if the Fortran main is written in such a way
// that Dyninst marks it with funcReturnStatus == NORETURN, then during
// rocprof-sys-run, the instrumented Fortran main will not be reached.
if(main_fname == "main")
{
// _MAIN__, MAIN__, main_, _main_, _QQmain
main_func = find_function(app_image, "^_?MAIN__|^_?main_|^_QQmain");
}
// Note: Some Fortran compilers (e.g. Cray) may name the Fortran main function after
// the program name in the PROGRAM statement. E.g, "PROGRAM hello" becomes "hello_"
// in the disassembly. In such cases, to avoid possible problems, users should specify
// their Fortran main with "--main-function"

if(!main_func) main_func = find_function(app_image, main_fname.c_str());
auto* user_start_func = find_function(app_image, "rocprofsys_user_start_trace",
{ "rocprofsys_user_start_thread_trace" });
auto* user_stop_func = find_function(app_image, "rocprofsys_user_stop_trace",
Expand Down Expand Up @@ -1934,7 +1952,6 @@ main(int argc, char** argv)

verbprintf(2, "Getting call expressions... ");

auto _init_arg0 = main_fname;
if(main_func) main_sign.get();

auto main_call_args = rocprofsys_call_expr(main_sign.get());
Expand Down
Loading