From 41744019e7a0ecb666ea518c357f817acb7c23e2 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Oct 2024 05:45:55 -0400 Subject: [PATCH 1/2] https://github.com/Trepan-Debuggers/bashdb/pull/49 Add a more expansive debugger call example --- docs/entry-exit.rst | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/docs/entry-exit.rst b/docs/entry-exit.rst index 45276a2..74d97b5 100644 --- a/docs/entry-exit.rst +++ b/docs/entry-exit.rst @@ -6,9 +6,9 @@ Entering the Zsh Debugger Invoking the Debugger Initially -==================================== +=============================== -The simplest way to debug your program is to run `zshdb`. Give +The simplest way to debug your program is to run ``zshdb``. Give the name of your program and its options and any debugger options: .. code:: console @@ -35,7 +35,7 @@ the name of your program and its options and any debugger options: $ zshdb /etc/profile -For help on `zshdb` or options, use the ``--help`` option. +For help on ``zshdb`` or options, use the ``--help`` option. .. code:: console @@ -52,35 +52,46 @@ For help on `zshdb` or options, use the ``--help`` option. Calling the debugger from your program -=========================================== +====================================== + +Sometimes it is not possible to invoke the program you want debugged +from the ``zshdb``. -Sometimes it is not feasible to invoke the program from the debugger. Although the debugger tries to set things up to make it look like your -program is called, sometimes the differences matter. Also the debugger -adds overhead and slows down your program. +program is called, sometimes the differences matter. Also, once the debugger +is loaded this can slows in parts that you do not want to debug. -Another possibility then is to add statements into your program to call -the debugger at the spot in the program you want. To do this, you source -`zshdb/dbg-trace.sh` from where wherever it appears on your filesystem. +So instead, you can add statements into your program to call the +debugger at the spot in the program you want. To do this, you source +``zshdb/dbg-trace.sh`` from where wherever it appears on your filesystem. This needs to be done only once. -After that you call `_Dbg_debugger`. +After that you call ``_Dbg_debugger``. Here is an Example: .. code:: console - source path-to-zshdb/zshdb/dbg-trace.sh - # work, work, work. - # ... some zsh code + if [ "${PS1-}" ]; then + # 15 lines omitted + fi - _Dbg_debugger - # start debugging here + if [ -d /etc/profile.d ]; then + for i in /etc/profile.d/*.sh; do + if [ -r $i ]; then + if [[ $i == "/etc/profile.d/bash_completion.sh"; then + # Load in debugger + . /usr/share/bashdb/bashdb-trace -q + # Call debugger + _Dbg_debugger + fi + . $i + fi + done + unset i + fi -Since `_Dbg_debugger` a function call, it can be nested inside some sort of -conditional statement allowing one to be very precise about the -conditions you want to debug under. And until first call to `_Dbg_debugger`, -there is no debugger overhead. +Until the first call to ``_Dbg_debugger``, there is no debugger overhead. -Note that `_Dbg_debugger` causes the statement *after* the call to be stopped at. +Note that ``_Dbg_debugger`` causes the statement *after* the call to be stopped. From 0019eef55ca9411cfd511f5c1f9d63904f01b798 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Oct 2024 05:48:38 -0400 Subject: [PATCH 2/2] Correct too-short section underlines --- docs/commands/running/continue.rst | 2 +- docs/commands/set/style.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/commands/running/continue.rst b/docs/commands/running/continue.rst index ca44523..cd9e41d 100644 --- a/docs/commands/running/continue.rst +++ b/docs/commands/running/continue.rst @@ -2,7 +2,7 @@ .. _continue: Continue Program Execution (``continue``) ---------------------------------------- +----------------------------------------- **continue** [ *loc* | **-*** ] diff --git a/docs/commands/set/style.rst b/docs/commands/set/style.rst index 2bd7e0b..4e9b932 100644 --- a/docs/commands/set/style.rst +++ b/docs/commands/set/style.rst @@ -1,8 +1,8 @@ .. index:: set; style .. _set_style: -Set whether to use Pygments in Formatting Listings (`set style`) ---------------------------------------------------------------- +Set whether to use Pygments in Formatting Listings (``set style``) +------------------------------------------------------------------ **set style** [*pygments-style*]