| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (itr != breakMap_.end()) return false; | 90 if (itr != breakMap_.end()) return false; |
| 91 | 91 |
| 92 uint8_t *data = new uint8_t[bp->size_]; | 92 uint8_t *data = new uint8_t[bp->size_]; |
| 93 if (NULL == data) return false; | 93 if (NULL == data) return false; |
| 94 | 94 |
| 95 // Copy the old code from here | 95 // Copy the old code from here |
| 96 if (IPlatform::GetMemory(address, bp->size_, data) == false) { | 96 if (IPlatform::GetMemory(address, bp->size_, data) == false) { |
| 97 delete[] data; | 97 delete[] data; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 if (IPlatform::SetMemory(address, bp->size_, bp->code_) == false) { | 100 if (IPlatform::SetMemory(nap_, address, bp->size_, bp->code_) == false) { |
| 101 delete[] data; | 101 delete[] data; |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 | 104 |
| 105 breakMap_[address] = data; | 105 breakMap_[address] = data; |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool Target::RemoveTemporaryBreakpoints(IThread *thread) { | 109 bool Target::RemoveTemporaryBreakpoints(IThread *thread) { |
| 110 const Abi::BPDef *bp_def = abi_->GetBreakpointDef(); | 110 const Abi::BPDef *bp_def = abi_->GetBreakpointDef(); |
| 111 uintptr_t prog_ctr = thread->GetContext()->prog_ctr; | 111 uintptr_t prog_ctr = thread->GetContext()->prog_ctr; |
| 112 | 112 |
| 113 // If this ABI does not support breakpoints then fail. | 113 // If this ABI does not support breakpoints then fail. |
| 114 if (!bp_def) { | 114 if (!bp_def) { |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Iterate through the map, removing breakpoints | 118 // Iterate through the map, removing breakpoints |
| 119 while (!breakMap_.empty()) { | 119 while (!breakMap_.empty()) { |
| 120 // Copy the key/value locally | 120 // Copy the key/value locally |
| 121 BreakMap_t::iterator cur = breakMap_.begin(); | 121 BreakMap_t::iterator cur = breakMap_.begin(); |
| 122 uint64_t addr = cur->first; | 122 uint64_t addr = cur->first; |
| 123 uint8_t *data = cur->second; | 123 uint8_t *data = cur->second; |
| 124 | 124 |
| 125 // Then remove it from the map | 125 // Then remove it from the map |
| 126 breakMap_.erase(cur); | 126 breakMap_.erase(cur); |
| 127 | 127 |
| 128 // Copy back the old code, and free the data | 128 // Copy back the old code, and free the data |
| 129 if (!IPlatform::SetMemory(addr, bp_def->size_, data)) | 129 if (!IPlatform::SetMemory(nap_, addr, bp_def->size_, data)) |
| 130 NaClLog(LOG_ERROR, "Failed to undo breakpoint.\n"); | 130 NaClLog(LOG_ERROR, "Failed to undo breakpoint.\n"); |
| 131 delete[] data; | 131 delete[] data; |
| 132 | 132 |
| 133 uintptr_t sys_prog_ctr; | 133 uintptr_t sys_prog_ctr; |
| 134 if (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32) { | 134 if (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32) { |
| 135 sys_prog_ctr = NaClUserToSysAddr(nap_, prog_ctr); | 135 sys_prog_ctr = NaClUserToSysAddr(nap_, prog_ctr); |
| 136 } else { | 136 } else { |
| 137 sys_prog_ctr = prog_ctr; | 137 sys_prog_ctr = prog_ctr; |
| 138 } | 138 } |
| 139 // If we hit the breakpoint, ensure that it is reported as SIGTRAP | 139 // If we hit the breakpoint, ensure that it is reported as SIGTRAP |
| (...skipping 343 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 uint8_t *block = new uint8_t[len]; | 490 uint8_t *block = new uint8_t[len]; |
| 491 pktIn->GetBlock(block, len); | 491 pktIn->GetBlock(block, len); |
| 492 | 492 |
| 493 if (!port::IPlatform::SetMemory(sys_addr, len, block)) { | 493 if (!port::IPlatform::SetMemory(nap_, sys_addr, len, block)) { |
| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 IThread* Target::GetThread(uint32_t id) { | 758 IThread* Target::GetThread(uint32_t id) { |
| 759 ThreadMap_t::const_iterator itr; | 759 ThreadMap_t::const_iterator itr; |
| 760 itr = threads_.find(id); | 760 itr = threads_.find(id); |
| 761 if (itr != threads_.end()) return itr->second; | 761 if (itr != threads_.end()) return itr->second; |
| 762 | 762 |
| 763 return NULL; | 763 return NULL; |
| 764 } | 764 } |
| 765 | 765 |
| 766 | 766 |
| 767 } // namespace gdb_rsp | 767 } // namespace gdb_rsp |
| OLD | NEW |