2

I just finished installing gdb (which took me more than three hours on a mac), and now I need to debug a project I have for my uni. It seems that none of my code works (Or am I doing something wrong?). I have tried running multiple files under gdb, and I usually get

[New Thread 0x2603 of process 964]
[New Thread 0x2303 of process 964]
During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.

Or this

[New Thread 0x2507 of process 995]
[New Thread 0x1803 of process 995]
During startup program terminated with signal ?, Unknown signal.

For a fact, I know this is a fully functional program. Any views as what may be the problem?

I'm compiling with gcc and -g flag. Code is written in simple c++.

The simplest code I could think of which gdb still refuses to debug.

#include <iostream>
using namespace std;

int main(void)
{

   int x, y, sum;

   cout << "Enter two integers..seperated by a space: ";
   cin >> x >> y;
   sum = x + y;
   cout << "The sum of the two numbers " << x << " and " << y << " is " << sum;
   cout << endl;

   return 0;
}
(gdb) start
Temporary breakpoint 1 at 0x100000d49: file HW1.cpp, line 12.
Starting program: /Users/ramindehghan/Desktop/C++ Educational Projects/CSCI 123F/main 
[New Thread 0x1903 of process 1148]
[New Thread 0x1c03 of process 1148]
During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.

I expected to get a value for some variable or a confirmation that the program has run, but this is all I get. where is the trap?

Ramin
  • 31
  • 1
  • 3
  • I think is a bug. Have a look here, maybe it is your case, you said you have a mac: https://sourceware.org/bugzilla/show_bug.cgi?id=20266 check your mac version, the link provides some info to fix it. – Valentino Apr 14 '19 at 22:26
  • And this link too: https://stackoverflow.com/questions/49001329/gdb-doesnt-work-on-macos-high-sierra-10-13-3 – Valentino Apr 14 '19 at 22:28
  • 1
    @Valentino I did as you suggested, however now I have a different error, gdb doesn't recognize my file formats at all! I'm running MacOS Mojave 10.14.4 – Ramin Apr 15 '19 at 16:12
  • Sorry, I've no idea what to do next. I think is better to edit the question to add the description of the new errors and see if somebody can help you. – Valentino Apr 15 '19 at 16:55
  • @Valentino thanks for your reply. I will edit the question. It seems GDB has lots of problems with MacOS Mojave. – Ramin Apr 15 '19 at 16:58
  • @Valentino I tried some other stuff people recommended, and ended up where I was, I get the SIGTRAP again :( – Ramin Apr 15 '19 at 18:27
  • I think it is this bug that are triggering the startup problems: https://sourceware.org/bugzilla/show_bug.cgi?id=24069 – thoni56 Oct 12 '21 at 12:19
  • MacOS Big Sur 11.3.1 has this issue as well – Sidharth Ghoshal Mar 28 '23 at 00:29
  • Switched to lldb, a way more hustle. – Albi93 Jul 15 '23 at 21:12

0 Answers0