PageRenderTime 967ms CodeModel.GetById 226ms app.highlight 348ms RepoModel.GetById 153ms app.codeStats 4ms

/demos/simulator-mips-simulator-arm.html

http://github.com/yinwang0/ydiff
HTML | 6277 lines | 5625 code | 652 blank | 0 comment | 0 complexity | ec09f9745486a02c584340cef5075eec MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1<html>
  2<head>
  3<META http-equiv="Content-Type" content="text/html; charset=utf-8">
  4<LINK href="diff-s.css" rel="stylesheet" type="text/css">
  5<script type="text/javascript" src="nav-div.js"></script>
  6</head>
  7<body>
  8<div id="left" class="src">
  9<pre>
 10<a id='leftstart' tid='rightstart'></a>
 11// Copyright 2011 the V8 project authors. All rights reserved.
 12// Redistribution and use in source and binary forms, with or without
 13// modification, are permitted provided that the following conditions are
 14// met:
 15//
 16//     * Redistributions of source code must retain the above copyright
 17//       notice, this list of conditions and the following disclaimer.
 18//     * Redistributions in binary form must reproduce the above
 19//       copyright notice, this list of conditions and the following
 20//       disclaimer in the documentation and/or other materials provided
 21//       with the distribution.
 22//     * Neither the name of Google Inc. nor the names of its
 23//       contributors may be used to endorse or promote products derived
 24//       from this software without specific prior written permission.
 25//
 26// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 27// &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 28// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 29// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 30// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 31// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 32// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 33// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 34// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 35// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 36// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 37
 38#<a id='9613' tid='9614', class="m">include</a> <a id='9615' tid='9616', class="m">&lt;</a><a id='9617' tid='9618', class="m">stdlib</a><a id='9619' tid='9620', class="m">.</a><a id='9621' tid='9622', class="m">h</a><a id='9623' tid='9624', class="m">&gt;</a>
 39#<a id='9601' tid='9602', class="m">include</a> <a id='9603' tid='9604', class="m">&lt;</a><a id='9605' tid='9606', class="m">math</a><a id='9607' tid='9608', class="m">.</a><a id='9609' tid='9610', class="m">h</a><a id='9611' tid='9612', class="m">&gt;</a>
 40<span class="d">#include &lt;limits.h&gt;</span>
 41<span class="d">#include &lt;cstdarg&gt;</span>
 42<span class="d">#include &quot;v8.h&quot;</span>
 43
 44<span class="d">#if defined(V8_TARGET_ARCH_MIPS)</span>
 45
 46<span class="d">#include &quot;disasm.h&quot;</span>
 47<span class="d">#include &quot;assembler.h&quot;</span>
 48<span class="d">#include &quot;globals.h&quot;</span>    // Need the BitCast.
 49<span class="d">#include &quot;mips/constants-mips.h&quot;</span>
 50<span class="d">#include &quot;mips/simulator-mips.h&quot;</span>
 51
 52
 53// Only build the simulator if not compiling for real MIPS hardware.
 54#<a id='9591' tid='9592', class="m">if</a> <a id='9593' tid='9594', class="m">defined</a><a id='9595' tid='9596', class="m">(</a><a id='9597' tid='9598', class="m">USE_SIMULATOR</a><a id='9599' tid='9600', class="m">)</a>
 55
 56namespace <span class="d">v8</span> {
 57namespace <span class="d">internal</span> {
 58
 59// Utils functions.
 60<span class="d">bool HaveSameSign(int32_t a, int32_t b) {
 61  return ((a ^ b) &gt;= 0);
 62}</span>
 63
 64
 65<span class="d">uint32_t get_fcsr_condition_bit(uint32_t cc) {
 66  if (cc == 0) {
 67    return 23;
 68  } else {
 69    return 24 + cc;
 70  }
 71}</span>
 72
 73
 74// This macro provides a platform independent use of sscanf. The reason for
 75// SScanF not being implemented in a platform independent was through
 76// ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time
 77// Library does not provide vsscanf.
 78<span class="d">#define SScanF sscanf</span>  // NOLINT
 79
 80// The MipsDebugger class is used by the simulator while debugging simulated
 81// code.
 82<span class="d">class</span> <span class="d">MipsDebugger</span> {
 83 <span class="d">public:</span>
 84  <span class="d">explicit MipsDebugger(Simulator* sim)</span>;
 85  <span class="d">~MipsDebugger();</span>
 86
 87  <a id='9581' tid='9582', class="m">void</a> <a id='9583' tid='9584', class="m">Stop</a>(<a id='9585' tid='9586', class="m">Instruction</a><a id='9587' tid='9588', class="m">*</a> <a id='9589' tid='9590', class="m">instr</a>);
 88  <span class="d">void Debug()</span>;
 89  // Print all registers with a nice formatting.
 90  <span class="d">void PrintAllRegs()</span>;
 91  <span class="d">void PrintAllRegsIncludingFPU()</span>;
 92
 93 <span class="d">private:</span>
 94  // We set the breakpoint code to 0xfffff to easily recognize it.
 95  <span class="d">static const Instr kBreakpointInstr = SPECIAL | BREAK | 0xfffff &lt;&lt; 6;</span>
 96  <span class="d">static const Instr kNopInstr =  0x0;</span>
 97
 98  <span class="d">Simulator* sim_;</span>
 99
100  <span class="d">int32_t GetRegisterValue(int regnum)</span>;
101  <span class="d">int32_t GetFPURegisterValueInt(int regnum)</span>;
102  <span class="d">int64_t GetFPURegisterValueLong(int regnum)</span>;
103  <span class="d">float GetFPURegisterValueFloat(int regnum)</span>;
104  <span class="d">double GetFPURegisterValueDouble(int regnum)</span>;
105  <a id='9563' tid='9564', class="m">bool</a> <a id='9565' tid='9566', class="m">GetValue</a>(<a id='9567' tid='9568', class="m">const</a> <a id='9569' tid='9570', class="m">char</a><a id='9571' tid='9572', class="m">*</a> <a id='9573' tid='9574', class="m">desc</a>, <a id='9575' tid='9576', class="m">int32_t</a><a id='9577' tid='9578', class="m">*</a> <a id='9579' tid='9580', class="m">value</a>);
106
107  // Set or delete a breakpoint. Returns true if successful.
108  <a id='9543' tid='9544', class="m">bool</a> <a id='9545' tid='9546', class="m">SetBreakpoint</a>(<a id='9547' tid='9548', class="m">Instruction</a><a id='9549' tid='9550', class="m">*</a> <a id='9551' tid='9552', class="m">breakpc</a>);
109  <a id='9499' tid='9500', class="m">bool</a> <a id='9501' tid='9502', class="m">DeleteBreakpoint</a>(<a id='9503' tid='9504', class="m">Instruction</a><a id='9505' tid='9506', class="m">*</a> <a id='9507' tid='9508', class="m">breakpc</a>);
110
111  // Undo and redo all breakpoints. This is needed to bracket disassembly and
112  // execution to skip past breakpoints when run from the debugger.
113  <span class="d">void UndoBreakpoints()</span>;
114  <span class="d">void RedoBreakpoints()</span>;
115};
116
117<span class="d">MipsDebugger::MipsDebugger(Simulator* sim) {
118  sim_ = sim;
119}</span>
120
121
122<span class="d">MipsDebugger::~MipsDebugger() {
123}</span>
124
125
126<span class="d">#ifdef GENERATED_CODE_COVERAGE</span>
127<a id='9553' tid='9554', class="m">static</a> <a id='9555' tid='9556', class="m">FILE</a><a id='9557' tid='9558', class="m">*</a> <a id='9559' tid='9560', class="m">coverage_log</a> = <a id='9561' tid='9562', class="m">NULL</a>;
128
129
130<a id='9509' tid='9510', class="m">static</a> <a id='9511' tid='9512', class="m">void</a> <a id='9513' tid='9514', class="m">InitializeCoverage</a>() {
131  <a id='9515' tid='9516', class="m">char</a><a id='9517' tid='9518', class="m">*</a> <a id='9519' tid='9520', class="m">file_name</a> = <a id='9521' tid='9522', class="m">getenv</a>(<a id='9523' tid='9524', class="m">&quot;V8_GENERATED_CODE_COVERAGE_LOG&quot;</a>);
132  <a id='9525' tid='9526', class="m">if</a> (<a id='9527' tid='9528', class="m">file_name</a> <a id='9529' tid='9530', class="m">!=</a> <a id='9531' tid='9532', class="m">NULL</a>) {
133    <a id='9533' tid='9534', class="m">coverage_log</a> <a id='9535' tid='9536', class="m">=</a> <a id='9537' tid='9538', class="m">fopen</a>(<a id='9539' tid='9540', class="m">file_name</a>, <a id='9541' tid='9542', class="m">&quot;aw+&quot;</a>);
134  }
135}
136
137
138<a id='9443' tid='9444', class="m">void</a> <span class="d">MipsDebugger::Stop</span>(<a id='9445' tid='9446', class="m">Instruction</a><a id='9447' tid='9448', class="m">*</a> <a id='9449' tid='9450', class="m">instr</a>) {
139  // Get the stop code.
140  <span class="d">uint32_t code = instr-&gt;Bits(25, 6);</span>
141  // Retrieve the encoded address, which comes just after this stop.
142  <span class="d">char** msg_address =
143    reinterpret_cast&lt;char**&gt;(sim_-&gt;get_pc() + Instr::kInstrSize);</span>
144  <a id='9489' tid='9490', class="m">char</a><a id='9491' tid='9492', class="m">*</a> <a id='9493' tid='9494', class="m">msg</a> = <a id='9495' tid='9496', class="m">*</a><a id='9497' tid='9498', class="m">msg_address</a>;
145  <span class="d">ASSERT(msg != NULL);</span>
146
147  // Update this stop description.
148  <span class="d">if</span> <span class="d">(!watched_stops[code].desc)</span> {
149    <a id='9479' tid='9480', class="m">watched_stops</a>[<a id='9481' tid='9482', class="m">code</a>].<a id='9483' tid='9484', class="m">desc</a> <a id='9485' tid='9486', class="m">=</a> <a id='9487' tid='9488', class="m">msg</a>;
150  }
151
152  <span class="d">if (strlen(msg) &gt; 0) {
153    if (coverage_log != NULL) {
154      fprintf(coverage_log, &quot;%s\n&quot;, str);
155      fflush(coverage_log);
156    }
157    // Overwrite the instruction and address with nops.
158    instr-&gt;SetInstructionBits(kNopInstr);
159    reinterpret_cast&lt;Instr*&gt;(msg_address)-&gt;SetInstructionBits(kNopInstr);
160  }</span>
161  <span class="d">sim_-&gt;set_pc(sim_-&gt;get_pc() + 2 * Instruction::kInstructionSize);</span>
162}
163
164
165<span class="d">#else</span>  // GENERATED_CODE_COVERAGE
166
167<span class="d">#define UNSUPPORTED() printf(&quot;Unsupported instruction.\n&quot;);</span>
168
169<span class="d">static void InitializeCoverage() {}</span>
170
171
172<a id='9405' tid='9406', class="m">void</a> <span class="d">MipsDebugger::Stop</span>(<a id='9407' tid='9408', class="m">Instruction</a><a id='9409' tid='9410', class="m">*</a> <a id='9411' tid='9412', class="m">instr</a>) {
173  // Get the stop code.
174  <span class="d">uint32_t code = instr-&gt;Bits(25, 6);</span>
175  // Retrieve the encoded address, which comes just after this stop.
176  <a id='9451' tid='9452', class="m">char</a><a id='9453' tid='9454', class="m">*</a> <a id='9455' tid='9456', class="m">msg</a> = <a id='9457' tid='9458', class="m">*</a><a id='9459' tid='9460', class="m">reinterpret_cast</a>&lt;<a id='9461' tid='9462', class="m">char</a><a id='9463' tid='9464', class="m">*</a><a id='9465' tid='9466', class="m">*</a>&gt;(<a id='9467' tid='9468', class="m">sim_</a>-&gt;<a id='9469' tid='9470', class="m">get_pc</a>() <a id='9471' tid='9472', class="m">+</a>
177      <a id='9473' tid='9474', class="m">Instruction</a><a id='9475' tid='9476', class="m">::</a><a id='9477' tid='9478', class="m">kInstrSize</a>);
178  // Update this stop description.
179  <a id='9381' tid='9382', class="m">if</a> (<a id='9383' tid='9384', class="m">!</a><a id='9385' tid='9386', class="m">sim_</a>-&gt;<a id='9387' tid='9388', class="m">watched_stops</a>[<a id='9389' tid='9390', class="m">code</a>].<a id='9391' tid='9392', class="m">desc</a>) {
180    <a id='9393' tid='9394', class="m">sim_</a>-&gt;<a id='9395' tid='9396', class="m">watched_stops</a>[<a id='9397' tid='9398', class="m">code</a>].<a id='9399' tid='9400', class="m">desc</a> <a id='9401' tid='9402', class="m">=</a> <a id='9403' tid='9404', class="m">msg</a>;
181  }
182  <span class="d">PrintF(&quot;Simulator hit %s (%u)\n&quot;, msg, code);</span>
183  <a id='9423' tid='9424', class="m">sim_</a>-&gt;<a id='9425' tid='9426', class="m">set_pc</a>(<a id='9427' tid='9428', class="m">sim_</a>-&gt;<a id='9429' tid='9430', class="m">get_pc</a>() <a id='9431' tid='9432', class="m">+</a> <a id='9433' tid='9434', class="m">2</a> <a id='9435' tid='9436', class="m">*</a> <a id='9437' tid='9438', class="m">Instruction</a><a id='9439' tid='9440', class="m">::</a><a id='9441' tid='9442', class="m">kInstrSize</a>);
184  <span class="d">Debug();</span>
185}
186<span class="d">#endif</span>  // GENERATED_CODE_COVERAGE
187
188
189<a id='9361' tid='9362', class="m">int32_t</a> <span class="d">MipsDebugger::GetRegisterValue</span>(<a id='9363' tid='9364', class="m">int</a> <a id='9365' tid='9366', class="m">regnum</a>) {
190  <span class="d">if</span> <span class="d">(regnum == kNumSimuRegisters)</span> <span class="d">{
191    return sim_-&gt;get_pc();
192  }</span> <a id='9413' tid='9414', class="m">else</a> {
193    <a id='9415' tid='9416', class="m">return</a> <a id='9417' tid='9418', class="m">sim_</a>-&gt;<a id='9419' tid='9420', class="m">get_register</a>(<a id='9421' tid='9422', class="m">regnum</a>);
194  }
195}
196
197
198<span class="d">int32_t MipsDebugger::GetFPURegisterValueInt(int regnum) {
199  if (regnum == kNumFPURegisters) {
200    return sim_-&gt;get_pc();
201  } else {
202    return sim_-&gt;get_fpu_register(regnum);
203  }
204}</span>
205
206
207<span class="d">int64_t MipsDebugger::GetFPURegisterValueLong(int regnum) {
208  if (regnum == kNumFPURegisters) {
209    return sim_-&gt;get_pc();
210  } else {
211    return sim_-&gt;get_fpu_register_long(regnum);
212  }
213}</span>
214
215
216<span class="d">float MipsDebugger::GetFPURegisterValueFloat(int regnum) {
217  if (regnum == kNumFPURegisters) {
218    return sim_-&gt;get_pc();
219  } else {
220    return sim_-&gt;get_fpu_register_float(regnum);
221  }
222}</span>
223
224
225<span class="d">double MipsDebugger::GetFPURegisterValueDouble(int regnum) {
226  if (regnum == kNumFPURegisters) {
227    return sim_-&gt;get_pc();
228  } else {
229    return sim_-&gt;get_fpu_register_double(regnum);
230  }
231}</span>
232
233
234<span class="d">bool</span> <span class="d">MipsDebugger::GetValue</span>(<a id='9367' tid='9368', class="m">const</a> <a id='9369' tid='9370', class="m">char</a><a id='9371' tid='9372', class="m">*</a> <a id='9373' tid='9374', class="m">desc</a>, <a id='9375' tid='9376', class="m">int32_t</a><a id='9377' tid='9378', class="m">*</a> <a id='9379' tid='9380', class="m">value</a>) {
235  <a id='9313' tid='9314', class="m">int</a> <a id='9315' tid='9316', class="m">regnum</a> = <a id='9317' tid='9318', class="m">Registers</a><a id='9319' tid='9320', class="m">::</a><a id='9321' tid='9322', class="m">Number</a>(<a id='9323' tid='9324', class="m">desc</a>);
236  <span class="d">int fpuregnum = FPURegisters::Number(desc);</span>
237
238  <span class="d">if</span> <span class="d">(regnum != kInvalidRegister)</span> {
239    <a id='9299' tid='9300', class="m">*</a><a id='9301' tid='9302', class="m">value</a> <a id='9303' tid='9304', class="m">=</a> <a id='9305' tid='9306', class="m">GetRegisterValue</a>(<a id='9307' tid='9308', class="m">regnum</a>);
240    <a id='9309' tid='9310', class="m">return</a> <a id='9311' tid='9312', class="m">true</a>;
241  } <span class="d">else</span> <span class="d">if</span> <span class="d">(fpuregnum != kInvalidFPURegister)</span> <span class="d">{
242    *value = GetFPURegisterValueInt(fpuregnum);
243    return true;
244  }</span> <a id='9237' tid='9238', class="m">else</a> <span class="d">if</span> (<a id='9239' tid='9240', class="m">strncmp</a>(<a id='9241' tid='9242', class="m">desc</a>, <a id='9243' tid='9244', class="m">&quot;0x&quot;</a>, <a id='9245' tid='9246', class="m">2</a>) <a id='9247' tid='9248', class="m">==</a> <a id='9249' tid='9250', class="m">0</a>) <span class="d">{
245    return SScanF(desc, &quot;%x&quot;, reinterpret_cast&lt;uint32_t*&gt;(value)) == 1;
246  }</span> <span class="d">else {
247    return SScanF(desc, &quot;%i&quot;, value) == 1;
248  }</span>
249  <span class="d">return false;</span>
250}
251
252
253<a id='9251' tid='9252', class="m">bool</a> <span class="d">MipsDebugger::SetBreakpoint</span>(<a id='9253' tid='9254', class="m">Instruction</a><a id='9255' tid='9256', class="m">*</a> <a id='9257' tid='9258', class="m">breakpc</a>) {
254  // Check if a breakpoint can be set. If not return without any side-effects.
255  <a id='9325' tid='9326', class="m">if</a> (<a id='9327' tid='9328', class="m">sim_</a>-&gt;<a id='9329' tid='9330', class="m">break_pc_</a> <a id='9331' tid='9332', class="m">!=</a> <a id='9333' tid='9334', class="m">NULL</a>) {
256    <a id='9335' tid='9336', class="m">return</a> <a id='9337' tid='9338', class="m">false</a>;
257  }
258
259  // Set the breakpoint.
260  <a id='9339' tid='9340', class="m">sim_</a>-&gt;<a id='9341' tid='9342', class="m">break_pc_</a> <a id='9343' tid='9344', class="m">=</a> <a id='9345' tid='9346', class="m">breakpc</a>;
261  <a id='9347' tid='9348', class="m">sim_</a>-&gt;<a id='9349' tid='9350', class="m">break_instr_</a> <a id='9351' tid='9352', class="m">=</a> <a id='9353' tid='9354', class="m">breakpc</a>-&gt;<a id='9355' tid='9356', class="m">InstructionBits</a>();
262  // Not setting the breakpoint instruction in the code itself. It will be set
263  // when the debugger shell continues.
264  <a id='9357' tid='9358', class="m">return</a> <a id='9359' tid='9360', class="m">true</a>;
265}
266
267
268<a id='9209' tid='9210', class="m">bool</a> <span class="d">MipsDebugger::DeleteBreakpoint</span>(<a id='9211' tid='9212', class="m">Instruction</a><a id='9213' tid='9214', class="m">*</a> <a id='9215' tid='9216', class="m">breakpc</a>) {
269  <a id='9259' tid='9260', class="m">if</a> (<a id='9261' tid='9262', class="m">sim_</a>-&gt;<a id='9263' tid='9264', class="m">break_pc_</a> <a id='9265' tid='9266', class="m">!=</a> <a id='9267' tid='9268', class="m">NULL</a>) {
270    <a id='9269' tid='9270', class="m">sim_</a>-&gt;<a id='9271' tid='9272', class="m">break_pc_</a>-&gt;<a id='9273' tid='9274', class="m">SetInstructionBits</a>(<a id='9275' tid='9276', class="m">sim_</a>-&gt;<a id='9277' tid='9278', class="m">break_instr_</a>);
271  }
272
273  <a id='9279' tid='9280', class="m">sim_</a>-&gt;<a id='9281' tid='9282', class="m">break_pc_</a> <a id='9283' tid='9284', class="m">=</a> <a id='9285' tid='9286', class="m">NULL</a>;
274  <a id='9287' tid='9288', class="m">sim_</a>-&gt;<a id='9289' tid='9290', class="m">break_instr_</a> <a id='9291' tid='9292', class="m">=</a> <a id='9293' tid='9294', class="m">0</a>;
275  <a id='9295' tid='9296', class="m">return</a> <a id='9297' tid='9298', class="m">true</a>;
276}
277
278
279<span class="d">void</span> <span class="d">MipsDebugger::UndoBreakpoints</span><span class="d">()</span> {
280  <a id='9217' tid='9218', class="m">if</a> (<a id='9219' tid='9220', class="m">sim_</a>-&gt;<a id='9221' tid='9222', class="m">break_pc_</a> <a id='9223' tid='9224', class="m">!=</a> <a id='9225' tid='9226', class="m">NULL</a>) {
281    <a id='9227' tid='9228', class="m">sim_</a>-&gt;<a id='9229' tid='9230', class="m">break_pc_</a>-&gt;<a id='9231' tid='9232', class="m">SetInstructionBits</a>(<a id='9233' tid='9234', class="m">sim_</a>-&gt;<a id='9235' tid='9236', class="m">break_instr_</a>);
282  }
283}
284
285
286<span class="d">void</span> <span class="d">MipsDebugger::RedoBreakpoints</span><span class="d">()</span> {
287  <a id='9191' tid='9192', class="m">if</a> (<a id='9193' tid='9194', class="m">sim_</a>-&gt;<a id='9195' tid='9196', class="m">break_pc_</a> <a id='9197' tid='9198', class="m">!=</a> <a id='9199' tid='9200', class="m">NULL</a>) {
288    <a id='9201' tid='9202', class="m">sim_</a>-&gt;<a id='9203' tid='9204', class="m">break_pc_</a>-&gt;<a id='9205' tid='9206', class="m">SetInstructionBits</a>(<a id='9207' tid='9208', class="m">kBreakpointInstr</a>);
289  }
290}
291
292
293<span class="d">void MipsDebugger::PrintAllRegs() {
294#define REG_INFO(n) Registers::Name(n), GetRegisterValue(n), GetRegisterValue(n)
295
296  PrintF(&quot;\n&quot;);
297  // at, v0, a0.
298  PrintF(&quot;%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
299         REG_INFO(1), REG_INFO(2), REG_INFO(4));
300  // v1, a1.
301  PrintF(&quot;%26s\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
302         &quot;&quot;, REG_INFO(3), REG_INFO(5));
303  // a2.
304  PrintF(&quot;%26s\t%26s\t%3s: 0x%08x %10d\n&quot;, &quot;&quot;, &quot;&quot;, REG_INFO(6));
305  // a3.
306  PrintF(&quot;%26s\t%26s\t%3s: 0x%08x %10d\n&quot;, &quot;&quot;, &quot;&quot;, REG_INFO(7));
307  PrintF(&quot;\n&quot;);
308  // t0-t7, s0-s7
309  for (int i = 0; i &lt; 8; i++) {
310    PrintF(&quot;%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
311           REG_INFO(8+i), REG_INFO(16+i));
312  }
313  PrintF(&quot;\n&quot;);
314  // t8, k0, LO.
315  PrintF(&quot;%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
316         REG_INFO(24), REG_INFO(26), REG_INFO(32));
317  // t9, k1, HI.
318  PrintF(&quot;%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
319         REG_INFO(25), REG_INFO(27), REG_INFO(33));
320  // sp, fp, gp.
321  PrintF(&quot;%3s: 0x%08x %10d\t%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
322         REG_INFO(29), REG_INFO(30), REG_INFO(28));
323  // pc.
324  PrintF(&quot;%3s: 0x%08x %10d\t%3s: 0x%08x %10d\n&quot;,
325         REG_INFO(31), REG_INFO(34));
326
327#undef REG_INFO
328#undef FPU_REG_INFO
329}</span>
330
331
332<span class="d">void MipsDebugger::PrintAllRegsIncludingFPU() {
333#define FPU_REG_INFO(n) FPURegisters::Name(n), FPURegisters::Name(n+1), \
334        GetFPURegisterValueInt(n+1), \
335        GetFPURegisterValueInt(n), \
336                        GetFPURegisterValueDouble(n)
337
338  PrintAllRegs();
339
340  PrintF(&quot;\n\n&quot;);
341  // f0, f1, f2, ... f31.
342  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(0) );
343  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(2) );
344  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(4) );
345  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(6) );
346  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(8) );
347  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(10));
348  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(12));
349  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(14));
350  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(16));
351  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(18));
352  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(20));
353  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(22));
354  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(24));
355  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(26));
356  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(28));
357  PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;, FPU_REG_INFO(30));
358
359#undef REG_INFO
360#undef FPU_REG_INFO
361}</span>
362
363
364<span class="d">void</span> <span class="d">MipsDebugger::Debug</span><span class="d">()</span> {
365  <a id='8965' tid='8966', class="m">intptr_t</a> <a id='8967' tid='8968', class="m">last_pc</a> = <a id='8969' tid='8970', class="m">-</a><a id='8971' tid='8972', class="m">1</a>;
366  <a id='8973' tid='8974', class="m">bool</a> <a id='8975' tid='8976', class="m">done</a> = <a id='8977' tid='8978', class="m">false</a>;
367
368#<a id='8979' tid='8980', class="m">define</a> <a id='8981' tid='8982', class="m">COMMAND_SIZE</a> <a id='8983' tid='8984', class="m">63</a>
369#<a id='8985' tid='8986', class="m">define</a> <a id='8987' tid='8988', class="m">ARG_SIZE</a> <a id='8989' tid='8990', class="m">255</a>
370
371#<a id='9177' tid='9178', class="m">define</a> <a id='9179' tid='9180', class="m">STR</a><a id='9181' tid='9182', class="m">(</a><a id='9183' tid='9184', class="m">a</a><a id='9185' tid='9186', class="m">)</a> <a id='9187' tid='9188', class="m">#</a><a id='9189' tid='9190', class="m">a</a>
372#<a id='8991' tid='8992', class="m">define</a> <a id='8993' tid='8994', class="m">XSTR</a><a id='8995' tid='8996', class="m">(</a><a id='8997' tid='8998', class="m">a</a><a id='8999' tid='9000', class="m">)</a> <a id='9001' tid='9002', class="m">STR</a><a id='9003' tid='9004', class="m">(</a><a id='9005' tid='9006', class="m">a</a><a id='9007' tid='9008', class="m">)</a>
373
374  <a id='9009' tid='9010', class="m">char</a> <a id='9011' tid='9012', class="m">cmd</a>[<a id='9013' tid='9014', class="m">COMMAND_SIZE</a> <a id='9015' tid='9016', class="m">+</a> <a id='9017' tid='9018', class="m">1</a>];
375  <a id='9019' tid='9020', class="m">char</a> <a id='9021' tid='9022', class="m">arg1</a>[<a id='9023' tid='9024', class="m">ARG_SIZE</a> <a id='9025' tid='9026', class="m">+</a> <a id='9027' tid='9028', class="m">1</a>];
376  <a id='9029' tid='9030', class="m">char</a> <a id='9031' tid='9032', class="m">arg2</a>[<a id='9033' tid='9034', class="m">ARG_SIZE</a> <a id='9035' tid='9036', class="m">+</a> <a id='9037' tid='9038', class="m">1</a>];
377  <a id='9039' tid='9040', class="m">char</a><a id='9041' tid='9042', class="m">*</a> <a id='9043' tid='9044', class="m">argv</a>[<a id='9045' tid='9046', class="m">3</a>] = { <a id='9047' tid='9048', class="m">cmd</a>, <a id='9049' tid='9050', class="m">arg1</a>, <a id='9051' tid='9052', class="m">arg2</a> };
378
379  // Make sure to have a proper terminating character if reaching the limit.
380  <a id='9053' tid='9054', class="m">cmd</a>[<a id='9055' tid='9056', class="m">COMMAND_SIZE</a>] <a id='9057' tid='9058', class="m">=</a> <a id='9059' tid='9060', class="m">0</a>;
381  <a id='9061' tid='9062', class="m">arg1</a>[<a id='9063' tid='9064', class="m">ARG_SIZE</a>] <a id='9065' tid='9066', class="m">=</a> <a id='9067' tid='9068', class="m">0</a>;
382  <a id='9069' tid='9070', class="m">arg2</a>[<a id='9071' tid='9072', class="m">ARG_SIZE</a>] <a id='9073' tid='9074', class="m">=</a> <a id='9075' tid='9076', class="m">0</a>;
383
384  // Undo all set breakpoints while running in the debugger shell. This will
385  // make them invisible to all commands.
386  <a id='9077' tid='9078', class="m">UndoBreakpoints</a>();
387
388  <span class="d">while</span> <span class="d">(!done && (sim_-&gt;get_pc() != Simulator::end_sim_pc))</span> {
389    <a id='9079' tid='9080', class="m">if</a> (<a id='9081' tid='9082', class="m">last_pc</a> <a id='9083' tid='9084', class="m">!=</a> <a id='9085' tid='9086', class="m">sim_</a>-&gt;<a id='9087' tid='9088', class="m">get_pc</a>()) {
390      <a id='9099' tid='9100', class="m">disasm</a><a id='9101' tid='9102', class="m">::</a><a id='9103' tid='9104', class="m">NameConverter</a> <a id='9105' tid='9106', class="m">converter</a>;
391      <a id='9089' tid='9090', class="m">disasm</a><a id='9091' tid='9092', class="m">::</a><a id='9093' tid='9094', class="m">Disassembler</a> <a id='9095' tid='9096', class="m">dasm</a>(<a id='9097' tid='9098', class="m">converter</a>);
392      // Use a reasonably large buffer.
393      <a id='9107' tid='9108', class="m">v8</a><a id='9109' tid='9110', class="m">::</a><a id='9111' tid='9112', class="m">internal</a><a id='9113' tid='9114', class="m">::</a><a id='9115' tid='9116', class="m">EmbeddedVector</a>&lt;<a id='9117' tid='9118', class="m">char</a>, <a id='9119' tid='9120', class="m">256</a>&gt; <a id='9121' tid='9122', class="m">buffer</a>;
394      <a id='9123' tid='9124', class="m">dasm</a>.<a id='9125' tid='9126', class="m">InstructionDecode</a>(<a id='9127' tid='9128', class="m">buffer</a>,
395                             <a id='9129' tid='9130', class="m">reinterpret_cast</a>&lt;<a id='9131' tid='9132', class="m">byte</a><a id='9133' tid='9134', class="m">*</a>&gt;(<a id='9135' tid='9136', class="m">sim_</a>-&gt;<a id='9137' tid='9138', class="m">get_pc</a>()));
396      <a id='9139' tid='9140', class="m">PrintF</a>(<a id='9141' tid='9142', class="m">&quot;  0x%08x  %s\n&quot;</a>, <a id='9143' tid='9144', class="m">sim_</a>-&gt;<a id='9145' tid='9146', class="m">get_pc</a>(), <a id='9147' tid='9148', class="m">buffer</a>.<a id='9149' tid='9150', class="m">start</a>());
397      <a id='9151' tid='9152', class="m">last_pc</a> <a id='9153' tid='9154', class="m">=</a> <a id='9155' tid='9156', class="m">sim_</a>-&gt;<a id='9157' tid='9158', class="m">get_pc</a>();
398    }
399    <a id='8115' tid='8116', class="m">char</a><a id='8117' tid='8118', class="m">*</a> <a id='8119' tid='8120', class="m">line</a> = <a id='8121' tid='8122', class="m">ReadLine</a>(<a id='8123' tid='8124', class="m">&quot;sim&gt; &quot;</a>);
400    <a id='8125' tid='8126', class="m">if</a> (<a id='8127' tid='8128', class="m">line</a> <a id='8129' tid='8130', class="m">==</a> <a id='8131' tid='8132', class="m">NULL</a>) {
401      <a id='8133' tid='8134', class="m">break</a>;
402    } <a id='8135' tid='8136', class="m">else</a> {
403      // Use sscanf to parse the individual parts of the command line. At the
404      // moment no command expects more than two parameters.
405      <a id='8137' tid='8138', class="m">int</a> <a id='8139' tid='8140', class="m">argc</a> = <a id='8141' tid='8142', class="m">SScanF</a>(<a id='8143' tid='8144', class="m">line</a>,
406                        <a id='8145' tid='8146', class="m">&quot;%&quot;</a> <a id='8147' tid='8148', class="m">XSTR</a>(<a id='8149' tid='8150', class="m">COMMAND_SIZE</a>) <a id='8151' tid='8152', class="m">&quot;s &quot;</a>
407                        <a id='8153' tid='8154', class="m">&quot;%&quot;</a> <a id='8155' tid='8156', class="m">XSTR</a>(<a id='8157' tid='8158', class="m">ARG_SIZE</a>) <a id='8159' tid='8160', class="m">&quot;s &quot;</a>
408                        <a id='8161' tid='8162', class="m">&quot;%&quot;</a> <a id='8163' tid='8164', class="m">XSTR</a>(<a id='8165' tid='8166', class="m">ARG_SIZE</a>) <a id='8167' tid='8168', class="m">&quot;s&quot;</a>,
409                        <a id='8169' tid='8170', class="m">cmd</a>, <a id='8171' tid='8172', class="m">arg1</a>, <a id='8173' tid='8174', class="m">arg2</a>);
410      <a id='8175' tid='8176', class="m">if</a> ((<a id='8177' tid='8178', class="m">strcmp</a>(<a id='8179' tid='8180', class="m">cmd</a>, <a id='8181' tid='8182', class="m">&quot;si&quot;</a>) <a id='8183' tid='8184', class="m">==</a> <a id='8185' tid='8186', class="m">0</a>) <a id='8187' tid='8188', class="m">||</a> (<a id='8189' tid='8190', class="m">strcmp</a>(<a id='8191' tid='8192', class="m">cmd</a>, <a id='8193' tid='8194', class="m">&quot;stepi&quot;</a>) <a id='8195' tid='8196', class="m">==</a> <a id='8197' tid='8198', class="m">0</a>)) {
411        <span class="d">Instruction* instr = reinterpret_cast&lt;Instruction*&gt;(sim_-&gt;get_pc());</span>
412        <span class="d">if</span> <span class="d">(!(instr-&gt;IsTrap()) ||
413            instr-&gt;InstructionBits() == rtCallRedirInstr)</span> {
414          <a id='8199' tid='8200', class="m">sim_</a>-&gt;<a id='8201' tid='8202', class="m">InstructionDecode</a>(
415              <a id='8203' tid='8204', class="m">reinterpret_cast</a>&lt;<a id='8205' tid='8206', class="m">Instruction</a><a id='8207' tid='8208', class="m">*</a>&gt;(<a id='8209' tid='8210', class="m">sim_</a>-&gt;<a id='8211' tid='8212', class="m">get_pc</a>()));
416        } <span class="d">else</span> {
417          // Allow si to jump over generated breakpoints.
418          <span class="d">PrintF(&quot;/!\\ Jumping over generated breakpoint.\n&quot;);</span>
419          <span class="d">sim_-&gt;set_pc</span>(<a id='8037' tid='8038', class="m">sim_</a>-&gt;<a id='8039' tid='8040', class="m">get_pc</a>() <a id='8041' tid='8042', class="m">+</a> <a id='8043' tid='8044', class="m">Instruction</a><a id='8045' tid='8046', class="m">::</a><a id='8047' tid='8048', class="m">kInstrSize</a>);
420        }
421      } <a id='8213' tid='8214', class="m">else</a> <a id='8215' tid='8216', class="m">if</a> ((<a id='8217' tid='8218', class="m">strcmp</a>(<a id='8219' tid='8220', class="m">cmd</a>, <a id='8221' tid='8222', class="m">&quot;c&quot;</a>) <a id='8223' tid='8224', class="m">==</a> <a id='8225' tid='8226', class="m">0</a>) <a id='8227' tid='8228', class="m">||</a> (<a id='8229' tid='8230', class="m">strcmp</a>(<a id='8231' tid='8232', class="m">cmd</a>, <a id='8233' tid='8234', class="m">&quot;cont&quot;</a>) <a id='8235' tid='8236', class="m">==</a> <a id='8237' tid='8238', class="m">0</a>)) {
422        // Execute the one instruction we broke at with breakpoints disabled.
423        <a id='8239' tid='8240', class="m">sim_</a>-&gt;<a id='8241' tid='8242', class="m">InstructionDecode</a>(<a id='8243' tid='8244', class="m">reinterpret_cast</a>&lt;<a id='8245' tid='8246', class="m">Instruction</a><a id='8247' tid='8248', class="m">*</a>&gt;(<a id='8249' tid='8250', class="m">sim_</a>-&gt;<a id='8251' tid='8252', class="m">get_pc</a>()));
424        // Leave the debugger shell.
425        <a id='8253' tid='8254', class="m">done</a> <a id='8255' tid='8256', class="m">=</a> <a id='8257' tid='8258', class="m">true</a>;
426      } <a id='8259' tid='8260', class="m">else</a> <a id='8261' tid='8262', class="m">if</a> ((<a id='8263' tid='8264', class="m">strcmp</a>(<a id='8265' tid='8266', class="m">cmd</a>, <a id='8267' tid='8268', class="m">&quot;p&quot;</a>) <a id='8269' tid='8270', class="m">==</a> <a id='8271' tid='8272', class="m">0</a>) <a id='8273' tid='8274', class="m">||</a> (<a id='8275' tid='8276', class="m">strcmp</a>(<a id='8277' tid='8278', class="m">cmd</a>, <a id='8279' tid='8280', class="m">&quot;print&quot;</a>) <a id='8281' tid='8282', class="m">==</a> <a id='8283' tid='8284', class="m">0</a>)) {
427        <span class="d">if</span> <span class="d">(argc == 2)</span> {
428          <span class="d">int32_t value;</span>
429          <span class="d">float fvalue;</span>
430          <span class="d">if</span> (<a id='8285' tid='8286', class="m">strcmp</a>(<a id='8287' tid='8288', class="m">arg1</a>, <a id='8289' tid='8290', class="m">&quot;all&quot;</a>) <a id='8291' tid='8292', class="m">==</a> <a id='8293' tid='8294', class="m">0</a>) <span class="d">{
431            PrintAllRegs();
432          }</span> <a id='8049' tid='8050', class="m">else</a> <span class="d">if</span> <span class="d">(strcmp(arg1, &quot;allf&quot;) == 0)</span> <span class="d">{
433            PrintAllRegsIncludingFPU();
434          }</span> <span class="d">else</span> {
435            <span class="d">int regnum = Registers::Number(arg1);</span>
436            <span class="d">int fpuregnum = FPURegisters::Number(arg1);</span>
437
438            <span class="d">if</span> <span class="d">(regnum != kInvalidRegister)</span> {
439              <span class="d">value = GetRegisterValue(regnum);</span>
440              <a id='8051' tid='8052', class="m">PrintF</a>(<a id='8053' tid='8054', class="m">&quot;%s: 0x%08x %d \n&quot;</a>, <a id='8055' tid='8056', class="m">arg1</a>, <a id='8057' tid='8058', class="m">value</a>, <a id='8059' tid='8060', class="m">value</a>);
441            } <span class="d">else if (fpuregnum != kInvalidFPURegister) {
442              if (fpuregnum % 2 == 1) {
443                value = GetFPURegisterValueInt(fpuregnum);
444                fvalue = GetFPURegisterValueFloat(fpuregnum);
445                PrintF(&quot;%s: 0x%08x %11.4e\n&quot;, arg1, value, fvalue);
446              } else {
447                double dfvalue;
448                int32_t lvalue1 = GetFPURegisterValueInt(fpuregnum);
449                int32_t lvalue2 = GetFPURegisterValueInt(fpuregnum + 1);
450                dfvalue = GetFPURegisterValueDouble(fpuregnum);
451                PrintF(&quot;%3s,%3s: 0x%08x%08x %16.4e\n&quot;,
452                       FPURegisters::Name(fpuregnum+1),
453                       FPURegisters::Name(fpuregnum),
454                       lvalue1,
455                       lvalue2,
456                       dfvalue);
457              }
458            } else {
459              PrintF(&quot;%s unrecognized\n&quot;, arg1);
460            }</span>
461          }
462        } <span class="d">else {
463          if (argc == 3) {
464            if (strcmp(arg2, &quot;single&quot;) == 0) {
465              int32_t value;
466              float fvalue;
467              int fpuregnum = FPURegisters::Number(arg1);
468
469              if (fpuregnum != kInvalidFPURegister) {
470                value = GetFPURegisterValueInt(fpuregnum);
471                fvalue = GetFPURegisterValueFloat(fpuregnum);
472                PrintF(&quot;%s: 0x%08x %11.4e\n&quot;, arg1, value, fvalue);
473              } else {
474                PrintF(&quot;%s unrecognized\n&quot;, arg1);
475              }
476            } else {
477              PrintF(&quot;print &lt;fpu register&gt; single\n&quot;);
478            }
479          } else {
480            PrintF(&quot;print &lt;register&gt; or print &lt;fpu register&gt; single\n&quot;);
481          }
482        }</span>
483      } <a id='8295' tid='8296', class="m">else</a> <a id='8297' tid='8298', class="m">if</a> ((<a id='8299' tid='8300', class="m">strcmp</a>(<a id='8301' tid='8302', class="m">cmd</a>, <a id='8303' tid='8304', class="m">&quot;po&quot;</a>) <a id='8305' tid='8306', class="m">==</a> <a id='8307' tid='8308', class="m">0</a>)
484                 <a id='8309' tid='8310', class="m">||</a> (<a id='8311' tid='8312', class="m">strcmp</a>(<a id='8313' tid='8314', class="m">cmd</a>, <a id='8315' tid='8316', class="m">&quot;printobject&quot;</a>) <a id='8317' tid='8318', class="m">==</a> <a id='8319' tid='8320', class="m">0</a>)) {
485        <a id='8321' tid='8322', class="m">if</a> (<a id='8323' tid='8324', class="m">argc</a> <a id='8325' tid='8326', class="m">==</a> <a id='8327' tid='8328', class="m">2</a>) {
486          <a id='8329' tid='8330', class="m">int32_t</a> <a id='8331' tid='8332', class="m">value</a>;
487          <a id='8333' tid='8334', class="m">if</a> (<a id='8335' tid='8336', class="m">GetValue</a>(<a id='8337' tid='8338', class="m">arg1</a>, <a id='8339' tid='8340', class="m">&</a><a id='8341' tid='8342', class="m">value</a>)) {
488            <a id='8343' tid='8344', class="m">Object</a><a id='8345' tid='8346', class="m">*</a> <a id='8347' tid='8348', class="m">obj</a> = <a id='8349' tid='8350', class="m">reinterpret_cast</a>&lt;<a id='8351' tid='8352', class="m">Object</a><a id='8353' tid='8354', class="m">*</a>&gt;(<a id='8355' tid='8356', class="m">value</a>);
489            <a id='8357' tid='8358', class="m">PrintF</a>(<a id='8359' tid='8360', class="m">&quot;%s: \n&quot;</a>, <a id='8361' tid='8362', class="m">arg1</a>);
490#<a id='8363' tid='8364', class="m">ifdef</a> <a id='8365' tid='8366', class="m">DEBUG</a>
491            <a id='8367' tid='8368', class="m">obj</a>-&gt;<a id='8369' tid='8370', class="m">PrintLn</a>();
492#<a id='8371' tid='8372', class="m">else</a>
493            <a id='8373' tid='8374', class="m">obj</a>-&gt;<a id='8375' tid='8376', class="m">ShortPrint</a>();
494            <a id='8377' tid='8378', class="m">PrintF</a>(<a id='8379' tid='8380', class="m">&quot;\n&quot;</a>);
495#<a id='8381' tid='8382', class="m">endif</a>
496          } <a id='8383' tid='8384', class="m">else</a> {
497            <a id='8385' tid='8386', class="m">PrintF</a>(<a id='8387' tid='8388', class="m">&quot;%s unrecognized\n&quot;</a>, <a id='8389' tid='8390', class="m">arg1</a>);
498          }
499        } <a id='8391' tid='8392', class="m">else</a> {
500          <a id='8393' tid='8394', class="m">PrintF</a>(<a id='8395' tid='8396', class="m">&quot;printobject &lt;value&gt;\n&quot;</a>);
501        }
502      } <a id='8397' tid='8398', class="m">else</a> <a id='8399' tid='8400', class="m">if</a> (<a id='8401' tid='8402', class="m">strcmp</a>(<a id='8403' tid='8404', class="m">cmd</a>, <a id='8405' tid='8406', class="m">&quot;stack&quot;</a>) <a id='8407' tid='8408', class="m">==</a> <a id='8409' tid='8410', class="m">0</a> <a id='8411' tid='8412', class="m">||</a> <a id='8413' tid='8414', class="m">strcmp</a>(<a id='8415' tid='8416', class="m">cmd</a>, <a id='8417' tid='8418', class="m">&quot;mem&quot;</a>) <a id='8419' tid='8420', class="m">==</a> <a id='8421' tid='8422', class="m">0</a>) {
503        <a id='8423' tid='8424', class="m">int32_t</a><a id='8425' tid='8426', class="m">*</a> <a id='8427' tid='8428', class="m">cur</a> = <a id='8429' tid='8430', class="m">NULL</a>;
504        <a id='8431' tid='8432', class="m">int32_t</a><a id='8433' tid='8434', class="m">*</a> <a id='8435' tid='8436', class="m">end</a> = <a id='8437' tid='8438', class="m">NULL</a>;
505        <a id='8439' tid='8440', class="m">int</a> <a id='8441' tid='8442', class="m">next_arg</a> = <a id='8443' tid='8444', class="m">1</a>;
506
507        <a id='8445' tid='8446', class="m">if</a> (<a id='8447' tid='8448', class="m">strcmp</a>(<a id='8449' tid='8450', class="m">cmd</a>, <a id='8451' tid='8452', class="m">&quot;stack&quot;</a>) <a id='8453' tid='8454', class="m">==</a> <a id='8455' tid='8456', class="m">0</a>) {
508          <a id='8457' tid='8458', class="m">cur</a> <a id='8459' tid='8460', class="m">=</a> <a id='8461' tid='8462', class="m">reinterpret_cast</a>&lt;<a id='8463' tid='8464', class="m">int32_t</a><a id='8465' tid='8466', class="m">*</a>&gt;(<a id='8467' tid='8468', class="m">sim_</a>-&gt;<a id='8469' tid='8470', class="m">get_register</a>(<a id='8471' tid='8472', class="m">Simulator</a><a id='8473' tid='8474', class="m">::</a><a id='8475' tid='8476', class="m">sp</a>));
509        } <a id='8477' tid='8478', class="m">else</a> {  // Command &quot;mem&quot;.
510          <a id='8479' tid='8480', class="m">int32_t</a> <a id='8481' tid='8482', class="m">value</a>;
511          <a id='8483' tid='8484', class="m">if</a> (<a id='8485' tid='8486', class="m">!</a><a id='8487' tid='8488', class="m">GetValue</a>(<a id='8489' tid='8490', class="m">arg1</a>, <a id='8491' tid='8492', class="m">&</a><a id='8493' tid='8494', class="m">value</a>)) {
512            <a id='8495' tid='8496', class="m">PrintF</a>(<a id='8497' tid='8498', class="m">&quot;%s unrecognized\n&quot;</a>, <a id='8499' tid='8500', class="m">arg1</a>);
513            <a id='8501' tid='8502', class="m">continue</a>;
514          }
515          <a id='8503' tid='8504', class="m">cur</a> <a id='8505' tid='8506', class="m">=</a> <a id='8507' tid='8508', class="m">reinterpret_cast</a>&lt;<a id='8509' tid='8510', class="m">int32_t</a><a id='8511' tid='8512', class="m">*</a>&gt;(<a id='8513' tid='8514', class="m">value</a>);
516          <a id='8515' tid='8516', class="m">next_arg</a><a id='8517' tid='8518', class="m">++</a>;
517        }
518
519        <a id='8519' tid='8520', class="m">int32_t</a> <a id='8521' tid='8522', class="m">words</a>;
520        <a id='8523' tid='8524', class="m">if</a> (<a id='8525' tid='8526', class="m">argc</a> <a id='8527' tid='8528', class="m">==</a> <a id='8529' tid='8530', class="m">next_arg</a>) {
521          <a id='8531' tid='8532', class="m">words</a> <a id='8533' tid='8534', class="m">=</a> <a id='8535' tid='8536', class="m">10</a>;
522        } <a id='8537' tid='8538', class="m">else</a> <a id='8539' tid='8540', class="m">if</a> (<a id='8541' tid='8542', class="m">argc</a> <a id='8543' tid='8544', class="m">==</a> <a id='8545' tid='8546', class="m">next_arg</a> <a id='8547' tid='8548', class="m">+</a> <a id='8549' tid='8550', class="m">1</a>) {
523          <a id='8551' tid='8552', class="m">if</a> (<a id='8553' tid='8554', class="m">!</a><a id='8555' tid='8556', class="m">GetValue</a>(<a id='8557' tid='8558', class="m">argv</a>[<a id='8559' tid='8560', class="m">next_arg</a>], <a id='8561' tid='8562', class="m">&</a><a id='8563' tid='8564', class="m">words</a>)) {
524            <a id='8565' tid='8566', class="m">words</a> <a id='8567' tid='8568', class="m">=</a> <a id='8569' tid='8570', class="m">10</a>;
525          }
526        }
527        <a id='8571' tid='8572', class="m">end</a> <a id='8573' tid='8574', class="m">=</a> <a id='8575' tid='8576', class="m">cur</a> <a id='8577' tid='8578', class="m">+</a> <a id='8579' tid='8580', class="m">words</a>;
528
529        <a id='8581' tid='8582', class="m">while</a> (<a id='8583' tid='8584', class="m">cur</a> <a id='8585' tid='8586', class="m">&lt;</a> <a id='8587' tid='8588', class="m">end</a>) {
530          <a id='8589' tid='8590', class="m">PrintF</a>(<a id='8591' tid='8592', class="m">&quot;  0x%08x:  0x%08x %10d&quot;</a>,
531                 <a id='8593' tid='8594', class="m">reinterpret_cast</a>&lt;<a id='8595' tid='8596', class="m">intptr_t</a>&gt;(<a id='8597' tid='8598', class="m">cur</a>), <a id='8599' tid='8600', class="m">*</a><a id='8601' tid='8602', class="m">cur</a>, <a id='8603' tid='8604', class="m">*</a><a id='8605' tid='8606', class="m">cur</a>);
532          <a id='8607' tid='8608', class="m">HeapObject</a><a id='8609' tid='8610', class="m">*</a> <a id='8611' tid='8612', class="m">obj</a> = <a id='8613' tid='8614', class="m">reinterpret_cast</a>&lt;<a id='8615' tid='8616', class="m">HeapObject</a><a id='8617' tid='8618', class="m">*</a>&gt;(<a id='8619' tid='8620', class="m">*</a><a id='8621' tid='8622', class="m">cur</a>);
533          <a id='8623' tid='8624', class="m">int</a> <a id='8625' tid='8626', class="m">value</a> = <a id='8627' tid='8628', class="m">*</a><a id='8629' tid='8630', class="m">cur</a>;
534          <a id='8631' tid='8632', class="m">Heap</a><a id='8633' tid='8634', class="m">*</a> <a id='8635' tid='8636', class="m">current_heap</a> = <a id='8637' tid='8638', class="m">v8</a><a id='8639' tid='8640', class="m">::</a><a id='8641' tid='8642', class="m">internal</a><a id='8643' tid='8644', class="m">::</a><a id='8645' tid='8646', class="m">Isolate</a><a id='8647' tid='8648', class="m">::</a><a id='8649' tid='8650', class="m">Current</a>()-&gt;<a id='8651' tid='8652', class="m">heap</a>();
535          <a id='8653' tid='8654', class="m">if</a> (<a id='8655' tid='8656', class="m">current_heap</a>-&gt;<a id='8657' tid='8658', class="m">Contains</a>(<a id='8659' tid='8660', class="m">obj</a>) <a id='8661' tid='8662', class="m">||</a> ((<a id='8663' tid='8664', class="m">value</a> <a id='8665' tid='8666', class="m">&</a> <a id='8667' tid='8668', class="m">1</a>) <a id='8669' tid='8670', class="m">==</a> <a id='8671' tid='8672', class="m">0</a>)) {
536            <a id='8673' tid='8674', class="m">PrintF</a>(<a id='8675' tid='8676', class="m">&quot; (&quot;</a>);
537            <a id='8677' tid='8678', class="m">if</a> ((<a id='8679' tid='8680', class="m">value</a> <a id='8681' tid='8682', class="m">&</a> <a id='8683' tid='8684', class="m">1</a>) <a id='8685' tid='8686', class="m">==</a> <a id='8687' tid='8688', class="m">0</a>) {
538              <a id='8689' tid='8690', class="m">PrintF</a>(<a id='8691' tid='8692', class="m">&quot;smi %d&quot;</a>, <a id='8693' tid='8694', class="m">value</a> <a id='8695' tid='8696', class="m">/</a> <a id='8697' tid='8698', class="m">2</a>);
539            } <a id='8699' tid='8700', class="m">else</a> {
540              <a id='8701' tid='8702', class="m">obj</a>-&gt;<a id='8703' tid='8704', class="m">ShortPrint</a>();
541            }
542            <a id='8705' tid='8706', class="m">PrintF</a>(<a id='8707' tid='8708', class="m">&quot;)&quot;</a>);
543          }
544          <a id='8709' tid='8710', class="m">PrintF</a>(<a id='8711' tid='8712', class="m">&quot;\n&quot;</a>);
545          <a id='8713' tid='8714', class="m">cur</a><a id='8715' tid='8716', class="m">++</a>;
546        }
547
548      } <a id='8717' tid='8718', class="m">else</a> <a id='8719' tid='8720', class="m">if</a> ((<a id='8721' tid='8722', class="m">strcmp</a>(<a id='8723' tid='8724', class="m">cmd</a>, <a id='8725' tid='8726', class="m">&quot;disasm&quot;</a>) <a id='8727' tid='8728', class="m">==</a> <a id='8729' tid='8730', class="m">0</a>) <span class="d">||</span>
549                 (<span class="d">strcmp(cmd, &quot;dpc&quot;) == 0</span>) <a id='8731' tid='8732', class="m">||</a>
550                 (<a id='8733' tid='8734', class="m">strcmp</a>(<a id='8735' tid='8736', class="m">cmd</a>, <a id='8737' tid='8738', class="m">&quot;di&quot;</a>) <a id='8739' tid='8740', class="m">==</a> <a id='8741' tid='8742', class="m">0</a>)) {
551        <span class="d">disasm::NameConverter converter;</span>
552        <a id='8743' tid='8744', class="m">disasm</a><a id='8745' tid='8746', class="m">::</a><a id='8747' tid='8748', class="m">Disassembler</a> <a id='8749' tid='8750', class="m">dasm</a>(<a id='8751' tid='8752', class="m">converter</a>);
553        // Use a reasonably large buffer.
554        <a id='8061' tid='8062', class="m">v8</a><a id='8063' tid='8064', class="m">::</a><a id='8065' tid='8066', class="m">internal</a><a id='8067' tid='8068', class="m">::</a><a id='8069' tid='8070', class="m">EmbeddedVector</a>&lt;<a id='8071' tid='8072', class="m">char</a>, <a id='8073' tid='8074', class="m">256</a>&gt; <a id='8075' tid='8076', class="m">buffer</a>;
555
556        <span class="d">byte* cur = NULL;</span>
557        <span class="d">byte* end = NULL;</span>
558
559        <a id='7545' tid='7546', class="m">if</a> (<a id='7547' tid='7548', class="m">argc</a> <a id='7549' tid='7550', class="m">==</a> <a id='7551' tid='7552', class="m">1</a>) {
560          <a id='7553' tid='7554', class="m">cur</a> <a id='7555' tid='7556', class="m">=</a> <a id='7557' tid='7558', class="m">reinterpret_cast</a>&lt;<a id='7559' tid='7560', class="m">byte</a><a id='7561' tid='7562', class="m">*</a>&gt;(<a id='7563' tid='7564', class="m">sim_</a>-&gt;<a id='7565' tid='7566', class="m">get_pc</a>());
561          <a id='7567' tid='7568', class="m">end</a> <a id='7569' tid='7570', class="m">=</a> <a id='7571' tid='7572', class="m">cur</a> <a id='7573' tid='7574', class="m">+</a> (<a id='7575' tid='7576', class="m">10</a> <a id='7577' tid='7578', class="m">*</a> <a id='7579' tid='7580', class="m">Instruction</a><a id='7581' tid='7582', class="m">::</a><a id='7583' tid='7584', class="m">kInstrSize</a>);
562        } <a id='7585' tid='7586', class="m">else</a> <a id='7587' tid='7588', class="m">if</a> (<a id='7589' tid='7590', class="m">argc</a> <a id='7591' tid='7592', class="m">==</a> <a id='7593' tid='7594', class="m">2</a>) {
563          <a id='7595' tid='7596', class="m">int</a> <a id='7597' tid='7598', class="m">regnum</a> = <a id='7599' tid='7600', class="m">Registers</a><a id='7601' tid='7602', class="m">::</a><a id='7603' tid='7604', class="m">Number</a>(<a id='7605' tid='7606', class="m">arg1</a>);
564          <a id='7607' tid='7608', class="m">if</a> (<span class="d">regnum != kInvalidRegister</span> <span class="d">||</span> <a id='7609' tid='7610', class="m">strncmp</a>(<a id='7611' tid='7612', class="m">arg1</a>, <a id='7613' tid='7614', class="m">&quot;0x&quot;</a>, <a id='7615' tid='7616', class="m">2</a>) <a id='7617' tid='7618', class="m">==</a> <a id='7619' tid='7620', class="m">0</a>) {
565            // The argument is an address or a register name.
566            <a id='7621' tid='7622', class="m">int32_t</a> <a id='7623' tid='7624', class="m">value</a>;
567            <a id='7625' tid='7626', class="m">if</a> (<a id='7627' tid='7628', class="m">GetValue</a>(<a id='7629' tid='7630', class="m">arg1</a>, <a id='7631' tid='7632', class="m">&</a><a id='7633' tid='7634', class="m">value</a>)) {
568              <a id='7635' tid='7636', class="m">cur</a> <a id='7637' tid='7638', class="m">=</a> <a id='7639' tid='7640', class="m">reinterpret_cast</a>&lt;<a id='7641' tid='7642', class="m">byte</a><a id='7643' tid='7644', class="m">*</a>&gt;(<a id='7645' tid='7646', class="m">value</a>);
569              // D…

Large files files are truncated, but you can click here to view the full file