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

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

Issue 8509015: MIPS: Repeat last debugger command in the arm simulator when command input is empty. (Closed)
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
« no previous file with comments | « src/mips/simulator-mips.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // This macro provides a platform independent use of sscanf. The reason for 65 // This macro provides a platform independent use of sscanf. The reason for
66 // SScanF not being implemented in a platform independent was through 66 // SScanF not being implemented in a platform independent was through
67 // ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time 67 // ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time
68 // Library does not provide vsscanf. 68 // Library does not provide vsscanf.
69 #define SScanF sscanf // NOLINT 69 #define SScanF sscanf // NOLINT
70 70
71 // The MipsDebugger class is used by the simulator while debugging simulated 71 // The MipsDebugger class is used by the simulator while debugging simulated
72 // code. 72 // code.
73 class MipsDebugger { 73 class MipsDebugger {
74 public: 74 public:
75 explicit MipsDebugger(Simulator* sim); 75 explicit MipsDebugger(Simulator* sim) : sim_(sim) { }
76 ~MipsDebugger(); 76 ~MipsDebugger();
77 77
78 void Stop(Instruction* instr); 78 void Stop(Instruction* instr);
79 void Debug(); 79 void Debug();
80 // Print all registers with a nice formatting. 80 // Print all registers with a nice formatting.
81 void PrintAllRegs(); 81 void PrintAllRegs();
82 void PrintAllRegsIncludingFPU(); 82 void PrintAllRegsIncludingFPU();
83 83
84 private: 84 private:
85 // We set the breakpoint code to 0xfffff to easily recognize it. 85 // We set the breakpoint code to 0xfffff to easily recognize it.
(...skipping 12 matching lines...) Expand all
98 // Set or delete a breakpoint. Returns true if successful. 98 // Set or delete a breakpoint. Returns true if successful.
99 bool SetBreakpoint(Instruction* breakpc); 99 bool SetBreakpoint(Instruction* breakpc);
100 bool DeleteBreakpoint(Instruction* breakpc); 100 bool DeleteBreakpoint(Instruction* breakpc);
101 101
102 // Undo and redo all breakpoints. This is needed to bracket disassembly and 102 // Undo and redo all breakpoints. This is needed to bracket disassembly and
103 // execution to skip past breakpoints when run from the debugger. 103 // execution to skip past breakpoints when run from the debugger.
104 void UndoBreakpoints(); 104 void UndoBreakpoints();
105 void RedoBreakpoints(); 105 void RedoBreakpoints();
106 }; 106 };
107 107
108 MipsDebugger::MipsDebugger(Simulator* sim) {
109 sim_ = sim;
110 }
111
112 108
113 MipsDebugger::~MipsDebugger() { 109 MipsDebugger::~MipsDebugger() {
114 } 110 }
115 111
116 112
117 #ifdef GENERATED_CODE_COVERAGE 113 #ifdef GENERATED_CODE_COVERAGE
118 static FILE* coverage_log = NULL; 114 static FILE* coverage_log = NULL;
119 115
120 116
121 static void InitializeCoverage() { 117 static void InitializeCoverage() {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 v8::internal::EmbeddedVector<char, 256> buffer; 380 v8::internal::EmbeddedVector<char, 256> buffer;
385 dasm.InstructionDecode(buffer, 381 dasm.InstructionDecode(buffer,
386 reinterpret_cast<byte*>(sim_->get_pc())); 382 reinterpret_cast<byte*>(sim_->get_pc()));
387 PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start()); 383 PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start());
388 last_pc = sim_->get_pc(); 384 last_pc = sim_->get_pc();
389 } 385 }
390 char* line = ReadLine("sim> "); 386 char* line = ReadLine("sim> ");
391 if (line == NULL) { 387 if (line == NULL) {
392 break; 388 break;
393 } else { 389 } else {
390 char* last_input = sim_->last_debugger_input();
391 if (strcmp(line, "\n") == 0 && last_input != NULL) {
392 line = last_input;
393 } else {
394 // Ownership is transferred to sim_;
395 sim_->set_last_debugger_input(line);
396 }
394 // Use sscanf to parse the individual parts of the command line. At the 397 // Use sscanf to parse the individual parts of the command line. At the
395 // moment no command expects more than two parameters. 398 // moment no command expects more than two parameters.
396 int argc = SScanF(line, 399 int argc = SScanF(line,
397 "%" XSTR(COMMAND_SIZE) "s " 400 "%" XSTR(COMMAND_SIZE) "s "
398 "%" XSTR(ARG_SIZE) "s " 401 "%" XSTR(ARG_SIZE) "s "
399 "%" XSTR(ARG_SIZE) "s", 402 "%" XSTR(ARG_SIZE) "s",
400 cmd, arg1, arg2); 403 cmd, arg1, arg2);
401 if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { 404 if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) {
402 Instruction* instr = reinterpret_cast<Instruction*>(sim_->get_pc()); 405 Instruction* instr = reinterpret_cast<Instruction*>(sim_->get_pc());
403 if (!(instr->IsTrap()) || 406 if (!(instr->IsTrap()) ||
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 PrintF(" or all stop(s).\n"); 753 PrintF(" or all stop(s).\n");
751 PrintF(" stop enable/disable all/<code> : enables / disables\n"); 754 PrintF(" stop enable/disable all/<code> : enables / disables\n");
752 PrintF(" all or number <code> stop(s)\n"); 755 PrintF(" all or number <code> stop(s)\n");
753 PrintF(" stop unstop\n"); 756 PrintF(" stop unstop\n");
754 PrintF(" ignore the stop instruction at the current location\n"); 757 PrintF(" ignore the stop instruction at the current location\n");
755 PrintF(" from now on\n"); 758 PrintF(" from now on\n");
756 } else { 759 } else {
757 PrintF("Unknown command: %s\n", cmd); 760 PrintF("Unknown command: %s\n", cmd);
758 } 761 }
759 } 762 }
760 DeleteArray(line);
761 } 763 }
762 764
763 // Add all the breakpoints back to stop execution and enter the debugger 765 // Add all the breakpoints back to stop execution and enter the debugger
764 // shell when hit. 766 // shell when hit.
765 RedoBreakpoints(); 767 RedoBreakpoints();
766 768
767 #undef COMMAND_SIZE 769 #undef COMMAND_SIZE
768 #undef ARG_SIZE 770 #undef ARG_SIZE
769 771
770 #undef STR 772 #undef STR
(...skipping 13 matching lines...) Expand all
784 } 786 }
785 787
786 788
787 static bool AllOnOnePage(uintptr_t start, int size) { 789 static bool AllOnOnePage(uintptr_t start, int size) {
788 intptr_t start_page = (start & ~CachePage::kPageMask); 790 intptr_t start_page = (start & ~CachePage::kPageMask);
789 intptr_t end_page = ((start + size) & ~CachePage::kPageMask); 791 intptr_t end_page = ((start + size) & ~CachePage::kPageMask);
790 return start_page == end_page; 792 return start_page == end_page;
791 } 793 }
792 794
793 795
796 void Simulator::set_last_debugger_input(char* input) {
797 DeleteArray(last_debugger_input_);
798 last_debugger_input_ = input;
799 }
800
801
794 void Simulator::FlushICache(v8::internal::HashMap* i_cache, 802 void Simulator::FlushICache(v8::internal::HashMap* i_cache,
795 void* start_addr, 803 void* start_addr,
796 size_t size) { 804 size_t size) {
797 intptr_t start = reinterpret_cast<intptr_t>(start_addr); 805 intptr_t start = reinterpret_cast<intptr_t>(start_addr);
798 int intra_line = (start & CachePage::kLineMask); 806 int intra_line = (start & CachePage::kLineMask);
799 start -= intra_line; 807 start -= intra_line;
800 size += intra_line; 808 size += intra_line;
801 size = ((size - 1) | CachePage::kLineMask) + 1; 809 size = ((size - 1) | CachePage::kLineMask) + 1;
802 int offset = (start & CachePage::kPageMask); 810 int offset = (start & CachePage::kPageMask);
803 while (!AllOnOnePage(start, size - 1)) { 811 while (!AllOnOnePage(start, size - 1)) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 // some buffer below. 912 // some buffer below.
905 registers_[sp] = reinterpret_cast<int32_t>(stack_) + stack_size_ - 64; 913 registers_[sp] = reinterpret_cast<int32_t>(stack_) + stack_size_ - 64;
906 // The ra and pc are initialized to a known bad value that will cause an 914 // The ra and pc are initialized to a known bad value that will cause an
907 // access violation if the simulator ever tries to execute it. 915 // access violation if the simulator ever tries to execute it.
908 registers_[pc] = bad_ra; 916 registers_[pc] = bad_ra;
909 registers_[ra] = bad_ra; 917 registers_[ra] = bad_ra;
910 InitializeCoverage(); 918 InitializeCoverage();
911 for (int i = 0; i < kNumExceptions; i++) { 919 for (int i = 0; i < kNumExceptions; i++) {
912 exceptions[i] = 0; 920 exceptions[i] = 0;
913 } 921 }
922
923 last_debugger_input_ = NULL;
914 } 924 }
915 925
916 926
917 // When the generated code calls an external reference we need to catch that in 927 // When the generated code calls an external reference we need to catch that in
918 // the simulator. The external reference will be a function compiled for the 928 // the simulator. The external reference will be a function compiled for the
919 // host architecture. We need to call that function instead of trying to 929 // host architecture. We need to call that function instead of trying to
920 // execute it with the simulator. We do that by redirecting the external 930 // execute it with the simulator. We do that by redirecting the external
921 // reference to a swi (software-interrupt) instruction that is handled by 931 // reference to a swi (software-interrupt) instruction that is handled by
922 // the simulator. We write the original destination of the jump just at a known 932 // the simulator. We write the original destination of the jump just at a known
923 // offset from the swi instruction so the simulator knows what to call. 933 // offset from the swi instruction so the simulator knows what to call.
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
2817 } 2827 }
2818 2828
2819 2829
2820 #undef UNSUPPORTED 2830 #undef UNSUPPORTED
2821 2831
2822 } } // namespace v8::internal 2832 } } // namespace v8::internal
2823 2833
2824 #endif // USE_SIMULATOR 2834 #endif // USE_SIMULATOR
2825 2835
2826 #endif // V8_TARGET_ARCH_MIPS 2836 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/simulator-mips.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698