Skip to content
Toby Ho edited this page Feb 8, 2020 · 2 revisions

Here is the Hello World example.

The sample code

01. #include <stdio.h>
02. 
03. int main(int argc, char *argv[])
04. {
05.    int ret;
06.
07.    printf("Hello ");
08.    ret = printf("World!\n");
09.
10.    return ret;
11. }

We can see that the source line numbers affect the return statement are: 8 10

Run the hello world example

Steps behind the Make command

  • Generate hello-world.bc file from source code by clang
  • Run the trace-giri pass to instrument the trace code of each basic block
  • Generate the instrumented executable file by clang++
  • Run the executable file (named hello-world.trace.exe), which will dump the hello-world.trace file containg Basic Block records.
  • Run the dgiri pass to do the dynamic slicing with trace files and dump the dynamic trace file in the hello-world.slice file
  • Post-process the hello-world.slice file and dump the source code line number

Dive Further

Now we rely on the default behavior of slicing criterion, which is the first return statement in the main function. You can also explore the start-slice option to specify the function name and the instruction number as the criterion, i.e. the starting point. See more examples.