Commit 5db2918b authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Extract runtime debugging macros into debug.h

parent 2fad1185
......@@ -43,4 +43,34 @@
}
/**
* Runtime debuging output macros.
*/
#define rdexec \
if (agent_debug_is_enabled ())
#define rdoutput(args...) \
fprintf (stdout, args);
#define __safe_name(name) \
(((name) == NULL) ? "<unknown>" : (name))
#define rdaprefix(args...) \
rdoutput (AGENT_NAME ": "); \
rdoutput (args);
#define rdatprefix(info, args...) \
rdoutput (AGENT_NAME " [%s]: ", __safe_name ((info)->name)); \
rdoutput (args);
#define rdaprintf(args...) \
rdexec { \
rdaprefix (args); \
}
#define rdatprintf(info, args...) \
rdexec { \
rdatprefix (info, args); \
}
#endif // _DEBUG_H
......@@ -2,6 +2,7 @@
#include "common.h"
#include "config.h"
#include "strutil.h"
#include "debug.h"
#include "jvmtiutil.h"
#include "connection.h"
......@@ -80,6 +81,17 @@ enum code_flags {
static struct config agent_config;
/**
* Returns true if runtime debugging is enabled. This is to allow querying
* the runtime debug status globally while keeping the config private to the
* main agent module.
*/
bool
agent_debug_is_enabled () {
return agent_config.debug;
}
/**
* Code option flags that control the instrumentation.
*/
......@@ -100,37 +112,6 @@ static volatile bool jvm_is_started;
static volatile bool jvm_is_initialized;
/**
* Runtime debuging output macros.
*/
#define rdexec \
if (agent_config.debug)
#define rdoutput(args...) \
fprintf (stdout, args);
#define __safe_name(name) \
(((name) == NULL) ? "<unknown>" : (name))
#define rdaprefix(args...) \
rdoutput (AGENT_NAME ": "); \
rdoutput (args);
#define rdatprefix(info, args...) \
rdoutput (AGENT_NAME " [%s]: ", __safe_name ((info)->name)); \
rdoutput (args);
#define rdaprintf(args...) \
rdexec { \
rdaprefix (args); \
}
#define rdatprintf(info, args...) \
rdexec { \
rdatprefix (info, args); \
}
// ****************************************************************************
// CLASS FILE LOAD
// ****************************************************************************
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment