fork(1) download
  1. # -- coding: cp1251 --
  2. #! /usr/bin/python3
  3. import socket
  4.  
  5. switch = { '$qSupported':'PacketSize=131072;swbreak+;hwbreak+',
  6. '$Hg0':'OK',
  7. '$Hg-1':'OK',
  8. '$qTStatus':'',
  9. '$qfThreadInfo':'m0',
  10. '$qsThreadInfo':'l',
  11. '$Hc-1':'OK',
  12. '$qC':'',
  13. '$qAttached':'1',
  14. '$qOffsets':'Text=00;Data=00;Bss=0',
  15. '$p20':'0000010000000000',
  16. '$qSymbol':'OK',
  17. '$vKill':'OK',
  18. '+$?':'S00',
  19. '$qTfV':'',
  20. '$qTsP':'',
  21. 'Hc0':'OK',
  22. 'c':'',
  23. '$#':'',
  24. '$D':'OK',
  25. '$!':'OK'
  26. }
  27.  
  28. def ReadMemory(data):
  29. #some code
  30. return value
  31.  
  32. def ReadRegisters(data):
  33. #some code
  34. return value
  35.  
  36. def WriteRegisters(data):
  37. #some code
  38. return "Ok"
  39.  
  40. def WriteRegisterN(data):
  41. #some code
  42. return "OK"
  43.  
  44. def WriteMemory(data):
  45. #some code
  46. return "OK"
  47.  
  48. def LastSignal(data):
  49. return "S05"
  50.  
  51. def Step():
  52. #some code
  53. return 'S00'
  54.  
  55. def Continue():
  56. #some code
  57. return 'S05'
  58.  
  59. def SetMemory(data):
  60. #some code
  61. return "OK"
  62.  
  63. def InsertBreakpoint(data):
  64. #some code
  65. return "OK"
  66.  
  67. def DeleteBreakpoint(data):
  68. #some code
  69. return "OK"
  70.  
  71. def VQuery(data):
  72. if (data.find('$vCont;c') != -1):
  73. return 'T0501:7ffff850;40:3000ce98'
  74. if (data.find('$vCont?') != -1):
  75. return ""
  76. if (data.find('$vCtrlC') != -1):
  77. printf("Client interrupt the process")
  78. if (data.find('$vKill') != -1):
  79. printf("Client kill the process")
  80. if (data.find('$vStopped') != -1):
  81. printf("Client stopped the process")
  82. if (data.find('$vMustReplyEmpty') != -1):
  83. return ''
  84. return "OK"
  85.  
  86. def Message(data):
  87. print('Data: ', data)
  88. if (data.find('$m') != -1):
  89. return ReadMemory(data)
  90. elif (data.find('$g') != -1):
  91. return ReadRegisters(data)
  92. elif (data.find('$G') != -1):
  93. return WriteRegisters(data)
  94. elif (data.find('$P') != -1):
  95. return WriteRegisterN(data)
  96. elif (data.find('$M') != -1):
  97. return WriteMemory(data)
  98. elif (data.find('$?') != -1):
  99. return LastSignal(data)
  100. elif (data.find('$s') != -1):
  101. return Step()
  102. elif (data.find('$c') != -1):
  103. return Continue()
  104. elif (data.find('$X') != -1):
  105. return SetMemory(data)
  106. elif (data.find('$Z') != -1):
  107. return InsertBreakpoint(data)
  108. elif (data.find('$z') != -1):
  109. return DeleteBreakpoint(data)
  110. elif (data.find('$v') != -1):
  111. return VQuery(data)
  112. else:
  113. for key in switch:
  114. if (data.find(key) != -1):
  115. return switch[key]
  116. return 'OK'
  117.  
  118. ###########################################################
  119. #*********************************************************#
  120. ###########################################################
  121. class GDBClientHandler(object):
  122. def __init__(self, clientsocket):
  123. #some code
  124. def run(self):
  125. msg=Message(data)
  126.  
  127. GDBClientHandler(conn).run()
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.5/py_compile.py", line 125, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./prog.py", line 124
    def run(self):
      ^
IndentationError: expected an indented block

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/py_compile.py", line 129, in compile
    raise py_exc
py_compile.PyCompileError: Sorry: IndentationError: expected an indented block (prog.py, line 124)
stdout
Standard output is empty