Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
70440072
Commit
70440072
authored
Mar 23, 2016
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23848: Expose _Py_DumpHexadecimal()
This function will be reused by faulthandler.
parent
1d423797
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
Include/traceback.h
Include/traceback.h
+14
-1
Python/traceback.c
Python/traceback.c
+9
-8
No files found.
Include/traceback.h
View file @
70440072
...
...
@@ -94,7 +94,20 @@ PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
/* Format an integer as decimal into the file descriptor fd.
This function is signal safe. */
PyAPI_FUNC
(
void
)
_Py_DumpDecimal
(
int
fd
,
unsigned
long
value
);
PyAPI_FUNC
(
void
)
_Py_DumpDecimal
(
int
fd
,
unsigned
long
value
);
/* Format an integer as hexadecimal into the file descriptor fd with at least
width digits.
The maximum width is sizeof(unsigned long)*2 digits.
This function is signal safe. */
PyAPI_FUNC
(
void
)
_Py_DumpHexadecimal
(
int
fd
,
unsigned
long
value
,
Py_ssize_t
width
);
#endif
/* !Py_LIMITED_API */
...
...
Python/traceback.c
View file @
70440072
...
...
@@ -506,14 +506,15 @@ _Py_DumpDecimal(int fd, unsigned long value)
This function is signal safe. */
static
void
dump_h
exadecimal
(
int
fd
,
unsigned
long
value
,
Py_ssize_t
width
)
void
_Py_DumpH
exadecimal
(
int
fd
,
unsigned
long
value
,
Py_ssize_t
width
)
{
char
buffer
[
sizeof
(
unsigned
long
)
*
2
+
1
],
*
ptr
,
*
end
;
const
Py_ssize_t
size
=
Py_ARRAY_LENGTH
(
buffer
)
-
1
;
if
(
width
>
size
)
width
=
size
;
/* it's ok if width is negative */
end
=
&
buffer
[
size
];
ptr
=
end
;
...
...
@@ -582,15 +583,15 @@ _Py_DumpASCII(int fd, PyObject *text)
}
else
if
(
ch
<=
0xff
)
{
PUTS
(
fd
,
"
\\
x"
);
dump_h
exadecimal
(
fd
,
ch
,
2
);
_Py_DumpH
exadecimal
(
fd
,
ch
,
2
);
}
else
if
(
ch
<=
0xffff
)
{
PUTS
(
fd
,
"
\\
u"
);
dump_h
exadecimal
(
fd
,
ch
,
4
);
_Py_DumpH
exadecimal
(
fd
,
ch
,
4
);
}
else
{
PUTS
(
fd
,
"
\\
U"
);
dump_h
exadecimal
(
fd
,
ch
,
8
);
_Py_DumpH
exadecimal
(
fd
,
ch
,
8
);
}
}
if
(
truncated
)
{
...
...
@@ -693,9 +694,9 @@ write_thread_id(int fd, PyThreadState *tstate, int is_current)
PUTS
(
fd
,
"Current thread 0x"
);
else
PUTS
(
fd
,
"Thread 0x"
);
dump_h
exadecimal
(
fd
,
(
unsigned
long
)
tstate
->
thread_id
,
sizeof
(
unsigned
long
)
*
2
);
_Py_DumpH
exadecimal
(
fd
,
(
unsigned
long
)
tstate
->
thread_id
,
sizeof
(
unsigned
long
)
*
2
);
PUTS
(
fd
,
" (most recent call first):
\n
"
);
}
...
...
Write
Preview
Markdown
is supported
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