Author Topic: GDB  (Read 22525 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #15 on: February 11, 2011, 08:29:38 pm »
Have you tried to execute:
Code
shell avarice -g -j USB -P $(MCU) -j usb localhost:4242

Is this on windows?
And what is $(MCU) ?

I still don't understand why the 'additional shell commands' can't have the same implementation like the 'Tools' menu?
Because it is easier to just remove them :)
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #16 on: February 11, 2011, 11:37:32 pm »
Have you tried to execute:
Code
shell avarice -g -j USB -P $(MCU) -j usb localhost:4242
Yes I've tried to execute every possible combination. With quotes, without quotes, with full path, without full path, some other executables like winamp etc... just to make sure that it isn't implemented as it's expressed on the link I posted on my previous post.

Is this on windows?
And what is $(MCU) ?
Yup windows, tried on both XP SP3 and Vista SP1. $(MCU) is a variable loaded with the target microcontroller type upon the execution of the AVR project template which I inserted into the template. It works fine on the tools menu and other things where needed.

I still don't understand why the 'additional shell commands' can't have the same implementation like the 'Tools' menu?
Because it is easier to just remove them :)
Doesn't compute! Remove what? Even though 'shell' gets implemented some day to AVR-gdb, there are other mcus on the market which have their own gdb servers and if they don't also support 'shell' that makes codeblocks inattractive imo if 'additional shell commands' won't be implemented. And I still think implementing them with just the same functionality of the 'tools' menu would be more than enough for now. Can the 'tools' menu code just copied and pasted with little modification to implement them?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #17 on: February 12, 2011, 12:56:27 am »
Yes I've tried to execute every possible combination. With quotes, without quotes, with full path, without full path, some other executables like winamp etc... just to make sure that it isn't implemented as it's expressed on the link I posted on my previous post.
Can you post a quote from the link, because there is no mention of shell in it. And as you can see here it looks pretty much as the normal gdb man page: http://linux.die.net/man/1/gdb

Can the 'tools' menu code just copied and pasted with little modification to implement them?
I've intended to to remove the additional shell commands or implement them using the gdb shell command.
Can you try something:
1. Start a debug session and break on some breakpoint
2. In combo where gdb commands can be executed type "shell dir" and execute the command
3. Paste the output here

If the shell command doesn't work everywhere probably I can use the tools code.
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #18 on: February 12, 2011, 10:51:31 am »
Yes I've tried to execute every possible combination. With quotes, without quotes, with full path, without full path, some other executables like winamp etc... just to make sure that it isn't implemented as it's expressed on the link I posted on my previous post.
Can you post a quote from the link, because there is no mention of shell in it. And as you can see here it looks pretty much as the normal gdb man page: http://linux.die.net/man/1/gdb

Sry my bad, I thought it wasn't implemented because there was no mention of it but it seems it's implemented.

I've intended to to remove the additional shell commands or implement them using the gdb shell command.
Can you try something:
1. Start a debug session and break on some breakpoint
2. In combo where gdb commands can be executed type "shell dir" and execute the command
3. Paste the output here

Ok, 'shell' works when executed as a gdb command during a debugging session but I couldn't manage to make it work through the 'additional gdb commands'. It just doesn't execute the command. I also tried it with a mingw project and it works with mingw-gdb either way but with avr-gdb, it only works when typed in and executed as a gdb command. Even though if it works somehow I have some concerns regarding this implementation.
1. This will be a VERY VERY VERY debugger specific implementation. How will it be when other debuggers without shell support will be supported by codeblocks?
2. Will it be as useful as 'tools' menu item (like piping, macros and other things)?
3. It will be a clear implementation to use 'additional shell commands' instead of 'additional gdb commands' in my opinion.

If the shell command doesn't work everywhere probably I can use the tools code.

Please implement it like 'tools' menu to make it future proof. ;)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #19 on: February 12, 2011, 02:43:04 pm »
scarphin: Keep in mind that the GUI in the project -> properties is added by the GDB plugin itself and it is not common for all plugins.
  So other plugins should implement it the best they can.

