author | Alan Coopersmith <Alan.Coopersmith@Sun.COM> |
Fri, 08 Aug 2008 16:28:28 -0700 | |
changeset 492 | abfa40ff15ef |
child 851 | d428083dbbdd |
permissions | -rw-r--r-- |
492
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
1 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
3 |
* Use subject to license terms. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
4 |
* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
5 |
* Permission is hereby granted, free of charge, to any person obtaining a |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
6 |
* copy of this software and associated documentation files (the |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
7 |
* "Software"), to deal in the Software without restriction, including |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
8 |
* without limitation the rights to use, copy, modify, merge, publish, |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
9 |
* distribute, and/or sell copies of the Software, and to permit persons |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
10 |
* to whom the Software is furnished to do so, provided that the above |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
11 |
* copyright notice(s) and this permission notice appear in all copies of |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
12 |
* the Software and that both the above copyright notice(s) and this |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
13 |
* permission notice appear in supporting documentation. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
14 |
* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
16 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
17 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
18 |
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
19 |
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
20 |
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
21 |
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
22 |
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
23 |
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
24 |
* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
25 |
* Except as contained in this notice, the name of a copyright holder |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
26 |
* shall not be used in advertising or otherwise to promote the sale, use |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
27 |
* or other dealings in this Software without prior written authorization |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
28 |
* of the copyright holder. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
29 |
* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
30 |
* @(#)Xserver_clients.c 1.2 08/08/08 |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
31 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
32 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
33 |
#pragma ident "@(#)Xserver_clients.c 1.2 08/08/08 SMI" |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
34 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
35 |
#include <sys/mdb_modapi.h> |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
36 |
#include "Xserver_headers.h" |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
37 |
#include <X11/extensions/interactive.h> |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
38 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
39 |
struct client_walk_data { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
40 |
uintptr_t client_next; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
41 |
uintptr_t clients_end; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
42 |
ClientRec client_data; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
43 |
}; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
44 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
45 |
#ifdef XORG |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
46 |
/* Xsun has these in a header, Xorg has them in sun-src/IA/interactive.c so |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
47 |
we just copy it here for now. XXX: Move to header in Xorg too. */ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
48 |
typedef struct _ClientProcessInfo { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
49 |
int count; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
50 |
ConnectionPidPtr pids; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
51 |
} ClientProcessRec, * ClientProcessPtr; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
52 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
53 |
typedef struct { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
54 |
ClientProcessPtr process; /* Process id information */ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
55 |
Bool wmgr; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
56 |
} IAClientPrivateRec, *IAClientPrivatePtr; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
57 |
#endif |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
58 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
59 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
60 |
* Initialize the client walker by either using the given starting address, |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
61 |
* or reading the value of the server's "clients" pointer. We also allocate |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
62 |
* a for storage, and save this using the walk_data pointer. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
63 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
64 |
static int |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
65 |
client_walk_init(mdb_walk_state_t *wsp) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
66 |
{ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
67 |
struct client_walk_data *cwda; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
68 |
short max_clients = 128; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
69 |
#ifdef XSUN |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
70 |
# define MAX_CLIENTS "max_clients" |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
71 |
#else |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
72 |
# define MAX_CLIENTS "currentMaxClients" |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
73 |
#endif |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
74 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
75 |
if (wsp->walk_addr == NULL) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
76 |
if (mdb_readvar(&wsp->walk_addr, "clients") == -1) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
77 |
mdb_warn("failed to read 'clients'"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
78 |
return (WALK_ERR); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
79 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
80 |
if (mdb_readvar(&max_clients, MAX_CLIENTS) == -1) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
81 |
mdb_warn("failed to read '%s'", MAX_CLIENTS); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
82 |
return (WALK_ERR); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
83 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
84 |
mdb_printf("%s = %d\n", MAX_CLIENTS, max_clients); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
85 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
86 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
87 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
88 |
wsp->walk_data = mdb_alloc(sizeof (struct client_walk_data), UM_SLEEP); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
89 |
cwda = (struct client_walk_data *) wsp->walk_data; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
90 |
cwda->clients_end = wsp->walk_addr + (max_clients * (sizeof(void *))); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
91 |
return (WALK_NEXT); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
92 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
93 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
94 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
95 |
* At each step, read a client struct into our private storage, and then invoke |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
96 |
* the callback function. We terminate when we reach the end of the clients |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
97 |
* array. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
98 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
99 |
static int |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
100 |
client_walk_step(mdb_walk_state_t *wsp) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
101 |
{ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
102 |
int status; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
103 |
uintptr_t clientPtr; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
104 |
struct client_walk_data *cwda = |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
105 |
(struct client_walk_data *) wsp->walk_data; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
106 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
107 |
if (wsp->walk_addr == NULL) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
108 |
return (WALK_DONE); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
109 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
110 |
do { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
111 |
if (mdb_vread(&clientPtr, sizeof (void *), wsp->walk_addr) == -1) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
112 |
mdb_warn("failed to read client table entry at %p", wsp->walk_addr); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
113 |
return (WALK_DONE); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
114 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
115 |
if (clientPtr == NULL) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
116 |
#ifdef DEBUG |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
117 |
mdb_printf("NULL entry at %p", wsp->walk_addr); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
118 |
#endif |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
119 |
wsp->walk_addr += sizeof(void *); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
120 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
121 |
if (wsp->walk_addr >= cwda->clients_end) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
122 |
#ifdef DEBUG |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
123 |
mdb_printf("End of client list at %p", cwda->clients_end); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
124 |
#endif |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
125 |
return (WALK_DONE); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
126 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
127 |
} while (clientPtr == NULL); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
128 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
129 |
if (clientPtr == NULL) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
130 |
return (WALK_DONE); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
131 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
132 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
133 |
if (mdb_vread(&(cwda->client_data), sizeof (ClientRec), (uintptr_t) clientPtr) == -1) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
134 |
mdb_warn("failed to read client data at %p", wsp->walk_addr); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
135 |
return (WALK_DONE); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
136 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
137 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
138 |
status = wsp->walk_callback(wsp->walk_addr, &(cwda->client_data), |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
139 |
wsp->walk_cbdata); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
140 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
141 |
wsp->walk_addr = wsp->walk_addr + sizeof(void *); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
142 |
return (status); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
143 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
144 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
145 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
146 |
* The walker's fini function is invoked at the end of each walk. Since we |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
147 |
* dynamically allocated a proc_t in client_walk_init, we must free it now. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
148 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
149 |
static void |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
150 |
client_walk_fini(mdb_walk_state_t *wsp) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
151 |
{ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
152 |
mdb_free(wsp->walk_data, sizeof (ClientRec)); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
153 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
154 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
155 |
static int |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
156 |
client_pids(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
157 |
{ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
158 |
uintptr_t clientP; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
159 |
ClientRec client_data; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
160 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
161 |
if (argc != 0) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
162 |
return (DCMD_USAGE); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
163 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
164 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
165 |
* If no client address was specified on the command line, we can |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
166 |
* print out all clients by invoking the walker, using this |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
167 |
* dcmd itself as the callback. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
168 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
169 |
if (!(flags & DCMD_ADDRSPEC)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
170 |
if (mdb_walk_dcmd("client_walk", "client_pids", |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
171 |
argc, argv) == -1) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
172 |
mdb_warn("failed to walk 'client_walk'"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
173 |
return (DCMD_ERR); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
174 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
175 |
return (DCMD_OK); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
176 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
177 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
178 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
179 |
* If this is the first invocation of the command, print a nice |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
180 |
* header line for the output that will follow. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
181 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
182 |
if (DCMD_HDRSPEC(flags)) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
183 |
mdb_printf("CLIENT SEQUENCE # FD PIDS\n"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
184 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
185 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
186 |
if (mdb_vread(&clientP, sizeof (clientP), addr) == sizeof (clientP)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
187 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
188 |
if (mdb_vread(&client_data, sizeof (client_data), clientP) == sizeof (client_data)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
189 |
mdb_printf("%5d %10d", client_data.index, client_data.sequence); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
190 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
191 |
if (client_data.osPrivate != NULL) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
192 |
OsCommRec oscomm; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
193 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
194 |
if (mdb_vread(&oscomm, sizeof (oscomm), |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
195 |
(uintptr_t)client_data.osPrivate) == sizeof (oscomm)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
196 |
ClientProcessPtr cpp; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
197 |
#ifdef XORG |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
198 |
int IAClientPrivateIndex; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
199 |
#endif |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
200 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
201 |
mdb_printf("%4d ", oscomm.fd); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
202 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
203 |
#ifdef XSUN |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
204 |
cpp = oscomm.process; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
205 |
#else /* XORG */ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
206 |
if (mdb_readvar(&IAClientPrivateIndex, |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
207 |
"libIA.so`IAClientPrivateIndex") == -1) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
208 |
mdb_warn("failed to read 'IAClientPrivateIndex'"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
209 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
210 |
DevUnion *cppaddr = &(client_data.devPrivates[IAClientPrivateIndex]); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
211 |
if (mdb_vread(&cpp, sizeof (cpp), (uintptr_t) cppaddr) != sizeof (cpp)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
212 |
cpp = NULL; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
213 |
mdb_warn("failed to read client_data.devPrivates[IAClientPrivateIndex]"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
214 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
215 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
216 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
217 |
#endif |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
218 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
219 |
if (cpp != NULL) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
220 |
ClientProcessRec cpr; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
221 |
ConnectionPidRec pid; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
222 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
223 |
if (mdb_vread(&cpr, sizeof (cpr), |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
224 |
(uintptr_t)cpp) == sizeof (cpr)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
225 |
int i; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
226 |
uintptr_t pidP = (uintptr_t) cpr.pids; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
227 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
228 |
for (i = 0; i < cpr.count; i++, pidP += sizeof(pid)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
229 |
if (mdb_vread(&pid, sizeof (pid), pidP) == sizeof (pid)) { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
230 |
mdb_printf("%d ", pid); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
231 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
232 |
mdb_warn("failed to read pid #%d from %p", i, pidP); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
233 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
234 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
235 |
mdb_printf("\n"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
236 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
237 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
238 |
mdb_warn("failed to read struct ClientProcessRec at %p", client_data.osPrivate); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
239 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
240 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
241 |
mdb_printf(" ??? - NULL ClientProcessPtr\n"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
242 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
243 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
244 |
mdb_warn("failed to read struct OsCommRec at %p", client_data.osPrivate); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
245 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
246 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
247 |
mdb_printf(" ??? - NULL ClientPtr->osPrivate\n"); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
248 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
249 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
250 |
mdb_warn("failed to read ClientRec at %p", clientP); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
251 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
252 |
} else { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
253 |
mdb_warn("failed to read ClientPtr at %p", addr); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
254 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
255 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
256 |
return (DCMD_OK); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
257 |
} |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
258 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
259 |
/* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
260 |
* MDB module linkage information: |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
261 |
* |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
262 |
* We declare a list of structures describing our dcmds, a list of structures |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
263 |
* describing our walkers, and a function named _mdb_init to return a pointer |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
264 |
* to our module information. |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
265 |
*/ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
266 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
267 |
static const mdb_dcmd_t dcmds[] = { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
268 |
{ "client_pids", NULL, "client process list", client_pids }, |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
269 |
{ NULL } |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
270 |
}; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
271 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
272 |
static const mdb_walker_t walkers[] = { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
273 |
{ "client_walk", "walk list of clients connected to Xsun", |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
274 |
client_walk_init, client_walk_step, client_walk_fini }, |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
275 |
{ NULL } |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
276 |
}; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
277 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
278 |
static const mdb_modinfo_t modinfo = { |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
279 |
MDB_API_VERSION, dcmds, walkers |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
280 |
}; |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
281 |
|
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
282 |
const mdb_modinfo_t * |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
283 |
_mdb_init(void) |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
284 |
{ |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
285 |
return (&modinfo); |
abfa40ff15ef
6735204 Port Xsun mdb dcmds/scripts to Xorg and move to open-src tree
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
286 |
} |