• <i id='G2GcT'><tr id='G2GcT'><dt id='G2GcT'><q id='G2GcT'><span id='G2GcT'><b id='G2GcT'><form id='G2GcT'><ins id='G2GcT'></ins><ul id='G2GcT'></ul><sub id='G2GcT'></sub></form><legend id='G2GcT'></legend><bdo id='G2GcT'><pre id='G2GcT'><center id='G2GcT'></center></pre></bdo></b><th id='G2GcT'></th></span></q></dt></tr></i><div id='G2GcT'><tfoot id='G2GcT'></tfoot><dl id='G2GcT'><fieldset id='G2GcT'></fieldset></dl></div>
  • <tfoot id='G2GcT'></tfoot>
      • <bdo id='G2GcT'></bdo><ul id='G2GcT'></ul>
    1. <legend id='G2GcT'><style id='G2GcT'><dir id='G2GcT'><q id='G2GcT'></q></dir></style></legend>

      <small id='G2GcT'></small><noframes id='G2GcT'>

        GDB 抱怨缺少 raise.c

        时间:2023-08-03
        <tfoot id='j2DWs'></tfoot>

        • <bdo id='j2DWs'></bdo><ul id='j2DWs'></ul>

              <legend id='j2DWs'><style id='j2DWs'><dir id='j2DWs'><q id='j2DWs'></q></dir></style></legend>

              <i id='j2DWs'><tr id='j2DWs'><dt id='j2DWs'><q id='j2DWs'><span id='j2DWs'><b id='j2DWs'><form id='j2DWs'><ins id='j2DWs'></ins><ul id='j2DWs'></ul><sub id='j2DWs'></sub></form><legend id='j2DWs'></legend><bdo id='j2DWs'><pre id='j2DWs'><center id='j2DWs'></center></pre></bdo></b><th id='j2DWs'></th></span></q></dt></tr></i><div id='j2DWs'><tfoot id='j2DWs'></tfoot><dl id='j2DWs'><fieldset id='j2DWs'></fieldset></dl></div>
              • <small id='j2DWs'></small><noframes id='j2DWs'>

                    <tbody id='j2DWs'></tbody>
                • 本文介绍了GDB 抱怨缺少 raise.c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  每次 gdb 捕获异常时,我都会收到一个烦人的错误.我已经运行了以下示例程序

                  #include int main() {抛出 std::invalid_argument("");返回0;}

                  运行 gdb 的结果是

                   在抛出一个 'std::invalid_argument' 实例后调用终止什么():程序收到信号 SIGABRT,中止.__GI_raise (sig=sig@entry=6) 在 ../sysdeps/unix/sysv/linux/raise.c:5151 ../sysdeps/unix/sysv/linux/raise.c:没有这样的文件或目录.

                  这还不算太糟,因为我确实得到了我需要的信息,只是让我烦恼...

                  有人知道如何解决这个问题吗?

                  解决方案

                  要在 Ubuntu 上对 C 库进行完整的源代码调试,只需几个步骤:

                  1. 安装 libc6 的 debuginfo 版本.

                    它可能已经安装 - Ubuntu 上的 gdb 软件包依赖于它 - 但如果没有,请运行 sudo apt install libc6-dbg.

                  2. 准备包系统以下载和处理源代码包(如果之前尚未完成).

                    sudo apt install dpkg-devgrep deb-src/etc/apt/sources.list

                    Grep 的输出应该显示(并且可能还有我们不需要担心的其他匹配项):

                    <块引用>

                    deb-src http://archive.ubuntu.com/ubuntu/bionic main 受限deb-src http://archive.ubuntu.com/ubuntu/bionic-updates main 受限

                    如果 grep 显示这些 deb-src 行用 # 注释掉:

                    <块引用>

                    # deb-src http://archive.ubuntu.com/ubuntu/bionic main 受限# deb-src http://archive.ubuntu.com/ubuntu/bionic-updates main 受限

                    然后编辑/etc/apt/sources.list删除这些行开头的#,然后运行sudo apt update.

                  3. 下载与安装的C库版本对应的源代码.

                    首先,在任何地方创建一个目录 - 我将在这里使用 /opt/src.

                    然后执行以下操作:

                    cd/opt/srcapt源libc6

                    如果 apt 命令给出类似

                    的错误信息<块引用>

                    E:您必须在您的 sources.list 中放入一些源"URI

                    那么我在第 2 步中的说明可能已经过时了;在这里发表评论.

                    下载完成后,运行:

                    find $PWD -maxdepth 1 -type d -name 'glibc*'

                    记住这个名字 - 它类似于 /opt/src/glibc-2.23

                  4. 确定 gdb 希望在哪里找到源代码并进行适当的调整.

                    运行 gdb,让它运行你的程序直到它停止,然后在 gdb 提示符下执行以下操作:

                    (gdb) 信息源当前源文件是 ../sysdeps/unix/sysv/linux/raise.c编译目录为/build/glibc-KM3i_a/glibc-2.23/signal

                    所以 gdb 期望源代码在 /build/glibc-KM3i_a/glibc-2.23 中.有两种方法可以解决此问题:

                    • 移动(或使用符号链接)使源代码位于(或看起来)位于 /build/glibc-KM3i_a/glibc-2.23 中.

                      或者

                    • 告诉 gdb 如何替换正确的源目录路径名:

                      (gdb) 设置替代路径/build/glibc-KM3i_a/glibc-2.23/opt/src/glibc-2.23

                    现在,回到你的框架,gdb 应该显示源代码行:

                    (gdb) 第 1 帧#1 0xb7e2fea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54返回 INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);

                  I'm getting an an annoying error every time gdb catches an exception. I've run the following example program

                  #include <stdexcept>
                  
                  int main() {
                    throw std::invalid_argument("");
                    return 0;
                  }
                  

                  And the result from running gdb is

                  terminate called after throwing an instance of 'std::invalid_argument'
                    what():  
                  
                  Program received signal SIGABRT, Aborted.
                  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
                  51  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
                  

                  It's not all that bad, as I do get the information I need, it's just bugging me...

                  Do anyone know how to fix this?

                  解决方案

                  To do full source code debugging of the C library on Ubuntu, there are just a few steps to take:

                  1. Install the debuginfo version of libc6.

                    It's probably already installed - the gdb package on Ubuntu has a dependency on it - but in case it isn't, run sudo apt install libc6-dbg.

                  2. Prepare the package system to download and process source code packages, if this hasn't previously been done.

                    sudo apt install dpkg-dev
                    grep deb-src /etc/apt/sources.list
                    

                    Grep's output should show (and there may be additional matches that we don't need to worry about):

                    deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted
                    deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
                    

                    If the grep shows that these deb-src lines are commented out with #:

                    # deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted
                    # deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
                    

                    then edit /etc/apt/sources.list to remove the # at the beginning of these lines and then run sudo apt update .

                  3. Download the source code corresponding to the installed version of the C library.

                    First, create a directory anywhere - I'll use /opt/src here.

                    Then do the following:

                    cd /opt/src
                    apt source libc6
                    

                    If the apt command gives an error message like

                    E: You must put some 'source' URIs in your sources.list

                    then my instructions in step 2 may have become outdated; post a comment here.

                    When the download is complete, run this:

                    find $PWD -maxdepth 1 -type d -name 'glibc*'
                    

                    Remember this name - it'll be something like /opt/src/glibc-2.23

                  4. Determine where gdb expects to find the source code and make appropriate adjustments.

                    Run gdb, have it run your program until it stops, and at the gdb prompt do this:

                    (gdb) info source
                    Current source file is ../sysdeps/unix/sysv/linux/raise.c
                    Compilation directory is /build/glibc-KM3i_a/glibc-2.23/signal
                    

                    So gdb is expecting the source code to be in /build/glibc-KM3i_a/glibc-2.23 . There are two ways to fix this:

                    • Move (or use a symlink) so that the source code is (or appears to be) in /build/glibc-KM3i_a/glibc-2.23 .

                      or

                    • Tell gdb how to substitute the correct source directory pathname:

                      (gdb) set substitute-path /build/glibc-KM3i_a/glibc-2.23 /opt/src/glibc-2.23
                      

                    Now, go back to your frame, and gdb should show the source code line:

                    (gdb) frame 1
                    #1 0xb7e2fea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
                             return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
                    

                  这篇关于GDB 抱怨缺少 raise.c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:C++、__try 和 try/catch/finally 下一篇:为什么 C++ 不使用 std::nested_exception 来允许从析构

                  相关文章

                  最新文章

                  <i id='W16Kl'><tr id='W16Kl'><dt id='W16Kl'><q id='W16Kl'><span id='W16Kl'><b id='W16Kl'><form id='W16Kl'><ins id='W16Kl'></ins><ul id='W16Kl'></ul><sub id='W16Kl'></sub></form><legend id='W16Kl'></legend><bdo id='W16Kl'><pre id='W16Kl'><center id='W16Kl'></center></pre></bdo></b><th id='W16Kl'></th></span></q></dt></tr></i><div id='W16Kl'><tfoot id='W16Kl'></tfoot><dl id='W16Kl'><fieldset id='W16Kl'></fieldset></dl></div>

                  <small id='W16Kl'></small><noframes id='W16Kl'>

                  <legend id='W16Kl'><style id='W16Kl'><dir id='W16Kl'><q id='W16Kl'></q></dir></style></legend><tfoot id='W16Kl'></tfoot>

                  • <bdo id='W16Kl'></bdo><ul id='W16Kl'></ul>