GDB Common Commands

Source: Internet
Author: User
Tags strcmp

Find./-name "*.sql" | awk ' {cmd_str= ' \ ' "" "" "" "" "; print Cmd_str} ' | Xargs Grep-rn Ifusedestroute

Dir/v8t/ngtf/server/trade_server: $cdir: $CWD
Break commit_mq_thread.cpp:59 if (processing_idx==636645)

Dir/tmp/src/data_pump: $cdir: $CWD
DIR/HOME/YONG.LIU2/SRC/ARCH/OFFER2/OFFER/EXCH_MARKET/OFFER_TEST/RECV_CZCEMD: $cdir: $CWD
Break zk_mgr.cpp:210
Break zk_mgr.cpp:902

Gdb-c core File Execution file #查看core文件

Gdb-d/tmp/jinyuankehuwenti/src_v8t/product/v8t/trade_server:/tmp/jinyuankehuwenti/src_v8t/ngtf/server/trade_ Server Trade_server
>dir/tmp/jinyuankehuwenti/src_v8t/product/v8t/trade_server:/tmp/jinyuankehuwenti/src_v8t/ngtf/server/trade_ Server: $cdir: $CWD #设置源代码路径
Break process_thread.cpp:123 if ((info.serialno==660390))
>break public_business.cpp:8321 if (fldcancelreturnreq.entrust_no==1)
>display Fldshmargindissyn.bs_margin_flag
>break public_business.cpp:5774 if ((cur_serial>=854398) && (cur_serial<=85502))
Break sync_hold_handle.cpp:5290 if ((strcmp (Req.tx_no.buf, "02200667") ==0) && (strcmp (Req.contract_code.buf, "ag1512") ==0))

Dir/tmp/offer:/tmp/offer/zk_2: $cdir: $CWD
Break zk_mgr.cpp:1153

Gdb-d/tmp/v8t_8316_test/src/product/v8t/trade_server Trade_server

gdb-d {src path} program name |;| Core file
>start #开始运行并在main中停止
>dir/tmp/v8t_8316_test/src/product/v8t/trade_server:/tmp/v8t_8316_test/src/ngtf/server/trade_server/: $cdir: $CWD #设置源代码路径
>list Cappserver::run () #查看源代码
>ctrl+x+a #显示/Hidden graphics
> Break appserver.cpp:318 if ((serialno==101475) | | (serialno==105431)) #条件断点

Break process_thread.cpp:123 if (nextsequence==25528)

Break appserver.cpp:238
> Break public_business.cpp:5933 if (flddonereturnreq.entrust_no==151940)
> Break order_manage.cpp:2045 if (strcmp (Fldfundreq.cust_no, "1001101771") ==0)
Break order_manage.cpp:12530
>break appserver.cpp:318 if ((serialno>=1023942)) # ((serialno>=1048506))
Break public_business.cpp:10088 if (strcmp (Flddonereturnreq.exch_done_no, "00000594") ==0)
(GDB) call Close (1)
(GDB) call Close (2)
(GDB) Shell TTY
/dev/pts/0
(GDB) Call Open ("/dev/pts/0", 2)
(GDB) Call Open ("/dev/pts/0", 2)

>dir/tmp/v8t_src/v8t_8311/product/v8t/trade_bu
>break entrust.cpp:78
> Break module_func.cpp:1258
Break trade_pub.cpp:14562
Break P_cal_can_open_qty

1. Command: File file name
Function: Loads the specified executable file into gdb;

Command:-d {Directory}
-directory={directory}
Function: Specify the path where the source and header files are located

Command: Set args run parameter
Show args
Features: Set or view run parameters

Command: path [directory] #把目录directory加入到搜索可执行文件和符号文件的路径中
Show Paths #查看程序的运行路径.
Function: Set or view program run path

Command:-cd={directory}
Function: Runs GDB with the specified directory as the current path

