@@ -4,6 +4,61 @@ Entering the Bash Debugger
44.. toctree::
55.. contents::
66
7+ Startup Behavior
8+ ================
9+
10+ You can customize bashdb's initialization process such as setting up
11+ breakpoints to facilitate complex issue trouble shooting. This can be achieved
12+ by creating per-user or per-project rc files named ``.bashdbrc`` under your
13+ home directory or any directory in your project. The per-user rc file is loaded
14+ first, followed by the per-project rc file. Therefore, you can override
15+ settings in your per-project ``.bashdbrc`` file.
16+
17+ The follow code snippet demonstrates a per-project ``.bashdbrc`` with a few
18+ breakpoints configured:
19+
20+ .. code:: console
21+
22+ $ cd my-project
23+ $ cat .bashdbrc
24+
25+ # explicit load is required to make
26+ # code in this file available to bashdb
27+ load ./libs/functions.sh
28+ break ./main.sh:13 $cmd == "start"
29+ break ./libs/functions.sh:332
30+
31+ Currently explicit loading of programs invoked by main script is required.
32+ Therefore, in this example, the ``load`` command makes the code defined in the
33+ ``libs/functions.sh`` available to the debugging session. Once the per-project
34+ ``.bashdbrc`` is configured, you can launch the debugger under the directory
35+ where the ``.bashdbrc`` located as follows:
36+
37+ .. code:: console
38+
39+ $ bashdb main.sh start
40+
41+ bash debugger, bashdb, release 5.2-1.1.2
42+
43+ Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021, 2023-2024 Rocky Bernstein
44+ This is free software, covered by the GNU General Public License, and you are
45+ welcome to change it and/or distribute copies of it under certain conditions.
46+
47+ (/home/user/my-project/main.sh:3):
48+ 3: source ./libs/functions.sh
49+ File /home/user/my-project/libs/functions.sh loaded.
50+ Breakpoint 1 set in file /home/user/my-project/libs/functions.sh, line 332.
51+ Breakpoint 2 set in file /home/user/my-project/main.sh, line 13.
52+ bashdb<4> info breakpoints
53+ Num Type Disp Enb What
54+ 1 breakpoint keep y /home/user/my-project/libs/functions.sh:332
55+ 2 breakpoint keep y /home/user/my-project/main.sh:13
56+ stop only if $cmd == "start"
57+
58+ In this example, bashdb shows the two breakpoints presetted by the
59+ ``.bashdbrc`` file when it finishes startup. The ``info breakpoints`` command,
60+ abbreviated as ``i b``, reveals the second breakpoint is a conditional
61+ breakpoint.
762
863Invoking the Debugger Initially
964===============================
0 commit comments