Code Monkey home page Code Monkey logo

100-gdb-tips's People

Contributors

enjolras1205 avatar franklin-qi avatar ir1d avatar jszxpan avatar junzhishen avatar nanxiao avatar teawater avatar tin-z avatar weekface avatar xanpeng avatar xingmingjie avatar zhuizhuhaomeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

100-gdb-tips's Issues

建设增加 使用文件来调试正在运行程序

-pid number
-p number
连接到进程ID 号
-command file
-x file
从file文件执行命令

ex:ps -x | grep 进程名
获取进程id 例: 2018
ex: gdb -pid 2018 -x gdb.txt

gdb.txt文件内容格式如:
b main.cpp:20
c
p a
q

本来想自己写一个md文件上传到分支的, 但创建一看, 编辑格式没找到, 上传了一个空文档

修改被调试程序的二进制文件,出现 Segmentation fault

$ gdb --write hello
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello...done.

(gdb)  disassemble /mr drawing
Dump of assembler code for function drawing:
6       {
   0x00000000000007d0 <+0>:     55      push   %rbp
   0x00000000000007d1 <+1>:     48 89 e5        mov    %rsp,%rbp
   0x00000000000007d4 <+4>:     48 83 ec 10     sub    $0x10,%rsp
   0x00000000000007d8 <+8>:     89 7d fc        mov    %edi,-0x4(%rbp)

7           if (n != 0)
   0x00000000000007db <+11>:    83 7d fc 00     cmpl   $0x0,-0x4(%rbp)
   0x00000000000007df <+15>:    74 0e   je     0x7ef <drawing+31>

8               puts ("Try again?\nAll you need is a dollar, and a dream.");
   0x00000000000007e1 <+17>:    48 8d 3d 40 01 00 00    lea    0x140(%rip),%rdi        # 0x928
   0x00000000000007e8 <+24>:    e8 53 fe ff ff  callq  0x640 <puts@plt>

9           else
10              puts ("You win $3000!");
   0x00000000000007ef <+31>:    48 8d 3d 64 01 00 00    lea    0x164(%rip),%rdi        # 0x95a
   0x00000000000007f6 <+38>:    e8 45 fe ff ff  callq  0x640 <puts@plt>

11      }
   0x00000000000007ed <+29>:    eb 0c   jmp    0x7fb <drawing+43>
   0x00000000000007fb <+43>:    90      nop
   0x00000000000007fc <+44>:    c9      leaveq
   0x00000000000007fd <+45>:    c3      retq

End of assembler dump.

(gdb) set variable *(short*)0x00000000000007df=0x0ceb
(gdb)  disassemble /mr drawing
Dump of assembler code for function drawing:
6       {
   0x00000000000007d0 <+0>:     55      push   %rbp
   0x00000000000007d1 <+1>:     48 89 e5        mov    %rsp,%rbp
   0x00000000000007d4 <+4>:     48 83 ec 10     sub    $0x10,%rsp
   0x00000000000007d8 <+8>:     89 7d fc        mov    %edi,-0x4(%rbp)

7           if (n != 0)
   0x00000000000007db <+11>:    83 7d fc 00     cmpl   $0x0,-0x4(%rbp)
   0x00000000000007df <+15>:    eb 0c   jmp    0x7ed <drawing+29>

8               puts ("Try again?\nAll you need is a dollar, and a dream.");
   0x00000000000007e1 <+17>:    48 8d 3d 40 01 00 00    lea    0x140(%rip),%rdi        # 0x928
   0x00000000000007e8 <+24>:    e8 53 fe ff ff  callq  0x640 <puts@plt>

9           else
10              puts ("You win $3000!");
   0x00000000000007ef <+31>:    48 8d 3d 64 01 00 00    lea    0x164(%rip),%rdi        # 0x95a
   0x00000000000007f6 <+38>:    e8 45 fe ff ff  callq  0x640 <puts@plt>

11      }
   0x00000000000007ed <+29>:    eb 0c   jmp    0x7fb <drawing+43>
   0x00000000000007fb <+43>:    90      nop
   0x00000000000007fc <+44>:    c9      leaveq
   0x00000000000007fd <+45>:    c3      retq

End of assembler dump.
(gdb) q
Segmentation fault

有些重要的介绍的还太浅

感觉有些实用的东西,比如core dump文件的分析,这在调试工程中是重点分析对象,应该介绍怎样用where、bt等命令分析core dump,从而找出问题所在,这才是关键呢。

set step-mode off 无效

我阅读了“step-and-next-function.md” 以后,
如果函数没有调试信息,我就希望step不要进入函数里面去,
可是,我执行set step-mode off 以后,却发现step,依旧可以进入printf,printf是没有调试信息的函数,
请问是为啥呢?有什么办法可以,让step不要进入没有调试信息的函数里面去吗?

(gdb) set step-mode off 
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/lc/Desktop/a.out 

Breakpoint 1, main () at ss.c:13
13	int main(void) {
(gdb) s
14	        ex_st st = {1, 2, 3, 4, PTHREAD_MUTEX_INITIALIZER};
(gdb) 
15	        printf("%d,%d,%d,%d\n", st.a, st.b, st.c, st.d);
(gdb) 
__printf (format=0x4006d4 "%d,%d,%d,%d\n") at printf.c:28
28	printf.c: No such file or directory.
(gdb) 

Better if publish it as a web site

It's inconvenient for us to view the tips. As we should 1) clone the repository, 2) prepare go build environment, 3) generate html files.

So maybe it's better to publish it as a site (e.x., 100-gbd-tips.github.io). Two ways to do this:

  • Contributor submit new tips by pull requests, repository owner merge commits, generate html and publish it.
  • Use jekyll instead of md2min, which need to change format of existing markdown files.

Example: https://github.com/sib9/cpp1x-study-resource

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.