[PATCH] Add Solaris support to DetermineClientCmd

2011-12-24 Thread Alan Coopersmith
Uses /proc/pid/psinfo to read command  partial arguments.

Moves cmdsize  argsize variables into non-Solaris #else clause
to avoid unused variable warnings.

Fixes format mismatch errors when building with DEBUG defined on
a 64-bit platform (where Mask is defined as CARD32).

Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
Reviewed-by: Rami Ylimäki rami.ylim...@vincit.fi
---
 os/client.c |   69 ++
 1 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/os/client.c b/os/client.c
index 4aec097..8f4707b 100644
--- a/os/client.c
+++ b/os/client.c
@@ -59,6 +59,11 @@
 #include os.h
 #include dixstruct.h
 
+#ifdef __sun
+#include errno.h
+#include procfs.h
+#endif
+
 /**
  * Try to determine a PID for a client from its connection
  * information. This should be called only once when new client has
@@ -117,8 +122,6 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, 
const char **cmdargs)
 {
 char path[PATH_MAX + 1];
 int totsize = 0;
-int cmdsize = 0;
-int argsize = 0;
 int fd = 0;
 
 if (cmdname)
@@ -129,6 +132,48 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, 
const char **cmdargs)
 if (pid == -1)
 return;
 
+#ifdef __sun /* Solaris */
+/* Solaris does not support /proc/pid/cmdline, but makes information
+ * similar to what ps shows available in a binary structure in the
+ * /proc/pid/psinfo file. */
+if (snprintf(path, sizeof(path), /proc/%d/psinfo, pid)  0)
+return;
+fd = open(path, O_RDONLY);
+if (fd  0)
+{
+ErrorF (Failed to open %s: %s\n, path, strerror(errno));
+return;
+}
+else
+{
+psinfo_t psinfo = { 0 };
+char *sp;
+
+totsize = read(fd, psinfo, sizeof(psinfo_t));
+close(fd);
+if (totsize = 0)
+return;
+
+/* pr_psargs is the first PRARGSZ (80) characters of the command
+ * line string - assume up to the first space is the command name,
+ * since it's not delimited.   While there is also pr_fname, that's
+ * more limited, giving only the first 16 chars of the basename of
+ * the file that was exec'ed, thus cutting off many long gnome
+ * command names, or returning isapython2.6 for all python scripts.
+ */
+psinfo.pr_psargs[PRARGSZ-1] = '\0';
+sp = strchr(psinfo.pr_psargs, ' ');
+if (sp)
+*sp++ = '\0';
+
+if (cmdname)
+*cmdname = strdup(psinfo.pr_psargs);
+
+if (cmdargs  sp)
+*cmdargs = strdup(sp);
+}
+#else /* not Solaris */
+
 /* Check if /proc/pid/cmdline exists. It's not supported on all
  * operating systems. */
 if (snprintf(path, sizeof(path), /proc/%d/cmdline, pid)  0)
@@ -146,17 +191,20 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, 
const char **cmdargs)
 path[totsize - 1] = '\0';
 
 /* Contruct the process name without arguments. */
-cmdsize = strlen(path) + 1;
 if (cmdname)
 {
 *cmdname = strdup(path);
 }
 
 /* Construct the arguments for client process. */
-argsize = totsize - cmdsize;
-if (cmdargs  (argsize  0))
+if (cmdargs)
 {
-char *args = malloc(argsize);
+int cmdsize = strlen(path) + 1;
+int argsize = totsize - cmdsize;
+char *args = NULL;
+
+if (argsize  0)
+args = malloc(argsize);
 if (args)
 {
 int i = 0;
@@ -169,6 +217,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, 
const char **cmdargs)
 *cmdargs = args;
 }
 }
+#endif
 }
 
 /**
@@ -192,9 +241,9 @@ void ReserveClientIds(struct _Client *client)
 DetermineClientCmd(client-clientIds-pid, 
client-clientIds-cmdname, client-clientIds-cmdargs);
 
 DebugF(client(%lx): Reserved pid(%d).\n,
-   client-clientAsMask, client-clientIds-pid);
+   (unsigned long) client-clientAsMask, client-clientIds-pid);
 DebugF(client(%lx): Reserved cmdname(%s) and cmdargs(%s).\n,
-   client-clientAsMask,
+   (unsigned long) client-clientAsMask,
client-clientIds-cmdname ? client-clientIds-cmdname : NULL,
client-clientIds-cmdargs ? client-clientIds-cmdargs : NULL);
 #endif /* CLIENTIDS */