Have you looked at the debugger's debug log when using avr-gdb? Also I think you should use the debuggers branch, in trunk the commands weren't working if I remember correctly.
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #20 on: February 12, 2011, 03:40:24 pm »
scarphin: Keep in mind that the GUI in the project -> properties is added by the GDB plugin itself and it is not common for all plugins.
  So other plugins should implement it the best they can.

Well didn't know that and that renders it quite useless really. I think u are working on separating the debugger and the gui, can it be implemented in the gui side after it's done then?

Have you looked at the debugger's debug log when using avr-gdb? Also I think you should use the debuggers branch, in trunk the commands weren't working if I remember correctly.

I've checked every tab related with the debugger and there is no trace of a directory listing with avr-gdb. Mingw however, lists the directories on the debugger(debug) tab. There isn't any problem executing shell commands when typed though. I'm always using the debuggers branch as the debugger doesn't launch for a 'native' target on the trunk branch which was a bug u corrected last summer. It can still be related with the target type like 'native' or 'console application' etc... Can u check that if they all have same options for a 'shell' execution or something?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #21 on: February 12, 2011, 05:00:05 pm »
I've checked every tab related with the debugger and there is no trace of a directory listing with avr-gdb. Mingw however, lists the directories on the debugger(debug) tab.
Do you see the shell commands executed in the debugger (debug) tab?
Where do you add them?
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #22 on: February 13, 2011, 12:28:04 am »
Here is mingw's log:
Code
Command-line: C:\GNU\MinGW\bin\gdb.exe -nx -fullname  -quiet -args bin/Debug/exC.exe
Working dir : D:\Coding\Projects\exC\src\
> set prompt >>>>>>cb_gdb:
Reading symbols from D:\Coding\Projects\exC\src/bin/Debug/exC.exe...done.
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb (GDB) 7.1
Copyright (C) 2010 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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set print elements -1
>>>>>>cb_gdb:
> set debugevents on
>>>>>>cb_gdb:
> set new-console on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source C:\GNU\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory D:/Coding/Projects/exC/src/
>>>>>>cb_gdb:
> shell dir
 Volume in drive D is Data
 Volume Serial Number is 743E-2D50
 Directory of D:\Coding\Projects\exC\src
02/12/2011  16:39    <DIR>          .
02/12/2011  16:39    <DIR>          ..
01/31/2011  20:28    <DIR>          bin
02/12/2011  16:28             1,392 exC.cbp
02/12/2011  16:39               238 exC.layout
01/31/2011  20:28               609 main.c
01/31/2011  20:28    <DIR>          obj
               3 File(s)          2,239 bytes
               4 Dir(s)  60,906,680,320 bytes free
>>>>>>cb_gdb:
> break main
Breakpoint 2 at 0x4013ce: file D:\Coding\Projects\exC\src\main.c, line 12.
>>>>>>cb_gdb:
> run
gdb: windows_init_thread_list
[New Thread 3936.0xfd0]
Breakpoint 2, main () at D:\Coding\Projects\exC\src\main.c:12
D:\Coding\Projects\exC\src\main.c:12:172:beg:0x4013ce
>>>>>>cb_gdb:
> set debugevents off
>>>>>>cb_gdb:
> info registers
eax            0x1 1
ecx            0x1 1
edx            0x0 0
ebx            0x7efde000 2130567168
esp            0x27ff00 0x27ff00
ebp            0x27ff28 0x27ff28
esi            0x0 0
edi            0x0 0
eip            0x4013ce 0x4013ce <main+14>
eflags         0x202 [ IF ]
cs             0x23 35
ss             0x2b 43
ds             0x2b 43
es             0x2b 43
fs             0x53 83
gs             0x2b 43
>>>>>>cb_gdb:
> bt 30
#0  main () at D:\Coding\Projects\exC\src\main.c:12
>>>>>>cb_gdb:
> if 1
disassemble 0x4013ce
info frame
end
 > > >Dump of assembler code for function main:
   0x004013c0 <+0>: push   %ebp
   0x004013c1 <+1>: mov    %esp,%ebp
   0x004013c3 <+3>: and    $0xfffffff0,%esp
   0x004013c6 <+6>: sub    $0x20,%esp
   0x004013c9 <+9>: call   0x401a80 <__main>
=> 0x004013ce <+14>: movl   $0x40140f,0x4(%esp)
   0x004013d6 <+22>: movl   $0x16,(%esp)
   0x004013dd <+29>: call   0x401cf8 <signal>
   0x004013e2 <+34>: movl   $0x401434,0x4(%esp)
   0x004013ea <+42>: movl   $0x2,(%esp)
   0x004013f1 <+49>: call   0x401cf8 <signal>
   0x004013f6 <+54>: lea    0x1c(%esp),%eax
   0x004013fa <+58>: mov    %eax,0x4(%esp)
   0x004013fe <+62>: movl   $0x403064,(%esp)
   0x00401405 <+69>: call   0x401d00 <scanf>
   0x0040140a <+74>: call   0x401d08 <abort>
End of assembler dump.
Stack level 0, frame at 0x27ff30:
 eip = 0x4013ce in main (D:\Coding\Projects\exC\src\main.c:12); saved eip 0x4010db
 source language c.
 Arglist at 0x27ff28, args:
 Locals at 0x27ff28, Previous frame's sp is 0x27ff30
 Saved registers:
  ebp at 0x27ff28, eip at 0x27ff2c
>>>>>>cb_gdb:
> x/32xb 0x0
Cannot access memory at address 0x0
0x0: >>>>>>cb_gdb:
> info threads
* 1 Thread 3936.0xfd0  main () at D:\Coding\Projects\exC\src\main.c:12
>>>>>>cb_gdb:
> disassemble 0x004013ce
Dump of assembler code for function main:
   0x004013c0 <+0>: push   %ebp
   0x004013c1 <+1>: mov    %esp,%ebp
   0x004013c3 <+3>: and    $0xfffffff0,%esp
   0x004013c6 <+6>: sub    $0x20,%esp
   0x004013c9 <+9>: call   0x401a80 <__main>
=> 0x004013ce <+14>: movl   $0x40140f,0x4(%esp)
   0x004013d6 <+22>: movl   $0x16,(%esp)
   0x004013dd <+29>: call   0x401cf8 <signal>
   0x004013e2 <+34>: movl   $0x401434,0x4(%esp)
   0x004013ea <+42>: movl   $0x2,(%esp)
   0x004013f1 <+49>: call   0x401cf8 <signal>
   0x004013f6 <+54>: lea    0x1c(%esp),%eax
   0x004013fa <+58>: mov    %eax,0x4(%esp)
   0x004013fe <+62>: movl   $0x403064,(%esp)
   0x00401405 <+69>: call   0x401d00 <scanf>
   0x0040140a <+74>: call   0x401d08 <abort>
End of assembler dump.
>>>>>>cb_gdb:
U can see the 'shell dir' is executed and the directory list after.

And avr-gdb's:
Code
Command-line: C:\GNU\WinAVR\bin\avr-gdb.exe -nx -fullname  -quiet -args bin/Release/RmCont
Working dir : D:\Electronics\Projects\RmCont\source\
> set prompt >>>>>>cb_gdb:
bin/Release/RmCont: No such file or directory.
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.8
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-pc-mingw32 --target=avr".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set print elements -1
>>>>>>cb_gdb:
> set debugevents on
No symbol table is loaded.  Use the "file" command.
>>>>>>cb_gdb:
> set disassembly-flavor att
No symbol table is loaded.  Use the "file" command.
>>>>>>cb_gdb:
> catch throw
No symbol table is loaded.  Use the "file" command.
>>>>>>cb_gdb:
> source C:\GNU\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory D:/Electronics/Projects/RmCont/source/
>>>>>>cb_gdb:
> run
Don't know how to run.  Try "help target".
>>>>>>cb_gdb:

