Home | History | Annotate | Download | only in tests
      1 # Nonsensical program used to generate an example DWARF4 and DWARF5 file.
      2 # The generated code is the same, but the DWARF representation is different.
      3 
      4 # = hello.h =
      5 
      6 extern int m;
      7 extern int baz (int x);
      8 
      9 static inline int
     10 frob (int a, int b)
     11 {
     12   int c = a;
     13 
     14   if (a > b)
     15     c -= b;
     16 
     17   return baz (c);
     18 }
     19 
     20 # = hello.c =
     21 
     22 #include <stddef.h>
     23 #include "hello.h"
     24 
     25 extern int main (int, char **);
     26 int m = 2;
     27 
     28 wchar_t foo (wchar_t);
     29 int baz (int x)
     30 {
     31   int r = x;
     32 
     33   if (x > m)
     34     r -= m;
     35 
     36   r = foo (r);
     37   return r;
     38 }
     39 
     40 wchar_t
     41 foo (wchar_t f)
     42 {
     43   if (f < 0)
     44     return main (f, NULL);
     45 
     46   return f > 0 ? frob (f - 1, m) : 0;
     47 }
     48 
     49 # = world.c =
     50 
     51 #include "hello.h"
     52 #include <stdlib.h>
     53 
     54 int
     55 calc (const char *word)
     56 {
     57   if (word == 0 || word[0] == '\0')
     58     return 0;
     59 
     60   return frob (word[0], m + 42);
     61 }
     62 
     63 int
     64 main (int argc, const char **argv)
     65 {
     66   const char *n;
     67   if (argc > 1)
     68     n = argv[0];
     69   else
     70     n = "world";
     71 
     72   exit (calc (n));
     73 }
     74 
     75 $ gcc -gdwarf-4 -gno-as-loc-support -gno-variable-location-views -O2 -c world.c
     76 $ gcc -gdwarf-4 -gno-as-loc-support -gno-variable-location-views -O2 -c hello.c
     77 $ gcc -o testfile-dwarf-4 hello.o world.o
     78 
     79 $ gcc -gdwarf-5 -gno-as-loc-support -gno-variable-location-views -O2 -c world.c
     80 $ gcc -gdwarf-5 -gno-as-loc-support -gno-variable-location-views -O2 -c hello.c
     81 $ gcc -o testfile-dwarf-5 hello.o world.o
     82 
     83 $ gcc -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2 -o testfile-world4.o -c world.c
     84 $ gcc -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2 -o testfile-hello4.o -c hello.c
     85 $ gcc -o testfile-splitdwarf-4 testfile-hello4.o testfile-world4.o
     86 
     87 $ gcc -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2 -o testfile-world5.o -c world.c
     88 $ gcc -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2 -o testfile-hello5.o -c hello.c
     89 $ gcc -o testfile-splitdwarf-5 testfile-hello5.o testfile-world5.o
     90