Because I still fighting with endless variants of unnamed types while processing linux kernel lets talk about persistence
The final goal of this plugin is to make from sources database of functions for methods they call and fields they use. After that you can find set of functions referring to some field/method and investigate them later with disasm for example
So sure plugin must store it`s results to somewhere
Probably graph databases is better suited for such data - like you can put symbols as vertices and references as edges, then all references to some symbol is just all of it`s incoming edges. But I am too lazy to install JVM and Neo4j, so I used SQLite (and simple YAML-like files for debugging). You can connect your own storage by implementing interface FPersistence
Details of most important methods from this interface
int connect(const char *path, const char *username, const char *password)
called during plugin initialization to connect to database.
path passed via plugin parameter -fplugin-arg-gptest-db
username passed via plugin parameter -fplugin-arg-gptest-user
passwordpassed via plugin parameter -fplugin-arg-gptest-password
method must return 0 if connection was successfully established
void cu_start(const char *filename)
called from PLUGIN_START_UNIT callback, so passed filename can be relative. Probably better to use function realpath to get full name of file
int func_start(const char *funcname)
called when plugin starts processing of next function, funcname is mangled name of function. If you don`t want to process this function method can just return non-zero value
void bb_start(int idx)
Basic blocks in gcc differs from what you can see in IDA Pro - they ends on first jump, if this is conditional jump then block will have two ongoing edges - to some other block and so called FALLTHRU to the next
idx is just index of basic block
void add_xref(xref_kind, const char *symname)
main method, called when plugin found in currently processing function cross-reference to something (usually even with symbol name)
void report_error(const char *err_msg)
I decided that it would be convenient to put errors in log/database, so this method called when plugin was unable to find something (like name of nameless structure when access to it`s field occurred and so on)
Комментариев нет:
Отправить комментарий