Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jason Beetham
wine
Commits
321a1972
Commit
321a1972
authored
25 years ago
by
Jeremy White
Committed by
Alexandre Julliard
25 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add debugstr_hex_dump to allow display hex dumps of data in any
debugging message.
parent
699d3cf8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/debugstr.h
+2
-0
2 additions, 0 deletions
include/debugstr.h
misc/debugstr.c
+106
-0
106 additions, 0 deletions
misc/debugstr.c
with
108 additions
and
0 deletions
include/debugstr.h
+
2
−
0
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 */
This diff is collapsed.
Click to expand it.
misc/debugstr.c
+
106
−
0
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 */
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