forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug 985566 - add some pretty printers to .gdbinit r=froydnj r=glandium
- Loading branch information
Showing
9 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,3 +179,5 @@ end | |
def ft | ||
call $arg0->DumpFrameTree() | ||
end | ||
|
||
source .gdbinit_python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
python | ||
import sys | ||
sys.path.append('python/gdbpp/') | ||
import gdbpp | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#filter substitution | ||
python | ||
import sys | ||
sys.path.append('@topsrcdir@/python/gdbpp') | ||
import gdbpp | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# vim: set filetype=python: | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import gdb | ||
import gdb.printing | ||
|
||
class GeckoPrettyPrinter(object): | ||
pp = gdb.printing.RegexpCollectionPrettyPrinter('GeckoPrettyPrinters') | ||
|
||
def __init__(self, name, regexp): | ||
self.name = name | ||
self.regexp = regexp | ||
|
||
def __call__(self, wrapped): | ||
GeckoPrettyPrinter.pp.add_printer(self.name, self.regexp, wrapped) | ||
return wrapped | ||
|
||
import gdbpp.owningthread | ||
import gdbpp.smartptr | ||
import gdbpp.string | ||
import gdbpp.tarray | ||
|
||
gdb.printing.register_pretty_printer(None, GeckoPrettyPrinter.pp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# vim: set filetype=python: | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import gdb | ||
from gdbpp import GeckoPrettyPrinter | ||
|
||
@GeckoPrettyPrinter('nsAutoOwningThread', '^nsAutoOwningThread$') | ||
class owning_thread_printer(object): | ||
def __init__(self, value): | ||
self.value = value | ||
|
||
def to_string(self): | ||
prthread_type = gdb.lookup_type('PRThread').pointer() | ||
prthread = self.value['mThread'].cast(prthread_type) | ||
name = prthread['name'] | ||
|
||
# if the thread doesn't have a name try to get its thread id (might not | ||
# work on !linux) | ||
name = prthread['tid'] | ||
|
||
return name if name else '(PRThread *) %s' % prthread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# vim: set filetype=python: | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import gdb | ||
from gdbpp import GeckoPrettyPrinter | ||
|
||
@GeckoPrettyPrinter('nsWeakPtr', '^nsCOMPtr<nsIWeakReference>$') | ||
class weak_ptr_printer(object): | ||
def __init__(self, value): | ||
self.value = value | ||
|
||
def to_string(self): | ||
proxy = self.value['mRawPtr'] | ||
if not proxy: | ||
return '[(%s) 0x0]' % proxy.type | ||
|
||
ref_type = proxy.dynamic_type | ||
weak_ptr = proxy.cast(ref_type).dereference()['mReferent'] | ||
if not weak_ptr: | ||
return '[(%s) %s]' % (weak_ptr.type, weak_ptr) | ||
|
||
return '[(%s) %s]' % (weak_ptr.dynamic_type, weak_ptr) | ||
|
||
@GeckoPrettyPrinter('nsAutoPtr', 'nsAutoPtr<.*>') | ||
@GeckoPrettyPrinter('nsCOMPtr', 'nsCOMPtr<.*>') | ||
@GeckoPrettyPrinter('RefPtr', 'RefPtr<.*>') | ||
class smartptr_printer(object): | ||
def __init__(self, value): | ||
self.value = value['mRawPtr'] | ||
|
||
def to_string(self): | ||
if not self.value: | ||
type_name = str(self.value.type) | ||
else: | ||
type_name = str(self.value.dereference().dynamic_type.pointer()) | ||
|
||
return '[(%s) %s]' % (type_name, str(self.value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# vim: set filetype=python: | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import gdb | ||
from gdbpp import GeckoPrettyPrinter | ||
|
||
@GeckoPrettyPrinter('nsString', '^ns.*String$') | ||
class string_printer(object): | ||
def __init__(self, value): | ||
self.value = value | ||
|
||
def to_string(self): | ||
return self.value['mData'] | ||
|
||
def display_hint(self): | ||
return 'string' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- | ||
# vim: set filetype=python: | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import gdb | ||
import itertools | ||
from gdbpp import GeckoPrettyPrinter | ||
|
||
@GeckoPrettyPrinter('TArray', '.*TArray<.*>$') | ||
class tarray_printer(object): | ||
def __init__(self, value): | ||
self.value = value | ||
self.elem_type = value.type.template_argument(0) | ||
|
||
def children(self): | ||
length = self.value['mHdr'].dereference()['mLength'] | ||
data = self.value['mHdr'] + 1 | ||
elements = data.cast(self.elem_type.pointer()) | ||
return (('%d' % i, (elements + i).dereference()) for i in range(0, int(length))) | ||
|
||
def to_string(self): | ||
return str(self.value.type) | ||
|
||
def display_hint(self): | ||
return 'array' |