Why doesn't gdb work for this simple world program?

Code (m1.cpp):

#include <iostream>
using namespace std;

int main (int argc, char *argv[])
{
   cout << "running m1" << endl;

   return 0;
}

GDB Version: GNU gdb (GDB) 7.6.2

Built with: g++ -g m1.cpp

Command line history:

(gdb) b main
Breakpoint 1 at 0x40087b: file m1.cpp, line 6.
(gdb) r
Starting program: .../a.out

Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaaac16a0 in strcmp () from /lib64/ld-linux-x86-64.so.2
(gdb) c
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb)

When I start without setting breakpoints, it works without errors.

According to the request:

(gdb) bt
#0  strcmp () from /lib64/ld-linux-x86-64.so.2
#1  in check_match.12104 () from /lib64/ld-linux-x86-64.so.2
#2  in do_lookup_x () from /lib64/ld-linux-x86-64.so.2
#3  in _dl_lookup_symbol_x () from /lib64/ld-linux-x86-64.so.2
#4  in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
#5  in dl_main () from /lib64/ld-linux-x86-64.so.2
#6  in _dl_sysdep_start () from /lib64/ld-linux-x86-64.so.2
#7  in _dl_start () from /lib64/ld-linux-x86-64.so.2
#8  in _start () from /lib64/ld-linux-x86-64.so.2
#9  in ?? ()
+4
source share
2 answers

OP ( ). GDB GCC . , , SHELL. tcsh ( 1.15.00). SHELL , ( ) gdb tcsh. SHELL, gdb sh. , . , tcsh, , , .

+1

GNU gdb 7.11.1. . , :

g++ -g m1.cpp

gdb :

gdb -q./a.out

, . . gdb .

0

Source: https://habr.com/ru/post/1674584/


All Articles