Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2cb9f48b
Commit
2cb9f48b
authored
Oct 31, 2009
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
robust protection against missing DBUG_RETURN
(instead of a C++ only thingy that was lost in a merge)
parent
319847a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
34 deletions
+26
-34
dbug/dbug.c
dbug/dbug.c
+26
-34
No files found.
dbug/dbug.c
View file @
2cb9f48b
...
...
@@ -324,7 +324,7 @@ static void Indent(CODE_STATE *cs, int indent);
static
void
DbugFlush
(
CODE_STATE
*
);
static
void
DbugExit
(
const
char
*
why
);
static
const
char
*
DbugStrTok
(
const
char
*
s
);
static
void
Dbug
F
printf
(
FILE
*
stream
,
const
char
*
format
,
va_list
args
);
static
void
Dbug
Vf
printf
(
FILE
*
stream
,
const
char
*
format
,
va_list
args
);
#ifndef THREAD
/* Open profile output stream */
...
...
@@ -339,7 +339,7 @@ static unsigned long Clock(void);
* Miscellaneous printf format strings.
*/
#define ERR_MISSING_RETURN "
%s:
missing DBUG_RETURN or DBUG_VOID_RETURN macro in function \"%s\"\n"
#define ERR_MISSING_RETURN "missing DBUG_RETURN or DBUG_VOID_RETURN macro in function \"%s\"\n"
#define ERR_OPEN "%s: can't open debug output stream \"%s\": "
#define ERR_CLOSE "%s: can't close debug file: "
#define ERR_ABORT "%s: debugger aborting because %s\n"
...
...
@@ -1228,7 +1228,6 @@ void _db_enter_(const char *_func_, const char *_file_,
*
*/
/* helper macro */
void
_db_return_
(
uint
_line_
,
struct
_db_stack_frame_
*
_stack_frame_
)
{
int
save_errno
=
errno
;
...
...
@@ -1236,34 +1235,29 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
CODE_STATE
*
cs
;
get_code_state_or_return
;
if
(
cs
->
level
!=
_slevel
_
)
if
(
cs
->
framep
!=
_stack_frame
_
)
{
if
(
!
cs
->
locked
)
pthread_mutex_lock
(
&
THR_LOCK_dbug
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
ERR_MISSING_RETURN
,
cs
->
process
,
cs
->
func
);
DbugFlush
(
cs
);
char
buf
[
512
];
my_snprintf
(
buf
,
sizeof
(
buf
),
ERR_MISSING_RETURN
,
cs
->
func
);
DbugExit
(
buf
);
}
else
{
#ifndef THREAD
if
(
DoProfile
(
cs
))
(
void
)
fprintf
(
cs
->
stack
->
prof_file
,
PROF_XFMT
,
Clock
(),
cs
->
func
);
if
(
DoProfile
(
cs
))
(
void
)
fprintf
(
cs
->
stack
->
prof_file
,
PROF_XFMT
,
Clock
(),
cs
->
func
);
#endif
if
(
DoTrace
(
cs
)
&
DO_TRACE
)
if
(
DoTrace
(
cs
)
&
DO_TRACE
)
{
if
((
cs
->
stack
->
flags
&
SANITY_CHECK_ON
)
&&
_sanity
(
_stack_frame_
->
file
,
_line_
))
cs
->
stack
->
flags
&=
~
SANITY_CHECK_ON
;
if
(
TRACING
)
{
if
((
cs
->
stack
->
flags
&
SANITY_CHECK_ON
)
&&
_sanity
(
_stack_frame_
->
file
,
_line_
))
cs
->
stack
->
flags
&=
~
SANITY_CHECK_ON
;
if
(
TRACING
)
{
if
(
!
cs
->
locked
)
pthread_mutex_lock
(
&
THR_LOCK_dbug
);
DoPrefix
(
cs
,
_line_
);
Indent
(
cs
,
cs
->
level
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"<%s
\n
"
,
cs
->
func
);
DbugFlush
(
cs
);
}
if
(
!
cs
->
locked
)
pthread_mutex_lock
(
&
THR_LOCK_dbug
);
DoPrefix
(
cs
,
_line_
);
Indent
(
cs
,
cs
->
level
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"<%s
\n
"
,
cs
->
func
);
DbugFlush
(
cs
);
}
}
/*
...
...
@@ -1353,7 +1347,7 @@ void _db_doprnt_(const char *format,...)
else
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
func
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
u_keyword
);
Dbug
F
printf
(
cs
->
stack
->
out_file
,
format
,
args
);
Dbug
Vf
printf
(
cs
->
stack
->
out_file
,
format
,
args
);
DbugFlush
(
cs
);
errno
=
save_errno
;
}
...
...
@@ -1361,10 +1355,10 @@ void _db_doprnt_(const char *format,...)
}
/*
* fprintf clone with consistent, platform independent output for
*
v
fprintf clone with consistent, platform independent output for
* problematic formats like %p, %zd and %lld.
*/
static
void
Dbug
F
printf
(
FILE
*
stream
,
const
char
*
format
,
va_list
args
)
static
void
Dbug
Vf
printf
(
FILE
*
stream
,
const
char
*
format
,
va_list
args
)
{
char
cvtbuf
[
1024
];
size_t
len
;
...
...
@@ -1388,14 +1382,13 @@ static void DbugFprintf(FILE *stream, const char* format, va_list args)
*
* DESCRIPTION
* Dump N characters in a binary array.
* Is used to examine corr
pu
ted memory or arrays.
* Is used to examine corr
up
ted memory or arrays.
*/
void
_db_dump_
(
uint
_line_
,
const
char
*
keyword
,
const
unsigned
char
*
memory
,
size_t
length
)
{
int
pos
;
char
dbuff
[
90
];
CODE_STATE
*
cs
;
get_code_state_or_return
;
...
...
@@ -1413,9 +1406,8 @@ void _db_dump_(uint _line_, const char *keyword,
{
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
func
);
}
sprintf
(
dbuff
,
"%s: Memory: 0x%lx Bytes: (%ld)
\n
"
,
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"%s: Memory: 0x%lx Bytes: (%ld)
\n
"
,
keyword
,
(
ulong
)
memory
,
(
long
)
length
);
(
void
)
fputs
(
dbuff
,
cs
->
stack
->
out_file
);
pos
=
0
;
while
(
length
--
>
0
)
...
...
@@ -2155,7 +2147,7 @@ static void DbugExit(const char *why)
CODE_STATE
*
cs
=
code_state
();
(
void
)
fprintf
(
stderr
,
ERR_ABORT
,
cs
?
cs
->
process
:
"(null)"
,
why
);
(
void
)
fflush
(
stderr
);
exit
(
1
);
DBUG_ABORT
(
);
}
...
...
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