#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
#include "../cr.h"
static unsigned int CR_STATE version = 1;
void hello() {
static bool CR_STATE said_hello = false;
if (!said_hello) {
said_hello = true;
fprintf(stdout, "hello world! ");
}
static int skip = 0;
if (++skip%50 == 0)
fprintf(stdout, "z");
}
void test_crash() {
int *addr = NULL; (void)addr; }
CR_EXPORT int cr_main(struct cr_plugin *ctx, enum cr_op operation) {
assert(ctx);
if (operation != CR_STEP) {
fprintf(stdout, "OP: %s(%d)\n", operation == CR_LOAD ? "LOAD" : "UNLOAD", ctx->version);
int *addr = NULL; (void)addr; return 0;
}
if (ctx->version < version) {
fprintf(stdout, "A rollback happened due to failure: %x!\n", ctx->failure);
}
version = ctx->version;
static bool print_version = true;
if (print_version) {
fprintf(stdout, "loaded version: %d\n", ctx->version);
print_version = false;
}
hello();
test_crash();
return 0;
}