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

Side by Side Diff: runtime/vm/debugger.cc

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/debugger_api_impl.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 864 }
865 if (best_fit_index >= 0) { 865 if (best_fit_index >= 0) {
866 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index)); 866 CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index));
867 // We should only ever have one code breakpoint at the same address. 867 // We should only ever have one code breakpoint at the same address.
868 if (bpt != NULL) { 868 if (bpt != NULL) {
869 return bpt; 869 return bpt;
870 } 870 }
871 871
872 bpt = new CodeBreakpoint(func, best_fit_index); 872 bpt = new CodeBreakpoint(func, best_fit_index);
873 if (FLAG_verbose_debug) { 873 if (FLAG_verbose_debug) {
874 OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n", 874 OS::Print("Setting breakpoint in function '%s' "
875 "(%s:%"Pd") (PC %#"Px")\n",
875 String::Handle(func.name()).ToCString(), 876 String::Handle(func.name()).ToCString(),
876 String::Handle(bpt->SourceUrl()).ToCString(), 877 String::Handle(bpt->SourceUrl()).ToCString(),
877 bpt->LineNumber(), 878 bpt->LineNumber(),
878 bpt->pc()); 879 bpt->pc());
879 } 880 }
880 RegisterCodeBreakpoint(bpt); 881 RegisterCodeBreakpoint(bpt);
881 return bpt; 882 return bpt;
882 } 883 }
883 return NULL; 884 return NULL;
884 } 885 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 if (bpt != NULL) { 917 if (bpt != NULL) {
917 // A source breakpoint for this uncompiled location already 918 // A source breakpoint for this uncompiled location already
918 // exists. 919 // exists.
919 return bpt; 920 return bpt;
920 } 921 }
921 } 922 }
922 bpt = new SourceBreakpoint(nextId(), target_function, first_token_pos); 923 bpt = new SourceBreakpoint(nextId(), target_function, first_token_pos);
923 RegisterSourceBreakpoint(bpt); 924 RegisterSourceBreakpoint(bpt);
924 if (FLAG_verbose_debug && !target_function.HasCode()) { 925 if (FLAG_verbose_debug && !target_function.HasCode()) {
925 OS::Print("Registering breakpoint for " 926 OS::Print("Registering breakpoint for "
926 "uncompiled function '%s' at line %d\n", 927 "uncompiled function '%s' at line %"Pd"\n",
927 target_function.ToFullyQualifiedCString(), 928 target_function.ToFullyQualifiedCString(),
928 bpt->LineNumber()); 929 bpt->LineNumber());
929 } 930 }
930 931
931 if (cbpt != NULL) { 932 if (cbpt != NULL) {
932 ASSERT(cbpt->src_bpt() == NULL); 933 ASSERT(cbpt->src_bpt() == NULL);
933 cbpt->set_src_bpt(bpt); 934 cbpt->set_src_bpt(bpt);
934 SignalBpResolved(bpt); 935 SignalBpResolved(bpt);
935 } else { 936 } else {
936 if (FLAG_verbose_debug) { 937 if (FLAG_verbose_debug) {
937 OS::Print("Failed to set breakpoint at '%s' line %d\n", 938 OS::Print("Failed to set breakpoint at '%s' line %"Pd"\n",
938 String::Handle(bpt->SourceUrl()).ToCString(), 939 String::Handle(bpt->SourceUrl()).ToCString(),
939 bpt->LineNumber()); 940 bpt->LineNumber());
940 } 941 }
941 } 942 }
942 bpt->Enable(); 943 bpt->Enable();
943 return bpt; 944 return bpt;
944 } 945 }
945 946
946 947
947 // Synchronize the enabled/disabled state of all code breakpoints 948 // Synchronize the enabled/disabled state of all code breakpoints
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 OS::Print("Failed to find script with url '%s'\n", 989 OS::Print("Failed to find script with url '%s'\n",
989 script_url.ToCString()); 990 script_url.ToCString());
990 } 991 }
991 return NULL; 992 return NULL;
992 } 993 }
993 intptr_t first_token_idx, last_token_idx; 994 intptr_t first_token_idx, last_token_idx;
994 script.TokenRangeAtLine(line_number, &first_token_idx, &last_token_idx); 995 script.TokenRangeAtLine(line_number, &first_token_idx, &last_token_idx);
995 if (first_token_idx < 0) { 996 if (first_token_idx < 0) {
996 // Script does not contain the given line number. 997 // Script does not contain the given line number.
997 if (FLAG_verbose_debug) { 998 if (FLAG_verbose_debug) {
998 OS::Print("Script '%s' does not contain line number %d\n", 999 OS::Print("Script '%s' does not contain line number %"Pd"\n",
999 script_url.ToCString(), line_number); 1000 script_url.ToCString(), line_number);
1000 } 1001 }
1001 return NULL; 1002 return NULL;
1002 } 1003 }
1003 const Function& func = 1004 const Function& func =
1004 Function::Handle(lib.LookupFunctionInScript(script, first_token_idx)); 1005 Function::Handle(lib.LookupFunctionInScript(script, first_token_idx));
1005 if (func.IsNull()) { 1006 if (func.IsNull()) {
1006 if (FLAG_verbose_debug) { 1007 if (FLAG_verbose_debug) {
1007 OS::Print("No executable code at line %d in '%s'\n", 1008 OS::Print("No executable code at line %"Pd" in '%s'\n",
1008 line_number, script_url.ToCString()); 1009 line_number, script_url.ToCString());
1009 } 1010 }
1010 return NULL; 1011 return NULL;
1011 } 1012 }
1012 if (last_token_idx < 0) { 1013 if (last_token_idx < 0) {
1013 // The token at first_token_index is past the requested source line. 1014 // The token at first_token_index is past the requested source line.
1014 // Set the breakpoint at the closest position after that line. 1015 // Set the breakpoint at the closest position after that line.
1015 last_token_idx = func.end_token_pos(); 1016 last_token_idx = func.end_token_pos();
1016 } 1017 }
1017 return SetBreakpoint(func, first_token_idx, last_token_idx); 1018 return SetBreakpoint(func, first_token_idx, last_token_idx);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 } 1233 }
1233 } 1234 }
1234 1235
1235 1236
1236 static void DefaultBreakpointHandler(SourceBreakpoint* bpt, 1237 static void DefaultBreakpointHandler(SourceBreakpoint* bpt,
1237 DebuggerStackTrace* stack) { 1238 DebuggerStackTrace* stack) {
1238 String& var_name = String::Handle(); 1239 String& var_name = String::Handle();
1239 Instance& value = Instance::Handle(); 1240 Instance& value = Instance::Handle();
1240 for (intptr_t i = 0; i < stack->Length(); i++) { 1241 for (intptr_t i = 0; i < stack->Length(); i++) {
1241 ActivationFrame* frame = stack->ActivationFrameAt(i); 1242 ActivationFrame* frame = stack->ActivationFrameAt(i);
1242 OS::Print(" %d. %s\n", 1243 OS::Print(" %"Pd". %s\n",
1243 i + 1, frame->ToCString()); 1244 i + 1, frame->ToCString());
1244 intptr_t num_locals = frame->NumLocalVariables(); 1245 intptr_t num_locals = frame->NumLocalVariables();
1245 for (intptr_t i = 0; i < num_locals; i++) { 1246 for (intptr_t i = 0; i < num_locals; i++) {
1246 intptr_t token_pos, end_pos; 1247 intptr_t token_pos, end_pos;
1247 frame->VariableAt(i, &var_name, &token_pos, &end_pos, &value); 1248 frame->VariableAt(i, &var_name, &token_pos, &end_pos, &value);
1248 OS::Print(" var %s (pos %d) = %s\n", 1249 OS::Print(" var %s (pos %"Pd") = %s\n",
1249 var_name.ToCString(), token_pos, value.ToCString()); 1250 var_name.ToCString(), token_pos, value.ToCString());
1250 } 1251 }
1251 } 1252 }
1252 } 1253 }
1253 1254
1254 1255
1255 void Debugger::SetBreakpointHandler(BreakpointHandler* handler) { 1256 void Debugger::SetBreakpointHandler(BreakpointHandler* handler) {
1256 bp_handler_ = handler; 1257 bp_handler_ = handler;
1257 if (bp_handler_ == NULL) { 1258 if (bp_handler_ == NULL) {
1258 bp_handler_ = &DefaultBreakpointHandler; 1259 bp_handler_ = &DefaultBreakpointHandler;
(...skipping 23 matching lines...) Expand all
1282 if (ignore_breakpoints_) { 1283 if (ignore_breakpoints_) {
1283 return; 1284 return;
1284 } 1285 }
1285 DebuggerStackTrace* stack_trace = CollectStackTrace(); 1286 DebuggerStackTrace* stack_trace = CollectStackTrace();
1286 ASSERT(stack_trace->Length() > 0); 1287 ASSERT(stack_trace->Length() > 0);
1287 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); 1288 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0);
1288 ASSERT(top_frame != NULL); 1289 ASSERT(top_frame != NULL);
1289 CodeBreakpoint* bpt = GetCodeBreakpoint(top_frame->pc()); 1290 CodeBreakpoint* bpt = GetCodeBreakpoint(top_frame->pc());
1290 ASSERT(bpt != NULL); 1291 ASSERT(bpt != NULL);
1291 if (FLAG_verbose_debug) { 1292 if (FLAG_verbose_debug) {
1292 OS::Print(">>> hit %s breakpoint at %s:%d (Address %p)\n", 1293 OS::Print(">>> hit %s breakpoint at %s:%"Pd" (Address %#"Px")\n",
1293 bpt->IsInternal() ? "internal" : "user", 1294 bpt->IsInternal() ? "internal" : "user",
1294 String::Handle(bpt->SourceUrl()).ToCString(), 1295 String::Handle(bpt->SourceUrl()).ToCString(),
1295 bpt->LineNumber(), 1296 bpt->LineNumber(),
1296 top_frame->pc()); 1297 top_frame->pc());
1297 } 1298 }
1298 1299
1299 if (!bpt->IsInternal()) { 1300 if (!bpt->IsInternal()) {
1300 // This is a user-defined breakpoint so we call the breakpoint 1301 // This is a user-defined breakpoint so we call the breakpoint
1301 // callback even if it is on the same line as the previous breakpoint. 1302 // callback even if it is on the same line as the previous breakpoint.
1302 last_bpt_line_ = -1; 1303 last_bpt_line_ = -1;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 } 1566 }
1566 1567
1567 1568
1568 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1569 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1569 ASSERT(bpt->next() == NULL); 1570 ASSERT(bpt->next() == NULL);
1570 bpt->set_next(code_breakpoints_); 1571 bpt->set_next(code_breakpoints_);
1571 code_breakpoints_ = bpt; 1572 code_breakpoints_ = bpt;
1572 } 1573 }
1573 1574
1574 } // namespace dart 1575 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698