Rizin
unix-like reverse engineering framework and cli tools
assert.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2018-2020 ret2libc <sirmy15@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_util.h>
5 
6 #ifdef RZ_ASSERT_STDOUT
7 static void stdout_log(const char *output, const char *funcname, const char *filename,
8  ut32 lineno, RzLogLevel level, const char *tag, const char *fmtstr, ...) {
9  printf("%s", output);
10 }
11 
12 static void print_message(RzLogLevel level, const char *fmt, va_list args) {
13  rz_log_add_callback(stdout_log);
14  RZ_VLOG(level, NULL, fmt, args);
15  rz_log_del_callback(stdout_log);
16 }
17 #else
18 static void print_message(RzLogLevel level, const char *fmt, va_list args) {
19  RZ_VLOG(level, NULL, fmt, args);
20 }
21 #endif
22 /*
23  * It prints a message to the log and it provides a single point of entrance in
24  * case of debugging. All rz_return_* functions call this.
25  */
26 RZ_API void rz_assert_log(RzLogLevel level, const char *fmt, ...) {
27  va_list args;
28  va_start(args, fmt);
29  print_message(level, fmt, args);
30  va_end(args);
31  char *env = rz_sys_getenv("RZ_DEBUG_ASSERT");
32  if (env) {
34  if (*env && atoi(env)) {
36  }
37  free(env);
38  }
39 }
static void print_message(RzLogLevel level, const char *fmt, va_list args)
Definition: assert.c:18
RZ_API void rz_assert_log(RzLogLevel level, const char *fmt,...)
Definition: assert.c:26
#define RZ_API
#define NULL
Definition: cris-opc.c:27
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
uint32_t ut32
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
const char * filename
Definition: ioapi.h:137
int args
Definition: mipsasm.c:18
enum rz_log_level RzLogLevel
RZ_API void rz_log_del_callback(RzLogCallback cbfunc)
Remove a logging callback.
Definition: log.c:67
RZ_API void rz_log_add_callback(RzLogCallback cbfunc)
Add a logging callback.
Definition: log.c:54
#define RZ_VLOG(lvl, tag, fmtstr, args)
Definition: rz_log.h:36
#define rz_sys_breakpoint()
Definition: rz_sys.h:178
RZ_API char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
Definition: sys.c:483
RZ_API char RZ_API void rz_sys_backtrace(void)
Print the backtrace at the point this function is called from.
Definition: sys.c:265
static char ** env
Definition: sys.c:32
static int level
Definition: vmenus.c:2424
diff_output_t output
Definition: zipcmp.c:237