From: Vladimir Mezentsev Date: Thu, 10 Aug 2023 02:38:14 +0000 (-0700) Subject: gprofng: pass gprofng location to gp-display-gui X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84004b2a709e4773b0fb1b01d629b0eb2fe81bbc;p=binutils-gdb.git 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. --- 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");