From 84004b2a709e4773b0fb1b01d629b0eb2fe81bbc Mon Sep 17 00:00:00 2001 From: Vladimir Mezentsev Date: Wed, 9 Aug 2023 19:38:14 -0700 Subject: [PATCH] gprofng: pass gprofng location to gp-display-gui gprofng GUI can be installed to the other directory. In this case, $PATH is used to find gp-display-gui from gprofng and option --gprofngdir is passed to gp-display-gui. gprofng/ChangeLog 2023-08-09 Vladimir Mezentsev * src/gprofng.cc (Gprofng::exec_cmd): Add option --gprofngdir. --- gprofng/src/gprofng.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gprofng/src/gprofng.cc b/gprofng/src/gprofng.cc index 23dcfe38fc7..30e07eb7cad 100644 --- a/gprofng/src/gprofng.cc +++ b/gprofng/src/gprofng.cc @@ -226,21 +226,34 @@ Gprofng::exec_cmd (char *tool_name, int argc, char **argv) exit (1); } - const char *aname = app_names[first].app_name;; + const char *aname = app_names[first].app_name; - char **arr = (char **) malloc ((argc + 3) * sizeof (char *)); - int n = 0; + char **arr = (char **) malloc ((argc + 5) * sizeof (char *)); char *pname = get_name (); - arr[n++] = dbe_sprintf ("%.*s%s", (int) (get_basename (pname) - pname), - pname, aname); + char *exe_name = dbe_sprintf ("%.*s%s", + (int) (get_basename (pname) - pname), pname, aname); + int n = 1; if (app_names[first].keyword) arr[n++] = dbe_sprintf ("--whoami=%s %s %s", whoami, tool_name, app_names[first].keyword); else arr[n++] = dbe_sprintf ("--whoami=%s %s", whoami, tool_name); + if (strcmp (aname, "gp-display-gui") == 0) + { + if (access (exe_name, X_OK | F_OK) != 0) + { // gprofng GUI can be installed to the other directory. + if (verbose) + printf ("gprofng: Cannot find '%s'\n", exe_name); + free (exe_name); + exe_name = get_realpath (aname); // Use $PATH to find gprofng GUI + } + arr[n++] = dbe_sprintf ("--gprofngdir=%.*s", + (int) (get_basename (pname) - pname), pname); + } for (int i = 1; i < argc; i++) arr[n++] = argv[i]; arr[n] = NULL; + arr[0] = exe_name; if (verbose) { printf ("gprofng::exec\n"); -- 2.30.2