Author Topic: [solved]remote debug on arm  (Read 37849 times)

Offline eliot-sa

  • Single posting newcomer
  • *
  • Posts: 5
[solved]remote debug on arm
« on: October 19, 2009, 02:30:14 pm »
Hi,

I want to use codeblocks for remote debug like ddd.
I'm working on a arm target (cortex-m3 stm32), I debug with arm-none-eabi-gdb from codeSourcery and openocd.

I have try 2 solutions:
  • I make my binary with a custom makefile. In project option build target I chose type="console application" (I'm not sure what I have to chose)
    When I start debug, codeblocks crash (see attachment for log).
    I'm using codeblocks svn5857, build Oct 09 2009 - wx2.8.10 on Kubuntu 9.04, arm-none-eabi-gdb 6.8.50.20081022-cvs from codeSourcery.
    I don't know what options I have to chose to configure my project
  • I have see, a pluging under development to use openocd in codeblock (http://forums.codeblocks.org/index.php?topic=9904.0).
    I download sources but compilation fail because I haven't codeblocks global variables cb and wx (I don't know what I have to put in)

I haven't found other solution to do remote debug wiht C:B.
if someone could help me, it would be great!

Thanks

[attachment deleted by admin]
« Last Edit: October 20, 2009, 09:07:58 am by eliot-sa »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: remote debug on arm
« Reply #1 on: October 19, 2009, 03:50:36 pm »
Have you tried Project -> properties -> debug -> remove debugging or something like that?
Although, I'm not sure if the debugging works at all with custom make files

Never tried to debug remotely, so I don't know if it works.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline eliot-sa

  • Single posting newcomer
  • *
  • Posts: 5
Re: remote debug on arm
« Reply #2 on: October 19, 2009, 05:23:21 pm »
Tanks for answer, but I haven't understand what you want to do.
I have no option to remove debug. I have option to add sources directory and add command to gdb.

I have find a solution:
C::B crash with arm gdb 6.8.50 from codeSourcery but work fine with 6.7.50.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: remote debug on arm
« Reply #3 on: October 19, 2009, 06:49:09 pm »
I think to used the remote debugging you go to
Project -> Properties -> Debugger tab -> Remote connection

Than click on you debug target, so you make the GUI active and then enter the connection parameters for the debugging session - TCP (ip/port) or serial connection parameters
Have you tried that?

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline eliot-sa

  • Single posting newcomer
  • *
  • Posts: 5
Re: remote debug on arm
« Reply #4 on: October 20, 2009, 09:07:25 am »
Yes, I have put tcp:localhost:3333 to connect gdb with openOCD. And it work fine.

The problem came from interaction with C::B and my version of gdb.
I had downgrade gdb and now the problem is solved.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: [solved]remote debug on arm
« Reply #5 on: October 20, 2009, 12:07:00 pm »
Can you build c::b on debug and provide a backtrace of the crash?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline eliot-sa

  • Single posting newcomer
  • *
  • Posts: 5
Re: [solved]remote debug on arm
« Reply #6 on: October 20, 2009, 03:03:49 pm »
I have rebuild codeblock with like this
Code
svn checkout svn://svn.berlios.de/codeblocks/trunk
./bootstrap
./configure --enable-debug
make
make install
/usr/local/bin/codeblocks -d

there the stack log of the crash (full log are in attachement)
Code
<stack>
<frame level="0" function="wxFatalSignalHandler" offset="00000026"/>
<frame level="1"/>
<frame level="2" function="DebuggerGDB::DoDebug()" offset="0000242e"/>
<frame level="3" function="DebuggerGDB::OnCompilerFinished(CodeBlocksEvent&)" offset="00000048"/>
<frame level="4" function="cbEventFunctor<DebuggerGDB, CodeBlocksEvent>::Call(CodeBlocksEvent&)" offset="00000029"/>
<frame level="5" function="Manager::ProcessEvent(CodeBlocksEvent&)" offset="0000007c"/>
<frame level="6" function="CompilerGCC::NotifyJobDone(bool)" offset="00000286"/>
<frame level="7" function="CompilerGCC::OnJobEnd(unsigned int, int)" offset="000004b5"/>
<frame level="8" function="CompilerGCC::OnGCCTerminated(CodeBlocksEvent&)" offset="00000036"/>
<frame level="9" function="wxAppConsole::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const" offset="00000041"/>
<frame level="10" function="wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)" offset="0000009a"/>
<frame level="11" function="wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)" offset="00000084"/>
<frame level="12" function="wxEvtHandler::ProcessEvent(wxEvent&)" offset="000000db"/>
<frame level="13" function="wxEvtHandler::ProcessPendingEvents()" offset="00000089"/>
<frame level="14" function="wxAppConsole::ProcessPendingEvents()" offset="00000061"/>
<frame level="15" function="wxAppBase::ProcessIdle()" offset="0000001f"/>
<frame level="16"/>
<frame level="17"/>
<frame level="18" function="g_main_context_dispatch" offset="000001e8"/>
<frame level="19"/>
<frame level="20" function="g_main_loop_run" offset="000001ca"/>
<frame level="21" function="gtk_main" offset="000000b9"/>
<frame level="22" function="wxEventLoop::Run()" offset="00000045"/>
<frame level="23" function="wxAppBase::MainLoop()" offset="0000004e"/>
<frame level="24" function="wxAppBase::OnRun()" offset="00000021"/>
<frame level="25" function="CodeBlocksApp::OnRun()" offset="00000000" file="/home/thomas/tmp/cbDebug/trunk/src/src/app.cpp" line="775"/>
</stack>

[attachment deleted by admin]
« Last Edit: October 20, 2009, 03:21:40 pm by eliot-sa »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: [solved]remote debug on arm
« Reply #7 on: October 20, 2009, 03:38:14 pm »
Thank you,
But in your report there are no line numbers, so it is a bit hard to find it exactly.
Can you run:
gdb codeblocks

Then you execute the "run" gdb commnad and when it crashes execute the "bt" command.
And then paste the result.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline eliot-sa

  • Single posting newcomer
  • *
  • Posts: 5
Re: [solved]remote debug on arm
« Reply #8 on: October 20, 2009, 03:55:52 pm »
Code
(gdb) run
[...]
Switching layout to "Code::Blocks default"

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb640e750 (LWP 5031)]
0xb3e35c3e in DebuggerGDB::DoDebug (this=0xa08b470) at debuggergdb.cpp:1550
1550            m_State.GetDriver()->Start(m_BreakOnEntry);
(gdb) bt
#0  0xb3e35c3e in DebuggerGDB::DoDebug (this=0xa08b470) at debuggergdb.cpp:1550
#1  0xb3e36308 in DebuggerGDB::OnCompilerFinished (this=0xa08b470, event=@0xbfaf3158) at debuggergdb.cpp:3021
#2  0xb3e3a249 in cbEventFunctor<DebuggerGDB, CodeBlocksEvent>::Call (this=0xa16b028, event=@0xbfaf3158) at ./cbfunctor.h:35
#3  0xb7ce90ec in Manager::ProcessEvent () from /usr/lib/libcodeblocks.so.0
#4  0xb31e3d16 in CompilerGCC::NotifyJobDone (this=0xb3321640, showNothingToBeDone=false) at compilergcc.cpp:3820
#5  0xb31e59f5 in CompilerGCC::OnJobEnd (this=0xb3321640, procIndex=0, exitCode=0) at compilergcc.cpp:3746
#6  0xb31e65d6 in CompilerGCC::OnGCCTerminated (this=0xb3321640, event=@0xa0a7a84) at compilergcc.cpp:3633
#7  0xb735a331 in wxAppConsole::HandleEvent () from /usr/lib/libwx_baseu-2.8.so.0
#8  0xb73f98aa in wxEvtHandler::ProcessEventIfMatches () from /usr/lib/libwx_baseu-2.8.so.0
#9  0xb73faac4 in wxEventHashTable::HandleEvent () from /usr/lib/libwx_baseu-2.8.so.0
#10 0xb73fabcb in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.8.so.0
#11 0xb73f9d29 in wxEvtHandler::ProcessPendingEvents () from /usr/lib/libwx_baseu-2.8.so.0
#12 0xb735a691 in wxAppConsole::ProcessPendingEvents () from /usr/lib/libwx_baseu-2.8.so.0
#13 0xb7664b0f in wxAppBase::ProcessIdle () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#14 0xb75b81a3 in ?? () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#15 0xb6992c81 in ?? () from /usr/lib/libglib-2.0.so.0
#16 0xb6994b88 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#17 0xb69980eb in ?? () from /usr/lib/libglib-2.0.so.0
#18 0xb69985ba in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#19 0xb6ded7d9 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#20 0xb75d1d35 in wxEventLoop::Run () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#21 0xb766497e in wxAppBase::MainLoop () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#22 0xb7664551 in wxAppBase::OnRun () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#23 0x0806f115 in CodeBlocksApp::OnRun (this=0x9812118) at app.cpp:773
#24 0xb739418a in wxEntry () from /usr/lib/libwx_baseu-2.8.so.0
#25 0xb7394387 in wxEntry () from /usr/lib/libwx_baseu-2.8.so.0
#26 0x0806f5f0 in main (argc=192, argv=0x18) at app.cpp:256
(gdb)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: [solved]remote debug on arm
« Reply #9 on: October 20, 2009, 04:38:48 pm »
1550            m_State.GetDriver()->Start(m_BreakOnEntry);
Probably there is no driver (i.e. it's NULL) for remote debugging?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

cermakpe

  • Guest
Re: [solved]remote debug on arm
« Reply #10 on: March 12, 2011, 12:21:42 pm »
There is small different problem.
If you does not support exeptions in arm C++ debugged code this crash appear. You must check off Catch C++ Exeption in Debugger Tab.
This crash is due to gdb finish before line 1550 in debugergdb.cpp
and GetDrive return NULL (no gdb running or finishing before)

in debug window:
"
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /mnt/sdb1/bl/blink/
Adding source dir: /mnt/sdb1/bl/blink/
Changing directory to: bin/Debug
Adding file: bin/Debug/blink
Starting debugger:
done
Running command: set prompt >>>>>>cb_gdb:
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting serial connection speed to 38400
Connecting to remote target
Setting breakpoints
Running command: show version
Running command: set confirm off
Debugger name and version: GNU gdb (eCosCentric GNU tools 4.3.2-sw) 6.8.50.20080706
Running command: set width 0
Running command: set height 0
Running command: set breakpoint pending on
Running command: set print asm-demangle on
Running command: set unwindonsignal on
Running command: set disassembly-flavor arm7tdmi
Running command: catch throw
Debugger finished with status 1
"
and Crash...


Solving:

    // Don't issue 'run' if attaching to a process (Bug #1391904)
    if (m_PidToAttach == 0)
   // in case finish gdb with result 1 (Catch C++ exeptions setting), GetDriver() return NULL
        if( m_State.GetDriver() != NULL)
      m_State.GetDriver()->Start(m_BreakOnEntry);

    // switch to the user-defined layout for debugging
    if (m_pProcess)
        DoSwitchToDebuggingLayout();
 
Best
Petr Cermak. :D

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: [solved]remote debug on arm
« Reply #11 on: March 12, 2011, 05:21:55 pm »
Can you try the latest debugger's branch nightly and report back if the problem is still there?

Keep in mind that trunk is frozen in regard to changes in the debugger, all development happens in the branch...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline martind

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: [solved]remote debug on arm
« Reply #12 on: March 26, 2011, 05:05:03 pm »
Hi,

I am the developer of the plugin you have mentioned. I have not done much work on it recently but am now back on it as I have been looking at the whole architecture of the plugin.

I have found an issue with CodeSourcery also when you are debugging, where each step causes the debugger to advance by 2 steps. It's something I have been meaning to look at but again have not made the time.

The variables cb relates to the source directory of CodeBlocks, and wx is the wxWidgets directory. Thats all you should need.

I have been debugging with CB and OpenOCD (with the cbmcu plugin) for some time using the Yagarto compiler: http://www.yagarto.de/



Regards,


Martin.