Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
bcdcbc2f
Commit
bcdcbc2f
authored
Jul 6, 2010
by
hjk
Browse files
Options
Downloads
Patches
Plain Diff
debugger: backport small fixes and synchronized code layout with master
parent
d7dd4e93
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
share/qtcreator/gdbmacros/dumper.py
+63
-18
63 additions, 18 deletions
share/qtcreator/gdbmacros/dumper.py
with
63 additions
and
18 deletions
share/qtcreator/gdbmacros/dumper.py
+
63
−
18
View file @
bcdcbc2f
from
__future__
import
with_statement
from
__future__
import
with_statement
#Note: Keep name-type-value-numchild-extra order
#return
import
sys
import
sys
import
gdb
import
gdb
...
@@ -9,6 +6,7 @@ import base64
...
@@ -9,6 +6,7 @@ import base64
import
__builtin__
import
__builtin__
import
os
import
os
# Fails on Windows.
# Fails on Windows.
try
:
try
:
import
curses.ascii
import
curses.ascii
...
@@ -128,6 +126,9 @@ def lookupType(typestring):
...
@@ -128,6 +126,9 @@ def lookupType(typestring):
typeCache
[
typestring
]
=
type
typeCache
[
typestring
]
=
type
return
type
return
type
def
cleanType
(
type
):
return
lookupType
(
str
(
type
))
def
cleanAddress
(
addr
):
def
cleanAddress
(
addr
):
if
addr
is
None
:
if
addr
is
None
:
return
"
<no address>
"
return
"
<no address>
"
...
@@ -240,9 +241,9 @@ class SubItem:
...
@@ -240,9 +241,9 @@ class SubItem:
if
len
(
type
)
>
0
and
type
!=
self
.
d
.
currentChildType
:
if
len
(
type
)
>
0
and
type
!=
self
.
d
.
currentChildType
:
self
.
d
.
put
(
'
type=
"
%s
"
,
'
%
type
)
# str(type.unqualified()) ?
self
.
d
.
put
(
'
type=
"
%s
"
,
'
%
type
)
# str(type.unqualified()) ?
if
not
self
.
d
.
currentValueEncoding
is
None
:
if
not
self
.
d
.
currentValueEncoding
is
None
:
self
.
d
.
put
Field
(
"
valueencoded
"
,
self
.
d
.
currentValueEncoding
)
self
.
d
.
put
(
'
valueencoded
=
"
%d
"
,
'
%
self
.
d
.
currentValueEncoding
)
if
not
self
.
d
.
currentValue
is
None
:
if
not
self
.
d
.
currentValue
is
None
:
self
.
d
.
put
Field
(
"
value
"
,
self
.
d
.
currentValue
)
self
.
d
.
put
(
'
value=
"
%s
"
,
'
%
self
.
d
.
currentValue
)
except
:
except
:
pass
pass
self
.
d
.
put
(
'
},
'
)
self
.
d
.
put
(
'
},
'
)
...
@@ -423,6 +424,8 @@ def listOfLocals(varList):
...
@@ -423,6 +424,8 @@ def listOfLocals(varList):
hasBlock
=
'
block
'
in
__builtin__
.
dir
(
frame
)
hasBlock
=
'
block
'
in
__builtin__
.
dir
(
frame
)
items
=
[]
items
=
[]
#warn("HAS BLOCK: %s" % hasBlock);
#warn("IS GOOD GDB: %s" % isGoodGdb());
if
hasBlock
and
isGoodGdb
():
if
hasBlock
and
isGoodGdb
():
#warn("IS GOOD: %s " % varList)
#warn("IS GOOD: %s " % varList)
try
:
try
:
...
@@ -783,8 +786,8 @@ def encodeString(value):
...
@@ -783,8 +786,8 @@ def encodeString(value):
p
+=
1
p
+=
1
return
s
return
s
def
stripTypedefs
(
type
obj
):
def
stripTypedefs
(
type
):
type
=
type
obj
type
=
type
.
unqualified
()
while
type
.
code
==
gdb
.
TYPE_CODE_TYPEDEF
:
while
type
.
code
==
gdb
.
TYPE_CODE_TYPEDEF
:
type
=
type
.
strip_typedefs
().
unqualified
()
type
=
type
.
strip_typedefs
().
unqualified
()
return
type
return
type
...
@@ -820,6 +823,50 @@ class Item:
...
@@ -820,6 +823,50 @@ class Item:
self
.
name
=
name
self
.
name
=
name
#######################################################################
#
# SetupCommand
#
#######################################################################
# This is a mapping from 'type name' to 'display alternatives'.
qqDumpers
=
{}
qqFormats
=
{}
class
SetupCommand
(
gdb
.
Command
):
"""
Setup Creator Pretty Printing
"""
def
__init__
(
self
):
super
(
SetupCommand
,
self
).
__init__
(
"
bbsetup
"
,
gdb
.
COMMAND_OBSCURE
)
def
invoke
(
self
,
args
,
from_tty
):
module
=
sys
.
modules
[
__name__
]
for
key
,
value
in
module
.
__dict__
.
items
():
if
key
.
startswith
(
"
qdump__
"
):
name
=
key
[
7
:]
qqDumpers
[
name
]
=
value
qqFormats
[
name
]
=
qqFormats
.
get
(
name
,
""
);
elif
key
.
startswith
(
"
qform__
"
):
name
=
key
[
7
:]
formats
=
""
try
:
formats
=
value
()
except
:
pass
qqFormats
[
name
]
=
formats
result
=
"
dumpers=[
"
# Too early: ns = qtNamespace()
for
key
,
value
in
qqFormats
.
items
():
result
+=
'
{type=
"
%s
"
,formats=
"
%s
"
},
'
%
(
key
,
value
)
result
+=
'
]
'
#result += '],namespace="%s"' % ns
print
(
result
)
SetupCommand
()
#######################################################################
#######################################################################
#
#
# FrameCommand
# FrameCommand
...
@@ -827,7 +874,7 @@ class Item:
...
@@ -827,7 +874,7 @@ class Item:
#######################################################################
#######################################################################
class
FrameCommand
(
gdb
.
Command
):
class
FrameCommand
(
gdb
.
Command
):
"""
Do fancy stuff.
Usage bb --verbose expandedINames
"""
"""
Do fancy stuff.
"""
def
__init__
(
self
):
def
__init__
(
self
):
super
(
FrameCommand
,
self
).
__init__
(
"
bb
"
,
gdb
.
COMMAND_OBSCURE
)
super
(
FrameCommand
,
self
).
__init__
(
"
bb
"
,
gdb
.
COMMAND_OBSCURE
)
...
@@ -1109,15 +1156,16 @@ class Dumper:
...
@@ -1109,15 +1156,16 @@ class Dumper:
def
childRange
(
self
):
def
childRange
(
self
):
return
xrange
(
qmin
(
self
.
currentMaxNumChilds
,
self
.
currentNumChilds
))
return
xrange
(
qmin
(
self
.
currentMaxNumChilds
,
self
.
currentNumChilds
))
#
c
onvenience
#
C
onvenience
function.
def
putItemCount
(
self
,
count
):
def
putItemCount
(
self
,
count
):
self
.
put
(
'
value=
"
<%s items>
"
,
'
%
count
)
# This needs to override the default value, so don't use 'put' directly.
self
.
putValue
(
'
<%s items>
'
%
count
)
def
putEllipsis
(
self
):
def
putEllipsis
(
self
):
self
.
put
(
'
{name=
"
<incomplete>
"
,value=
""
,type=
""
,numchild=
"
0
"
},
'
)
self
.
put
(
'
{name=
"
<incomplete>
"
,value=
""
,type=
""
,numchild=
"
0
"
},
'
)
def
putType
(
self
,
type
,
priority
=
0
):
def
putType
(
self
,
type
,
priority
=
0
):
#
h
igher priority values override lower ones
#
H
igher priority values override lower ones
.
if
priority
>=
self
.
currentTypePriority
:
if
priority
>=
self
.
currentTypePriority
:
self
.
currentType
=
type
self
.
currentType
=
type
self
.
currentTypePriority
=
priority
self
.
currentTypePriority
=
priority
...
@@ -1131,7 +1179,7 @@ class Dumper:
...
@@ -1131,7 +1179,7 @@ class Dumper:
self
.
put
(
'
numchild=
"
%s
"
,
'
%
numchild
)
self
.
put
(
'
numchild=
"
%s
"
,
'
%
numchild
)
def
putValue
(
self
,
value
,
encoding
=
None
,
priority
=
0
):
def
putValue
(
self
,
value
,
encoding
=
None
,
priority
=
0
):
#
h
igher priority values override lower ones
#
H
igher priority values override lower ones
.
if
priority
>=
self
.
currentValuePriority
:
if
priority
>=
self
.
currentValuePriority
:
self
.
currentValue
=
value
self
.
currentValue
=
value
self
.
currentValuePriority
=
priority
self
.
currentValuePriority
=
priority
...
@@ -1267,9 +1315,6 @@ class Dumper:
...
@@ -1267,9 +1315,6 @@ class Dumper:
value
=
item
.
value
value
=
item
.
value
type
=
value
.
type
type
=
value
.
type
if
type
.
code
==
gdb
.
TYPE_CODE_TYPEDEF
:
type
=
type
.
target
()
typedefStrippedType
=
stripTypedefs
(
type
);
typedefStrippedType
=
stripTypedefs
(
type
);
nsStrippedType
=
self
.
stripNamespaceFromType
(
nsStrippedType
=
self
.
stripNamespaceFromType
(
typedefStrippedType
).
replace
(
"
::
"
,
"
__
"
)
typedefStrippedType
).
replace
(
"
::
"
,
"
__
"
)
...
@@ -1423,8 +1468,8 @@ class Dumper:
...
@@ -1423,8 +1468,8 @@ class Dumper:
charptr
=
lookupType
(
"
unsigned char
"
).
pointer
()
charptr
=
lookupType
(
"
unsigned char
"
).
pointer
()
addr1
=
(
baseptr
+
1
).
cast
(
charptr
)
addr1
=
(
baseptr
+
1
).
cast
(
charptr
)
addr0
=
baseptr
.
cast
(
charptr
)
addr0
=
baseptr
.
cast
(
charptr
)
self
.
put
Field
(
"
addrbase
"
%
cleanAddress
(
addr0
))
self
.
put
(
'
addrbase
=
"
%s
"
,
'
%
cleanAddress
(
addr0
))
self
.
put
Field
(
"
addrstep
"
%
(
addr1
-
addr0
))
self
.
put
(
'
addrstep
=
"
%s
"
,
'
%
(
addr1
-
addr0
))
innerType
=
None
innerType
=
None
if
len
(
fields
)
==
1
and
fields
[
0
].
name
is
None
:
if
len
(
fields
)
==
1
and
fields
[
0
].
name
is
None
:
...
@@ -1468,7 +1513,7 @@ class Dumper:
...
@@ -1468,7 +1513,7 @@ class Dumper:
item
.
iname
,
"
@%d
"
%
baseNumber
,
field
.
name
)
item
.
iname
,
"
@%d
"
%
baseNumber
,
field
.
name
)
baseNumber
+=
1
baseNumber
+=
1
with
SubItem
(
self
):
with
SubItem
(
self
):
self
.
put
Field
(
"
iname
"
,
child
.
iname
)
self
.
put
(
'
iname=
"
%s
"
,
'
%
child
.
iname
)
self
.
putItemHelper
(
child
)
self
.
putItemHelper
(
child
)
elif
len
(
field
.
name
)
==
0
:
elif
len
(
field
.
name
)
==
0
:
# Anonymous union. We need a dummy name to distinguish
# Anonymous union. We need a dummy name to distinguish
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment