zoukankan      html  css  js  c++  java
  • remote gdb

    https://blog.csdn.net/snow_5288/article/details/72982594
    https://alex.dzyoba.com/blog/gdb-source-path/

    gdb调试多进程与多线程

    moonx@moonx:/usr/download/test/mygcc$ cat testthread.cc -n
         1    // thread example
         2    #include <iostream>       // std::cout
         3    #include <thread>         // std::thread
         4     
         5    void foo() 
         6    {
         7      // do stuff...
         8    }
         9    
        10    void bar(int x)
        11    {
        12      // do stuff...
        13    }
        14    
        15    int main() 
        16    {
        17      std::thread first (foo);     // spawn new thread that calls foo()
        18      std::thread second (bar,0);  // spawn new thread that calls bar(0)
        19    
        20      std::cout << "main, foo and bar now execute concurrently...
    ";
        21    
        22      // synchronize threads:
        23      first.join();                // pauses until first finishes
        24      second.join();               // pauses until second finishes
        25    
        26      std::cout << "foo and bar completed.
    ";
        27      while(1) std::cout << "dddd" << std::endl;
        28      return 0;
        29    }
    
    
    moonx@moonx:/usr/download/test/mygcc$ ps aux |grep a.out 
    moonx 21046 0.0 0.0 15976 976 pts/22 S+ 11:34 0:00 grep --color=auto a.out
    moonx@moonx:/usr/download/test/mygcc$ gdbserver 192.168.3.199:8084 nohup ./a.out &
    [1] 21068
    moonx@moonx:/usr/download/test/mygcc$ Process nohup created; pid = 21073
    Listening on port 8084
    Remote debugging from host 192.168.5.45
    nohup: ignoring input and appending output to 'nohup.out'
    
    
    moonx@moonx:/usr/download/test/mygcc$ tail -f nohup.out 
    
    main, foo and bar now execute concurrently...
    foo and bar completed.
    dddd
    dddd
    dddd
    dddd
    dddd
    dddd
    dddd
    dddd
    dddd
    dddd
    yangpeng@mx:~/develop/apollo$ gdb
    GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
    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".
    (gdb) target remote 192.168.3.199:8084
    Remote debugging using 192.168.3.199:8084
    Reading /usr/bin/nohup from remote target...
    warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
    Reading /usr/bin/nohup from remote target...
    Reading symbols from target:/usr/bin/nohup...Reading /usr/bin/a35c78152db5d2034893ca21a04cc8ab08094f.debug from remote target...
    Reading /usr/bin/.debug/a35c78152db5d2034893ca21a04cc8ab08094f.debug from remote target...
    (no debugging symbols found)...done.
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading symbols from target:/lib64/ld-linux-x86-64.so.2...Reading /lib64/ld-2.23.so from remote target...
    Reading /lib64/.debug/ld-2.23.so from remote target...
    (no debugging symbols found)...done.
    0x00007ffff7dd7c30 in ?? ()
       from target:/lib64/ld-linux-x86-64.so.2
    (gdb) list
    No symbol table is loaded.  Use the "file" command.
    (gdb) b main
    Function "main" not defined.
    Make breakpoint pending on future shared library load? (y or [n]) y
    Breakpoint 1 (main) pending.
    (gdb) b testthread.cc:27
    No symbol table is loaded.  Use the "file" command.
    Make breakpoint pending on future shared library load? (y or [n]) y
    Breakpoint 2 (testthread.cc:27) pending.
    (gdb) c
    Continuing.
    Reading /lib/x86_64-linux-gnu/libc.so.6 from remote target...
    Reading /lib/x86_64-linux-gnu/libc-2.23.so from remote target...
    Reading /lib/x86_64-linux-gnu/.debug/libc-2.23.so from remote target...
    warning: the debug information found in "/usr/lib/debug/lib/x86_64-linux-gnu//libc-2.23.so" does not match "target:/lib/x86_64-linux-gnu/libc.so.6" (CRC mismatch).
    
    process 21073 is executing new program: /usr/download/test/mygcc/a.out
    Reading /usr/download/test/mygcc/a.out from remote target...
    Reading /usr/download/test/mygcc/a.out from remote target...
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading /lib64/ld-2.23.so from remote target...
    Reading /lib64/.debug/ld-2.23.so from remote target...
    Reading /usr/lib/x86_64-linux-gnu/libstdc++.so.6 from remote target...
    Reading /lib/x86_64-linux-gnu/libgcc_s.so.1 from remote target...
    Reading /lib/x86_64-linux-gnu/libpthread.so.0 from remote target...
    Reading /lib/x86_64-linux-gnu/libc.so.6 from remote target...
    Reading /lib/x86_64-linux-gnu/libm.so.6 from remote target...
    Reading /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 from remote target...
    Reading /usr/lib/x86_64-linux-gnu/.debug/libstdc++.so.6.0.21 from remote target...
    Reading /lib/x86_64-linux-gnu/.debug/libgcc_s.so.1 from remote target...
    Reading /lib/x86_64-linux-gnu/7c21299099640a6d863e423d99265824e7bb16.debug from remote target...
    Reading /lib/x86_64-linux-gnu/.debug/7c21299099640a6d863e423d99265824e7bb16.debug from remote target...
    Reading /lib/x86_64-linux-gnu/libc-2.23.so from remote target...
    Reading /lib/x86_64-linux-gnu/.debug/libc-2.23.so from remote target...
    warning: the debug information found in "/usr/lib/debug/lib/x86_64-linux-gnu//libc-2.23.so" does not match "target:/lib/x86_64-linux-gnu/libc.so.6" (CRC mismatch).
    
    Reading /lib/x86_64-linux-gnu/libm-2.23.so from remote target...
    Reading /lib/x86_64-linux-gnu/.debug/libm-2.23.so from remote target...
    warning: the debug information found in "/usr/lib/debug/lib/x86_64-linux-gnu//libm-2.23.so" does not match "target:/lib/x86_64-linux-gnu/libm.so.6" (CRC mismatch).
    
    
    Breakpoint 1, main () at testthread.cc:16
    16    testthread.cc: No such file or directory.
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) list
    22    in testthread.cc
    (gdb) list
    22    in testthread.cc
    (gdb) list
    22    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) cc
    Undefined command: "cc".  Try "help".
    (gdb) 
    Undefined command: "cc".  Try "help".
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) c
    Continuing.
    
    Breakpoint 2, main () at testthread.cc:27
    27    in testthread.cc
    (gdb) 
  • 相关阅读:
    在线加密解密
    ctcms Nginx 伪静态
    iTem2 保持连接,解决ssh的"Write failed: Broken pipe"问题
    打开窗口弹出页面
    点击弹窗
    javascript 技巧
    使用Chrome工具来分析页面的绘制状态
    jquery结合JSONP教程—明河谈jquery
    使用 JSONP 实现跨域通信,第 1 部分: 结合 JSONP 和 jQuery 快速构建强大的 mashup
    jsonp详解
  • 原文地址:https://www.cnblogs.com/cjyp/p/11770336.html
Copyright © 2011-2022 走看看