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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d3bf417d
Commit
d3bf417d
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
6eaf0b5a
Changes
1
Show 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 @
d3bf417d
...
@@ -324,7 +324,7 @@ static void Indent(CODE_STATE *cs, int indent);
...
@@ -324,7 +324,7 @@ static void Indent(CODE_STATE *cs, int indent);
static
void
DbugFlush
(
CODE_STATE
*
);
static
void
DbugFlush
(
CODE_STATE
*
);
static
void
DbugExit
(
const
char
*
why
);
static
void
DbugExit
(
const
char
*
why
);
static
const
char
*
DbugStrTok
(
const
char
*
s
);
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
#ifndef THREAD
/* Open profile output stream */
/* Open profile output stream */
...
@@ -339,7 +339,7 @@ static unsigned long Clock(void);
...
@@ -339,7 +339,7 @@ static unsigned long Clock(void);
* Miscellaneous printf format strings.
* 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_OPEN "%s: can't open debug output stream \"%s\": "
#define ERR_CLOSE "%s: can't close debug file: "
#define ERR_CLOSE "%s: can't close debug file: "
#define ERR_ABORT "%s: debugger aborting because %s\n"
#define ERR_ABORT "%s: debugger aborting because %s\n"
...
@@ -1228,7 +1228,6 @@ void _db_enter_(const char *_func_, const char *_file_,
...
@@ -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_
)
void
_db_return_
(
uint
_line_
,
struct
_db_stack_frame_
*
_stack_frame_
)
{
{
int
save_errno
=
errno
;
int
save_errno
=
errno
;
...
@@ -1236,16 +1235,12 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
...
@@ -1236,16 +1235,12 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
CODE_STATE
*
cs
;
CODE_STATE
*
cs
;
get_code_state_or_return
;
get_code_state_or_return
;
if
(
cs
->
level
!=
_slevel
_
)
if
(
cs
->
framep
!=
_stack_frame
_
)
{
{
if
(
!
cs
->
locked
)
char
buf
[
512
];
pthread_mutex_lock
(
&
THR_LOCK_dbug
);
my_snprintf
(
buf
,
sizeof
(
buf
),
ERR_MISSING_RETURN
,
cs
->
func
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
ERR_MISSING_RETURN
,
cs
->
process
,
DbugExit
(
buf
);
cs
->
func
);
DbugFlush
(
cs
);
}
}
else
{
#ifndef THREAD
#ifndef THREAD
if
(
DoProfile
(
cs
))
if
(
DoProfile
(
cs
))
(
void
)
fprintf
(
cs
->
stack
->
prof_file
,
PROF_XFMT
,
Clock
(),
cs
->
func
);
(
void
)
fprintf
(
cs
->
stack
->
prof_file
,
PROF_XFMT
,
Clock
(),
cs
->
func
);
...
@@ -1265,7 +1260,6 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
...
@@ -1265,7 +1260,6 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
DbugFlush
(
cs
);
DbugFlush
(
cs
);
}
}
}
}
}
/*
/*
Check to not set level < 0. This can happen if DBUG was disabled when
Check to not set level < 0. This can happen if DBUG was disabled when
function was entered and enabled in function.
function was entered and enabled in function.
...
@@ -1353,7 +1347,7 @@ void _db_doprnt_(const char *format,...)
...
@@ -1353,7 +1347,7 @@ void _db_doprnt_(const char *format,...)
else
else
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
func
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
func
);
(
void
)
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
u_keyword
);
(
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
);
DbugFlush
(
cs
);
errno
=
save_errno
;
errno
=
save_errno
;
}
}
...
@@ -1361,10 +1355,10 @@ void _db_doprnt_(const char *format,...)
...
@@ -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.
* 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
];
char
cvtbuf
[
1024
];
size_t
len
;
size_t
len
;
...
@@ -1388,14 +1382,13 @@ static void DbugFprintf(FILE *stream, const char* format, va_list args)
...
@@ -1388,14 +1382,13 @@ static void DbugFprintf(FILE *stream, const char* format, va_list args)
*
*
* DESCRIPTION
* DESCRIPTION
* Dump N characters in a binary array.
* 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
,
void
_db_dump_
(
uint
_line_
,
const
char
*
keyword
,
const
unsigned
char
*
memory
,
size_t
length
)
const
unsigned
char
*
memory
,
size_t
length
)
{
{
int
pos
;
int
pos
;
char
dbuff
[
90
];
CODE_STATE
*
cs
;
CODE_STATE
*
cs
;
get_code_state_or_return
;
get_code_state_or_return
;
...
@@ -1413,9 +1406,8 @@ void _db_dump_(uint _line_, const char *keyword,
...
@@ -1413,9 +1406,8 @@ void _db_dump_(uint _line_, const char *keyword,
{
{
fprintf
(
cs
->
stack
->
out_file
,
"%s: "
,
cs
->
func
);
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
);
keyword
,
(
ulong
)
memory
,
(
long
)
length
);
(
void
)
fputs
(
dbuff
,
cs
->
stack
->
out_file
);
pos
=
0
;
pos
=
0
;
while
(
length
--
>
0
)
while
(
length
--
>
0
)
...
@@ -2155,7 +2147,7 @@ static void DbugExit(const char *why)
...
@@ -2155,7 +2147,7 @@ static void DbugExit(const char *why)
CODE_STATE
*
cs
=
code_state
();
CODE_STATE
*
cs
=
code_state
();
(
void
)
fprintf
(
stderr
,
ERR_ABORT
,
cs
?
cs
->
process
:
"(null)"
,
why
);
(
void
)
fprintf
(
stderr
,
ERR_ABORT
,
cs
?
cs
->
process
:
"(null)"
,
why
);
(
void
)
fflush
(
stderr
);
(
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