OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2017 the V8 project authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import lldb | |
6 import re | |
7 | |
8 def jst(debugger, command, result, dict): | |
Michael Achenbach
2017/03/23 11:30:01
nit: since command, result, dict are always unused
| |
9 """Print the current JavaScript stack trace""" | |
10 target = debugger.GetSelectedTarget() | |
11 process = target.GetProcess() | |
12 thread = process.GetSelectedThread() | |
13 frame = thread.GetSelectedFrame() | |
14 frame.EvaluateExpression("_v8_internal_Print_StackTrace();") | |
15 print("") | |
16 | |
17 def jss(debugger, command, result, dict): | |
18 """Skip the jitted stack on x64 to where we entered JS last""" | |
19 target = debugger.GetSelectedTarget() | |
20 process = target.GetProcess() | |
21 thread = process.GetSelectedThread() | |
22 frame = thread.GetSelectedFrame() | |
23 js_entry_sp = frame.EvaluateExpression("v8::internal::Isolate::Current()->thre ad_local_top()->js_entry_sp_;").GetValue() | |
Michael Achenbach
2017/03/23 11:30:01
nit: 80 char line limit
| |
24 sizeof_void = frame.EvaluateExpression("sizeof(void*)").GetValue() | |
25 rbp = frame.FindRegister("rbp") | |
26 rsp = frame.FindRegister("rsp") | |
27 pc = frame.FindRegister("pc") | |
28 rbp = js_entry_sp | |
29 rsp = js_entry_sp + 2 *sizeof_void | |
30 pc.value = js_entry_sp + sizeof_void | |
31 | |
32 def bta(debugger, command, result, dict): | |
33 """Print stack trace with assertion scopes""" | |
34 func_name_re = re.compile("([^(<]+)(?:\(.+\))?") | |
35 assert_re = re.compile("^v8::internal::Per\w+AssertType::(\w+)_ASSERT, (false| true)>") | |
36 target = debugger.GetSelectedTarget() | |
37 process = target.GetProcess() | |
38 thread = process.GetSelectedThread() | |
39 frame = thread.GetSelectedFrame() | |
40 for frame in thread: | |
41 functionSignature = frame.GetDisplayFunctionName() | |
42 if functionSignature is None: | |
43 continue | |
44 functionName = func_name_re.match(functionSignature) | |
45 line = frame.GetLineEntry().GetLine() | |
46 sourceFile = frame.GetLineEntry().GetFileSpec().GetFilename() | |
47 if line: | |
48 sourceFile = sourceFile + ":" + str(line) | |
49 | |
50 if sourceFile is None: | |
51 sourceFile = "" | |
52 print("[%-2s] %-60s %-40s" % (frame.GetFrameID(), | |
53 functionName.group(1), | |
54 sourceFile)) | |
55 match = assert_re.match(str(functionSignature)) | |
56 if match: | |
57 if match.group(3) == "false": | |
58 prefix = "Disallow" | |
59 color = "\033[91m" | |
60 else: | |
61 prefix = "Allow" | |
62 color = "\033[92m" | |
63 print("%s -> %s %s (%s)\033[0m" % (color, prefix, match.group(2), match.gr oup(1))) | |
64 | |
65 def __lldb_init_module (debugger, dict): | |
66 debugger.HandleCommand('command script add -f lldb_commands.jst jst') | |
67 debugger.HandleCommand('command script add -f lldb_commands.jss jss') | |
68 debugger.HandleCommand('command script add -f lldb_commands.bta bta') | |
OLD | NEW |