diff options
-rw-r--r-- | configure.ac | 29 | ||||
-rw-r--r-- | dix/Makefile.am | 20 | ||||
-rw-r--r-- | dix/Xserver-dtrace.h.in | 100 | ||||
-rw-r--r-- | dix/Xserver.d | 59 | ||||
-rw-r--r-- | dix/dispatch.c | 119 | ||||
-rw-r--r-- | dix/events.c | 14 | ||||
-rw-r--r-- | dix/extension.c | 14 | ||||
-rw-r--r-- | dix/resource.c | 56 | ||||
-rw-r--r-- | include/dix-config.h.in | 6 | ||||
-rw-r--r-- | os/Makefile.am | 12 | ||||
-rw-r--r-- | os/connection.c | 30 |
11 files changed, 453 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 473ff9b07..c23bf5082 100644 --- a/configure.ac +++ b/configure.ac @@ -66,6 +66,26 @@ AC_PROG_YACC AC_SYS_LARGEFILE XORG_PROG_RAWCPP +dnl Check for dtrace program (needed to build Xserver dtrace probes) +AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH], + [Enable dtrace probes (default: enabled if dtrace found)]), + [WDTRACE=$withval], [WDTRACE=auto]) +if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then + AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin]) + if test "x$DTRACE" = "xnot_found" ; then + if test "x$WDTRACE" = "xyes" ; then + AC_MSG_FAILURE([dtrace requested but not found]) + fi + WDTRACE="no" + fi +fi +if test "x$WDTRACE" != "xno" ; then + AC_DEFINE(XSERVER_DTRACE, 1, + [Define to 1 if the DTrace Xserver provider probes should be built in.]) +fi +AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"]) +AC_DEFINE_DIR(XERRORDB_PATH, libdir/XErrorDB, [Path to XErrorDB file]) + AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) @@ -873,8 +893,13 @@ AC_DEFINE(XCMISC, 1, [Support XCMisc extension]) AC_DEFINE(BIGREQS, 1, [Support BigRequests extension]) AC_DEFINE(PIXPRIV, 1, [Support pixmap privates]) -DIX_LIB='$(top_builddir)/dix/libdix.la' -OS_LIB='$(top_builddir)/os/libos.la' +if test "x$WDTRACE" != "xno" ; then + DIX_LIB='$(top_builddir)/dix/dix.O' + OS_LIB='$(top_builddir)/os/os.O' +else + DIX_LIB='$(top_builddir)/dix/libdix.la' + OS_LIB='$(top_builddir)/os/libos.la' +fi CWRAP_LIB='$(top_builddir)/os/libcwrapper.la' MI_LIB='$(top_builddir)/mi/libmi.la' MINIMI_LIB='$(top_builddir)/mi/libminimi.la' diff --git a/dix/Makefile.am b/dix/Makefile.am index 724d1d1f6..d0d6e8785 100644 --- a/dix/Makefile.am +++ b/dix/Makefile.am @@ -38,4 +38,22 @@ libxpstubs_la_SOURCES = \ INCLUDES = -I$(top_srcdir)/Xprint -EXTRA_DIST = buildatoms BuiltInAtoms CHANGES +EXTRA_DIST = buildatoms BuiltInAtoms CHANGES Xserver.d Xserver-dtrace.h.in + +if XSERVER_DTRACE +# Generate dtrace header file for C sources to include +BUILT_SOURCES = Xserver-dtrace.h + +Xserver-dtrace.h: $(srcdir)/Xserver.d + $(DTRACE) -C -h -o $@ -s $(srcdir)/Xserver.d \ + || cp Xserver-dtrace.h.in $@ + +# Generate dtrace object code for probes in libdix +dtrace-dix.o: $(top_srcdir)/dix/Xserver.d $(am_libdix_la_OBJECTS) + $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o + +noinst_LIBRARIES = dix.O + +dix.O: dtrace-dix.o $(am_libdix_la_OBJECTS) + ld -r -o $@ .libs/*.o +endif diff --git a/dix/Xserver-dtrace.h.in b/dix/Xserver-dtrace.h.in new file mode 100644 index 000000000..26a8b4099 --- /dev/null +++ b/dix/Xserver-dtrace.h.in @@ -0,0 +1,100 @@ +/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +/* + * Generated by dtrace(1M), and then modified for backwards compatibility + * with older versions of dtrace. Used if dtrace -h fails. + * (Since _ENABLED support was added after dtrace -h, this assumes if + * dtrace -h fails, _ENABLED will too.) + */ + +#ifndef _XSERVER_DTRACE_H +#define _XSERVER_DTRACE_H + +#include <unistd.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#if _DTRACE_VERSION + +#define XSERVER_CLIENT_AUTH(arg0, arg1, arg2, arg3) \ + __dtrace_Xserver___client__auth(arg0, arg1, arg2, arg3) +#define XSERVER_CLIENT_CONNECT(arg0, arg1) \ + __dtrace_Xserver___client__connect(arg0, arg1) +#define XSERVER_CLIENT_DISCONNECT(arg0) \ + __dtrace_Xserver___client__disconnect(arg0) +#define XSERVER_REQUEST_DONE(arg0, arg1, arg2, arg3, arg4) \ + __dtrace_Xserver___request__done(arg0, arg1, arg2, arg3, arg4) +#define XSERVER_REQUEST_START(arg0, arg1, arg2, arg3, arg4) \ + __dtrace_Xserver___request__start(arg0, arg1, arg2, arg3, arg4) +#define XSERVER_RESOURCE_ALLOC(arg0, arg1, arg2, arg3) \ + __dtrace_Xserver___resource__alloc(arg0, arg1, arg2, arg3) +#define XSERVER_RESOURCE_FREE(arg0, arg1, arg2, arg3) \ + __dtrace_Xserver___resource__free(arg0, arg1, arg2, arg3) +#define XSERVER_SEND_EVENT(arg0, arg1, arg2) \ + __dtrace_Xserver___send__event(arg0, arg1, arg2) + + +extern void __dtrace_Xserver___client__auth(int, string, pid_t, zoneid_t); +extern void __dtrace_Xserver___client__connect(int, int); +extern void __dtrace_Xserver___client__disconnect(int); +extern void __dtrace_Xserver___request__done(string, uint8_t, uint32_t, int, int); +extern void __dtrace_Xserver___request__start(string, uint8_t, uint16_t, int, void *); +extern void __dtrace_Xserver___resource__alloc(uint32_t, uint32_t, void *, string); +extern void __dtrace_Xserver___resource__free(uint32_t, uint32_t, void *, string); +extern void __dtrace_Xserver___send__event(int, uint8_t, void *); + +#else + +#define XSERVER_CLIENT_AUTH(arg0, arg1, arg2, arg3) +#define XSERVER_CLIENT_CONNECT(arg0, arg1) +#define XSERVER_CLIENT_DISCONNECT(arg0) +#define XSERVER_REQUEST_DONE(arg0, arg1, arg2, arg3, arg4) +#define XSERVER_REQUEST_START(arg0, arg1, arg2, arg3, arg4) +#define XSERVER_RESOURCE_ALLOC(arg0, arg1, arg2, arg3) +#define XSERVER_RESOURCE_FREE(arg0, arg1, arg2, arg3) +#define XSERVER_SEND_EVENT(arg0, arg1, arg2) + +#endif + +#define XSERVER_CLIENT_AUTH_ENABLED() (1) +#define XSERVER_CLIENT_CONNECT_ENABLED() (1) +#define XSERVER_CLIENT_DISCONNECT_ENABLED() (1) +#define XSERVER_REQUEST_DONE_ENABLED() (1) +#define XSERVER_REQUEST_START_ENABLED() (1) +#define XSERVER_RESOURCE_ALLOC_ENABLED() (1) +#define XSERVER_RESOURCE_FREE_ENABLED() (1) +#define XSERVER_SEND_EVENT_ENABLED() (1) + +#ifdef __cplusplus +} +#endif + +#endif /* _XSERVER_DTRACE_H */ diff --git a/dix/Xserver.d b/dix/Xserver.d new file mode 100644 index 000000000..e4c9b8320 --- /dev/null +++ b/dix/Xserver.d @@ -0,0 +1,59 @@ +/* Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +/* + * Xserver dtrace provider definition + */ + +#include <sys/types.h> + +provider Xserver { + /* reqType, data, length, client id, request buffer */ + probe request__start(string, uint8_t, uint16_t, int, void *); + /* reqType, data, sequence, client id, result */ + probe request__done(string, uint8_t, uint32_t, int, int); + /* client id, client fd */ + probe client__connect(int, int); + /* client id, client address, client pid, client zone id */ + probe client__auth(int, string, pid_t, zoneid_t); + /* client id */ + probe client__disconnect(int); + /* resource id, resource type, value, resource type name */ + probe resource__alloc(uint32_t, uint32_t, void *, string); + /* resource id, resource type, value, resource type name */ + probe resource__free(uint32_t, uint32_t, void *, string); + /* client id, event type, event* */ + probe send__event(int, uint8_t, void *); +}; + +#pragma D attributes Unstable/Unstable/Common provider Xserver provider +#pragma D attributes Private/Private/Unknown provider Xserver module +#pragma D attributes Private/Private/Unknown provider Xserver function +#pragma D attributes Unstable/Unstable/Common provider Xserver name +#pragma D attributes Unstable/Unstable/Common provider Xserver args + diff --git a/dix/dispatch.c b/dix/dispatch.c index 6347e3924..2e7fa79ab 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -74,6 +74,36 @@ Equipment Corporation. ******************************************************************/ +/* XSERVER_DTRACE additions: + * Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + + #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -119,6 +149,17 @@ int ProcInitialConnection(); #include <X11/extensions/XKBsrv.h> #endif +#ifdef XSERVER_DTRACE +#include <sys/types.h> +typedef const char *string; +#include "Xserver-dtrace.h" + +char *RequestNames[256]; +static void LoadRequestNames(void); +static void FreeRequestNames(void); +#define GetRequestName(i) (RequestNames[i]) +#endif + #define mskcnt ((MAXCLIENTS + 31) / 32) #define BITMASK(i) (1U << ((i) & 31)) #define MASKIDX(i) ((i) >> 5) @@ -373,6 +414,10 @@ Dispatch(void) if (!clientReady) return; +#ifdef XSERVER_DTRACE + LoadRequestNames(); +#endif + while (!dispatchException) { if (*icheck[0] != *icheck[1]) @@ -452,6 +497,11 @@ Dispatch(void) client->requestLog[client->requestLogIndex] = MAJOROP; client->requestLogIndex++; #endif +#ifdef XSERVER_DTRACE + XSERVER_REQUEST_START(GetRequestName(MAJOROP), MAJOROP, + ((xReq *)client->requestBuffer)->length, + client->index, client->requestBuffer); +#endif if (result > (maxBigRequestSize << 2)) result = BadLength; else @@ -464,7 +514,11 @@ Dispatch(void) #else result = (* client->requestVector[MAJOROP])(client); #endif /* XACE */ - +#ifdef XSERVER_DTRACE + XSERVER_REQUEST_DONE(GetRequestName(MAJOROP), MAJOROP, + client->sequence, client->index, result); +#endif + if (result != Success) { if (client->noClientException != Success) @@ -495,6 +549,9 @@ Dispatch(void) KillAllClients(); DEALLOCATE_LOCAL(clientReady); dispatchException &= ~DE_RESET; +#ifdef XSERVER_DTRACE + FreeRequestNames(); +#endif } #undef MAJOROP @@ -3569,6 +3626,9 @@ CloseDownClient(register ClientPtr client) CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); } FreeClientResources(client); +#ifdef XSERVER_DTRACE + XSERVER_CLIENT_DISCONNECT(client->index); +#endif if (client->index < nextFreeClientID) nextFreeClientID = client->index; clients[client->index] = NullClient; @@ -3995,3 +4055,60 @@ MarkClientException(ClientPtr client) { client->noClientException = -1; } + +#ifdef XSERVER_DTRACE +#include <ctype.h> + +/* Load table of request names for dtrace probes */ +static void LoadRequestNames(void) +{ + int i; + FILE *xedb; + extern void LoadExtensionNames(char **RequestNames); + + bzero(RequestNames, 256 * sizeof(char *)); + + xedb = fopen(XERRORDB_PATH, "r"); + if (xedb != NULL) { + char buf[256]; + while (fgets(buf, sizeof(buf), xedb)) { + if ((strncmp("XRequest.", buf, 9) == 0) && (isdigit(buf[9]))) { + char *name; + i = strtol(buf + 9, &name, 10); + if (RequestNames[i] == 0) { + char *end = strchr(name, '\n'); + if (end) { *end = '\0'; } + RequestNames[i] = strdup(name + 1); + } + } + } + fclose(xedb); + } + + LoadExtensionNames(RequestNames); + + for (i = 0; i < 256; i++) { + if (RequestNames[i] == 0) { +#define RN_SIZE 12 /* "Request#' + up to 3 digits + \0 */ + RequestNames[i] = xalloc(RN_SIZE); + if (RequestNames[i]) { + snprintf(RequestNames[i], RN_SIZE, "Request#%d", i); + } + } + /* fprintf(stderr, "%d: %s\n", i, RequestNames[i]); */ + } +} + +static void FreeRequestNames(void) +{ + int i; + + for (i = 0; i < 256; i++) { + if (RequestNames[i] != 0) { + free(RequestNames[i]); + RequestNames[i] = 0; + } + } +} + +#endif diff --git a/dix/events.c b/dix/events.c index 3425cb433..3b1a0aaf4 100644 --- a/dix/events.c +++ b/dix/events.c @@ -141,6 +141,12 @@ extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); #include "xace.h" #endif +#ifdef XSERVER_DTRACE +#include <sys/types.h> +typedef const char *string; +#include "Xserver-dtrace.h" +#endif + #ifdef XEVIE extern WindowPtr *WindowTable; extern int xevieFlag; @@ -4553,6 +4559,14 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) eventinfo.count = count; CallCallbacks(&EventCallback, (pointer)&eventinfo); } +#ifdef XSERVER_DTRACE + if (XSERVER_SEND_EVENT_ENABLED()) { + for (i = 0; i < count; i++) + { + XSERVER_SEND_EVENT(pClient->index, events[i].u.u.type, &events[i]); + } + } +#endif if(pClient->swapped) { for(i = 0; i < count; i++) diff --git a/dix/extension.c b/dix/extension.c index f58c73138..fe779b2be 100644 --- a/dix/extension.c +++ b/dix/extension.c @@ -482,3 +482,17 @@ RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) } return TRUE; } + +#ifdef XSERVER_DTRACE +void LoadExtensionNames(char **RequestNames) { + int i; + + for (i=0; i<NumExtensions; i++) { + int r = extensions[i]->base; + + if (RequestNames[r] == NULL) { + RequestNames[r] = strdup(extensions[i]->name); + } + } +} +#endif diff --git a/dix/resource.c b/dix/resource.c index b2d01c8f3..efb759e75 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -72,6 +72,34 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ +/* XSERVER_DTRACE additions: + * Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ /* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */ @@ -125,6 +153,14 @@ Equipment Corporation. #endif #include <assert.h> +#ifdef XSERVER_DTRACE +#include <sys/types.h> +typedef const char *string; +#include "Xserver-dtrace.h" + +#define TypeNameString(t) NameForAtom(ResourceNames[t & TypeMask]) +#endif + static void RebuildTable( int /*client*/ ); @@ -429,6 +465,9 @@ AddResource(XID id, RESTYPE type, pointer value) register ClientResourceRec *rrec; register ResourcePtr res, *head; +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_ALLOC(id, type, value, TypeNameString(type)); +#endif client = CLIENT_ID(id); rrec = &clientTable[client]; if (!rrec->buckets) @@ -528,6 +567,11 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType) if (res->id == id) { RESTYPE rtype = res->type; + +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(res->id, res->type, + res->value, TypeNameString(res->type)); +#endif *prev = res->next; elements = --*eltptr; if (rtype & RC_CACHED) @@ -569,6 +613,10 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree) { if (res->id == id && res->type == type) { +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(res->id, res->type, + res->value, TypeNameString(res->type)); +#endif *prev = res->next; if (type & RC_CACHED) FlushClientCaches(res->id); @@ -731,6 +779,10 @@ FreeClientNeverRetainResources(ClientPtr client) RESTYPE rtype = this->type; if (rtype & RC_NEVERRETAIN) { +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(this->id, this->type, + this->value, TypeNameString(this->type)); +#endif *prev = this->next; if (rtype & RC_CACHED) FlushClientCaches(this->id); @@ -777,6 +829,10 @@ FreeClientResources(ClientPtr client) for (this = *head; this; this = *head) { RESTYPE rtype = this->type; +#ifdef XSERVER_DTRACE + XSERVER_RESOURCE_FREE(this->id, this->type, + this->value, TypeNameString(this->type)); +#endif *head = this->next; if (rtype & RC_CACHED) FlushClientCaches(this->id); diff --git a/include/dix-config.h.in b/include/dix-config.h.in index fc1e69ace..1120337e8 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -460,4 +460,10 @@ /* Have a monotonic clock from clock_gettime() */ #undef MONOTONIC_CLOCK +/* Define to 1 if the DTrace Xserver provider probes should be built in */ +#undef XSERVER_DTRACE + +/* Path to XErrorDB file */ +#undef XERRORDB_PATH + #endif /* _DIX_CONFIG_H_ */ diff --git a/os/Makefile.am b/os/Makefile.am index 71e24c086..dcfe80ac3 100644 --- a/os/Makefile.am +++ b/os/Makefile.am @@ -50,3 +50,15 @@ libcwrapper_la_CFLAGS = \ EXTRA_DIST = $(K5AUTH_SOURCES) $(SECURERPC_SOURCES) $(INTERNALMALLOC_SOURCES) \ $(XCSECURITY_SOURCES) $(XDMCP_SOURCES) $(LBX_SOURCES) $(STRLCAT_SOURCES) + +if XSERVER_DTRACE +# Generate dtrace object code for probes in libos & libdix +dtrace.o: $(top_srcdir)/dix/Xserver.d $(am_libos_la_OBJECTS) + $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o ../dix/.libs/*.o + +noinst_LIBRARIES = os.O + +os.O: dtrace.o $(am_libos_la_OBJECTS) + ld -r -o $@ dtrace.o .libs/*.o + +endif diff --git a/os/connection.c b/os/connection.c index ecdae0f79..cdd1d184a 100644 --- a/os/connection.c +++ b/os/connection.c @@ -170,6 +170,13 @@ extern __const__ int _nfiles; # include <zone.h> #endif +#ifdef XSERVER_DTRACE +# include <sys/types.h> +typedef const char *string; +# include "../dix/Xserver-dtrace.h" +# include <ucred.h> +#endif + int lastfdesc; /* maximum file descriptor */ fd_set WellKnownConnections; /* Listener mask */ @@ -619,14 +626,22 @@ AuthAudit (ClientPtr client, Bool letin, client_uid_string[0] = '\0'; } - if (proto_n) +#ifdef XSERVER_DTRACE + XSERVER_CLIENT_AUTH(client->index, addr, client_pid, client_zid); + if (auditTrailLevel > 1) { +#endif + if (proto_n) AuditF("client %d %s from %s%s\n Auth name: %.*s ID: %d\n", client->index, letin ? "connected" : "rejected", addr, client_uid_string, (int)proto_n, auth_proto, auth_id); - else + else AuditF("client %d %s from %s%s\n", client->index, letin ? "connected" : "rejected", addr, client_uid_string); + +#ifdef XSERVER_DTRACE + } +#endif } XID @@ -693,7 +708,11 @@ ClientAuthorized(ClientPtr client, else { auth_id = (XID) 0; +#ifdef XSERVER_DTRACE + if ((auditTrailLevel > 1) || XSERVER_CLIENT_AUTH_ENABLED()) +#else if (auditTrailLevel > 1) +#endif AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen, proto_n, auth_proto, auth_id); @@ -709,7 +728,11 @@ ClientAuthorized(ClientPtr client, return "Client is not authorized to connect to Server"; } } +#ifdef XSERVER_DTRACE + else if ((auditTrailLevel > 1) || XSERVER_CLIENT_AUTH_ENABLED()) +#else else if (auditTrailLevel > 1) +#endif { if (_XSERVTransGetPeerAddr (trans_conn, &family, &fromlen, &from) != -1) @@ -787,6 +810,9 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n", client->index, fd); #endif +#ifdef XSERVER_DTRACE + XSERVER_CLIENT_CONNECT(client->index, fd); +#endif return client; } |