@@ -216,9 +265,9 @@ void ReleaseClientIds(struct _Client *client)
 return;
 
 DebugF(client(%lx): Released pid(%d).\n,
-   client-clientAsMask, client-clientIds-pid);
+   (unsigned long) client-clientAsMask, client-clientIds-pid);
 DebugF(client(%lx): Released cmdline(%s) and cmdargs(%s).\n,
-   client-clientAsMask,
+   (unsigned long) client-clientAsMask,
client-clientIds-cmdname ? client-clientIds-cmdname : NULL,
client-clientIds-cmdargs ? client-clientIds-cmdargs : NULL);
 
-- 
1.7.3.2

___
xorg-devel@lists.x.org: 

Re: [PATCH] Fix build regression on ia64.

2011-12-24 Thread Jeremy Huddleston
Right ... I understand how it works around the issue ... my concern is that I 
don't think this is the fix.  Why is it happening only for outl (ie why isnt it 
happening for outb or others)... I think all 6 should not be exported... 
perhaps all 6 should not be declared...

Sent from my iPhone...

On Dec 23, 2011, at 19:20, Alan Coopersmith alan.coopersm...@oracle.com wrote:

 On 12/23/11 15:59, Jeremy Huddleston wrote:
 I'm sorry, but I fail to see why this would be the fix to your issue... Can 
 you please provide some context.
 
 |   CCLD   Xorg
 | sdksyms.o:(.data.rel+0x27d8): undefined reference to `outl'
 -extern _X_EXPORT void outl(unsigned long port, unsigned int val);
 
 sdksyms.c is the autogenerated source file containing a pointer to every
 struct marked as _X_EXPORT in some header, so as long as there is a header
 processed by the sdksyms script claiming we export that function, sdksyms
 will generate a reference to it so the linker pulls it into the resulting
 Xorg binary.
 
 -- 
-Alan Coopersmith-alan.coopersm...@oracle.com
 Oracle Solaris Platform Engineering: X Window System
 
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: X.org testing with Google Test

2011-12-24 Thread Chase Douglas
On 12/23/2011 03:36 PM, Ian Romanick wrote:
 The big advantage of a test framework like gtest is that the 
 infrastructure makes it easy to write a large number of small, easy to 
 understand (WTF is this testing?), easy to debug (WTF is this failing?) 
 tests.  For the work mentioned above, I wrote about 75 tests.  It wasn't 
 until I was done that I even realized how many there were.  This seems 
 like a good thing.

Because our usage doesn't require real display, xorg-gtest runs with the
dummy video driver by default. This is accomplished by providing a dummy
xorg.conf file and forking the X.org server with it. However, xorg-gtest
allows for using the existing display (using $DISPLAY), or using a
different xorg.conf file.

Do you think xorg-gtest would be helpful for your testing? We want to
make it useful for a broad range of test scenarios.

-- Chase
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH 01/11] glx: Fix mishandling of shared contexts

2011-12-24 Thread Eric Anholt
On Fri, 23 Dec 2011 15:18:19 -0800, Ian Romanick i...@freedesktop.org wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
  glx/glxcmds.c |   22 +++---
  1 files changed, 11 insertions(+), 11 deletions(-)
 
 diff --git a/glx/glxcmds.c b/glx/glxcmds.c
 index d5b764f..c5de60d 100644

 + /* Page 26 (page 32 of the PDF) of the GLX 1.4 spec says:
 +  *
 +  * The server context state for all sharing contexts must exist
 +  * in a single address space or a BadMatch error is generated.
 +  *
 +  * If the share context is indirect, force the new context to also be
 +  * indirect.  If the shard context is direct but the new context

shared.

Other than that, I'm assuming that checking for address space matches
between two direct contexts is handled by the client side (I think I
recall code to that effect, and seems like the only possible place),
which would make this:

Reviewed-by: Eric Anholt e...@anholt.net


pgp5HGNcSrGHG.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] Fix build regression on ia64.

2011-12-24 Thread Cyril Brulebois
Jeremy Huddleston jerem...@apple.com (24/12/2011):
 Right ... I understand how it works around the issue ... my concern is
 that I don't think this is the fix.  Why is it happening only for outl
 (ie why isnt it happening for outb or others)... I think all 6 should
 not be exported... perhaps all 6 should not be declared...

Given how painful sdksyms* is, I guess the fix would be killing that
entirely. In the meanwhile…

Mraw,
KiBi.


signature.asc
Description: Digital signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel