gdb教程:4. How do I use breakpoints?
来源:互联网 发布:mac安全控件 编辑:程序博客网 时间:2024/05/22 00:32
Breakpoints are a way of telling gdb that you want it to stop your program at certain lines of code. You can also have it stop when your program makes specific function calls. Once the program is stopped, you can poke around in memory and see what the values of all your variables are, examine the stack, and step through your program's execution.
4.1 How do I set a breakpoint on a line?
The command to set a breakpoint is break. If you only have one source file, you can set a breakpoint like so:
(gdb) break 19Breakpoint 1 at 0x80483f8: file test.c, line 19
If you have more than one file, you must give the break command a filename as well:
(gdb) break test.c:19Breakpoint 2 at 0x80483f8: file test.c, line 19
4.2 How do I set a breakpoint on a C function?
To set a breakpoint on a C function, pass it's name to break.
(gdb) break func1Breakpoint 3 at 0x80483ca: file test.c, line 10
4.3 How do I set a breakpoint on a C++ function?
Setting a breakpoint on a C++ function is similar to setting a breakpoint on a C function. However C++ is polymorphic, so you must tell break which version of the function you want to break on (even if there is only one). To do this, you tell it the list of argument types.
(gdb) break TestClass::testFunc(int) Breakpoint 1 at 0x80485b2: file cpptest.cpp, line 16.
4.4 How do I set a temporary breakpoint?
Use the tbreak command instead of break. A temporary breakpoint only stops the program once, and is then removed.
4.5 How do I get a list of breakpoints?
Use the info breakpoints command.
(gdb) info breakpointsNum Type Disp Enb Address What2 breakpoint keep y 0x080483c3 in func2 at test.c:53 breakpoint keep y 0x080483da in func1 at test.c:10
4.6 How do I disable breakpoints?
Use the disable command. Pass the number of the breakpoint you wish to disable as an argument to this command. You can find the breakpoint number in the list of breakpoints, as shown above. In the example below we can see that breakpoint number 2 has been disabled (there is an 'n' under the Enb column).
(gdb) disable 2(gdb) info breakpointsNum Type Disp Enb Address What2 breakpoint keep n 0x080483c3 in func2 at test.c:53 breakpoint keep y 0x080483da in func1 at test.c:10
4.7 How do I skip breakpoints?
To skip a breakpoint a certain number of times, we use the ignore command. Theignore command takes two arguments: the breakpoint number to skip, and the number of times to skip it.
(gdb) ignore 2 5Will ignore next 5 crossings of breakpoint 2.
- gdb教程:4. How do I use breakpoints?
- gdb教程:1. How do I use gdb?
- gdb教程:5. How do I use watchpoints?
- How do I use gcc, g++, and gdb?
- How do I use gcc, g++, and gdb?
- How do I use IStream?
- How do I set breakpoints in modal dialogs?
- How do I use Cygwin in Geophysics ?
- UE4 How do I use InstancedStaticMeshes ?
- ActiveMQ - How do I use SSL
- gdb教程:2. How do I watch the execution of my program?
- How do I use software from a PPA?
- How do I use WPF bindings with RelativeSource?
- What is a cronjob and how do I use it?
- How do I use Form authentication with Tomcat?
- How do I use Spring Property Placeholder with Camel XML
- How do I find which phpize to use?
- How do I use “slice_before” with initial_state in Ruby 1.9?
- Tomcat7.0配置
- Linux环境变量的设置和查看方法
- oracle partition table related operations
- PHP 迭代器
- 为UITableView的列设置间隔颜色
- gdb教程:4. How do I use breakpoints?
- memcached原理结构图详解
- 【Android】获取手机中已安装apk文件信息(PackageInfo、ResolveInfo)(应用图片、应用名、包名等)
- Java内部类及匿名内部类
- 慧都独家揭秘十大Mac和iOS应用开发工具
- gdb教程:5. How do I use watchpoints?
- keil 软件的使用注意事项(持续更新中)
- 多线程的一些小问题集锦
- Objective-C特点及特征