Skip to content

Commit dce5e40

Browse files
committed
Added x bugging tools
1 parent e6ac98b commit dce5e40

3 files changed

Lines changed: 253 additions & 1 deletion

File tree

‎Xlib/protocol/request.py‎

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: request.py,v 1.4 2000-08-21 10:03:46 petli Exp $
1+
# $Id: request.py,v 1.5 2000-11-30 10:13:52 petli Exp $
22
#
33
# Xlib.protocol.request -- definitions of core requests
44
#
@@ -1744,3 +1744,126 @@ class NoOperation(rq.Request):
17441744
rq.RequestLength(),
17451745
)
17461746

1747+
1748+
major_codes = {
1749+
1: CreateWindow,
1750+
2: ChangeWindowAttributes,
1751+
3: GetWindowAttributes,
1752+
4: DestroyWindow,
1753+
5: DestroySubWindows,
1754+
6: ChangeSaveSet,
1755+
7: ReparentWindow,
1756+
8: MapWindow,
1757+
9: MapSubwindows,
1758+
10: UnmapWindow,
1759+
11: UnmapSubwindows,
1760+
12: ConfigureWindow,
1761+
13: CirculateWindow,
1762+
14: GetGeometry,
1763+
15: QueryTree,
1764+
16: InternAtom,
1765+
17: GetAtomName,
1766+
18: ChangeProperty,
1767+
19: DeleteProperty,
1768+
20: GetProperty,
1769+
21: ListProperties,
1770+
22: SetSelectionOwner,
1771+
23: GetSelectionOwner,
1772+
24: ConvertSelection,
1773+
25: SendEvent,
1774+
26: GrabPointer,
1775+
27: UngrabPointer,
1776+
28: GrabButton,
1777+
29: UngrabButton,
1778+
30: ChangeActivePointerGrab,
1779+
31: GrabKeyboard,
1780+
32: UngrabKeyboard,
1781+
33: GrabKey,
1782+
34: UngrabKey,
1783+
35: AllowEvents,
1784+
36: GrabServer,
1785+
37: UngrabServer,
1786+
38: QueryPointer,
1787+
39: GetMotionEvents,
1788+
40: TranslateCoords,
1789+
41: WarpPointer,
1790+
42: SetInputFocus,
1791+
43: GetInputFocus,
1792+
44: QueryKeymap,
1793+
45: OpenFont,
1794+
46: CloseFont,
1795+
47: QueryFont,
1796+
48: QueryTextExtents,
1797+
49: ListFonts,
1798+
50: ListFontsWithInfo,
1799+
51: SetFontPath,
1800+
52: GetFontPath,
1801+
53: CreatePixmap,
1802+
54: FreePixmap,
1803+
55: CreateGC,
1804+
56: ChangeGC,
1805+
57: CopyGC,
1806+
58: SetDashes,
1807+
59: SetClipRectangles,
1808+
60: FreeGC,
1809+
61: ClearArea,
1810+
62: CopyArea,
1811+
63: CopyPlane,
1812+
64: PolyPoint,
1813+
65: PolyLine,
1814+
66: PolySegment,
1815+
67: PolyRectangle,
1816+
68: PolyArc,
1817+
69: FillPoly,
1818+
70: PolyFillRectangle,
1819+
71: PolyFillArc,
1820+
72: PutImage,
1821+
73: GetImage,
1822+
74: PolyText8,
1823+
75: PolyText16,
1824+
76: ImageText8,
1825+
77: ImageText16,
1826+
78: CreateColormap,
1827+
79: FreeColormap,
1828+
80: CopyColormapAndFree,
1829+
81: InstallColormap,
1830+
82: UninstallColormap,
1831+
83: ListInstalledColormaps,
1832+
84: AllocColor,
1833+
85: AllocNamedColor,
1834+
86: AllocColorCells,
1835+
87: AllocColorPlanes,
1836+
88: FreeColors,
1837+
89: StoreColors,
1838+
90: StoreNamedColor,
1839+
91: QueryColors,
1840+
92: LookupColor,
1841+
93: CreateCursor,
1842+
94: CreateGlyphCursor,
1843+
95: FreeCursor,
1844+
96: RecolorCursor,
1845+
97: QueryBestSize,
1846+
98: QueryExtension,
1847+
99: ListExtensions,
1848+
100: ChangeKeyboardMapping,
1849+
101: GetKeyboardMapping,
1850+
102: ChangeKeyboardControl,
1851+
103: GetKeyboardControl,
1852+
104: Bell,
1853+
105: ChangePointerControl,
1854+
106: GetPointerControl,
1855+
107: SetScreenSaver,
1856+
108: GetScreenSaver,
1857+
109: ChangeHosts,
1858+
110: ListHosts,
1859+
111: SetAccessControl,
1860+
112: SetCloseDownMode,
1861+
113: KillClient,
1862+
114: RotateProperties,
1863+
115: ForceScreenSaver,
1864+
116: SetPointerMapping,
1865+
117: GetPointerMapping,
1866+
118: SetModifierMapping,
1867+
119: GetModifierMapping,
1868+
127: NoOperation,
1869+
}

