Skip to content
Snippets Groups Projects
Commit 83970cf6 authored by Kostyantyn Vorobyov's avatar Kostyantyn Vorobyov
Browse files

[RTL] Make debug functions in ADT-based models be compilable only with

debug macro
parent 545f53aa
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
/* */ /* */
/**************************************************************************/ /**************************************************************************/
#ifndef E_ACSL_ADT_MMODEL
#define E_ACSL_ADT_MMODEL
#include "e_acsl_string.h" #include "e_acsl_string.h"
#include "e_acsl_printf.h" #include "e_acsl_printf.h"
#include "e_acsl_assert.h" #include "e_acsl_assert.h"
...@@ -386,11 +389,12 @@ void __e_acsl_memory_init(int *argc_ref, char ***argv_ref) { } ...@@ -386,11 +389,12 @@ void __e_acsl_memory_init(int *argc_ref, char ***argv_ref) { }
/**********************/ /**********************/
/* DEBUG */ /* DEBUG */
/**********************/ /**********************/
#ifdef E_ACSL_DEBUG
/* print the information about a block */ /* print the information about a block */
void __print_block (struct _block * ptr) { void __e_acsl_print_block (struct _block * ptr) {
if (ptr != NULL) { if (ptr != NULL) {
printf("%p; %zu Bytes; %slitteral; [init] : %li ", DLOG("%p; %zu Bytes; %slitteral; [init] : %li ",
(char*)ptr->ptr, ptr->size, (char*)ptr->ptr, ptr->size,
ptr->is_litteral_string ? "" : "not ", ptr->init_cpt); ptr->is_litteral_string ? "" : "not ", ptr->init_cpt);
if(ptr->init_ptr != NULL) { if(ptr->init_ptr != NULL) {
...@@ -398,14 +402,17 @@ void __print_block (struct _block * ptr) { ...@@ -398,14 +402,17 @@ void __print_block (struct _block * ptr) {
for(i = 0; i < ptr->size; i++) { for(i = 0; i < ptr->size; i++) {
int ind = i / 8; int ind = i / 8;
int one_bit = (unsigned)1 << (8 - (i % 8) - 1); int one_bit = (unsigned)1 << (8 - (i % 8) - 1);
printf("%i", (ptr->init_ptr[ind] & one_bit) != 0); DLOG("%i", (ptr->init_ptr[ind] & one_bit) != 0);
} }
} }
printf("\n"); DLOG("\n");
} }
} }
/* print the content of the abstract structure */ /* print the content of the abstract structure */
void __debug() { void __e_acsl_debug() {
__debug_struct(); __e_acsl_debug_struct();
} }
#endif
#endif
...@@ -431,31 +431,33 @@ static void __clean_struct () { ...@@ -431,31 +431,33 @@ static void __clean_struct () {
/* DEBUG */ /* DEBUG */
/*********************/ /*********************/
#ifdef E_ACSL_DEBUG
/* called from __debug_struct */ /* called from __debug_struct */
/* recursively print the content of the structure */ /* recursively print the content of the structure */
/*@ assigns \nothing; /*@ assigns \nothing;
@*/ @*/
static void __debug_rec (struct bittree * ptr, int depth) { static void debug_rec (struct bittree * ptr, int depth) {
int i; int i;
if(ptr == NULL) if(ptr == NULL)
return; return;
for(i = 0; i < depth; i++) for(i = 0; i < depth; i++)
printf(" "); DLOG(" ");
if(ptr->is_leaf) if(ptr->is_leaf)
__print_block(ptr->leaf); __e_acsl_print_block(ptr->leaf);
else { else {
printf("%p -- %p\n", (void*)ptr->mask, (void*)ptr->addr); DLOG("%p -- %p\n", (void*)ptr->mask, (void*)ptr->addr);
__debug_rec(ptr->left, depth+1); debug_rec(ptr->left, depth+1);
__debug_rec(ptr->right, depth+1); debug_rec(ptr->right, depth+1);
} }
} }
/* print the content of the structure */ /* print the content of the structure */
/*@ assigns \nothing; /*@ assigns \nothing;
@*/ @*/
static void __debug_struct () { void __e_acsl_debug_struct () {
printf("------------DEBUG\n"); DLOG("------------DEBUG\n");
__debug_rec(__root, 0); debug_rec(__root, 0);
printf("-----------------\n"); DLOG("-----------------\n");
} }
#endif #endif
#endif
...@@ -123,14 +123,19 @@ static void __clean_struct() { ...@@ -123,14 +123,19 @@ static void __clean_struct() {
} }
} }
/*********************/
static void __debug_struct() { /* DEBUG */
/*********************/
#ifdef E_ACSL_DEBUG
void __e_acsl_debug_struct() {
struct _node * tmp = __list; struct _node * tmp = __list;
printf("\t\t\t------------DEBUG\n"); DLOG("\t\t\t------------DEBUG\n");
for(; tmp != NULL; tmp = tmp->next) { for(; tmp != NULL; tmp = tmp->next) {
printf("\t\t\t"); DLOG("\t\t\t");
__print_block(tmp->value); __e_acsl_print_block(tmp->value);
} }
printf("\t\t\t-----------------\n"); DLOG("\t\t\t-----------------\n");
} }
#endif
#endif #endif
...@@ -180,17 +180,23 @@ static void __clean_struct() { ...@@ -180,17 +180,23 @@ static void __clean_struct() {
__clean_rec(__root); __clean_rec(__root);
} }
static void __debug_rec(struct _node * ptr) { /*********************/
/* DEBUG */
/*********************/
#ifdef E_ACSL_DEBUG
static void debug_rec(struct _node * ptr) {
if(ptr == NULL) return; if(ptr == NULL) return;
__debug_rec(ptr->left); debug_rec(ptr->left);
printf("\t\t\t"); DLOG("\t\t\t");
__print_block(ptr->value); __e_acsl_print_block(ptr->value);
__debug_rec(ptr->right); debug_rec(ptr->right);
} }
static void __debug_struct() { void __e_acsl_debug_struct() {
printf("\t\t\t------------DEBUG\n"); DLOG("\t\t\t------------DEBUG\n");
__debug_rec(__root); debug_rec(__root);
printf("\t\t\t-----------------\n"); DLOG("\t\t\t-----------------\n");
} }
#endif
#endif #endif
...@@ -140,18 +140,23 @@ static void __clean_struct() { ...@@ -140,18 +140,23 @@ static void __clean_struct() {
__clean_rec(__root); __clean_rec(__root);
} }
/*********************/
static void __debug_rec(struct _node * ptr) { /* DEBUG */
/*********************/
#ifdef E_ACSL_DEBUG
static void debug_rec(struct _node * ptr) {
if(ptr == NULL) return; if(ptr == NULL) return;
__debug_rec(ptr->left); debug_rec(ptr->left);
printf("\t\t\t"); DLOG("\t\t\t");
__print_block(ptr->value); __e_acsl_print_block(ptr->value);
__debug_rec(ptr->right); debug_rec(ptr->right);
} }
static void __debug_struct() { void __e_acsl_debug_struct() {
printf("\t\t\t------------DEBUG\n"); DLOG("\t\t\t------------DEBUG\n");
__debug_rec(__root); __debug_rec(__root);
printf("\t\t\t-----------------\n"); DLOF("\t\t\t-----------------\n");
} }
#endif
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment