First steps (Tutorial)ΒΆ

The following tutorial illustrates basic usage of bjoern. You will learn how to start the server, import code, spawn a bjoern-shell and run queries against the database.

  1. Begin by starting the bjoern-server:
./bjoern-server.sh

This starts an orientDB server instance, along with the OrientDB Studio on port 2480. Studio provides a useful interface to explore the database contents (see http://orientdb.com/docs/last/Home-page.html).

  1. In another shell, import some code
./bjoern-import.sh /bin/ls

This will start a thread inside the server process which performs the import. You will see an ‘Import finished’ message in the server log upon completion.

  1. Create a shell thread using bjosh
bjosh create
  1. Connect to the shell process using bjosh
bjosh connect
  1. Get names of all functions (sample query)
 _     _           _
| |__ (_) ___  ___| |__
| '_ \| |/ _ \/ __| '_ \
| |_) | | (_) \__ \ | | |
|_.__// |\___/|___/_| |_|
     |__/     bjoern shell


bjoern> queryNodeIndex('nodeType:Func').repr
  1. Get all calls
getCallsTo('').map
  1. Get basic blocks containing calls to ‘malloc’
getCallsTo('malloc').in('IS_BB_OF').repr
  1. Walk to first instruction of each function
getFunctions('').funcToInstr().repr