diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -10,7 +10,31 @@ The `DEFINITION` node includes the definitions for the structures that are aggre ## Demo For a practical example, look at the example XML file under `resources`. The XML file describes the format of a WASM object file:<br/> -To run the demo, run `run.sh`, go to the `test` direcotory and run `make`. Then run the executable.<br/> +To run the demo, run `run.sh`, go to the `test` direcotory and run `make test` to run the executable.<br/> +To run `valgrind --leak-check=yes` run `make valgrind`.<br/> + +## Memory Leaks +Code generated by faultreiber should not leak any memory if everything went according to plan during code-gen. If that's not the case let me knkow.<br/> + +## How to Use +A function named `read_aggr_{name}` will be generated that takes an `int _fd` file descriptor for the file that it will read.`{name}` is what you pass to faultreiber with the `--name` option.<br/> +The return type will be a C structure with type `{name}_lib_ret_t`. The struct is defined as:<br/> +```C +typedef struct { + name_obj_t obj; + void** void_train; + uint64_t* current_void_size; + uint64_t* current_void_count; +}name_lib_ret_t +``` +`{name}_obj_t` is a C structure defined in `aggregate.h` that holds all the read modules.<br/> +A function named `release_all_{name}` will be generated in `aggregate.c` that releases almost all the memory.<br/> +The proper order of realeasing the memory in the client code will be like below assuming the return value of `read_aggr_{name}` is stored in `lib_ret` and `--name` was passed a value of `wasm`:<br/> +```C +release_all_wasm(lib_ret->void_train, lib_ret->current_void_count); +free(lib_ret->obj); +free(lib_ret); +``` ### Rules: @@ -80,6 +104,7 @@ The `FT::conditional` tag for a type means that the actual content of the node w --singlefile the generated code will be put in a single file --singlefilename SINGLEFILENAME name of the single file + --name will be used in generating some code identifiers ``` @@ -88,6 +113,7 @@ Big-Endian reads are not supported.<br/> None-byte-sized raw reads are not supported.<br/> ## makefile +That would be on you but there is an example makefile in the `test` directory so you can take a look if you want.<br/> To get a list of the targets the makfile supports you can run its `help` target.<br/> ## TODO |