vi 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. .TH VI 1
  2. .SH NAME
  3. 0i, 5i, ki, vi, qi \- instruction simulators
  4. .SH SYNOPSIS
  5. .B vi
  6. [
  7. .I textfile
  8. ]
  9. .br
  10. .B vi
  11. .I pid
  12. .br
  13. .B 0i
  14. [
  15. .I textfile
  16. ]
  17. .br
  18. .B 0i
  19. .I pid
  20. .br
  21. .B 5i
  22. [
  23. .I textfile
  24. ]
  25. .br
  26. .B 5i
  27. .I pid
  28. .br
  29. .B ki
  30. [
  31. .I textfile
  32. ]
  33. .br
  34. .B ki
  35. .I pid
  36. .br
  37. .B qi
  38. [
  39. .I textfile
  40. ]
  41. .br
  42. .B qi
  43. .I pid
  44. .SH DESCRIPTION
  45. .I Vi
  46. simulates the execution of a MIPS binary in
  47. a Plan 9 environment.
  48. It has two main uses: as
  49. a debugger and as a statistics gatherer.
  50. Programs running under
  51. .I vi
  52. execute about two hundred times
  53. slower than normal\(embut faster than
  54. single stepping under
  55. .IR db .
  56. .IR 0i ,
  57. .IR 5i ,
  58. .IR ki ,
  59. and
  60. .IR qi
  61. are similar to
  62. .I vi
  63. but interpret little-endian MIPS, ARM, SPARC, and PowerPC binaries.
  64. The following discussion refers to
  65. .I vi
  66. but applies to the others
  67. as well.
  68. .PP
  69. .I Vi
  70. will simulate the execution of a named
  71. .IR textfile .
  72. It will also make a copy of an existing process with process id
  73. .I pid
  74. and simulate its continuation.
  75. .PP
  76. As a debugger
  77. .I vi
  78. offers more complete information
  79. than
  80. .IR db (1).
  81. Tracing can be performed at the level of instructions,
  82. system calls, or function calls.
  83. .I Vi
  84. allows breakpoints to be triggered when specified addresses
  85. in memory are accessed.
  86. A report of instruction counts,
  87. load delay fills and distribution is produced for
  88. each run.
  89. .I Vi
  90. simulates the CPU's caches and MMU
  91. to assist the optimization of compilers and programs.
  92. .PP
  93. The command interface mirrors the interface to
  94. .IR db ;
  95. see
  96. .IR db (1)
  97. for a detailed description.
  98. Data formats and addressing are compatible with
  99. .I db
  100. except
  101. for disassembly:
  102. .I vi
  103. offers only MIPS
  104. .RB ( db
  105. .BR -mmipsco )
  106. mnemonics for
  107. machine instructions.
  108. .I Ki
  109. offers both Plan 9 and Sun SPARC formats.
  110. .PP
  111. Several extra commands allow
  112. extended tracing and printing of statistics:
  113. .TP
  114. .BR $t [ 0ics ]
  115. The
  116. .I t
  117. command controls tracing. Zero cancels all tracing
  118. options.
  119. .RS
  120. .TP
  121. .B i
  122. Enable instruction tracing
  123. .TP
  124. .B c
  125. Enable call tracing
  126. .TP
  127. .B s
  128. Enable system call tracing
  129. .RE
  130. .TP
  131. .BR $i [ itsp ]
  132. The
  133. .B i
  134. command prints statistics accumulated by
  135. all code run in this session.
  136. .RS
  137. .TP
  138. .B i
  139. Print instruction counts and frequency.
  140. .TP
  141. .B p
  142. Print cycle profile.
  143. .TP
  144. .B t
  145. .RI ( Vi
  146. only) Print TLB and cache statistics.
  147. .TP
  148. .B s
  149. Print memory reference, working set and size statistics.
  150. .RE
  151. .TP
  152. .BR :b [ arwe ]
  153. .I Vi
  154. allows breakpoints to be set on any memory location.
  155. These breakpoints monitor when a location is
  156. accessed, read, written, or equals a certain value.
  157. For equality the compared value is the
  158. .I count
  159. (see
  160. .IR db (1))
  161. supplied to the command.
  162. .SH SOURCE
  163. .B /sys/src/cmd/vi
  164. etc.
  165. .SH "SEE ALSO"
  166. .IR nm (1),
  167. .IR db (1)
  168. .SH BUGS
  169. The code generated by
  170. the compilers
  171. is well supported, but some unusual instructions are unimplemented.
  172. Some Plan 9 system calls such as
  173. .I rfork
  174. cause simulated traps.
  175. The floating point simulation makes assumptions about the interpreting
  176. machine's floating point support. The floating point conversions performed
  177. by
  178. .I vi
  179. may cause a loss of precision.