On 25/9/18 4:18 am, Nicholas Kazlauskas wrote:
Some programs start with the path and command line arguments in
argv[0] (program_invocation_name). Chromium is an example of
an application using mesa that does this.
This tries to query the real path for the symbolic link /proc/self/exe
to find the program name instead.
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlaus...@amd.com>
---
src/util/u_process.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/util/u_process.c b/src/util/u_process.c
index 5e5927678d..4cae6f6dee 100644
--- a/src/util/u_process.c
+++ b/src/util/u_process.c
@@ -41,8 +41,22 @@ static const char *
__getProgramName()
{
char * arg = strrchr(program_invocation_name, '/');
- if (arg)
+ if (arg) {
+ /* This is likely part of a Linux file path.
+ * Try to get the program name without any command line arguments. */
+ static char * full_path;
+
+ if (!full_path)
+ full_path = realpath("/proc/self/exe", NULL);
+
+ if (full_path) {
+ char * res = strrchr(full_path, '/');
+ if (res)
+ return res+1;
+ }
+
return arg+1;
+ }
This patch still breaks wine apps. Only some apps end up in the code
path below this code hunk i.e. with windows like paths (seems to be
32-bit apps). Others have proper unix paths and end up in your code path
above.
Apologies for not jumping on this earlier you did say this was where you
were headed. I believe you are going to have to implement Nicolai's
suggestion or some other logic to strip off the extra params from the
string.
/usr/lib/chromium/chromium --type=gpu-process --field-trial-handle=...
For the above the current logic should give you:
chromium --type=gpu-process --field-trial-handle=...
Is there a reason you can't just break the string at the space. Do
binary names/paths in program_invocation_name end up with the escape
char? e.g if you rename "chromium" "chrom ium" Do you end up with
"chrom\ ium"?
If so you can look for a space and if it isn't preceded with '\' you can
truncate it.
/* If there was no '/' at all we likely have a windows like path from
* a wine application.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev