Author Topic: GDB command  (Read 10360 times)

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
GDB command
« on: December 11, 2008, 12:38:01 am »
How use GDB command after start debugger? Is it possible? I can't find this option. GDB console is also not available.

mariocup

  • Guest
Re: GDB command
« Reply #1 on: December 11, 2008, 07:53:14 am »
Hi electrolot,

a GDB console is not available in CB.
For setting debugger options select: Project->Properties and go to the tab Debugger. In this view select additional commands tab and insert your commands.

Bye,

Mario

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: GDB command
« Reply #2 on: December 11, 2008, 04:36:13 pm »
Hi Mario,

Thank you.
I set only one additional command After connection:
Code
target sim
and GDB always close after start:
Code
Debugger finished with status 1
.
When I use the same command in GDB console it works fine.
« Last Edit: December 11, 2008, 04:38:16 pm by electrolot »

mariocup

  • Guest
Re: GDB command
« Reply #3 on: December 11, 2008, 09:27:46 pm »
Hi electrolot,

I think you must specify also the parameters for the e.g. remote protocol <IP>:<Port> like this

Code
target sim localhost:6785
b main

Bye,

Mario

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: GDB command
« Reply #4 on: December 12, 2008, 05:35:38 pm »
Hi Mario,

I tried with parameters of remote protocol.
Still the same  :(

I don't know why it does not work because in GDB console it works OK.

I try to make visible GDB console in C::B and I change DebuggerGDB::LaunchProcess function:

   
Code
m_Pid = wxExecute(cmd, wxEXEC_ASYNC, m_pProcess);
to
   
Code
m_Pid = wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_NOHIDE, m_pProcess); 

now I see GDB console but without commands line.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: GDB command
« Reply #5 on: December 12, 2008, 05:56:57 pm »
The commands are redirected.

To make visible what is sent and returned to and from gdb you have to check "Settings -> Compiler and debugger... -> Debugger settings -> Display debugger's log".

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: GDB command
« Reply #6 on: December 12, 2008, 06:13:38 pm »
Thank you jens.
My debug log:
Code
Working dir : C:\Program Files\CodeBlocks\projects\arm_emul\
> set prompt >>>>>>cb_gdb:
(gdb)
>>>>>>cb_gdb:>>>>>>cb_gdb:
> show version
GNU gdb (Sourcery G++ Lite 2008q1-126) 6.7.50.20080107-cvs
Copyright (C) 2008 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 "--host=i686-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.
>>>>>>cb_gdb:GNU gdb (Sourcery G++ Lite 2008q1-126) 6.7.50.20080107-cvs
> set confirm off
C
opyright (C) 2008 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 "--host=i686-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.
>>>>>>cb_gdb:>>>>>>cb_gdb:>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set debugevents on
No symbol "debugevents" in current context.
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set new-console on
No symbol "debugevents" in current context.
No symbol "new" in current context.
>>>>>>cb_gdb:>>>>>>cb_gdb:
> set disassembly-flavor att
No symbol "new" in current context.
No symbol "disassembly" in current context.
>>>>>>cb_gdb:>>>>>>cb_gdb:
> catch throw
No symbol "disassembly" in current context.
Function "__cxa_throw" not defined.
>>>>>>cb_gdb:>>>>>>cb_gdb:
> cd bin/Debug
Function "__cxa_throw" not defined.
>>>>>>cb_gdb:>>>>>>cb_gdb:
> directory C:/PROGRA~1/CODEBL~1/projects/arm_emul/
>>>>>>cb_gdb:>>>>>>cb_gdb:
> target sim
Connected to the simulator.
>>>>>>cb_gdb:
> break "C:/Program Files/CodeBlocks/projects/arm_emul/main.c:11"
No source file named C:/Program Files/CodeBlocks/projects/arm_emul/main.c.
Connected to the simulator.
>>>>>>cb_gdb:Breakpoint 1 ("C:/Program Files/CodeBlocks/projects/arm_emul/main.c:11) pending.
> run
No source file named C:/Program Files/CodeBlocks/projects/arm_emul/main.c.
>>>>>>cb_gdb:Breakpoint 2 ("C:/Program Files/CodeBlocks/projects/arm_emul/main.c:11) pending.
>>>>>>cb_gdb:
warning: No program loaded.

File C:/Program Files/CodeBlocks/projects/arm_emul/main.c exist.
Is it problem with Linux path ("/") ?

mariocup

  • Guest
Re: GDB command
« Reply #7 on: December 13, 2008, 12:12:47 am »
Hi electrolot,

please try to put your files in a path without spaces and then tell me if the problem still occurs. I had some time ago similar problems, since gdb tries to change to the pwd and then load the symbols e.g. with the absolute path.

Bye,

Mario

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: GDB command
« Reply #8 on: December 14, 2008, 03:19:17 pm »
Hi Mario,

I put files in a path without spaces and my last problem does not exist. But I have few new problems with GDB output parsing by C::B. I've got very simple program:

Code
#include <stdio.h>
int i,j;
main (void)
{
  int k;
  printf("Hello World!\n");

  while (1)
    {
      for (i=0;i<100;i++)
        {
          j++;
          k+=2;
        }
    }

  return 0;
}


I can run my program in debugger, set breakpoint, stepping etc. My new problems:
1) Watch does not work propertly. I add to watch i,j variable, i value does not show, "j = type = int". Local variables is empty. Function arguments is k = 102.
Debug log after next line command:
Code
> next
Breakpoint 1, main () at main.c:12
c:/projects/arm_emul/main.c:12:145:beg:0x144
>>>>>>cb_gdb:c:/projects/arm_emul/main.c:13:161:beg:0x158
> info locals
>>>>>>cb_gdb:
> info args
k = 102
>>>>>>cb_gdb:k = 102
> whatis i
>>>>>>cb_gdb:No arguments.
> output i
>>>>>>cb_gdb:No arguments.
> whatis j
>>>>>>cb_gdb:
> output j
type = int
>>>>>>cb_gdb:type = int
>>>>>>cb_gdb:51>>>>>>cb_gdb:51>>>>>>cb_gdb:type = int
>>>>>>cb_gdb:type = int
>>>>>>cb_gdb:52>>>>>>cb_gdb:52>>>>>>cb_gdb:



2) disassembly does not work. I still see "Please wait while disassembling..."
Debug log:
Code
> info frame
Stack level 0, frame at 0x200000:
 pc = 0x134 in main (main.c:10); saved pc 0x2cb4
 source language c.
 Arglist at 0x1ffff0, args:
 Locals at 0x1ffff0, Previous frame's sp is 0x200000
 Saved registers:
  r11 at 0x1ffff8, lr at 0x1ffffc, pc at 0x1ffffc
>>>>>>cb_gdb:Stack level 0, frame at 0x200000:
> disassemble
 pc = 0x134 in main (main.c:10); saved pc 0x2cb4
 source language c.
 Arglist at 0x1ffff0, args:
 Locals at 0x1ffff0, Previous frame's sp is 0x200000
 Saved registers:
  r11 at 0x1ffff8, lr at 0x1ffffc, pc at 0x1ffffc
>>>>>>cb_gdb:
Dump of assembler code for function main:
0x00000120 <main+0>: push {r11, lr}
0x00000124 <main+4>: add r11, sp, #4 ; 0x4
0x00000128 <main+8>: sub sp, sp, #8 ; 0x8
0x0000012c <main+12>: ldr r0, [pc, #88] ; 0x18c <main+108>
0x00000130 <main+16>: bl 0x260 <puts>
0x00000134 <main+20>: ldr r2, [pc, #84] ; 0x190 <main+112>
0x00000138 <main+24>: mov r3, #0 ; 0x0
0x0000013c <main+28>: str r3, [r2]
0x00000140 <main+32>: b 0x178 <main+88>
0x00000144 <main+36>: ldr r3, [pc, #72] ; 0x194 <main+116>
0x00000148 <main+40>: ldr r3, [r3]
0x0000014c <main+44>: add r2, r3, #1 ; 0x1
0x00000150 <main+48>: ldr r3, [pc, #60] ; 0x194 <main+116>
0x00000154 <main+52>: str r2, [r3]
0x00000158 <main+56>: ldr r3, [r11, #-8]
0x0000015c <main+60>: add r3, r3, #2 ; 0x2
0x00000160 <main+64>: str r3, [r11, #-8]
0x00000164 <main+68>: ldr r3, [pc, #36] ; 0x190 <main+112>
0x00000168 <main+72>: ldr r3, [r3]
0x0000016c <main+76>: add r2, r3, #1 ; 0x1
0x00000170 <main+80>: ldr r3, [pc, #24] ; 0x190 <main+112>
0x00000174 <main+84>: str r2, [r3]
0x00000178 <main+88>: ldr r3, [pc, #16] ; 0x190 <main+112>
0x0000017c <main+92>: ldr r3, [r3]
0x00000180 <main+96>: cmp r3, #99 ; 0x63
0x00000184 <main+100>: ble 0x144 <main+36>
0x00000188 <main+104>: b 0x134 <main+20>
0x0000018c <main+108>: andeq r3, r0, r4, lsl r2
0x00000190 <main+112>: andeq r3, r0, r12, asr #21
0x00000194 <main+116>: ldrdeq r3, [r0], -r0
End of assembler dump.
>>>>>>cb_gdb:Dump of assembler code for function main:
0x00000120 <main+0>: push {r11, lr}
0x00000124 <main+4>: add r11, sp, #4 ; 0x4
0x00000128 <main+8>: sub sp, sp, #8 ; 0x8
0x0000012c <main+12>: ldr r0, [pc, #88] ; 0x18c <main+108>
0x00000130 <main+16>: bl 0x260 <puts>
0x00000134 <main+20>: ldr r2, [pc, #84] ; 0x190 <main+112>
0x00000138 <main+24>: mov r3, #0 ; 0x0
0x0000013c <main+28>: str r3, [r2]
0x00000140 <main+32>: b 0x178 <main+88>
0x00000144 <main+36>: ldr r3, [pc, #72] ; 0x194 <main+116>
0x00000148 <main+40>: ldr r3, [r3]
0x0000014c <main+44>: add r2, r3, #1 ; 0x1
0x00000150 <main+48>: ldr r3, [pc, #60] ; 0x194 <main+116>
0x00000154 <main+52>: str r2, [r3]
0x00000158 <main+56>: ldr r3, [r11, #-8]
0x0000015c <main+60>: add r3, r3, #2 ; 0x2
0x00000160 <main+64>: str r3, [r11, #-8]
0x00000164 <main+68>: ldr r3, [pc, #36] ; 0x190 <main+112>
0x00000168 <main+72>: ldr r3, [r3]
0x0000016c <main+76>: add r2, r3, #1 ; 0x1
0x00000170 <main+80>: ldr r3, [pc, #24] ; 0x190 <main+112>
0x00000174 <main+84>: str r2, [r3]
0x00000178 <main+88>: ldr r3, [pc, #16] ; 0x190 <main+112>
0x0000017c <main+92>: ldr r3, [r3]
0x00000180 <main+96>: cmp r3, #99 ; 0x63
0x00000184 <main+100>: ble 0x144 <main+36>
0x00000188 <main+104>: b 0x134 <main+20>
0x0000018c <main+108>: andeq r3, r0, r4, lsl r2
0x00000190 <main+112>: andeq r3, r0, r12, asr #21
0x00000194 <main+116>: ldrdeq r3, [r0], -r0
End of assembler dump.
>>>>>>cb_gdb:

3) CPU registers refresh only first time. Next Line commands does not refresh values of registers.




mariocup

  • Guest
Re: GDB command
« Reply #9 on: December 14, 2008, 04:38:00 pm »
Hi,

could you attach your C::B project file and then I will have a look at it.

Bye,

Mario

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: GDB command
« Reply #10 on: December 14, 2008, 07:45:38 pm »
Attached. Thanks in advance.




[attachment deleted by admin]

mariocup

  • Guest
Re: GDB command
« Reply #11 on: December 14, 2008, 09:57:30 pm »
Hi electrolot,

I have just tested your project. Since I have no ARM Compiler installed on my private laptop I changed the project for the GNU TriCore compiler. I did the following steps:
1. start the tricore simulator
2. Add in the debug settings in before command:
tar extended-remote localhost:6785
load arm_emul.elf
b main

If I start Debug->Start, then the program runs to main and if I step to next line everything works perfectly. See the debugger screenshot in the attached archive.

Sorry but I can't reproduce the problem.

Bye,

Mario

[attachment deleted by admin]

Offline electrolot

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: GDB command
« Reply #12 on: December 16, 2008, 09:15:13 pm »
Hi Mario,

thank you for your help.

I use gdb.exe file from another toolchain and all works fine.
I don't know why if I use CodeSourcery toolchain it does not work.
I've got one problem now. When I use Next Instruction command I see disassembly window but address cursor is still in source. I think that the cursor should be in disassembly window.

regards