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

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

Issue 419343003: when open macro GENERATED_CODE_COVERAGE, fix compiler error and fd leak (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Created 6 years, 4 months 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 | « no previous file | src/ia32/assembler-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 69
70 70
71 #ifdef GENERATED_CODE_COVERAGE 71 #ifdef GENERATED_CODE_COVERAGE
72 static FILE* coverage_log = NULL; 72 static FILE* coverage_log = NULL;
73 73
74 74
75 static void InitializeCoverage() { 75 static void InitializeCoverage() {
76 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG"); 76 char* file_name = getenv("V8_GENERATED_CODE_COVERAGE_LOG");
77 if (file_name != NULL) { 77 if (file_name != NULL && NULL == coverage_log) {
78 coverage_log = fopen(file_name, "aw+"); 78 coverage_log = fopen(file_name, "aw+");
79 } 79 }
80 } 80 }
81 81
82 static void DeinitCoverageLog() {
83 if (coverage_log != NULL) {
84 fclose(coverage_log);
85 coverage_log = NULL;
86 }
87 }
82 88
83 void ArmDebugger::Stop(Instruction* instr) { 89 void ArmDebugger::Stop(Instruction* instr) {
84 // Get the stop code. 90 // Get the stop code.
85 uint32_t code = instr->SvcValue() & kStopCodeMask; 91 uint32_t code = instr->SvcValue() & kStopCodeMask;
86 // Retrieve the encoded address, which comes just after this stop. 92 // Retrieve the encoded address, which comes just after this stop.
87 char** msg_address = 93 char** msg_address =
88 reinterpret_cast<char**>(sim_->get_pc() + Instruction::kInstrSize); 94 reinterpret_cast<char**>(sim_->get_pc() + Instruction::kInstrSize);
89 char* msg = *msg_address; 95 char* msg = *msg_address;
90 ASSERT(msg != NULL); 96 ASSERT(msg != NULL);
91 97
(...skipping 11 matching lines...) Expand all
103 instr->SetInstructionBits(kNopInstr); 109 instr->SetInstructionBits(kNopInstr);
104 reinterpret_cast<Instruction*>(msg_address)->SetInstructionBits(kNopInstr); 110 reinterpret_cast<Instruction*>(msg_address)->SetInstructionBits(kNopInstr);
105 } 111 }
106 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize); 112 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize);
107 } 113 }
108 114
109 #else // ndef GENERATED_CODE_COVERAGE 115 #else // ndef GENERATED_CODE_COVERAGE
110 116
111 static void InitializeCoverage() { 117 static void InitializeCoverage() {
112 } 118 }
113 119 static void DeinitCoverageLog() {
120 }
114 121
115 void ArmDebugger::Stop(Instruction* instr) { 122 void ArmDebugger::Stop(Instruction* instr) {
116 // Get the stop code. 123 // Get the stop code.
117 uint32_t code = instr->SvcValue() & kStopCodeMask; 124 uint32_t code = instr->SvcValue() & kStopCodeMask;
118 // Retrieve the encoded address, which comes just after this stop. 125 // Retrieve the encoded address, which comes just after this stop.
119 char* msg = *reinterpret_cast<char**>(sim_->get_pc() 126 char* msg = *reinterpret_cast<char**>(sim_->get_pc()
120 + Instruction::kInstrSize); 127 + Instruction::kInstrSize);
121 // Update this stop description. 128 // Update this stop description.
122 if (sim_->isWatchedStop(code) && !sim_->watched_stops_[code].desc) { 129 if (sim_->isWatchedStop(code) && !sim_->watched_stops_[code].desc) {
123 sim_->watched_stops_[code].desc = msg; 130 sim_->watched_stops_[code].desc = msg;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 // access violation if the simulator ever tries to execute it. 775 // access violation if the simulator ever tries to execute it.
769 registers_[pc] = bad_lr; 776 registers_[pc] = bad_lr;
770 registers_[lr] = bad_lr; 777 registers_[lr] = bad_lr;
771 InitializeCoverage(); 778 InitializeCoverage();
772 779
773 last_debugger_input_ = NULL; 780 last_debugger_input_ = NULL;
774 } 781 }
775 782
776 783
777 Simulator::~Simulator() { 784 Simulator::~Simulator() {
785 DeinitCoverageLog();
778 } 786 }
779 787
780 788
781 // When the generated code calls an external reference we need to catch that in 789 // When the generated code calls an external reference we need to catch that in
782 // the simulator. The external reference will be a function compiled for the 790 // the simulator. The external reference will be a function compiled for the
783 // host architecture. We need to call that function instead of trying to 791 // host architecture. We need to call that function instead of trying to
784 // execute it with the simulator. We do that by redirecting the external 792 // execute it with the simulator. We do that by redirecting the external
785 // reference to a svc (Supervisor Call) instruction that is handled by 793 // reference to a svc (Supervisor Call) instruction that is handled by
786 // the simulator. We write the original destination of the jump just at a known 794 // the simulator. We write the original destination of the jump just at a known
787 // offset from the svc instruction so the simulator knows what to call. 795 // offset from the svc instruction so the simulator knows what to call.
(...skipping 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after
3830 uintptr_t address = *stack_slot; 3838 uintptr_t address = *stack_slot;
3831 set_register(sp, current_sp + sizeof(uintptr_t)); 3839 set_register(sp, current_sp + sizeof(uintptr_t));
3832 return address; 3840 return address;
3833 } 3841 }
3834 3842
3835 } } // namespace v8::internal 3843 } } // namespace v8::internal
3836 3844
3837 #endif // USE_SIMULATOR 3845 #endif // USE_SIMULATOR
3838 3846
3839 #endif // V8_TARGET_ARCH_ARM 3847 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ia32/assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698