include asan with debug builds

This commit is contained in:
2026-07-15 17:52:09 +10:00
parent c06f070921
commit f84525fa3a
2 changed files with 9 additions and 2 deletions

View File

@@ -7,6 +7,11 @@ sources = [
'src/instruction.c'
]
args = ['-Wall', '-Wextra', '-O3', '-ggdb', '-fsanitize=address']
args = ['-Wall', '-Wextra', '-O3']
if get_option('buildtype') == 'debug'
args = ['-Wall', '-Wextra', '-O3', '-ggdb', '-fsanitize=address']
add_project_arguments('-fsanitize=address', language : 'c')
add_project_link_arguments('-fsanitize=address', language : 'c')
endif
executable('emu', sources, c_args: args)

View File

@@ -11,13 +11,15 @@ int main() {
Instruction program[] = {
{INST_MVI, {REG_A, 0, 0}, 5, true},
{INST_MVI, {REG_B, 0, 0}, 3, true},
{INST_ADD, {REG_A, REG_B, 0}, 0, false}
{INST_ADD, {REG_A, REG_B, 0}, 0, false},
{INST_HLT, {}, 0, false}
};
memoryLoadProgram(emu->mem, program, sizeof(program)/sizeof(program[0]));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
printf("%s\n", instructionToCStr(decodeInstruction(emu->mem, &emu->pc)));
freeEmulator(emu);