Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
321a1972
Commit
321a1972
authored
Nov 12, 1999
by
Jeremy White
Committed by
Alexandre Julliard
Nov 12, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add debugstr_hex_dump to allow display hex dumps of data in any
debugging message.
parent
699d3cf8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
debugstr.h
include/debugstr.h
+2
-0
debugstr.c
misc/debugstr.c
+106
-0
No files found.
include/debugstr.h
View file @
321a1972
...
...
@@ -14,6 +14,7 @@ extern LPSTR debugstr_w (LPCWSTR s);
extern
LPSTR
debugres_a
(
LPCSTR
res
);
extern
LPSTR
debugres_w
(
LPCWSTR
res
);
extern
void
debug_dumpstr
(
LPCSTR
s
);
extern
LPSTR
debugstr_hex_dump
(
const
void
*
ptr
,
int
len
);
#ifdef __GNUC__
extern
int
dbg_printf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
...
...
@@ -21,4 +22,5 @@ extern int dbg_printf(const char *format, ...) __attribute__((format (printf,1,2
extern
int
dbg_printf
(
const
char
*
format
,
...);
#endif
#endif
/* __WINE_DEBUGSTR_H */
misc/debugstr.c
View file @
321a1972
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "debugstr.h"
#include "debugtools.h"
...
...
@@ -198,3 +200,107 @@ int dbg_printf(const char *format, ...)
return
ret
;
}
/*--< Function >---------------------------------------------------------
**
** debugstr_hex_dump
**
** Description:
** This function creates a hex dump, with a readable ascii
** section, for displaying memory.
**
** Parameters:
** 1. ptr Pointer to memory
** 2. len How much to dump.
**
** Returns:
** Temporarily allocated buffer, with the hex dump in it.
** Don't rely on this pointer being around for very long, just
** long enough to use it in a TRACE statement; e.g.:
** TRACE("struct dump is \n%s", debugstr_hex_dump(&x, sizeof(x)));
**
**-------------------------------------------------------------------------*/
LPSTR
debugstr_hex_dump
(
const
void
*
ptr
,
int
len
)
{
/* Locals */
char
dumpbuf
[
59
];
char
charbuf
[
20
];
char
tempbuf
[
8
];
const
char
*
p
;
int
i
;
unsigned
int
nosign
;
LPSTR
dst
;
LPSTR
outptr
;
/* Begin function dbg_hex_dump */
/*-----------------------------------------------------------------------
** Allocate an output buffer
** A reasonable value is one line overhand (80 chars), and
** then one line (80) for every 16 bytes.
**---------------------------------------------------------------------*/
outptr
=
dst
=
gimme1
((
len
*
(
80
/
16
))
+
80
);
/*-----------------------------------------------------------------------
** Loop throught the input buffer, one character at a time
**---------------------------------------------------------------------*/
for
(
i
=
0
,
p
=
ptr
;
(
i
<
len
);
i
++
,
p
++
)
{
/*-------------------------------------------------------------------
** If we're just starting a line,
** we need to possibly flush the old line, and then
** intialize the line buffer.
**-----------------------------------------------------------------*/
if
((
i
%
16
)
==
0
)
{
if
(
i
)
{
sprintf
(
outptr
,
" %-43.43s %-16.16s
\n
"
,
dumpbuf
,
charbuf
);
outptr
+=
strlen
(
outptr
);
}
sprintf
(
dumpbuf
,
"%04x: "
,
i
);
strcpy
(
charbuf
,
""
);
}
/*-------------------------------------------------------------------
** Add the current data byte to the dump section.
**-----------------------------------------------------------------*/
nosign
=
(
unsigned
char
)
*
p
;
sprintf
(
tempbuf
,
"%02X"
,
nosign
);
/*-------------------------------------------------------------------
** If we're two DWORDS through, add a hyphen for readability,
** if it's a DWORD boundary, add a space for more
** readability.
**-----------------------------------------------------------------*/
if
((
i
%
16
)
==
7
)
strcat
(
tempbuf
,
" - "
);
else
if
(
(
i
%
4
)
==
3
)
strcat
(
tempbuf
,
" "
);
strcat
(
dumpbuf
,
tempbuf
);
/*-------------------------------------------------------------------
** Add the current byte to the character display part of the
** hex dump
**-----------------------------------------------------------------*/
sprintf
(
tempbuf
,
"%c"
,
isprint
(
*
p
)
?
*
p
:
'.'
);
strcat
(
charbuf
,
tempbuf
);
}
/*-----------------------------------------------------------------------
** Flush the last line, if any
**---------------------------------------------------------------------*/
if
(
i
>
0
)
{
sprintf
(
outptr
,
" %-43.43s %-16.16s
\n
"
,
dumpbuf
,
charbuf
);
outptr
+=
strlen
(
outptr
);
}
return
(
dst
);
}
/* End function dbg_hex_dump */
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