gdbinit 3.95 KB
Newer Older
1 2 3 4 5 6
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Print HeapObjects.
define job
7
call _v8_internal_Print_Object((void*)($arg0))
8 9 10 11 12 13
end
document job
Print a v8 JavaScript object
Usage: job tagged_ptr
end

14 15
# Print v8::Local handle value.
define jlh
Yang Guo's avatar
Yang Guo committed
16
call _v8_internal_Print_Object(*((v8::internal::Object**)($arg0).val_))
17 18 19 20 21 22
end
document jlh
Print content of a v8::Local handle
Usage: jlh local_handle
end

23 24
# Print Code objects containing given PC.
define jco
25
call _v8_internal_Print_Code((void*)($arg0))
26 27 28 29 30 31
end
document jco
Print a v8 Code object from an internal code address
Usage: jco pc
end

32
# Print FeedbackVector
33
define jfv
34
call _v8_internal_Print_FeedbackVector((void*)($arg0))
35 36
end
document jfv
37 38
Print a v8 FeedbackVector object
Usage: jfv tagged_ptr
39 40
end

41
# Print FeedbackMetadata
42
define jfm
43
call _v8_internal_Print_FeedbackMetadata((void*)($arg0))
44 45
end
document jfm
46 47
Print a v8 FeedbackMetadata object
Usage: jfm tagged_ptr
48 49 50
end


51 52
# Print DescriptorArray.
define jda
53
call _v8_internal_Print_DescriptorArray((void*)($arg0))
54 55 56 57 58 59
end
document jda
Print a v8 DescriptorArray object
Usage: jda tagged_ptr
end

60 61 62 63 64 65 66 67 68
# Print LayoutDescriptor.
define jld
call _v8_internal_Print_LayoutDescriptor((void*)($arg0))
end
document jld
Print a v8 LayoutDescriptor object
Usage: jld tagged_ptr
end

69 70
# Print TransitionArray.
define jta
71
call _v8_internal_Print_TransitionArray((void*)($arg0))
72 73 74 75 76 77
end
document jta
Print a v8 TransitionArray object
Usage: jta tagged_ptr
end

78 79 80 81 82 83 84 85 86
# Print TransitionTree.
define jtt
call _v8_internal_Print_TransitionTree((void*)($arg0))
end
document jtt
Print the complete transition tree of the given v8 Map.
Usage: jtt tagged_ptr
end

87
# Print JavaScript stack trace.
88
define jst
89
call _v8_internal_Print_StackTrace()
90 91 92 93 94 95
end
document jst
Print the current JavaScript stack trace
Usage: jst
end

96 97 98 99 100 101 102 103 104 105 106 107
# Skip the JavaScript stack.
define jss
set $js_entry_sp=v8::internal::Isolate::Current()->thread_local_top()->js_entry_sp_
set $rbp=*(void**)$js_entry_sp
set $rsp=$js_entry_sp + 2*sizeof(void*)
set $pc=*(void**)($js_entry_sp+sizeof(void*))
end
document jss
Skip the jitted stack on x64 to where we entered JS last.
Usage: jss
end

108 109 110 111
# Print stack trace with assertion scopes.
define bta
python
import re
112
frame_re = re.compile("^#(\d+)\s*(?:0x[a-f\d]+ in )?(.+) \(.+ at (.+)")
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
assert_re = re.compile("^\s*(\S+) = .+<v8::internal::Per\w+AssertType::(\w+)_ASSERT, (false|true)>")
btl = gdb.execute("backtrace full", to_string = True).splitlines()
for l in btl:
  match = frame_re.match(l)
  if match:
    print("[%-2s] %-60s %-40s" % (match.group(1), match.group(2), match.group(3)))
  match = assert_re.match(l)
  if match:
    if match.group(3) == "false":
      prefix = "Disallow"
      color = "\033[91m"
    else:
      prefix = "Allow"
      color = "\033[92m"
    print("%s -> %s %s (%s)\033[0m" % (color, prefix, match.group(2), match.group(1)))
end
129
end
130 131 132 133 134
document bta
Print stack trace with assertion scopes
Usage: bta
end

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
# Search for a pointer inside all valid pages.
define space_find
  set $space = $arg0
  set $current_page = $space->anchor()->next_page()
  while ($current_page != $space->anchor())
    printf "#   Searching in %p - %p\n", $current_page->area_start(), $current_page->area_end()-1
    find $current_page->area_start(), $current_page->area_end()-1, $arg1
    set $current_page = $current_page->next_page()
  end
end

define heap_find
  set $heap = v8::internal::Isolate::Current()->heap()
  printf "# Searching for %p in old_space  ===============================\n", $arg0
  space_find $heap->old_space() ($arg0)
  printf "# Searching for %p in map_space  ===============================\n", $arg0
  space_find $heap->map_space() $arg0
  printf "# Searching for %p in code_space ===============================\n", $arg0
  space_find $heap->code_space() $arg0
end
document heap_find
Find the location of a given address in V8 pages.
Usage: heap_find address
end

160
set disassembly-flavor intel
161
set disable-randomization off