As u can see there is no sign of 'shell dir' on the avr-gdb log. They are both entered in the 'additional gdb commands' 'before connection' part. I don't have the needed hardware at home so avr-gdb can't connect to target, can this be the reason for 'shell' not to work? Also as I said before mingw project is a 'console application' and avr-gdb is 'native'.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #23 on: February 13, 2011, 08:27:16 am »
Hm, can you enter any other valid gdb command in the avr project and see if it is executed.
If it isn't, can you try to switch it to console?
Probably this is another bug and it should be fixed.
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #24 on: February 13, 2011, 09:47:26 am »
Tried with the 'help' command, same results, works with mingw but not with avr.

If it isn't, can you try to switch it to console?
Sorry, how is 'switching to console' performed?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #25 on: February 13, 2011, 10:12:17 am »
Project -> properties -> build targets -> type -> console
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #26 on: February 13, 2011, 11:42:37 am »
Project -> properties -> build targets -> type -> console
Oh sry I though it was something related with the debugger. ;) Switched to console saved the project options and everything and restarted cb and the same result, it doesn't work. But there is something wrong though. While debugging that project gdb stops at 'main' at the start which is a result of execution of the 'break main' command. But I can't also see that being executed on the log. I guess the problem might be something related with gdb being connected to the gdb-server or not. I'm going to check that tomorrow at work where I have the equipment to debug.

cbuser405

  • Guest
Re: GDB
« Reply #27 on: February 14, 2011, 08:51:44 am »
OK. It works.
What do you prefer, combined list or two separe lists (probably I should check CDB) ?

I think one list is enough

Could you add a check box "use extended-remote" to configuration page for GDB RemoteConnection:
if not checked - works as before (send target remote)
if checked - send target extended-remote.
Is this per project or global setting?

It is right be done at the project level.
« Last Edit: February 15, 2011, 01:47:49 pm by cbuser405 »

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: GDB
« Reply #28 on: February 15, 2011, 11:25:44 am »
Sry for the delay. I think the problem was the target type, when I switched to 'debug' from 'release' it worked, don't know why? Unfortunately there are other problems which are much more worse imo. Here is the log:
Code
Command-line: C:\GNU\WinAVR\bin\avr-gdb.exe -nx -fullname  -quiet -args bin/Debug/RmCont
Working dir : D:\Electronics\Projects\RmCont\source\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.8
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-pc-mingw32 --target=avr".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set print elements -1
>>>>>>cb_gdb:
> set debugevents on
No symbol "debugevents" in current context.
>>>>>>cb_gdb:
> set disassembly-flavor att
No symbol "disassembly" in current context.
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
>>>>>>cb_gdb:
> source C:\GNU\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory D:/Electronics/Projects/RmCont/source/
>>>>>>cb_gdb:
> shell avarice -g -j USB -P attiny2313 -j usb localhost:4242
AVaRICE version 2.9, Jan  7 2010 22:42:57
Defaulting JTAG bitrate to 250 kHz.
avarice -g -j USB -P attiny2313 -j usb localhost:4242 exited with status 1
read error from AVaRICE: Connection reset by peer
>>>>>>cb_gdb:
> target remote tcp:localhost:4242
tcp:localhost:4242: No connection could be made because the target machine actively refused it.
>>>>>>cb_gdb:
> break main
Breakpoint 1 at 0x486: file RmCont.c, line 216.
>>>>>>cb_gdb:
> continue
The program is not being run.
>>>>>>cb_gdb:
> quit
As u can see the gdbserver is launched with the line 'shell avarice -g -j USB -P attiny2313 -j usb localhost:4242'. Server is there waiting for connection but gdb doesn't resume till shell command exits so I had to kill avarice (exited with status 1) to make gdb resume its initialization and as u can guess it couldn't connect to server (which I had to kill to make gdb resume ;)) and quit.
Macros also doesn't work. I had to replace my '$MCU' with its actual value to make it work. In the tools menu I can use '$MCU' without a problem. And the working dir, is there any way to define the working dir, it might be needed.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: GDB
« Reply #29 on: February 15, 2011, 11:58:15 am »
1. You can make a shell script which uses "avarice  .... & "
2. Macros could be implemented, I think
(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!]