Debian Codegraph @

tools/cgreen-debug.argbash

raw
1 #!/bin/bash
2 # cgreen-debug
3 #
4 # Script to start cgreen-runner under gdb, load a library and break
5 # on a named test.
6 #
7
8 # If you are viewing 'cgreen-debug' this *is* that script and you'll
9 # find the logic at the end of this file. To update it, edit
10 # `cgreen-debug.argbash` instead.
11
12 # But if you are looking at 'cgreen-debug.argbash' then this is
13 # actually a template for argbash (https://argbash.io) which generates
14 # argument parsing capable bash scripts from a template just like
15 # this.
16
17 # To generate a new 'cgreen-debug' use
18 #
19 # 'argbash cgreen-debug.argbash -o cgreen-debug'
20 #
21 # if you have argbash installed, or go to https://argbash.io and paste
22 # this file into the online version.
23
24 # ARG_HELP([Start cgreen-runner under GDB (or other debugger) and break at a specific test])
25 # ARG_OPTIONAL_SINGLE([debugger], d, [The debugger to use], [cgdb])
26 # ARG_POSITIONAL_SINGLE([library], [Dynamically loadable library with Cgreen tests], )
27 # ARG_POSITIONAL_SINGLE([testname], [The test to debug, in Cgreen notation ('<Context>:<test>')], )
28 # ARGBASH_GO
29
30 # [ <-- needed because of Argbash
31
32 if [ "$_arg_debugger" == "" ]; then
33 if command -v cgdb > /dev/null 2>&1 ; then
34 debugger=cgdb
35 else
36 debugger=gdb
37 fi
38 else
39 if command -v $_arg_debugger > /dev/null 2>&1 ; then
40 debugger=$_arg_debugger
41 else
42 echo "No such debugger: $_arg_debugger"
43 exit 1
44 fi
45 fi
46
47 # Figure out where to place breakpoint by replacing ':' with '__'
48 bp=${_arg_testname//:/__}
49
50 if [ "$debugger" == "lldb" ] ; then
51 echo break set -n $bp > .cgreen-debug-commands
52 echo run $_arg_library $_arg_testname >> .cgreen-debug-commands
53 $debugger cgreen-runner --source .cgreen-debug-commands
54 else
55 echo break $bp > .cgreen-debug-commands
56 echo run $_arg_library $_arg_testname >> .cgreen-debug-commands
57 $debugger -ex "set breakpoint pending on" cgreen-runner --command=.cgreen-debug-commands
58 fi
59
60 rm .cgreen-debug-commands
61
62 # ] <-- needed because of Argbash