Author Topic: gdb break command  (Read 47372 times)

Offline Joerg

  • Multiple posting newcomer
  • *
  • Posts: 100
gdb break command
« on: June 09, 2008, 03:14:29 pm »
need a gdb break command urgently!
to stop the program, not to stop debugging
I don't understand the usage of run and continue
in C::B,too.
Apart from that, remote debugging on ARM7
works not bad.  :)
It's never too late to fail!

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: gdb break command
« Reply #1 on: June 09, 2008, 03:43:03 pm »
need a gdb break command urgently!
to stop the program, not to stop debugging

If you hit the stop-button (the red one with the white cross) once, the program should stop, not the debugging process.

In most cases you don't see the yellow triangle, because you are in a library without debugging symbols, but you can open the disassembly window, and in the Debugger Log you can see where you are.

You are now able to click (for example) "Step out" unless you are in code gdb can find the sources.
From this point you can debug as usual.

mariocup

  • Guest
Re: gdb break command
« Reply #2 on: June 09, 2008, 03:57:42 pm »
Hi rekisum,

the debug interrupt button works under linux. If you hit stop the program will be interrupted and if you press again stop the debugger will be stopped. This does not work for windows. If you want to interrupt the debug process under windows there is only the workaround to send an user command to the debugger

Code
interpreter-exec mi interrupt 

Bye,

Mario

Offline Joerg

  • Multiple posting newcomer
  • *
  • Posts: 100
Re: gdb break command
« Reply #3 on: June 10, 2008, 10:29:44 am »
Hi,

hitting the red button sends a 'quit' command to gdb.
I can see this in the Debugger (debug) window.

As I remotely debug my ARM7 I can see
Info: server.c:355 server_loop(): dropped 'gdb' connection in my OpenOCD info window.
(OpenOCD is a popular JTAG gdb server)

Mostly even that doesn't work and Codeblocks hangs with:
Trying to pause the running process...

I'm not able to send a user command when the debugger is running!?

What do you mean with 'the debug interrupt button works under linux' ?
I do remote debugging over JTAG with arm-elf-gdb / OpenOCD ..... under WinXP.

Bye

It's never too late to fail!

Offline martind

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: gdb break command
« Reply #4 on: June 10, 2008, 01:47:53 pm »
Hi Rekisum,

I had the same problem. I tried various methods of sending ctrl-C interrupts to GDB but was unsuccessful. I found some code on the net that even injected code into GDB's process space to try and issue ctrl-C via software but no luck.

How CodeBlocks gets around this for Windows app debugging is to DebugBreak the process being debugged.

I am currently working on a plugin with OpenOCD, and I establish a telnet connection with OpenOCD (wxSocketClient) and send the "halt" command. It's fairly easy to do, and I have code if you want it.

I would not have thought that the "interpreter-exec mi interrupt" command would work in this case, as GDB goes modal when you continue? (send command to debugger is greyed out).

Also, on the MI note, perhaps changing to MI in the long term for CodeBlocks?


Martin.



Offline Joerg

  • Multiple posting newcomer
  • *
  • Posts: 100
Re: gdb break command
« Reply #5 on: June 11, 2008, 09:42:20 am »
Hi martin,

Quote
How CodeBlocks gets around this for Windows app debugging is to DebugBreak the process being debugged.
I am currently working on a plugin with OpenOCD, and I establish a telnet connection with OpenOCD (wxSocketClient) and send the "halt" command. It's fairly easy to do, and I have code if you want it.
I will try to open a telnet console to OpenOCD.
If your plugin offers a new button sending a break it would be a nice workaround.
Quote
Also, on the MI note, perhaps changing to MI in the long term for CodeBlocks?
Ah, thats interesting.
So Codeblocks doesn't use MI to talk with GDB like Eclipse does?
I don't like Eclipse but remote debugging with the plugin from Zylin works, after all.
How is Codeblocks talking to GDB, and is this the reason why the break command
is not supported under windows?
Joerg

It's never too late to fail!

Offline martind

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: gdb break command
« Reply #6 on: June 11, 2008, 01:36:04 pm »
Hi Joerg,

My plugin uses the existing halt button. The functionality of this button is if GDB is running, then pressing it will halt. If GDB has halted, pressing it will terminate debugging.

There are 3 messages that have been created for plugins:

cbEVT_DEBUGGER_STARTED
cbEVT_DEBUGGER_PAUSED
cbEVT_DEBUGGER_FINISHED

However, these do not appear to be implmented yet. I have modified debuggergdb.cpp to dispatch these 3 messages (would like to suggest method via patch soon). The plugin then picks this up and issues the "halt\r" command when it receives the paused message.

