首页 文章

gdb在显示第一行代码之前挂起

提问于
浏览
0

我给出了预期的输出 . 当然,逻辑是错误的 . 要进行调试,请使用 gdb . 但是当附加了这个程序时,gdb会挂起警告 . 以下是代码,编译命令,运行代码和示例输出如下所示 .

#include <stdio.h>

void array_former(long long int *lst, int *length) {
    int i;
    long long int value;
    for (i=0; i < *length; i++) {
        value = lst[i];
        if(value < 12)
            continue;
        lst[*length++] = value / 2;
        lst[*length++] = value / 3;
        lst[*length++] = value / 4;
    }
}
void clear_array(long long int *lst) {
    int i;
    for(i=0; i<100000; i++)
        lst[i] = 0;
}

int main() {
    long long int n;
    long long int array[100000];
    int length, i;
    while((n = scanf("%lld", &n)) != EOF) {
        clear_array(array);
        array[0] = n;
        length = 1;
        array_former(array, &length);
        for(i=0; i<length; i++)
            printf("%lld ", array[i]);
    }
    return 0;
}

Commands

gcc -g test.c
gdb ./a.out

At gdb console:

deepak@ubuntu:~/Desktop$ gdb ./a.out
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 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".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/deepak/Desktop/a.out...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/deepak/Desktop/a.out 15
warning: no loadable sections found in added symbol-file system-supplied DSO at    0x7ffff7ffa000
[cursor keep blinking for sometime and stops like forever, gdb hangs]

我搜索了上面的警告,发现here,它可以被忽略 .

问题:如何在不挂起的情况下运行gdb,以便我可以调试此程序 .

1 回答

  • 0

    我必须在gdb中“启动”该程序 . 这对我来说非常愚蠢 .

相关问题