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

Unified Diff: runtime/vm/debugger.cc

Issue 131853006: Fix debugger stub patching on x64 architecture (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 31757)
+++ runtime/vm/debugger.cc (working copy)
@@ -708,6 +708,7 @@
is_enabled_(false),
src_bpt_(NULL),
next_(NULL) {
+ saved_value_ = 0;
ASSERT(!func.HasOptimizedCode());
Code& code = Code::Handle(func.unoptimized_code());
ASSERT(!code.IsNull()); // Function must be compiled.
@@ -758,72 +759,6 @@
}
-void CodeBreakpoint::PatchCode() {
- ASSERT(!is_enabled_);
- switch (breakpoint_kind_) {
- case PcDescriptors::kIcCall: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- saved_bytes_.target_address_ =
- CodePatcher::GetInstanceCallAt(pc_, code, NULL);
- CodePatcher::PatchInstanceCallAt(pc_, code,
- StubCode::BreakpointDynamicEntryPoint());
- break;
- }
- case PcDescriptors::kUnoptStaticCall: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- saved_bytes_.target_address_ =
- CodePatcher::GetStaticCallTargetAt(pc_, code);
- CodePatcher::PatchStaticCallAt(pc_, code,
- StubCode::BreakpointStaticEntryPoint());
- break;
- }
- case PcDescriptors::kRuntimeCall:
- case PcDescriptors::kClosureCall:
- case PcDescriptors::kReturn: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- saved_bytes_.target_address_ =
- CodePatcher::GetStaticCallTargetAt(pc_, code);
- CodePatcher::PatchStaticCallAt(pc_, code,
- StubCode::BreakpointRuntimeEntryPoint());
- break;
- }
- default:
- UNREACHABLE();
- }
- is_enabled_ = true;
-}
-
-
-void CodeBreakpoint::RestoreCode() {
- ASSERT(is_enabled_);
- switch (breakpoint_kind_) {
- case PcDescriptors::kIcCall: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- CodePatcher::PatchInstanceCallAt(pc_, code,
- saved_bytes_.target_address_);
- break;
- }
- case PcDescriptors::kUnoptStaticCall:
- case PcDescriptors::kClosureCall:
- case PcDescriptors::kRuntimeCall:
- case PcDescriptors::kReturn: {
- const Code& code =
- Code::Handle(Function::Handle(function_).unoptimized_code());
- CodePatcher::PatchStaticCallAt(pc_, code,
- saved_bytes_.target_address_);
- break;
- }
- default:
- UNREACHABLE();
- }
- is_enabled_ = false;
-}
-
-
void CodeBreakpoint::Enable() {
if (!is_enabled_) {
PatchCode();
@@ -1011,6 +946,7 @@
void Debugger::InstrumentForStepping(const Function& target_function) {
+ //printf("Instrumenting: %s\n", target_function.ToFullyQualifiedCString());
if (target_function.is_native()) {
// Can't instrument native functions.
return;
@@ -1029,14 +965,16 @@
ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
for (intptr_t i = 0; i < desc.Length(); i++) {
- CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(i));
- if (bpt != NULL) {
- // There is already a breakpoint for this address. Make sure
- // it is enabled.
- bpt->Enable();
- continue;
- }
if (IsSafePoint(desc.DescriptorKind(i))) {
+ CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(i));
+ if (bpt != NULL) {
+ // There is already a breakpoint for this address. Make sure
+ // it is enabled.
+//printf("IFS: found bp i %ld pc 0x%lx\n", i, desc.PC(i));
+ bpt->Enable();
+ continue;
+ }
+//printf("IFS: make new bp i %ld pc 0x%lx\n", i, desc.PC(i));
bpt = new CodeBreakpoint(target_function, i);
RegisterCodeBreakpoint(bpt);
bpt->Enable();
@@ -1359,17 +1297,21 @@
Code& code = Code::Handle(func.unoptimized_code());
ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
+//printf("XXX make code bp at %ld\n", bpt->token_pos_);
for (intptr_t i = 0; i < desc.Length(); i++) {
intptr_t desc_token_pos = desc.TokenPos(i);
if ((desc_token_pos == bpt->token_pos_) &&
IsSafePoint(desc.DescriptorKind(i))) {
+//printf("XXX found matching safe point i %ld pos %ld\n", i, desc_token_pos);
CodeBreakpoint* code_bpt = GetCodeBreakpoint(desc.PC(i));
if (code_bpt == NULL) {
+//printf("making new code breakpoint\n");
// No code breakpoint for this code exists; create one.
code_bpt = new CodeBreakpoint(func, i);
RegisterCodeBreakpoint(code_bpt);
}
- code_bpt->set_src_bpt(bpt);
+//else printf("found existing code breakpoint pc 0x%lx srcbp 0x%p\n", code_bpt->pc(), code_bpt->src_bpt());
+// code_bpt->set_src_bpt(bpt);
if (bpt->IsEnabled()) {
code_bpt->Enable();
}
@@ -1561,6 +1503,7 @@
for (intptr_t i = 0; i < num_functions; i++) {
func ^= functions.At(i);
if (func.HasCode()) {
+//printf("func %s\n", func.ToFullyQualifiedCString());
MakeCodeBreakpointsAt(func, bpt);
}
}
@@ -2179,9 +2122,10 @@
uword Debugger::GetPatchedStubAddress(uword breakpoint_address) {
+//printf("GPSA 0x%lx\n", breakpoint_address);
CodeBreakpoint* bpt = GetCodeBreakpoint(breakpoint_address);
if (bpt != NULL) {
- return bpt->saved_bytes_.target_address_;
+ return bpt->OrigStubAddress();
}
UNREACHABLE();
return 0L;
@@ -2238,6 +2182,7 @@
CodeBreakpoint* curr_bpt = code_breakpoints_;
while (curr_bpt != NULL) {
if (curr_bpt->src_bpt() == NULL) {
+//printf("RIBP for 0x%lx\n", curr_bpt->pc());
if (prev_bpt == NULL) {
code_breakpoints_ = code_breakpoints_->next();
} else {

Powered by Google App Engine
This is Rietveld 408576698