No MI interpreter is not used, the output of GDB is regex'd. Input is sent to GDB via console input stream. This means that when GDB is running, GDB is unresponsive to anything but signals (ctrl-C etc). That's why the break command does not work.

With MI, I believe the interpreter is running all the time? Havent used MI much so not an expert.

Eclipse is nice, but there are a few things that need changing. Adding / removing source files is my biggest bug-bear. Being Java is good for transparent cross platform, but slowish on older machines.




Martin.

Offline Joerg

  • Multiple posting newcomer
  • *
  • Posts: 100
Re: gdb break command
« Reply #7 on: June 11, 2008, 03:00:40 pm »
sending halt via telnet works
a 'halt' button would be very nice
Hopefully waiting for your plugin  ;-)
« Last Edit: June 11, 2008, 03:08:55 pm by rekisum »
It's never too late to fail!

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: gdb break command
« Reply #8 on: June 12, 2008, 10:34:42 am »
Hi,

hitting the red button sends a 'quit' command to gdb.
I can see this in the Debugger (debug) window.
That's funny, because what I see is this:
Child process PID: 3520
Trying to pause the running process...
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Program received signal SIGTRAP, Trace/breakpoint trap.
In ntdll!DbgUiConnectToDbg () (C:\WINDOWS\system32\ntdll.dll)
Continuing...
Trying to pause the running process...
Program received signal SIGTRAP, Trace/breakpoint trap.
In ntdll!DbgUiConnectToDbg () (C:\WINDOWS\system32\ntdll.dll)


Maybe you're using a very old version, or you're hitting the wrong button?
« Last Edit: June 12, 2008, 10:36:32 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline martind

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: gdb break command
« Reply #9 on: June 12, 2008, 07:14:49 pm »
Hi Thomas,

Is this when you are debugging a windows / linux native executable?

Martin.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: gdb break command
« Reply #10 on: June 12, 2008, 08:22:16 pm »
It's on windows, on linux it's SIGINT.

Offline martind

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: gdb break command
« Reply #11 on: June 12, 2008, 10:25:40 pm »
Hi Jens,

Ok so when you are debugging a windows program, the SIGTRAP signal occurs because a DebugBreakProcess Kernel32 call has been issued to the GDB child process (program being debugged), causing a debug exception. In this case, GDB receives this exception in the form of the SIGTRAP signal:

Code
long pid = m_State.GetDriver()->GetChildPID();

if (DebugBreakProcessFunc && pid > 0)
{
Log(_("Trying to pause the running process..."));
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
if (proc)
{
DebugBreakProcessFunc(proc); // yay!
CloseHandle(proc);
done = true;
}
else
Log(_("Failed."));
}

When you connect to a remote host e.g target remote localhost:2000 (in the case of OpenOCD), GDB does not have a child process. Therefore the DebugBreak mechanism is unsuitable in this case.

If you run pure GDB from the command line, to break GDB you can press ctrl-C. But I am unsuccessfull in doing this programatically.


Martin.

Offline starkeeper

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: gdb break command
« Reply #12 on: July 05, 2008, 10:55:17 pm »
This annoying behaviour bothers me for at least two years now. And it doesn't seem to be fixed in the future, that is really frustrating.
And then there are these PC software gurus that don't stop to tell you that it works fine, when they hit the stop button. But none of them has even tried to debug a remote target.

This little neat "Bug" or missing feature makes codeblocks still unusable for embedded devlopement.

Btw. the arm-elf-insight debugger works fine, and the stop button really stops the target as expected.

Offline martind

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: gdb break command
« Reply #13 on: July 11, 2008, 12:15:56 am »
Thats because they use GDB MI.

Offline g2003p

  • Single posting newcomer
  • *
  • Posts: 3
Re: gdb break command
« Reply #14 on: September 15, 2008, 01:29:51 pm »
Good Day All!

I've found a partial solution to this problem, it works well for me. Not really found a method to send ctrl-C to the debugger process, but I did following change in DebuggerGDB::LaunchProcess:
    //m_Pid = wxExecute(cmd, wxEXEC_ASYNC, m_pProcess);
    m_Pid = wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_NOHIDE, m_pProcess);
Now a console window appears when the debugger is started. If I hit the ctrl-C inside, the debugger breaks as expected....

Additionally, I changed behavior of start command to gdb, so that in case off remote debugging always continue and never run ist omitted.

If somebody is interested, I can post affected files etc. or a complete binary (trunk from 2008-09-12).

Gottfried