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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 2116563003: [DevTools] Report unhandled exceptions and promise rejections through Runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after ExceptionDetails change Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 std::unique_ptr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerC lient* client) 78 std::unique_ptr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerC lient* client)
79 { 79 {
80 return wrapUnique(new V8DebuggerImpl(isolate, client)); 80 return wrapUnique(new V8DebuggerImpl(isolate, client));
81 } 81 }
82 82
83 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) 83 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client)
84 : m_isolate(isolate) 84 : m_isolate(isolate)
85 , m_client(client) 85 , m_client(client)
86 , m_capturingStackTracesCount(0) 86 , m_capturingStackTracesCount(0)
87 , m_muteConsoleCount(0) 87 , m_muteConsoleCount(0)
88 , m_lastConsoleMessageId(0) 88 , m_lastExceptionId(0)
89 , m_enabledAgentsCount(0) 89 , m_enabledAgentsCount(0)
90 , m_breakpointsActivated(true) 90 , m_breakpointsActivated(true)
91 , m_runningNestedMessageLoop(false) 91 , m_runningNestedMessageLoop(false)
92 , m_maxAsyncCallStackDepth(0) 92 , m_maxAsyncCallStackDepth(0)
93 { 93 {
94 } 94 }
95 95
96 V8DebuggerImpl::~V8DebuggerImpl() 96 V8DebuggerImpl::~V8DebuggerImpl()
97 { 97 {
98 } 98 }
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 if (!inspectedContext) 1022 if (!inspectedContext)
1023 return; 1023 return;
1024 std::vector<v8::Local<v8::Value>> arguments; 1024 std::vector<v8::Local<v8::Value>> arguments;
1025 if (!arg1.IsEmpty()) 1025 if (!arg1.IsEmpty())
1026 arguments.push_back(arg1); 1026 arguments.push_back(arg1);
1027 if (!arg2.IsEmpty()) 1027 if (!arg2.IsEmpty())
1028 arguments.push_back(arg2); 1028 arguments.push_back(arg2);
1029 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr eateForConsoleAPI(m_client->currentTimeMS(), LogMessageType, LogMessageLevel, me ssage, arguments.size() ? &arguments : nullptr, captureStackTrace(false), inspec tedContext)); 1029 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr eateForConsoleAPI(m_client->currentTimeMS(), LogMessageType, LogMessageLevel, me ssage, arguments.size() ? &arguments : nullptr, captureStackTrace(false), inspec tedContext));
1030 } 1030 }
1031 1031
1032 unsigned V8DebuggerImpl::promiseRejected(v8::Local<v8::Context> context, const S tring16& errorMessage, v8::Local<v8::Value> reason, const String16& url, unsigne d lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, i nt scriptId) 1032 void V8DebuggerImpl::exceptionThrown(int contextGroupId, const String16& errorMe ssage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::uni que_ptr<V8StackTrace> stackTrace, int scriptId)
1033 {
1034 if (m_muteConsoleCount || !contextGroupId)
1035 return;
1036 m_client->messageAddedToConsole(contextGroupId, JSMessageSource, ErrorMessag eLevel, errorMessage, url, lineNumber, columnNumber, stackTrace.get());
1037 unsigned exceptionId = ++m_lastExceptionId;
1038 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumb er, std::move(stackTrace), scriptId, m_isolate, 0, v8::Local<v8::Value>(), excep tionId);
1039 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage));
1040 }
1041
1042 unsigned V8DebuggerImpl::promiseRejected(v8::Local<v8::Context> context, const S tring16& errorMessage, v8::Local<v8::Value> exception, const String16& url, unsi gned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace , int scriptId)
1033 { 1043 {
1034 if (m_muteConsoleCount) 1044 if (m_muteConsoleCount)
1035 return 0; 1045 return 0;
1036 int contextGroupId = getGroupId(context); 1046 int contextGroupId = getGroupId(context);
1037 if (!contextGroupId) 1047 if (!contextGroupId)
1038 return 0; 1048 return 0;
1039 1049
1040 const String16 defaultMessage = "Uncaught (in promise)"; 1050 const String16 defaultMessage = "Uncaught (in promise)";
1041 String16 message = errorMessage; 1051 String16 message = errorMessage;
1042 if (message.isEmpty()) 1052 if (message.isEmpty())
1043 message = defaultMessage; 1053 message = defaultMessage;
1044 else if (message.startWith("Uncaught ")) 1054 else if (message.startWith("Uncaught "))
1045 message = message.substring(0, 8) + " (in promise)" + message.substring( 8); 1055 message = message.substring(0, 8) + " (in promise)" + message.substring( 8);
1046 1056
1047 m_client->messageAddedToConsole(contextGroupId, JSMessageSource, ErrorMessag eLevel, message, url, lineNumber, columnNumber, stackTrace.get()); 1057 m_client->messageAddedToConsole(contextGroupId, JSMessageSource, ErrorMessag eLevel, message, url, lineNumber, columnNumber, stackTrace.get());
1048 std::unique_ptr<V8ConsoleMessage> consoleMessage = wrapUnique(new V8ConsoleM essage(m_client->currentTimeMS(), JSMessageSource, ErrorMessageLevel, message, u rl, lineNumber, columnNumber, std::move(stackTrace), scriptId, String16())); 1058 unsigned exceptionId = ++m_lastExceptionId;
1049 unsigned id = ++m_lastConsoleMessageId; 1059 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orException(m_client->currentTimeMS(), message, url, lineNumber, columnNumber, s td::move(stackTrace), scriptId, m_isolate, contextId(context), exception, except ionId);
1050 consoleMessage->assignId(id);
1051
1052 std::vector<v8::Local<v8::Value>> arguments;
1053 arguments.push_back(toV8String(m_isolate, defaultMessage));
1054 arguments.push_back(reason);
1055 consoleMessage->addArguments(m_isolate, contextId(context), &arguments);
1056
1057 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage)); 1060 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage));
1058 return id; 1061 return exceptionId;
1059 } 1062 }
1060 1063
1061 void V8DebuggerImpl::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId) 1064 void V8DebuggerImpl::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId)
1062 { 1065 {
1063 if (m_muteConsoleCount) 1066 if (m_muteConsoleCount)
1064 return; 1067 return;
1065 int contextGroupId = getGroupId(context); 1068 int contextGroupId = getGroupId(context);
1066 if (!contextGroupId) 1069 if (!contextGroupId)
1067 return; 1070 return;
1068 1071
1069 const String16 message = "Handler added to rejected promise"; 1072 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orRevokedException(m_client->currentTimeMS(), "Handler added to rejected promise ", promiseRejectionId);
1070 m_client->messageAddedToConsole(contextGroupId, JSMessageSource, RevokedErro rMessageLevel, message, String16(), 0, 0, nullptr);
1071 std::unique_ptr<V8ConsoleMessage> consoleMessage = wrapUnique(new V8ConsoleM essage(m_client->currentTimeMS(), JSMessageSource, RevokedErrorMessageLevel, mes sage, String16(), 0, 0, nullptr, 0, String16()));
1072 consoleMessage->assignRelatedId(promiseRejectionId);
1073 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage)); 1073 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage));
1074 } 1074 }
1075 1075
1076 void V8DebuggerImpl::consoleMessagesCount(int contextGroupId, unsigned* total, u nsigned* withArguments) 1076 void V8DebuggerImpl::consoleMessagesCount(int contextGroupId, unsigned* total, u nsigned* withArguments)
1077 { 1077 {
1078 *total = 0; 1078 *total = 0;
1079 *withArguments = 0; 1079 *withArguments = 0;
1080 ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGrou pId); 1080 ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGrou pId);
1081 if (storageIt == m_consoleStorageMap.end()) 1081 if (storageIt == m_consoleStorageMap.end())
1082 return; 1082 return;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 1129
1130 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d) 1130 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d)
1131 { 1131 {
1132 if (!contextGroupId) 1132 if (!contextGroupId)
1133 return nullptr; 1133 return nullptr;
1134 SessionMap::iterator iter = m_sessions.find(contextGroupId); 1134 SessionMap::iterator iter = m_sessions.find(contextGroupId);
1135 return iter == m_sessions.end() ? nullptr : iter->second; 1135 return iter == m_sessions.end() ? nullptr : iter->second;
1136 } 1136 }
1137 1137
1138 } // namespace blink 1138 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698