‎utils/parsexbug.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/python
2+
3+
class BugFile:
4+
def __init__(self, file):
5+
self.file = file
6+
self.cbuf = self.sbuf = ''
7+
8+
def read_client(self, bytes):
9+
while len(self.cbuf) < bytes and self.file:
10+
self.read_next()
11+
12+
d = self.cbuf[:bytes]
13+
self.cbuf = self.cbuf[bytes:]
14+
15+
return d
16+
17+
def read_server(self, bytes):
18+
while len(self.sbuf) < bytes and self.file:
19+
self.read_next()
20+
21+
d = self.sbuf[:bytes]
22+
self.sbuf = self.sbuf[bytes:]
23+
24+
return d
25+
26+
def read_next(self):
27+
line = self.file.readline()
28+
if line == '':
29+
self.file = None
30+
return
31+
32+
src = line[0]
33+
length = int(line[1:-1])
34+
data = self.file.read(length)
35+
if src == 'C':
36+
self.cbuf = self.cbuf + data
37+
elif src == 'S':
38+
self.sbuf = self.sbuf + data
39+
else:
40+
raise ValueError('Bad control line: %s' % line)
41+

‎utils/tcpbug.py‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/python
2+
3+
import socket
4+
import select
5+
import sys
6+
import os
7+
8+
def tcpbug(listenaddr, destaddr, outputfd):
9+
listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
10+
listen.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
11+
listen.bind(listenaddr)
12+
listen.listen(1)
13+
14+
client, addr = listen.accept()
15+
16+
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
17+
server.connect(destaddr)
18+
19+
cwbuf = swbuf = outbuf = ''
20+
21+
while client or server or outbuf:
22+
readset = []
23+
if client:
24+
readset.append(client)
25+
if server:
26+
readset.append(server)
27+
28+
writeset = []
29+
if cwbuf and client:
30+
writeset.append(client)
31+
if swbuf and server:
32+
writeset.append(server)
33+
if outbuf:
34+
writeset.append(outputfd)
35+
36+
readset, writeset, e = select.select(readset, writeset, [])
37+
38+
if client in readset:
39+
data = client.recv(2000)
40+
if data:
41+
swbuf = swbuf + data
42+
outbuf = outbuf + 'C%d\n%s' % (len(data), data)
43+
else:
44+
client = None
45+
46+
if server in readset:
47+
data = server.recv(2000)
48+
if data:
49+
cwbuf = cwbuf + data
50+
outbuf = outbuf + 'S%d\n%s' % (len(data), data)
51+
else:
52+
server = None
53+
54+
if client in writeset:
55+
n = client.send(cwbuf)
56+
cwbuf = cwbuf[n:]
57+
58+
if server in writeset:
59+
n = server.send(swbuf)
60+
swbuf = swbuf[n:]
61+
62+
if outputfd in writeset:
63+
n = os.write(outputfd, outbuf)
64+
outbuf = outbuf[n:]
65+
66+
if client and not cwbuf and not server:
67+
client.close()
68+
client = None
69+
70+
if server and not swbuf and not client:
71+
server.close()
72+
server = None
73+
74+
def main():
75+
try:
76+
lport = int(sys.argv[1])
77+
dhost = sys.argv[2]
78+
dport = int(sys.argv[3])
79+
except (IndexError, ValueError):
80+
sys.stderr.write('Usage: %s listenport desthost destport\n'
81+
% sys.argv[0])
82+
exit(1)
83+
84+
tcpbug(('', lport), (dhost, dport), 1)
85+
86+
if __name__ == '__main__':
87+
main()
88+

0 commit comments

Comments
 (0)