Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fuzz_parser.cpp File Reference
#include <sysio/wasm_backend/parser.hpp>
#include <fstream>
#include <iostream>
#include <chrono>
Include dependency graph for fuzz_parser.cpp:

Go to the source code of this file.

Functions

std::vector< uint8_tread_wasm (const std::string &fname)
 
int main (int argc, const char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
const char * argv[] )

Definition at line 34 of file fuzz_parser.cpp.

34 {
35 high_resolution_clock::time_point start;
36 try {
37 memory_manager::set_memory_limits( 128*1024, 64*1024 );
38 binary_parser bp;
39 module mod;
41 start = high_resolution_clock::now();
42 bp.parse_module( test, mod );
43 } catch (fc::exception& e) {
44 std::cout << "FAIL : " << e.what() <<"\n";
45 }
46 auto stop = high_resolution_clock::now();
47 auto duration = duration_cast<microseconds>(stop - start);
48 std::cout << "TIME : " << duration.count() << "us\n";
49
50#if 0
51 catch ( wasm_parse_exception& ex ) {
52 } catch ( wasm_interpreter_exception& ex ) {
53 } catch ( wasm_section_length_exception& ex ) {
54 } catch ( wasm_bad_alloc& ex ) {
55 } catch ( wasm_double_free& ex ) {
56 } catch ( wasm_vector_oob_exception& ex ) {
57 } catch ( wasm_memory_exception& ex ) {
58 } catch ( wasm_unsupported_import_exception& ex ) {
59 } catch ( wasm_illegal_opcode_exception& ex ) {
60 } catch ( guarded_ptr_exception& ex ) {
61 }
62#endif
63}
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
const char * what() const noexcept override
std::vector< uint8_t > read_wasm(const std::string &fname)
char ** argv
static const Reg16 bp(Operand::BP)
std::vector< uint8_t > wasm_code
Definition types.hpp:147
@ test
Unit testing utility error code.
Definition error.hpp:96
Here is the call graph for this function:

◆ read_wasm()

std::vector< uint8_t > read_wasm ( const std::string & fname)

Definition at line 11 of file fuzz_parser.cpp.

11 {
12 std::ifstream wasm_file(fname, std::ios::binary);
13 FC_ASSERT( wasm_file.is_open(), "wasm file cannot be found" );
14 wasm_file.seekg(0, std::ios::end);
15 std::vector<uint8_t> wasm;
16 int len = wasm_file.tellg();
17 FC_ASSERT( len >= 0, "wasm file length is -1" );
18 wasm.resize(len);
19 wasm_file.seekg(0, std::ios::beg);
20 wasm_file.read((char*)wasm.data(), wasm.size());
21 wasm_file.close();
22 return wasm;
23}
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
size_t len
Here is the caller graph for this function: