Skip to content

Commit

Permalink
c++
Browse files Browse the repository at this point in the history
  • Loading branch information
Costa Shulyupin authored and Costa Shulyupin committed Dec 22, 2020
1 parent 767e7d6 commit dbcfc7f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
46 changes: 46 additions & 0 deletions ctracer-testpp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
ctracer.h demonstarion and testing
- Test as user application:
make -B ctracer-testpp && ./ctracer-testpp
*/


#include "ctracer.h"
#include <sys/sysinfo.h>

int sub(void)
{ _entry:;
return 0;
}

int main(void)
{ _entry:;
int i;
for (i=0; i < 10; i++)
sub();
trl();
trvp(i);
trvx(i);
trvd(i);
trvd(sizeof(long long));
trvd(sizeof(size_t));
trvd(sizeof(void*));
trvd(sizeof(int));
trvd(sizeof(short));
trvd(sizeof(char));
if (0)
tracef("Should not be printed\n");
else
tracef("Should be printed\n");
if (1)
tracef("Should be printed\n");
else
tracef("Should not be printed\n");

freeram();
return 0;
}
6 changes: 3 additions & 3 deletions ctracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static inline int empty_function(void)
#if 1
/* omit full absolute path for modules */
#ifdef __GNUG__
//#include <string.h>
#include <cstring>
#else
extern char *strrchr(const char *s, int c);
#endif
Expand Down Expand Up @@ -325,7 +325,7 @@ static void *malloc_trace;
#ifndef trace_time_defined
#define trace_time_defined

void trace_time();
void trace_time(void);
/*
extern double time_prev_f;
void static inline trace_time()
Expand Down Expand Up @@ -449,7 +449,7 @@ int lookup_symbol_name(unsigned long addr, char *symbol)
{ char _caller[_CTRACRE_BUF_LEN]; \
lookup_symbol_name((unsigned long)__builtin_return_address(0), _caller); \
if (_trace_enter_num < 100) { \
_ret_msg = malloc(_CTRACRE_BUF_LEN); \
_ret_msg = (char*)malloc(_CTRACRE_BUF_LEN); \
if (_ret_msg) snprintf(_ret_msg, _CTRACRE_BUF_LEN, "%s < %s }", _caller, __func__); \
tracef("%s > %s { @ %s:%d #%d" EOL, _caller, __func__, __file__, __LINE__, _trace_enter_num); \
} }
Expand Down

0 comments on commit dbcfc7f

Please sign in to comment.