| 543 | |
| 544 | template<int T> |
| 545 | bool LibcInfoWithPatchFunctions<T>::Patch(const LibcInfo& me_info) { |
| 546 | CopyFrom(me_info); // copies the module_entry and the windows_fn_ array |
| 547 | for (int i = 0; i < kNumFunctions; i++) { |
| 548 | if (windows_fn_[i] && windows_fn_[i] != perftools_fn_[i]) { |
| 549 | // if origstub_fn_ is not NULL, it's left around from a previous |
| 550 | // patch. We need to set it to NULL for the new Patch call. |
| 551 | // Since we've patched Unpatch() not to delete origstub_fn_ (it |
| 552 | // causes problems in some contexts, though obviously not this |
| 553 | // one), we should delete it now, before setting it to NULL. |
| 554 | // NOTE: casting from a function to a pointer is contra the C++ |
| 555 | // spec. It's not safe on IA64, but is on i386. We use |
| 556 | // a C-style cast here to emphasize this is not legal C++. |
| 557 | delete[] (char*)(origstub_fn_[i]); |
| 558 | origstub_fn_[i] = NULL; // Patch() will fill this in |
| 559 | CHECK_EQ(sidestep::SIDESTEP_SUCCESS, |
| 560 | PreamblePatcher::Patch(windows_fn_[i], perftools_fn_[i], |
| 561 | &origstub_fn_[i])); |
| 562 | } |
| 563 | } |
| 564 | set_is_valid(true); |
| 565 | return true; |
| 566 | } |
| 567 | |
| 568 | template<int T> |
| 569 | void LibcInfoWithPatchFunctions<T>::Unpatch() { |
no test coverage detected