<commit_before>#ifndef __SH_COMMON_H__
#define __SH_COMMON_H__

#define _XOPEN_SOURCE 700
#define _BSD_SOURCE

#include <stdio.h>
#include <stdlib.h>

// ensure is kinda like assert but it is always executed
#define ensure(p, msg)                                   \
do {                                                     \
    if (!(p)) {                                          \
        printf("%s - %s:%d", msg, __FILE__, __LINE__);   \
        abort();                                         \
    }                                                    \
} while(0)

#endif <commit_msg>Add backtrace to ensure<commit_after>#ifndef __SH_COMMON_H__
#define __SH_COMMON_H__

#define _XOPEN_SOURCE 700
#define _BSD_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <execinfo.h>

// TODO: Move this to a better place
static inline void printBacktrace() {
    void* tracePtrs[100];
    int count = backtrace(tracePtrs, 100);
    char** funcNames = backtrace_symbols(tracePtrs, count);

    for (int i = 0; i < count; i++) {
        printf("%s\n", funcNames[i]);
    }

    free(funcNames);
}

// ensure is kinda like assert but it is always executed
#define ensure(p, msg)                                   \
do {                                                     \
    if (!(p)) {                                          \
        printf("%s - %s:%d\n", msg, __FILE__, __LINE__);   \
        printBacktrace();                                \
        abort();                                         \
    }                                                    \
} while(0)

#endif
{'fraction_non_alphanumeric': 0.10377358490566038, 'fraction_numerical': 0.009433962264150943, 'mean_word_length': 1.1413189771197847, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4070801', 'n_tokens_mistral': 432, 'n_tokens_neox': 412, 'n_words': 111}