sgx_emmt.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env python
  2. #
  3. # Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. #
  9. # * Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in
  13. # the documentation and/or other materials provided with the
  14. # distribution.
  15. # * Neither the name of Intel Corporation nor the names of its
  16. # contributors may be used to endorse or promote products derived
  17. # from this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #
  31. #
  32. import gdb
  33. ENABLE_EMMT = 0
  34. TC_PREFIX = None
  35. TC_PREFIX_DONE = False
  36. class enable_emmt (gdb.Command):
  37. def __init__ (self):
  38. gdb.Command.__init__ (self, "enable sgx_emmt", gdb.COMMAND_RUNNING)
  39. def invoke (self, arg, from_tty):
  40. global ENABLE_EMMT
  41. ENABLE_EMMT = 1
  42. class disable_emmt (gdb.Command):
  43. def __init__ (self):
  44. gdb.Command.__init__ (self, "disable sgx_emmt", gdb.COMMAND_RUNNING)
  45. def invoke (self, arg, from_tty):
  46. global ENABLE_EMMT
  47. ENABLE_EMMT = 0
  48. class show_emmt (gdb.Command):
  49. def __init__ (self):
  50. gdb.Command.__init__ (self, "show sgx_emmt", gdb.COMMAND_RUNNING)
  51. def invoke (self, arg, from_tty):
  52. global ENABLE_EMMT
  53. if ENABLE_EMMT == 1:
  54. print ("sgx_emmt enabled")
  55. if ENABLE_EMMT == 0:
  56. print ("sgx_emmt disabled")
  57. class set_tc_prefix(gdb.Command):
  58. def __init__ (self):
  59. gdb.Command.__init__ (self, "set_tc_prefix", gdb.COMMAND_NONE)
  60. def invoke (self, arg, from_tty):
  61. global TC_PREFIX, TC_PREFIX_DONE
  62. #For internal use, and don't allow input by gdb user
  63. if TC_PREFIX_DONE == True:
  64. return
  65. TC_PREFIX = arg
  66. TC_PREFIX_DONE = True
  67. class get_tc_prefix(gdb.Command):
  68. def __init__ (self):
  69. gdb.Command.__init__ (self, "get_tc_prefix", gdb.COMMAND_NONE)
  70. def invoke (self, arg, from_tty):
  71. global TC_PREFIX
  72. #For internal use, and don't allow output to tty
  73. if from_tty == True:
  74. return
  75. print (TC_PREFIX)
  76. def init_emmt():
  77. enable_emmt()
  78. disable_emmt()
  79. show_emmt()
  80. set_tc_prefix()
  81. get_tc_prefix()