Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1064)

Side by Side Diff: chrome/test/data/nacl/gdb_rsp.py

Issue 1153293003: NaCl cleanup: Stop connecting to the SRPC trusted command channel (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove uncalled OnChannelError() Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # This file is based on gdb_rsp.py file from NaCl repository. 5 # This file is based on gdb_rsp.py file from NaCl repository.
6 6
7 import re 7 import re
8 import socket 8 import socket
9 import time 9 import time
10 10
11 11
12 def RspChecksum(data): 12 def RspChecksum(data):
13 checksum = 0 13 checksum = 0
14 for char in data: 14 for char in data:
15 checksum = (checksum + ord(char)) % 0x100 15 checksum = (checksum + ord(char)) % 0x100
16 return checksum 16 return checksum
17 17
18 18
19 class EofOnReplyException(Exception):
20
bradn 2015/06/11 19:51:59 extra line?
Mark Seaborn 2015/06/11 20:05:11 Well, it's consistent with "One blank line between
21 pass
22
23
19 class GdbRspConnection(object): 24 class GdbRspConnection(object):
20 25
21 def __init__(self, addr): 26 def __init__(self, addr):
22 self._socket = self._Connect(addr) 27 self._socket = self._Connect(addr)
23 28
24 def _Connect(self, addr): 29 def _Connect(self, addr):
25 # We have to poll because we do not know when sel_ldr has 30 # We have to poll because we do not know when sel_ldr has
26 # successfully done bind() on the TCP port. This is inherently 31 # successfully done bind() on the TCP port. This is inherently
27 # unreliable. 32 # unreliable.
28 # TODO(mseaborn): Add a more reliable connection mechanism to 33 # TODO(mseaborn): Add a more reliable connection mechanism to
(...skipping 11 matching lines...) Expand all
40 else: 45 else:
41 return sock 46 return sock
42 raise Exception('Could not connect to sel_ldr\'s debug stub in %i seconds' 47 raise Exception('Could not connect to sel_ldr\'s debug stub in %i seconds'
43 % timeout_in_seconds) 48 % timeout_in_seconds)
44 49
45 def _GetReply(self): 50 def _GetReply(self):
46 reply = '' 51 reply = ''
47 while True: 52 while True:
48 data = self._socket.recv(1024) 53 data = self._socket.recv(1024)
49 if len(data) == 0: 54 if len(data) == 0:
55 if reply == '+':
56 raise EofOnReplyException()
50 raise AssertionError('EOF on socket reached with ' 57 raise AssertionError('EOF on socket reached with '
51 'incomplete reply message: %r' % reply) 58 'incomplete reply message: %r' % reply)
52 reply += data 59 reply += data
53 if '#' in data: 60 if '#' in data:
54 break 61 break
55 match = re.match('\+\$([^#]*)#([0-9a-fA-F]{2})$', reply) 62 match = re.match('\+\$([^#]*)#([0-9a-fA-F]{2})$', reply)
56 if match is None: 63 if match is None:
57 raise AssertionError('Unexpected reply message: %r' % reply) 64 raise AssertionError('Unexpected reply message: %r' % reply)
58 reply_body = match.group(1) 65 reply_body = match.group(1)
59 checksum = match.group(2) 66 checksum = match.group(2)
(...skipping 10 matching lines...) Expand all
70 msg = '$%s#%02x' % (data, RspChecksum(data)) 77 msg = '$%s#%02x' % (data, RspChecksum(data))
71 return self._socket.send(msg) 78 return self._socket.send(msg)
72 79
73 def RspRequest(self, data): 80 def RspRequest(self, data):
74 self.RspSendOnly(data) 81 self.RspSendOnly(data)
75 return self._GetReply() 82 return self._GetReply()
76 83
77 def RspInterrupt(self): 84 def RspInterrupt(self):
78 self._socket.send('\x03') 85 self._socket.send('\x03')
79 return self._GetReply() 86 return self._GetReply()
OLDNEW
« no previous file with comments | « chrome/test/data/nacl/debug_stub_browser_tests.py ('k') | components/nacl/loader/nacl_trusted_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698