StanfordSNR / gg

The Stanford Builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add model generation for a custom binary

drunksaint opened this issue · comments

I have a custom binary that counts the number of lines from an input file and writes it to an output file:

$ fileiotest.o input.txt output.txt

Running gg infer /path/to/file/fileiotest.o input.txt output.txt seems to directly run the command instead of generating the thunks for fileiotest. I tried adding a file src/models/wrappers/fileiotest.o with the following text:

#!/bin/bash
model-generic "/path/to/file/fileiotest.o @infile @outfile" "$@"

but this too doesn't seem to generate the required thunks.
what can i do to get a custom binary working with gg?

i've attached the c file used to generate fileiotest.o if it helps (gcc -o fileiotest.o fileiotest.c)
fileiotest.c.txt

UPDATE: I got the thunk generation working. i needed to use gg infer fileiotest.o input.txt output.txt and change the permissions of the wrapper file to be an executable. But now I get the following error:

$ gg infer fileiotest.o input.txt output.txt
$ cat output.txt 
#!/usr/bin/env gg-force-and-run
ToVrXfLNBzFtE4lV.nWBkfjq8qa2I4P5w.xfGC7s1v5E0000010a
$ ./output.txt 
→ Loading the thunks...  done (0 ms).
./output.txt: execv: Exec format error

UPDATE 2: Got it working! I had to run gg force output.txt

Hi @drunksaint,

Glad you fixed the problem! Running ./output.txt will first force the thunk and then will try to execute the output, hence the execv: Exec format error.

Thank you for trying out gg, and please let us know if you face any other issues!

Best,
Sadjad

Hi @sadjad

Yeah, i figured that force and run are independent of each other. Thanks for your amazing work with this library!