From 1dfdeee85deabcb964438e2a1d96eb4d6d297cfd Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Wed, 12 Sep 2018 21:02:09 +0430 Subject: update --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index a3af814..97e8ccd 100644 --- a/README.md +++ b/README.md @@ -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:
-To run the demo, run `run.sh`, go to the `test` direcotory and run `make`. Then run the executable.
+To run the demo, run `run.sh`, go to the `test` direcotory and run `make test` to run the executable.
+To run `valgrind --leak-check=yes` run `make valgrind`.
+ +## 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.
+ +## 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.
+The return type will be a C structure with type `{name}_lib_ret_t`. The struct is defined as:
+```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.
+A function named `release_all_{name}` will be generated in `aggregate.c` that releases almost all the memory.
+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`:
+```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.
None-byte-sized raw reads are not supported.
## 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.
To get a list of the targets the makfile supports you can run its `help` target.
## TODO -- cgit v1.2.3