Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
ed35ec3d
Commit
ed35ec3d
authored
Mar 15, 2010
by
hjk
Browse files
debugger: use pseudo-enums instead of magical constants in python dumpers
parent
e8936ad9
Changes
2
Hide whitespace changes
Inline
Side-by-side
share/qtcreator/gdbmacros/dumper.py
View file @
ed35ec3d
...
...
@@ -27,6 +27,28 @@ import tempfile
verbosity
=
0
verbosity
=
1
# Some "Enums"
# Encodings
Unencoded8Bit
,
\
Base64Encoded8BitWithQuotes
,
\
Base64Encoded16BitWithQuotes
,
\
Base64Encoded32BitWithQuotes
,
\
Base64Encoded16Bit
,
\
Base64Encoded8Bit
,
\
Hex2EncodedLatin1
,
\
Hex4EncodedLittleEndian
,
\
Hex8EncodedLittleEndian
,
\
Hex2EncodedUtf8
,
\
Hex8EncodedBigEndian
,
\
Hex4EncodedBigEndian
\
=
range
(
12
)
# Display modes
StopDisplay
,
DisplayImage1
,
DisplayString
,
DisplayImage
,
DisplayProcess
=
range
(
5
)
def
select
(
condition
,
if_expr
,
else_expr
):
if
condition
:
return
if_expr
...
...
@@ -829,7 +851,6 @@ SalCommand()
#
#######################################################################
StopDisplay
,
DisplayImage1
,
DisplayString
,
DisplayImage
,
DisplayProcess
=
range
(
5
)
class
Dumper
:
def
__init__
(
self
):
...
...
@@ -933,7 +954,7 @@ class Dumper:
self
.
put
(
'value="<not available>",'
)
else
:
str
=
encodeString
(
value
)
self
.
put
(
'valueencoded="%d",value="%s",'
%
(
7
,
str
))
self
.
put
(
'valueencoded="%d",value="%s",'
%
(
Hex4EncodedLittleEndian
,
str
))
def
putDisplay
(
self
,
format
,
value
=
None
,
cmd
=
None
):
self
.
put
(
'editformat="%s",'
%
format
)
...
...
@@ -945,7 +966,7 @@ class Dumper:
def
putByteArrayValue
(
self
,
value
):
str
=
encodeByteArray
(
value
)
self
.
put
(
'valueencoded="%d",value="%s",'
%
(
6
,
str
))
self
.
put
(
'valueencoded="%d",value="%s",'
%
(
Hex2EncodedLatin1
,
str
))
def
putName
(
self
,
name
):
self
.
put
(
'name="%s",'
%
name
)
...
...
@@ -1148,14 +1169,14 @@ class Dumper:
self
.
putValue
(
str
(
cleanAddress
(
value
.
address
)))
elif
format
==
1
or
format
==
2
:
# Latin1 or UTF-8
f
=
select
(
format
==
1
,
"6"
,
"9"
)
f
=
select
(
format
==
1
,
Hex2EncodedLatin1
,
Hex2EncodedUtf8
)
self
.
putValue
(
encodeCharArray
(
value
,
100
),
f
)
elif
format
==
3
:
# UTF-16.
self
.
putValue
(
encodeChar2Array
(
value
,
100
),
"11"
)
self
.
putValue
(
encodeChar2Array
(
value
,
100
),
Hex4EncodedBigEndian
)
elif
format
==
4
:
# UCS-4:
self
.
putValue
(
encodeChar4Array
(
value
,
100
),
"10"
)
self
.
putValue
(
encodeChar4Array
(
value
,
100
),
Hex8EncodedBigEndian
)
if
(
not
isHandled
)
and
str
(
type
.
strip_typedefs
()).
find
(
"("
)
!=
-
1
:
# A function pointer.
...
...
@@ -1185,7 +1206,7 @@ class Dumper:
# Display values up to given length directly
#warn("CHAR AUTODEREF: %s" % value.address)
self
.
putType
(
item
.
value
.
type
)
self
.
putValue
(
encodeCharArray
(
value
,
100
),
"6"
)
self
.
putValue
(
encodeCharArray
(
value
,
100
),
Hex2EncodedLatin1
)
self
.
putNumChild
(
0
)
isHandled
=
True
...
...
share/qtcreator/gdbmacros/gdbmacros.py
View file @
ed35ec3d
...
...
@@ -1884,7 +1884,7 @@ def qdump__std__string(d, item):
for
i
in
xrange
(
size
):
s
+=
format
%
int
(
p
.
dereference
())
p
+=
1
d
.
putValue
(
s
,
6
)
d
.
putValue
(
s
,
Hex2EncodedLittleEndian
)
d
.
putNumChild
(
0
)
elif
charType
.
sizeof
==
2
:
format
=
"%02x%02x"
...
...
@@ -1892,7 +1892,7 @@ def qdump__std__string(d, item):
val
=
int
(
p
.
dereference
())
s
+=
format
%
(
val
%
256
,
val
/
256
)
p
+=
1
d
.
putValue
(
s
,
7
)
d
.
putValue
(
s
,
Hex4EncodedLittleEndian
)
else
:
# FIXME: This is not always a proper solution.
format
=
"%02x%02x%02x%02x"
...
...
@@ -1902,7 +1902,7 @@ def qdump__std__string(d, item):
lo
=
val
%
65536
s
+=
format
%
(
lo
%
256
,
lo
/
256
,
hi
%
256
,
hi
/
256
)
p
+=
1
d
.
putValue
(
s
,
8
)
d
.
putValue
(
s
,
Hex8EncodedLittleEndian
)
d
.
putNumChild
(
0
)
...
...
@@ -1966,7 +1966,7 @@ def qdump__TBuf(d, item):
max
=
numericTemplateArgument
(
item
.
value
.
type
,
0
)
check
(
0
<=
size
and
size
<=
max
)
d
.
putNumChild
(
0
)
d
.
putValue
(
encodeSymbianString
(
base
,
size
),
"7"
)
d
.
putValue
(
encodeSymbianString
(
base
,
size
),
Hex4EncodedLittleEndian
)
def
qdump__TLitC
(
d
,
item
):
size
=
item
.
value
[
"iTypeLength"
]
&
0xffff
...
...
@@ -1974,7 +1974,7 @@ def qdump__TLitC(d, item):
max
=
numericTemplateArgument
(
item
.
value
.
type
,
0
)
check
(
0
<=
size
and
size
<=
max
)
d
.
putNumChild
(
0
)
d
.
putValue
(
encodeSymbianString
(
base
,
size
),
"7"
)
d
.
putValue
(
encodeSymbianString
(
base
,
size
),
Hex4EncodedLittleEndian
)
#######################################################################
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment