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

Side by Side Diff: src/arm/simulator-arm.cc

Issue 8506015: Repeat last debugger command in the arm simulator when command input is empty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/simulator-arm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // This macro provides a platform independent use of sscanf. The reason for 46 // This macro provides a platform independent use of sscanf. The reason for
47 // SScanF not being implemented in a platform independent way through 47 // SScanF not being implemented in a platform independent way through
48 // ::v8::internal::OS in the same way as SNPrintF is that the 48 // ::v8::internal::OS in the same way as SNPrintF is that the
49 // Windows C Run-Time Library does not provide vsscanf. 49 // Windows C Run-Time Library does not provide vsscanf.
50 #define SScanF sscanf // NOLINT 50 #define SScanF sscanf // NOLINT
51 51
52 // The ArmDebugger class is used by the simulator while debugging simulated ARM 52 // The ArmDebugger class is used by the simulator while debugging simulated ARM
53 // code. 53 // code.
54 class ArmDebugger { 54 class ArmDebugger {
55 public: 55 public:
56 explicit ArmDebugger(Simulator* sim); 56 explicit ArmDebugger(Simulator* sim) : sim_(sim) { };
57 ~ArmDebugger(); 57 ~ArmDebugger();
58 58
59 void Stop(Instruction* instr); 59 void Stop(Instruction* instr);
60 void Debug(); 60 void Debug();
61 61
62 private: 62 private:
63 static const Instr kBreakpointInstr = 63 static const Instr kBreakpointInstr =
64 (al | (7*B25) | (1*B24) | kBreakpoint); 64 (al | (7*B25) | (1*B24) | kBreakpoint);
65 static const Instr kNopInstr = (al | (13*B21)); 65 static const Instr kNopInstr = (al | (13*B21));
66 66
(...skipping 10 matching lines...) Expand all
77 bool SetBreakpoint(Instruction* breakpc); 77 bool SetBreakpoint(Instruction* breakpc);
78 bool DeleteBreakpoint(Instruction* breakpc); 78 bool DeleteBreakpoint(Instruction* breakpc);
79 79
80 // Undo and redo all breakpoints. This is needed to bracket disassembly and 80 // Undo and redo all breakpoints. This is needed to bracket disassembly and
81 // execution to skip past breakpoints when run from the debugger. 81 // execution to skip past breakpoints when run from the debugger.
82 void UndoBreakpoints(); 82 void UndoBreakpoints();
83 void RedoBreakpoints(); 83 void RedoBreakpoints();
84 }; 84 };
85 85
86 86
87 ArmDebugger::ArmDebugger(Simulator* sim) {
88 sim_ = sim;
89 }
90
91
92 ArmDebugger::~ArmDebugger() { 87 ArmDebugger::~ArmDebugger() {
93 } 88 }
94 89
95 90
96 91
97 #ifdef GENERATED_CODE_COVERAGE 92 #ifdef GENERATED_CODE_COVERAGE
98 static FILE* coverage_log = NULL; 93 static FILE* coverage_log = NULL;
99 94
100 95
101 static void InitializeCoverage() { 96 static void InitializeCoverage() {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 v8::internal::EmbeddedVector<char, 256> buffer; 284 v8::internal::EmbeddedVector<char, 256> buffer;
290 dasm.InstructionDecode(buffer, 285 dasm.InstructionDecode(buffer,
291 reinterpret_cast<byte*>(sim_->get_pc())); 286 reinterpret_cast<byte*>(sim_->get_pc()));
292 PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start()); 287 PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start());
293 last_pc = sim_->get_pc(); 288 last_pc = sim_->get_pc();
294 } 289 }
295 char* line = ReadLine("sim> "); 290 char* line = ReadLine("sim> ");
296 if (line == NULL) { 291 if (line == NULL) {
297 break; 292 break;
298 } else { 293 } else {
294 char* last_input = sim_->last_debugger_input();
295 if (strcmp(line, "\n") == 0 && last_input != NULL) {
296 line = last_input;
297 } else {
298 // Ownership is transferred to sim_;
299 sim_->set_last_debugger_input(line);
300 }
299 // Use sscanf to parse the individual parts of the command line. At the 301 // Use sscanf to parse the individual parts of the command line. At the
300 // moment no command expects more than two parameters. 302 // moment no command expects more than two parameters.
301 int argc = SScanF(line, 303 int argc = SScanF(line,
302 "%" XSTR(COMMAND_SIZE) "s " 304 "%" XSTR(COMMAND_SIZE) "s "
303 "%" XSTR(ARG_SIZE) "s " 305 "%" XSTR(ARG_SIZE) "s "
304 "%" XSTR(ARG_SIZE) "s", 306 "%" XSTR(ARG_SIZE) "s",
305 cmd, arg1, arg2); 307 cmd, arg1, arg2);
306 if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { 308 if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) {
307 sim_->InstructionDecode(reinterpret_cast<Instruction*>(sim_->get_pc())); 309 sim_->InstructionDecode(reinterpret_cast<Instruction*>(sim_->get_pc()));
308 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { 310 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 PrintF(" or all stop(s).\n"); 606 PrintF(" or all stop(s).\n");
605 PrintF(" stop enable/disable all/<code> : enables / disables\n"); 607 PrintF(" stop enable/disable all/<code> : enables / disables\n");
606 PrintF(" all or number <code> stop(s)\n"); 608 PrintF(" all or number <code> stop(s)\n");
607 PrintF(" stop unstop\n"); 609 PrintF(" stop unstop\n");
608 PrintF(" ignore the stop instruction at the current location\n"); 610 PrintF(" ignore the stop instruction at the current location\n");
609 PrintF(" from now on\n"); 611 PrintF(" from now on\n");
610 } else { 612 } else {
611 PrintF("Unknown command: %s\n", cmd); 613 PrintF("Unknown command: %s\n", cmd);
612 } 614 }
613 } 615 }
614 DeleteArray(line);
615 } 616 }
616 617
617 // Add all the breakpoints back to stop execution and enter the debugger 618 // Add all the breakpoints back to stop execution and enter the debugger
618 // shell when hit. 619 // shell when hit.
619 RedoBreakpoints(); 620 RedoBreakpoints();
620 621
621 #undef COMMAND_SIZE 622 #undef COMMAND_SIZE
622 #undef ARG_SIZE 623 #undef ARG_SIZE
623 624
624 #undef STR 625 #undef STR
(...skipping 13 matching lines...) Expand all
638 } 639 }
639 640
640 641
641 static bool AllOnOnePage(uintptr_t start, int size) { 642 static bool AllOnOnePage(uintptr_t start, int size) {
642 intptr_t start_page = (start & ~CachePage::kPageMask); 643 intptr_t start_page = (start & ~CachePage::kPageMask);
643 intptr_t end_page = ((start + size) & ~CachePage::kPageMask); 644 intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
644 return start_page == end_page; 645 return start_page == end_page;
645 } 646 }
646 647
647 648
649 void Simulator::set_last_debugger_input(char* input) {
650 DeleteArray(last_debugger_input_);
651 last_debugger_input_ = input;
652 }
653
654
648 void Simulator::FlushICache(v8::internal::HashMap* i_cache, 655 void Simulator::FlushICache(v8::internal::HashMap* i_cache,
649 void* start_addr, 656 void* start_addr,
650 size_t size) { 657 size_t size) {
651 intptr_t start = reinterpret_cast<intptr_t>(start_addr); 658 intptr_t start = reinterpret_cast<intptr_t>(start_addr);
652 int intra_line = (start & CachePage::kLineMask); 659 int intra_line = (start & CachePage::kLineMask);
653 start -= intra_line; 660 start -= intra_line;
654 size += intra_line; 661 size += intra_line;
655 size = ((size - 1) | CachePage::kLineMask) + 1; 662 size = ((size - 1) | CachePage::kLineMask) + 1;
656 int offset = (start & CachePage::kPageMask); 663 int offset = (start & CachePage::kPageMask);
657 while (!AllOnOnePage(start, size - 1)) { 664 while (!AllOnOnePage(start, size - 1)) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 781
775 // The sp is initialized to point to the bottom (high address) of the 782 // The sp is initialized to point to the bottom (high address) of the
776 // allocated stack area. To be safe in potential stack underflows we leave 783 // allocated stack area. To be safe in potential stack underflows we leave
777 // some buffer below. 784 // some buffer below.
778 registers_[sp] = reinterpret_cast<int32_t>(stack_) + stack_size - 64; 785 registers_[sp] = reinterpret_cast<int32_t>(stack_) + stack_size - 64;
779 // The lr and pc are initialized to a known bad value that will cause an 786 // The lr and pc are initialized to a known bad value that will cause an
780 // access violation if the simulator ever tries to execute it. 787 // access violation if the simulator ever tries to execute it.
781 registers_[pc] = bad_lr; 788 registers_[pc] = bad_lr;
782 registers_[lr] = bad_lr; 789 registers_[lr] = bad_lr;
783 InitializeCoverage(); 790 InitializeCoverage();
791
792 last_debugger_input_ = NULL;
784 } 793 }
785 794
786 795
787 // When the generated code calls an external reference we need to catch that in 796 // When the generated code calls an external reference we need to catch that in
788 // the simulator. The external reference will be a function compiled for the 797 // the simulator. The external reference will be a function compiled for the
789 // host architecture. We need to call that function instead of trying to 798 // host architecture. We need to call that function instead of trying to
790 // execute it with the simulator. We do that by redirecting the external 799 // execute it with the simulator. We do that by redirecting the external
791 // reference to a svc (Supervisor Call) instruction that is handled by 800 // reference to a svc (Supervisor Call) instruction that is handled by
792 // the simulator. We write the original destination of the jump just at a known 801 // the simulator. We write the original destination of the jump just at a known
793 // offset from the svc instruction so the simulator knows what to call. 802 // offset from the svc instruction so the simulator knows what to call.
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
3417 uintptr_t address = *stack_slot; 3426 uintptr_t address = *stack_slot;
3418 set_register(sp, current_sp + sizeof(uintptr_t)); 3427 set_register(sp, current_sp + sizeof(uintptr_t));
3419 return address; 3428 return address;
3420 } 3429 }
3421 3430
3422 } } // namespace v8::internal 3431 } } // namespace v8::internal
3423 3432
3424 #endif // USE_SIMULATOR 3433 #endif // USE_SIMULATOR
3425 3434
3426 #endif // V8_TARGET_ARCH_ARM 3435 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698