authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2015-11-24 19:07:33-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2015-11-24 19:07:33-07:00
logca836191e199603056fc2c5f854f8e134f98af4d
tree2ecd475ca1d2fca0822246433886636f364551df
parentbaf5167171fa0159adb8bd55c6a111b006f8c038

debug information for functions


9 files changed, 258 insertions(+), 96 deletions(-)

src/buffer.hpp-17
......@@ -134,23 +134,6 @@ static inline void buf_splice_buf(Buf *buf, int start, int end, Buf *other) {
134134 memcpy(buf_ptr(buf) + start, buf_ptr(other), buf_len(other));
135135}
136136
137// TODO this method needs work
138static inline Buf *buf_dirname(Buf *buf) {
139 if (buf_len(buf) <= 2)
140 zig_panic("TODO buf_dirname small");
141 int last_index = buf_len(buf) - 1;
142 if (buf_ptr(buf)[buf_len(buf) - 1] == '/') {
143 last_index = buf_len(buf) - 2;
144 }
145 for (int i = last_index; i >= 0; i -= 1) {
146 uint8_t c = buf_ptr(buf)[i];
147 if (c == '/') {
148 return buf_slice(buf, 0, i);
149 }
150 }
151 return buf_create_from_mem("", 0);
152}
153
154137static inline uint32_t buf_hash(Buf *buf) {
155138 // FNV 32-bit hash
156139 uint32_t h = 2166136261;
src/codegen.cpp+227-67
......@@ -9,27 +9,63 @@
99#include "hash_map.hpp"
1010#include "zig_llvm.hpp"
1111#include "os.hpp"
12#include "config.h"
1213
1314#include <stdio.h>
1415
16#include <llvm/IR/DIBuilder.h>
17#include <llvm/IR/DiagnosticInfo.h>
18#include <llvm/IR/DiagnosticPrinter.h>
19
1520struct FnTableEntry {
1621 LLVMValueRef fn_value;
1722 AstNode *proto_node;
1823};
1924
25enum TypeId {
26 TypeIdUserDefined,
27 TypeIdPointer,
28 TypeIdU8,
29 TypeIdI32,
30 TypeIdVoid,
31 TypeIdUnreachable,
32};
33
34struct TypeTableEntry {
35 TypeId id;
36 LLVMTypeRef type_ref;
37 llvm::DIType *di_type;
38
39 TypeTableEntry *pointer_child;
40 bool pointer_is_const;
41 int user_defined_id;
42 Buf name;
43 TypeTableEntry *pointer_const_parent;
44 TypeTableEntry *pointer_mut_parent;
45};
46
2047struct CodeGen {
2148 LLVMModuleRef mod;
2249 AstNode *root;
2350 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> fn_defs;
2451 ZigList<ErrorMsg> errors;
2552 LLVMBuilderRef builder;
53 llvm::DIBuilder *dbuilder;
54 llvm::DICompileUnit *compile_unit;
2655 HashMap<Buf *, FnTableEntry *, buf_hash, buf_eql_buf> fn_table;
2756 HashMap<Buf *, LLVMValueRef, buf_hash, buf_eql_buf> str_table;
57 HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> type_table;
58 TypeTableEntry *invalid_type_entry;
59 LLVMTargetDataRef target_data_ref;
60 unsigned pointer_size_bytes;
61 bool is_static;
62 LLVMTargetMachineRef target_machine;
63 Buf in_file;
64 Buf in_dir;
2865};
2966
3067struct TypeNode {
31 LLVMTypeRef type_ref;
32 bool is_unreachable;
68 TypeTableEntry *entry;
3369};
3470
3571struct CodeGenNode {
......@@ -38,12 +74,16 @@ struct CodeGenNode {
3874 } data;
3975};
4076
41CodeGen *create_codegen(AstNode *root) {
77CodeGen *create_codegen(AstNode *root, bool is_static, Buf *in_full_path) {
4278 CodeGen *g = allocate<CodeGen>(1);
4379 g->root = root;
4480 g->fn_defs.init(32);
4581 g->fn_table.init(32);
4682 g->str_table.init(32);
83 g->type_table.init(32);
84 g->is_static = is_static;
85
86 os_path_split(in_full_path, &g->in_dir, &g->in_file);
4787 return g;
4888}
4989
......@@ -60,9 +100,17 @@ static void add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
60100static LLVMTypeRef to_llvm_type(AstNode *type_node) {
61101 assert(type_node->type == NodeTypeType);
62102 assert(type_node->codegen_node);
63 assert(type_node->codegen_node->data.type_node.type_ref);
103 assert(type_node->codegen_node->data.type_node.entry);
104
105 return type_node->codegen_node->data.type_node.entry->type_ref;
106}
107
108static llvm::DIType *to_llvm_debug_type(AstNode *type_node) {
109 assert(type_node->type == NodeTypeType);
110 assert(type_node->codegen_node);
111 assert(type_node->codegen_node->data.type_node.entry);
64112
65 return type_node->codegen_node->data.type_node.type_ref;
113 return type_node->codegen_node->data.type_node.entry->di_type;
66114}
67115
68116
......@@ -72,6 +120,56 @@ static bool type_is_unreachable(AstNode *type_node) {
72120 buf_eql_str(&type_node->data.type.primitive_name, "unreachable");
73121}
74122
123static void analyze_node(CodeGen *g, AstNode *node);
124
125static void resolve_type_and_recurse(CodeGen *g, AstNode *node) {
126 assert(!node->codegen_node);
127 node->codegen_node = allocate<CodeGenNode>(1);
128 TypeNode *type_node = &node->codegen_node->data.type_node;
129 switch (node->data.type.type) {
130 case AstNodeTypeTypePrimitive:
131 {
132 Buf *name = &node->data.type.primitive_name;
133 auto table_entry = g->type_table.maybe_get(name);
134 if (table_entry) {
135 type_node->entry = table_entry->value;
136 } else {
137 add_node_error(g, node,
138 buf_sprintf("invalid type name: '%s'", buf_ptr(name)));
139 type_node->entry = g->invalid_type_entry;
140 }
141 break;
142 }
143 case AstNodeTypeTypePointer:
144 {
145 analyze_node(g, node->data.type.child_type);
146 TypeNode *child_type_node = &node->data.type.child_type->codegen_node->data.type_node;
147 if (child_type_node->entry->id == TypeIdUnreachable) {
148 add_node_error(g, node,
149 buf_create_from_str("pointer to unreachable not allowed"));
150 }
151 TypeTableEntry **parent_pointer = node->data.type.is_const ?
152 &child_type_node->entry->pointer_const_parent :
153 &child_type_node->entry->pointer_mut_parent;
154 const char *const_or_mut_str = node->data.type.is_const ? "const" : "mut";
155 if (*parent_pointer) {
156 type_node->entry = *parent_pointer;
157 } else {
158 TypeTableEntry *entry = allocate<TypeTableEntry>(1);
159 entry->id = TypeIdPointer;
160 entry->type_ref = LLVMPointerType(child_type_node->entry->type_ref, 0);
161 buf_appendf(&entry->name, "*%s %s", const_or_mut_str, buf_ptr(&child_type_node->entry->name));
162 entry->di_type = g->dbuilder->createPointerType(child_type_node->entry->di_type,
163 g->pointer_size_bytes * 8, g->pointer_size_bytes * 8, buf_ptr(&entry->name));
164 g->type_table.put(&entry->name, entry);
165 type_node->entry = entry;
166 *parent_pointer = entry;
167 }
168 break;
169 }
170 }
171}
172
75173static void analyze_node(CodeGen *g, AstNode *node) {
76174 switch (node->type) {
77175 case NodeTypeRoot:
......@@ -148,42 +246,10 @@ static void analyze_node(CodeGen *g, AstNode *node) {
148246 case NodeTypeParamDecl:
149247 analyze_node(g, node->data.param_decl.type);
150248 break;
249
151250 case NodeTypeType:
152251 {
153 node->codegen_node = allocate<CodeGenNode>(1);
154 TypeNode *type_node = &node->codegen_node->data.type_node;
155 switch (node->data.type.type) {
156 case AstNodeTypeTypePrimitive:
157 {
158 Buf *name = &node->data.type.primitive_name;
159 if (buf_eql_str(name, "u8")) {
160 type_node->type_ref = LLVMInt8Type();
161 } else if (buf_eql_str(name, "i32")) {
162 type_node->type_ref = LLVMInt32Type();
163 } else if (buf_eql_str(name, "void")) {
164 type_node->type_ref = LLVMVoidType();
165 } else if (buf_eql_str(name, "unreachable")) {
166 type_node->type_ref = LLVMVoidType();
167 type_node->is_unreachable = true;
168 } else {
169 add_node_error(g, node,
170 buf_sprintf("invalid type name: '%s'", buf_ptr(name)));
171 type_node->type_ref = LLVMVoidType();
172 }
173 break;
174 }
175 case AstNodeTypeTypePointer:
176 {
177 analyze_node(g, node->data.type.child_type);
178 TypeNode *child_type_node = &node->data.type.child_type->codegen_node->data.type_node;
179 if (child_type_node->is_unreachable) {
180 add_node_error(g, node,
181 buf_create_from_str("pointer to unreachable not allowed"));
182 }
183 type_node->type_ref = LLVMPointerType(child_type_node->type_ref, 0);
184 break;
185 }
186 }
252 resolve_type_and_recurse(g, node);
187253 break;
188254 }
189255 case NodeTypeBlock:
......@@ -224,10 +290,85 @@ static void analyze_node(CodeGen *g, AstNode *node) {
224290 }
225291}
226292
293static void add_types(CodeGen *g) {
294 {
295 TypeTableEntry *entry = allocate<TypeTableEntry>(1);
296 entry->id = TypeIdU8;
297 entry->type_ref = LLVMInt8Type();
298 buf_init_from_str(&entry->name, "u8");
299 entry->di_type = g->dbuilder->createBasicType(buf_ptr(&entry->name), 8, 8, llvm::dwarf::DW_ATE_unsigned);
300 g->type_table.put(&entry->name, entry);
301 }
302 {
303 TypeTableEntry *entry = allocate<TypeTableEntry>(1);
304 entry->id = TypeIdI32;
305 entry->type_ref = LLVMInt32Type();
306 buf_init_from_str(&entry->name, "i32");
307 entry->di_type = g->dbuilder->createBasicType(buf_ptr(&entry->name), 32, 32,
308 llvm::dwarf::DW_ATE_signed);
309 g->type_table.put(&entry->name, entry);
310 }
311 {
312 TypeTableEntry *entry = allocate<TypeTableEntry>(1);
313 entry->id = TypeIdVoid;
314 entry->type_ref = LLVMVoidType();
315 buf_init_from_str(&entry->name, "void");
316 entry->di_type = g->dbuilder->createBasicType(buf_ptr(&entry->name), 0, 0,
317 llvm::dwarf::DW_ATE_unsigned);
318 g->type_table.put(&entry->name, entry);
319
320 // invalid types are void
321 g->invalid_type_entry = entry;
322 }
323 {
324 TypeTableEntry *entry = allocate<TypeTableEntry>(1);
325 entry->id = TypeIdUnreachable;
326 entry->type_ref = LLVMVoidType();
327 buf_init_from_str(&entry->name, "unreachable");
328 entry->di_type = g->invalid_type_entry->di_type;
329 g->type_table.put(&entry->name, entry);
330 }
331}
332
227333
228334void semantic_analyze(CodeGen *g) {
335 LLVMInitializeAllTargets();
336 LLVMInitializeAllTargetMCs();
337 LLVMInitializeAllAsmPrinters();
338 LLVMInitializeAllAsmParsers();
339 LLVMInitializeNativeTarget();
340
341 char *native_triple = LLVMGetDefaultTargetTriple();
342
343 LLVMTargetRef target_ref;
344 char *err_msg = nullptr;
345 if (LLVMGetTargetFromTriple(native_triple, &target_ref, &err_msg)) {
346 zig_panic("unable to get target from triple: %s", err_msg);
347 }
348
349 char *native_cpu = LLVMZigGetHostCPUName();
350 char *native_features = LLVMZigGetNativeFeatures();
351
352 LLVMCodeGenOptLevel opt_level = LLVMCodeGenLevelNone;
353
354 LLVMRelocMode reloc_mode = g->is_static ? LLVMRelocStatic : LLVMRelocPIC;
355
356 g->target_machine = LLVMCreateTargetMachine(target_ref, native_triple,
357 native_cpu, native_features, opt_level, reloc_mode, LLVMCodeModelDefault);
358
359 g->target_data_ref = LLVMGetTargetMachineData(g->target_machine);
360
361
229362 g->mod = LLVMModuleCreateWithName("ZigModule");
230363
364 g->pointer_size_bytes = LLVMPointerSize(g->target_data_ref);
365
366 g->builder = LLVMCreateBuilder();
367 g->dbuilder = new llvm::DIBuilder(*llvm::unwrap(g->mod), true);
368
369
370 add_types(g);
371
231372 // Pass 1.
232373 analyze_node(g, g->root);
233374}
......@@ -344,8 +485,29 @@ static void gen_block(CodeGen *g, AstNode *block_node) {
344485 }
345486}
346487
488static llvm::DISubroutineType *create_di_function_type(CodeGen *g, AstNodeFnProto *fn_proto, llvm::DIFile *unit) {
489 llvm::SmallVector<llvm::Metadata *, 8> types;
490
491 llvm::DIType *return_type = to_llvm_debug_type(fn_proto->return_type);
492 types.push_back(return_type);
493
494 for (int i = 0; i < fn_proto->params.length; i += 1) {
495 AstNode *param_node = fn_proto->params.at(i);
496 llvm::DIType *param_type = to_llvm_debug_type(param_node);
497 types.push_back(param_type);
498 }
499
500 return g->dbuilder->createSubroutineType(unit, g->dbuilder->getOrCreateTypeArray(types));
501}
502
347503void code_gen(CodeGen *g) {
348 g->builder = LLVMCreateBuilder();
504 Buf *producer = buf_sprintf("zig %s", ZIG_VERSION_STRING);
505 bool is_optimized = false;
506 const char *flags = "";
507 unsigned runtime_version = 0;
508 g->compile_unit = g->dbuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99,
509 buf_ptr(&g->in_file), buf_ptr(&g->in_dir),
510 buf_ptr(producer), is_optimized, flags, runtime_version);
349511
350512 auto it = g->fn_defs.entry_iterator();
351513 for (;;) {
......@@ -369,9 +531,29 @@ void code_gen(CodeGen *g) {
369531 LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, fn_proto->params.length, 0);
370532 LLVMValueRef fn = LLVMAddFunction(g->mod, buf_ptr(&fn_proto->name), function_type);
371533
534 bool internal_linkage = false;
535 LLVMSetLinkage(fn, internal_linkage ? LLVMPrivateLinkage : LLVMExternalLinkage);
536
372537 if (type_is_unreachable(fn_proto->return_type)) {
373538 LLVMAddFunctionAttr(fn, LLVMNoReturnAttribute);
374539 }
540 LLVMAddFunctionAttr(fn, LLVMNoUnwindAttribute);
541
542 // Add debug info.
543 llvm::DIFile *unit = g->dbuilder->createFile(g->compile_unit->getFilename(),
544 g->compile_unit->getDirectory());
545 llvm::DIScope *fn_scope = unit;
546 unsigned line_number = fn_def_node->line + 1;
547 unsigned scope_line = line_number;
548 bool is_definition = true;
549 unsigned flags = 0;
550 llvm::Function *unwrapped_function = reinterpret_cast<llvm::Function*>(llvm::unwrap(fn));
551 g->dbuilder->createFunction(
552 fn_scope, buf_ptr(&fn_proto->name), "", unit, line_number,
553 create_di_function_type(g, fn_proto, unit), internal_linkage,
554 is_definition, scope_line, flags, is_optimized, unwrapped_function);
555
556
375557
376558 LLVMBasicBlockRef entry_block = LLVMAppendBasicBlock(fn, "entry");
377559 LLVMPositionBuilderAtEnd(g->builder, entry_block);
......@@ -379,6 +561,8 @@ void code_gen(CodeGen *g) {
379561 gen_block(g, fn_def->body);
380562 }
381563
564 g->dbuilder->finalize();
565
382566 LLVMDumpModule(g->mod);
383567
384568 char *error = nullptr;
......@@ -390,14 +574,7 @@ ZigList<ErrorMsg> *codegen_error_messages(CodeGen *g) {
390574}
391575
392576
393void code_gen_link(CodeGen *g, bool is_static, const char *out_file) {
394 LLVMInitializeAllTargets();
395 LLVMInitializeAllTargetMCs();
396 LLVMInitializeAllAsmPrinters();
397 LLVMInitializeAllAsmParsers();
398 LLVMInitializeNativeTarget();
399
400
577void code_gen_link(CodeGen *g, const char *out_file) {
401578 LLVMPassRegistryRef registry = LLVMGetGlobalPassRegistry();
402579 LLVMInitializeCore(registry);
403580 LLVMInitializeCodeGen(registry);
......@@ -405,29 +582,12 @@ void code_gen_link(CodeGen *g, bool is_static, const char *out_file) {
405582 LLVMZigInitializeLowerIntrinsicsPass(registry);
406583 LLVMZigInitializeUnreachableBlockElimPass(registry);
407584
408 char *native_triple = LLVMGetDefaultTargetTriple();
409
410 LLVMTargetRef target_ref;
411 char *err_msg = nullptr;
412 if (LLVMGetTargetFromTriple(native_triple, &target_ref, &err_msg)) {
413 zig_panic("unable to get target from triple: %s", err_msg);
414 }
415
416 char *native_cpu = LLVMZigGetHostCPUName();
417 char *native_features = LLVMZigGetNativeFeatures();
418
419 LLVMCodeGenOptLevel opt_level = LLVMCodeGenLevelNone;
420
421 LLVMRelocMode reloc_mode = is_static ? LLVMRelocStatic : LLVMRelocPIC;
422
423 LLVMTargetMachineRef target_machine = LLVMCreateTargetMachine(target_ref, native_triple,
424 native_cpu, native_features, opt_level, reloc_mode, LLVMCodeModelDefault);
425
426585 Buf out_file_o = BUF_INIT;
427586 buf_init_from_str(&out_file_o, out_file);
428587 buf_append_str(&out_file_o, ".o");
429588
430 if (LLVMTargetMachineEmitToFile(target_machine, g->mod, buf_ptr(&out_file_o), LLVMObjectFile, &err_msg)) {
589 char *err_msg = nullptr;
590 if (LLVMTargetMachineEmitToFile(g->target_machine, g->mod, buf_ptr(&out_file_o), LLVMObjectFile, &err_msg)) {
431591 zig_panic("unable to write object file: %s", err_msg);
432592 }
433593
src/codegen.hpp+2-2
......@@ -21,13 +21,13 @@ struct ErrorMsg {
2121};
2222
2323
24CodeGen *create_codegen(AstNode *root);
24CodeGen *create_codegen(AstNode *root, bool is_static, Buf *in_file);
2525
2626void semantic_analyze(CodeGen *g);
2727
2828void code_gen(CodeGen *g);
2929
30void code_gen_link(CodeGen *g, bool is_static, const char *out_file);
30void code_gen_link(CodeGen *g, const char *out_file);
3131
3232ZigList<ErrorMsg> *codegen_error_messages(CodeGen *g);
3333
src/main.cpp+3-6
......@@ -62,18 +62,15 @@ static int build(const char *arg0, const char *in_file, const char *out_file, Zi
6262 return usage(arg0);
6363
6464 FILE *in_f;
65 Buf *cur_dir_path;
6665 if (strcmp(in_file, "-") == 0) {
6766 in_f = stdin;
6867 char *result = getcwd(cur_dir, sizeof(cur_dir));
6968 if (!result)
7069 zig_panic("unable to get current working directory: %s", strerror(errno));
71 cur_dir_path = buf_create_from_str(result);
7270 } else {
7371 in_f = fopen(in_file, "rb");
7472 if (!in_f)
7573 zig_panic("unable to open %s for reading: %s\n", in_file, strerror(errno));
76 cur_dir_path = buf_dirname(buf_create_from_str(in_file));
7774 }
7875
7976 fprintf(stderr, "Original source:\n");
......@@ -83,7 +80,7 @@ static int build(const char *arg0, const char *in_file, const char *out_file, Zi
8380
8481 fprintf(stderr, "\nTokens:\n");
8582 fprintf(stderr, "---------\n");
86 ZigList<Token> *tokens = tokenize(in_data, cur_dir_path);
83 ZigList<Token> *tokens = tokenize(in_data);
8784 print_tokens(in_data, tokens);
8885
8986 fprintf(stderr, "\nAST:\n");
......@@ -94,7 +91,7 @@ static int build(const char *arg0, const char *in_file, const char *out_file, Zi
9491
9592 fprintf(stderr, "\nSemantic Analysis:\n");
9693 fprintf(stderr, "--------------------\n");
97 CodeGen *codegen = create_codegen(root);
94 CodeGen *codegen = create_codegen(root, false, buf_create_from_str(in_file));
9895 semantic_analyze(codegen);
9996 ZigList<ErrorMsg> *errors = codegen_error_messages(codegen);
10097 if (errors->length == 0) {
......@@ -115,7 +112,7 @@ static int build(const char *arg0, const char *in_file, const char *out_file, Zi
115112
116113 fprintf(stderr, "\nLink:\n");
117114 fprintf(stderr, "------------------\n");
118 code_gen_link(codegen, false, out_file);
115 code_gen_link(codegen, out_file);
119116 fprintf(stderr, "OK\n");
120117
121118 return 0;
src/os.cpp+20
......@@ -31,3 +31,23 @@ void os_spawn_process(const char *exe, ZigList<const char *> &args, bool detache
3131 execvp(exe, const_cast<char * const *>(argv));
3232 zig_panic("execvp failed: %s", strerror(errno));
3333}
34
35void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename) {
36 if (buf_len(full_path) <= 2)
37 zig_panic("TODO full path small");
38 int last_index = buf_len(full_path) - 1;
39 if (buf_ptr(full_path)[buf_len(full_path) - 1] == '/') {
40 last_index = buf_len(full_path) - 2;
41 }
42 for (int i = last_index; i >= 0; i -= 1) {
43 uint8_t c = buf_ptr(full_path)[i];
44 if (c == '/') {
45 buf_init_from_mem(out_dirname, buf_ptr(full_path), i);
46 buf_init_from_mem(out_basename, buf_ptr(full_path) + i + 1, buf_len(full_path) - (i + 1));
47 return;
48 }
49 }
50 buf_init_from_mem(out_dirname, ".", 1);
51 buf_init_from_buf(out_basename, full_path);
52}
53
src/os.hpp+3
......@@ -13,4 +13,7 @@
1313
1414void os_spawn_process(const char *exe, ZigList<const char *> &args, bool detached);
1515
16void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename);
17
18
1619#endif
src/tokenizer.cpp+1-3
......@@ -100,7 +100,6 @@ struct Tokenize {
100100 int line;
101101 int column;
102102 Token *cur_tok;
103 Buf *cur_dir_path;
104103};
105104
106105__attribute__ ((format (printf, 2, 3)))
......@@ -159,11 +158,10 @@ static void end_token(Tokenize *t) {
159158 t->cur_tok = nullptr;
160159}
161160
162ZigList<Token> *tokenize(Buf *buf, Buf *cur_dir_path) {
161ZigList<Token> *tokenize(Buf *buf) {
163162 Tokenize t = {0};
164163 t.tokens = allocate<ZigList<Token>>(1);
165164 t.buf = buf;
166 t.cur_dir_path = cur_dir_path;
167165 for (t.pos = 0; t.pos < buf_len(t.buf); t.pos += 1) {
168166 uint8_t c = buf_ptr(t.buf)[t.pos];
169167 switch (t.state) {
src/tokenizer.hpp+1-1
......@@ -50,7 +50,7 @@ enum TokenizeState {
5050 TokenizeStateSawDash,
5151};
5252
53ZigList<Token> *tokenize(Buf *buf, Buf *cur_dir_path);
53ZigList<Token> *tokenize(Buf *buf);
5454
5555void print_tokens(Buf *buf, ZigList<Token> *tokens);
5656
src/util.hpp+1
......@@ -12,6 +12,7 @@
1212#include <string.h>
1313#include <assert.h>
1414
15#include <new>
1516
1617#define BREAKPOINT __asm("int $0x03")
1718