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

Side by Side Diff: tools/lldb_commands.py

Issue 2758373002: [tools] add lldbinit (Closed)
Patch Set: *args and line limit Created 3 years, 9 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
« no previous file with comments | « no previous file | tools/lldbinit » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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, *args):
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, *args):
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(
24 "v8::internal::Isolate::Current()->thread_local_top()->js_entry_sp_;") \
25 .GetValue()
26 sizeof_void = frame.EvaluateExpression("sizeof(void*)").GetValue()
27 rbp = frame.FindRegister("rbp")
28 rsp = frame.FindRegister("rsp")
29 pc = frame.FindRegister("pc")
30 rbp = js_entry_sp
31 rsp = js_entry_sp + 2 *sizeof_void
32 pc.value = js_entry_sp + sizeof_void
33
34 def bta(debugger, *args):
35 """Print stack trace with assertion scopes"""
36 func_name_re = re.compile("([^(<]+)(?:\(.+\))?")
37 assert_re = re.compile(
38 "^v8::internal::Per\w+AssertType::(\w+)_ASSERT, (false|true)>")
39 target = debugger.GetSelectedTarget()
40 process = target.GetProcess()
41 thread = process.GetSelectedThread()
42 frame = thread.GetSelectedFrame()
43 for frame in thread:
44 functionSignature = frame.GetDisplayFunctionName()
45 if functionSignature is None:
46 continue
47 functionName = func_name_re.match(functionSignature)
48 line = frame.GetLineEntry().GetLine()
49 sourceFile = frame.GetLineEntry().GetFileSpec().GetFilename()
50 if line:
51 sourceFile = sourceFile + ":" + str(line)
52
53 if sourceFile is None:
54 sourceFile = ""
55 print("[%-2s] %-60s %-40s" % (frame.GetFrameID(),
56 functionName.group(1),
57 sourceFile))
58 match = assert_re.match(str(functionSignature))
59 if match:
60 if match.group(3) == "false":
61 prefix = "Disallow"
62 color = "\033[91m"
63 else:
64 prefix = "Allow"
65 color = "\033[92m"
66 print("%s -> %s %s (%s)\033[0m" % (
67 color, prefix, match.group(2), match.group(1)))
68
69 def __lldb_init_module (debugger, dict):
70 debugger.HandleCommand('command script add -f lldb_commands.jst jst')
71 debugger.HandleCommand('command script add -f lldb_commands.jss jss')
72 debugger.HandleCommand('command script add -f lldb_commands.bta bta')
OLDNEW
« no previous file with comments | « no previous file | tools/lldbinit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698