OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (itr != breakMap_.end()) return false; | 91 if (itr != breakMap_.end()) return false; |
92 | 92 |
93 uint8_t *data = new uint8_t[bp->size_]; | 93 uint8_t *data = new uint8_t[bp->size_]; |
94 if (NULL == data) return false; | 94 if (NULL == data) return false; |
95 | 95 |
96 // Copy the old code from here | 96 // Copy the old code from here |
97 if (IPlatform::GetMemory(address, bp->size_, data) == false) { | 97 if (IPlatform::GetMemory(address, bp->size_, data) == false) { |
98 delete[] data; | 98 delete[] data; |
99 return false; | 99 return false; |
100 } | 100 } |
101 if (IPlatform::SetMemory(address, bp->size_, bp->code_) == false) { | 101 if (IPlatform::SetMemory(nap_, address, bp->size_, bp->code_) == false) { |
102 delete[] data; | 102 delete[] data; |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 breakMap_[address] = data; | 106 breakMap_[address] = data; |
107 return true; | 107 return true; |
108 } | 108 } |
109 | 109 |
110 bool Target::RemoveTemporaryBreakpoints(IThread *thread) { | 110 bool Target::RemoveTemporaryBreakpoints(IThread *thread) { |
111 const Abi::BPDef *bp_def = abi_->GetBreakpointDef(); | 111 const Abi::BPDef *bp_def = abi_->GetBreakpointDef(); |
112 uintptr_t prog_ctr = thread->GetContext()->prog_ctr; | 112 uintptr_t prog_ctr = thread->GetContext()->prog_ctr; |
113 | 113 |
114 // If this ABI does not support breakpoints then fail. | 114 // If this ABI does not support breakpoints then fail. |
115 if (!bp_def) { | 115 if (!bp_def) { |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
119 // Iterate through the map, removing breakpoints | 119 // Iterate through the map, removing breakpoints |
120 while (!breakMap_.empty()) { | 120 while (!breakMap_.empty()) { |
121 // Copy the key/value locally | 121 // Copy the key/value locally |
122 BreakMap_t::iterator cur = breakMap_.begin(); | 122 BreakMap_t::iterator cur = breakMap_.begin(); |
123 uint64_t addr = cur->first; | 123 uint64_t addr = cur->first; |
124 uint8_t *data = cur->second; | 124 uint8_t *data = cur->second; |
125 | 125 |
126 // Then remove it from the map | 126 // Then remove it from the map |
127 breakMap_.erase(cur); | 127 breakMap_.erase(cur); |
128 | 128 |
129 // Copy back the old code, and free the data | 129 // Copy back the old code, and free the data |
130 if (!IPlatform::SetMemory(addr, bp_def->size_, data)) | 130 if (!IPlatform::SetMemory(nap_, addr, bp_def->size_, data)) |
131 NaClLog(LOG_ERROR, "Failed to undo breakpoint.\n"); | 131 NaClLog(LOG_ERROR, "Failed to undo breakpoint.\n"); |
132 delete[] data; | 132 delete[] data; |
133 | 133 |
134 uintptr_t sys_prog_ctr; | 134 uintptr_t sys_prog_ctr; |
135 if (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32) { | 135 if (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32) { |
136 sys_prog_ctr = NaClUserToSysAddr(nap_, prog_ctr); | 136 sys_prog_ctr = NaClUserToSysAddr(nap_, prog_ctr); |
137 } else { | 137 } else { |
138 sys_prog_ctr = prog_ctr; | 138 sys_prog_ctr = prog_ctr; |
139 } | 139 } |
140 // If we hit the breakpoint, ensure that it is reported as SIGTRAP | 140 // If we hit the breakpoint, ensure that it is reported as SIGTRAP |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 uint64_t sys_addr = UserToSysAddr(user_addr); | 483 uint64_t sys_addr = UserToSysAddr(user_addr); |
484 if (sys_addr == kNaClBadAddress) { | 484 if (sys_addr == kNaClBadAddress) { |
485 err = FAILED; | 485 err = FAILED; |
486 break; | 486 break; |
487 } | 487 } |
488 | 488 |
489 len = static_cast<uint32_t>(wlen); | 489 len = static_cast<uint32_t>(wlen); |
490 nacl::scoped_array<uint8_t> block(new uint8_t[len]); | 490 nacl::scoped_array<uint8_t> block(new uint8_t[len]); |
491 pktIn->GetBlock(block.get(), len); | 491 pktIn->GetBlock(block.get(), len); |
492 | 492 |
493 if (!port::IPlatform::SetMemory(sys_addr, len, block.get())) { | 493 if (!port::IPlatform::SetMemory(nap_, sys_addr, len, block.get())) { |
494 err = FAILED; | 494 err = FAILED; |
495 break; | 495 break; |
496 } | 496 } |
497 | 497 |
498 pktOut->AddString("OK"); | 498 pktOut->AddString("OK"); |
499 break; | 499 break; |
500 } | 500 } |
501 | 501 |
502 case 'q': { | 502 case 'q': { |
503 string tmp; | 503 string tmp; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 &exception_code)) { | 799 &exception_code)) { |
800 *signal = IThread::ExceptionToSignal(exception_code); | 800 *signal = IThread::ExceptionToSignal(exception_code); |
801 *thread_id = thread->GetId(); | 801 *thread_id = thread->GetId(); |
802 return; | 802 return; |
803 } | 803 } |
804 } | 804 } |
805 NaClLog(LOG_FATAL, "UnqueueAnyFaultedThread: No threads queued\n"); | 805 NaClLog(LOG_FATAL, "UnqueueAnyFaultedThread: No threads queued\n"); |
806 } | 806 } |
807 | 807 |
808 } // namespace gdb_rsp | 808 } // namespace gdb_rsp |
OLD | NEW |