Command:
Set environment varname [=value] #设置环境变量. such as: Set env User=hchen
Show environment [VarName] #查看环境变量.
Features: setting or viewing environment variables

Command: CD

Command:
Attach
Detach
Features: hooking/canceling a hooked up process

Command: Info program #查看程序的是否在运行, process number
Info break [n] #查看断点
info breakpoints [n]
Info watchpoints #列出当前设置的所有观察点
Info Locals #打印出当前函数中所有局部变量及其值
Info Catch #打印出当前的函数中的异常处理信息
info [Files/share] #列出当前的文件, shared library
Function: Check whether the program is running, process number

Command:?????
Function: Specify working directory, run parameters

Command:?????
Features: loading executables or dependent dynamic libraries




Command: List
Function: View Source code

Command:?????
Function: View the source code of the specified file, specified location, or function


Command: B/break [line number] #设置断点
B/break [function name] #设置断点
B/break [+/-]offset
B/break File:func | File:nth
B/break *address
B/break Line-number If condition
B/break Line Threadthread-number
Tbreak #设置临时的断点. Breakpoints are deleted after one break
Command: D/delete [Breakpoint-number] #删除所有断点
D/delete [Range]
Clear Func #清除函数func处的断点
Clear Nth #清除第nth行处的断点
Disable [Breakpoint-number | range] #
Enable [Breakpiont-number | range] #
Enable once Breakpint-number #设置指定断点有效 when the breakpoint is reached is invalid
Enable del Breakpiont-number #设置指定断点有效 to delete a breakpoint when it is reached

Command: Condition <break_list Breakpoint Number list > (condition condition)
Features: such as cond 4 i==3 add interrupt condition on breakpoint 4



Command: Run
Function: Run

Command: Start
Function: Run, single stop at main;

Command: C
Function: Continue running until end or hit breakpoint

Command: N/next
N/next number
Functions: Single Step execution

Command: Step
S/step Number-of-steps-to-perform #
Function: Enter function execution

Command: Finish
Function: Runs the program until the current function finishes returning.
and prints information such as the stack address and return value and parameter values when the function returns

Command: U/until #当你厌倦了在一个循环体内单步跟踪时, this command can run the program until you exit the loop body
U/until Line-number #继续运行直到到达指定行号, or functions, addresses, etc.
U/until Line-number ifcondition
Function: When you are tired of stepping through a loop, this command can run the program until you exit the loop body

Command: Bt/backtrace [n]
Function: Prints all the information of the current function call stack
n is a positive integer representing only the stack information at the top n-tier of the stack


Command:
Watch #为表达式 (variable) expr sets an observer point. Stop the program as soon as the value of an expression changes
Rwatch #当表达式 (variable) when expr is read, stop the program
Awatch the value of the #当表达式 (variable) is read or written, stop the program.

Command:
Display #程序停止时显示变量和表达时
Info display #显示当前所有的要显示值的表达式.
Delete Display/undisplay [expression number] #删除要显示值的表达式
Disable display [expression number] #暂时不显示一个要表达式的值
The Enable display expression number #与disable display instead, use an expression to resume displaying
Whatis #显示变量或函数类型
PType #比whatis的功能更强 that he could provide a definition of a structure

Second, remote debugging
1. Service-side
gdbserver:2345 [Options] Trade_server-b
gdbserver [Options] COMM PROG [ARGS ...]
Gdbserver []--attach COMM PID
Gdbserver []--multi COMM

Options:
--debug
--remote-debug Enable remote protocol debugging output.
2. Client
Gdb
> Target Remote Ip:port

Break public_business.cpp:14746 if (strcmp (Cust_no, "82070418") ==0)
Break order_manage.cpp:2103 if (strcmp (Req_vector[0].all_contract_code.getvalue (), "sr1705-c-7000") ==0)
Break order_manage.cpp:753
Break match_return.cpp:235
Break public_business.cpp:6715

GDB Common Commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.