Skip to content

Commit

Permalink
common/assert: record assert info in g_assert_* globals
Browse files Browse the repository at this point in the history
These will then be available for others who are interested.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Jun 19, 2018
1 parent 72139f0 commit b0e59ce
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/common/assert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ namespace ceph {
void __ceph_assert_fail(const char *assertion, const char *file, int line,
const char *func)
{
g_assert_condition = assertion;
g_assert_file = file;
g_assert_line = line;
g_assert_func = func;
g_assert_thread = (unsigned long long)pthread_self();
pthread_getname_np(pthread_self(), g_assert_thread_name,
sizeof(g_assert_thread_name));

ostringstream tss;
tss << ceph_clock_now();

Expand Down Expand Up @@ -75,6 +83,14 @@ namespace ceph {
ostringstream tss;
tss << ceph_clock_now();

g_assert_condition = assertion;
g_assert_file = file;
g_assert_line = line;
g_assert_func = func;
g_assert_thread = (unsigned long long)pthread_self();
pthread_getname_np(pthread_self(), g_assert_thread_name,
sizeof(g_assert_thread_name));

class BufAppender {
public:
BufAppender(char* buf, int size) : bufptr(buf), remaining(size) {
Expand Down
7 changes: 7 additions & 0 deletions src/global/global_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@
*/
CephContext *g_ceph_context = NULL;
md_config_t *g_conf = NULL;

const char *g_assert_file = 0;
int g_assert_line = 0;
const char *g_assert_func = 0;
const char *g_assert_condition = 0;
unsigned long long g_assert_thread = 0;
char g_assert_thread_name[4096];
7 changes: 7 additions & 0 deletions src/global/global_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ struct md_config_t;
extern CephContext *g_ceph_context;
extern md_config_t *g_conf;

extern const char *g_assert_file;
extern int g_assert_line;
extern const char *g_assert_func;
extern const char *g_assert_condition;
extern unsigned long long g_assert_thread;
extern char g_assert_thread_name[4096];

#endif

0 comments on commit b0e59ce

Please sign in to comment.