Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
dbus
dbus
Commits
7f3e29ff
Commit
7f3e29ff
authored
Dec 19, 2009
by
Ralf Habacker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let dbus_verbose print file name, line number and function name if available; this eases debugging.
parent
25ac34ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
2 deletions
+71
-2
dbus/dbus-internals.c
dbus/dbus-internals.c
+55
-1
dbus/dbus-internals.h
dbus/dbus-internals.h
+16
-1
No files found.
dbus/dbus-internals.c
View file @
7f3e29ff
...
...
@@ -329,6 +329,46 @@ _dbus_verbose_init (void)
}
}
/** @def DBUS_IS_DIR_SEPARATOR(c)
* macro for checking if character c is a patch separator
*
* @todo move to a header file so that others can use this too
*/
#ifdef DBUS_WIN
#define DBUS_IS_DIR_SEPARATOR(c) (c == '\\' || c == '/')
#else
#define DBUS_IS_DIR_SEPARATOR(c) (c == '/')
#endif
/**
remove source root from file path
the source root is determined by
*/
static
char
*
_dbus_file_path_extract_elements_from_tail
(
const
char
*
file
,
int
level
)
{
static
int
prefix
=
-
1
;
char
*
p
;
if
(
prefix
==
-
1
)
{
char
*
p
=
(
char
*
)
file
+
strlen
(
file
);
int
i
=
0
;
prefix
=
0
;
for
(;
p
>=
file
;
p
--
)
{
if
(
DBUS_IS_DIR_SEPARATOR
(
*
p
))
{
if
(
++
i
>=
level
)
{
prefix
=
p
-
file
+
1
;
break
;
}
}
}
}
return
(
char
*
)
file
+
prefix
;
}
/**
* Implementation of dbus_is_verbose() macro if built with verbose logging
* enabled.
...
...
@@ -350,7 +390,14 @@ _dbus_is_verbose_real (void)
* @param format printf-style format string.
*/
void
#ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS
_dbus_verbose_real
(
const
char
*
file
,
const
int
line
,
const
char
*
function
,
const
char
*
format
,
#else
_dbus_verbose_real
(
const
char
*
format
,
#endif
...)
{
va_list
args
;
...
...
@@ -382,17 +429,24 @@ _dbus_verbose_real (const char *format,
need_pid
=
TRUE
;
else
need_pid
=
FALSE
;
va_start
(
args
,
format
);
#ifdef DBUS_USE_OUTPUT_DEBUG_STRING
{
char
buf
[
1024
];
strcpy
(
buf
,
module_name
);
#ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS
vsprintf
(
buf
+
strlen
(
buf
),
"[%s(%d):%s] "
,
_dbus_file_path_extract_elements_from_tail
(
file
,
2
),
line
,
function
);
#endif
vsprintf
(
buf
+
strlen
(
buf
),
format
,
args
);
va_end
(
args
);
OutputDebugString
(
buf
);
}
#else
#ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS
fprintf
(
stderr
,
"[%s(%d):%s] "
,
_dbus_file_path_extract_elements_from_tail
(
file
,
2
),
line
,
function
);
#endif
vfprintf
(
stderr
,
format
,
args
);
va_end
(
args
);
...
...
dbus/dbus-internals.h
View file @
7f3e29ff
...
...
@@ -83,12 +83,27 @@ void _dbus_warn_check_failed (const char *format,
#ifdef DBUS_ENABLE_VERBOSE_MODE
/*
at least gnu cc and msvc compiler are known to
have support for variable macro argument lists
add other compilers is required
*/
#if defined(__GNUC__) || defined(_MSC_VER)
#define DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS
#endif
#ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS
void
_dbus_verbose_real
(
const
char
*
file
,
const
int
line
,
const
char
*
function
,
const
char
*
format
,...)
_DBUS_GNUC_PRINTF
(
4
,
5
);
# define _dbus_verbose(fmt,...) _dbus_verbose_real( __FILE__,__LINE__,__FUNCTION__,fmt, ## __VA_ARGS__)
#else
void
_dbus_verbose_real
(
const
char
*
format
,
...)
_DBUS_GNUC_PRINTF
(
1
,
2
);
# define _dbus_verbose _dbus_verbose_real
#endif
void
_dbus_verbose_reset_real
(
void
);
dbus_bool_t
_dbus_is_verbose_real
(
void
);
# define _dbus_verbose _dbus_verbose_real
# define _dbus_verbose_reset _dbus_verbose_reset_real
# define _dbus_is_verbose _dbus_is_verbose_real
#else
...
...
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