shell bashdb debug

来源:互联网 发布:数据库系统原理 编辑:程序博客网 时间:2024/05/31 06:21
我是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 $thisString in
  6:      *"$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
原创粉丝点击