shell bashdb debug

我是ubuntu的系统首先通过sudo apt install bashdb 按照bashdb

然后通过sudo bashdb --debug sh2 来调试sh2 这个shell脚本

下面是实际运行的结果


tao@tao-ThinkCentre-M8600t-N000:~$ sudo bashdb --debug sh2

bash debugger, bashdb, release 4.3-0.91


Copyright 2002, 2003, 2004, 2006-2012, 2014 Rocky Bernstein

This is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.


(/home/tao/sh2:3):

3:    thisString=“Hisilicon D05 UEFI 16.12 Release” # 源字符串

bashdb<0> print $thisString


bashdb<1> n

(/home/tao/sh2:4):

4:    searchString=“D05” # 搜索字符串

bashdb<2> print $thisString

Hisilicon D05 UEFI 16.12 Release

bashdb<2> l

  1:    

  2:    #!/bin/sh

  3: => thisString=“D05 UEFI 16.12 Release” # 源字符串

  4:    searchString=“D05” # 搜索字符串

  5:    case KaTeX parse error: Expected 'EOF', got '&' at position 19: …sString in<br> &̲nbsp; 6:&nbsp;&…searchString"*) echo Enemy Spot ;;

  7:      *) echo nope ;;

  8:    esac

  9:    

bashdb<3> b 5

Breakpoint 1 set in file /home/tao/sh2, line 5

bashdb<4> c

Breakpoint 1 hit (1 times).

(/home/tao/sh2:5):

5:    case $thisString in


最常用的命令是:

n:表示单步执行

print :用来打印当前变量,省去了原来用echo显示变量内容的步奏

l:列出未来10行要执行的内容

b:断点

c :继续运行到断点出。




bashdb的其他命令如下:

bashdb<0> help

Available commands:

  action     condition  edit     frame    load     run     source  unalias  

  alias      continue   enable   handle   next     search  step    undisplay

  backtrace  debug      eval     help     print    set     step-   untrace  

  break      delete     examine  history  pwd      shell   step+   up       

  clear      disable    export   info     quit     show    tbreak  watch    

  commands   display    file     kill     return   signal  trace   watche   

  complete   down       finish   list     reverse  skip    tty   


Readline command line editing (emacs/vi mode) is available.

Type “help” followed by command name for full documentation.


可以通过help 命令查询每个命令详细的说明

bashdb<1> help show

show alias       – Show list of aliases currently in effect.

show annotate    – Show annotation_level

show args        – Show argument list to give program on restart.

show autoeval    – Show if we evaluate unrecognized commands.

show autolist    – Run list before command loop?

show basename    – Show if we are are to show short or long filenames.

show commands    – commands [+|n] – Show the history of commands you typed.

You can supply a command number to start with, or a + to start after

the previous command number shown. A negative number indicates the

number of lines to list.

show copying     – Conditions for redistributing copies of debugger.

show debug       – Show if we are set to debug the debugger.

show different   – Show if debugger stops at a different line.

show directories – Show file directories searched for listing source.

show editing     – Show editing of command lines and edit style.

show highlight   – Show if we syntax highlight source listings.

show history     – Show if we are recording command history.

show listsize    – Show number of source lines debugger will list by default.

show prompt      – Show debugger prompt.

show warranty    – Various kinds of warranty you do not have.

show width       – maximum width of a line.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值