From: vladimir.mezentsev@oracle.com
To: binutils@sourceware.org
Cc: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Subject: [PATCH 2/2] gprofng: pass gprofng location to gp-display-gui
Date: Thu, 10 Aug 2023 11:48:48 -0700 [thread overview]
Message-ID: <20230810184849.3014338-1-vladimir.mezentsev@oracle.com> (raw)
From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
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 <vladimir.mezentsev@oracle.com>
* 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.31.1
reply other threads:[~2023-08-10 18:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230810184849.3014338-1-vladimir.mezentsev@oracle.com \
--to=vladimir.mezentsev@oracle.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).