Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Visitor
huangbilly
Posts: 18
Registered: ‎06-29-2010
0

Microblaze Native GDB Debugging

Hi,

 

This is not a request for help, but to let you know that I have recently ported GDB to run natively on Linux.

 

To get the debugger working, you can follow the instructions at:

http://fusion.phys.tue.nl/fpga/doku.php?id=microblaze_gdb

 

This means that Microblaze code can be debugged on an FPGA board without the need to use XMD, and also debug programs using all the normal libraries.  Threaded debugging also works.

 

Additionally the kernel needs patching but this is relatively straight forward.

 

Good luck and happy debugging!

 

Billy.

Regular Contributor
marco.hoefle@nanotronic.ch
Posts: 54
Registered: ‎10-05-2010
0

Re: Microblaze Native GDB Debugging

Hello Billy,

that is nearly what I am looking for. I think most users would like to run gdb on a development pc and use gdbserver on the microblaze system rather than running gdb itself on the microblaze.

 

Have you used GDB + gdbserver yourself?

Thanks,

Marco

Visitor
huangbilly
Posts: 18
Registered: ‎06-29-2010
0

Re: Microblaze Native GDB Debugging

Hi Marco,

 

gdbserver will compile with patch I have provided, however I found it insufficient for large programs which required specific libraries compiled for the microblaze.  This led me to make gdb run on the microblaze so that all the libraries for debugging an executable would be loaded automatically.

 

the default gdb 7.2 should compile gdbserver (just cd to gdb/gdbserver and make from that directory) and try it.   i tested compiling and running gdbserver but found the native microblaze much more useful at debugging even if a bit slower.

 

If you find gdbserver better then please reply with some details as I think loads of people read these pages,

 

Cheers,

 

Billy.

Regular Contributor
marco.hoefle@nanotronic.ch
Posts: 54
Registered: ‎10-05-2010
0

Re: Microblaze Native GDB Debugging

Hello Billy,

I am using the latest xlnx kernel (2.6.37 stable) and I tried your patch already. There are a few hunks rejected so I didn't spend more time in that as I read onthe Microblaze-linux facebook site that you have created a patch for Michael.

I'll try your kernel and give you feedback regarding debugging using gdbserver.

Thanks,

Marco

Regular Contributor
marco.hoefle@nanotronic.ch
Posts: 54
Registered: ‎10-05-2010
0

Re: Microblaze Native GDB Debugging

Hello Billy,

I tried to build gdb native for the Microblaze. I followed the the steps as described in your wiki ( http://fusion.phys.tue.nl/fpga/doku.php?id=microblaze_gdb ).

I used your kernel sources; kernel was compiled and is running successfully.

A small thing to your wiki, the link to download is not correct: hhttp://www.ccfe.ac.uk/fpga/d/fpgaworkshop2011/linux-2.6.35-microblaze.tar.gz, so one 'h' needs to be removed.

 

Compling GDB worked nearly as described, replacing ptrace.h did not work for me as PTRACE_GETREGS is not defined in 

arch/microblaze/inlcude/asm/ptrace.h, thus I left the original one which is part of the xlnx tool chain.

 

After that GDB comiled succesfully but it throws errors when running on the target:

 

# ./gdb_test
Got: 0
Got: 1
Got: 2
Got: 3
Got: 4
Got: 5
Got: 6
Got: 7
Got: 8
Got: 9
#
#
# ./gdb gdb_test
GNU gdb (GDB) 7.2
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 "microblaze-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/gdb_test...done.
(gdb) run
Starting program: /root/gdb_test
warning: Unable to fetch general register.
warning: Unable to fetch general register.
warning: Unable to fetch general register.
warning: Unable to fetch general registers.
warning: Unable to fetch general register.
warning: Unable to fetch general register.
warning: Unable to fetch general register.

Program received signal SIGILL, Illegal instruction.
warning: Unable to fetch general register.
warning: Unable to fetch general register.
warning: Unable to fetch general register.
0x00000000 in ?? ()
warning: Unable to fetch general register.
(gdb)

 

Any ideas what is wrong here?

 

regarding the gdbserver:

It needs to be configured seperatly and the configuration script states that the target is not supported.

The main task of getting gdbserver 7.2 to work is probably to add linux-micorblaze-low.c

 

Thanks,

Marco

Visitor
goudard.olivier
Posts: 8
Registered: ‎03-31-2011
0

Re: Microblaze Native GDB Debugging

Hello Marco and Billy,

 

I have the same behaviour as Marco when trying to run a server with gdb for microblaze :

 

warning: Unable to fetch general register.
#0  0x00000000 in ?? ()

Marco did you solved this problem ?

I will let you know if I find why we have this behaviour.

 

Best regards,

Olivier

 

Regular Contributor
marco.hoefle@nanotronic.ch
Posts: 54
Registered: ‎10-05-2010
0

Re: Microblaze Native GDB Debugging

Hello Olivier,

no I haven't found a solution yet; printf() is what I am using :-(

Did you patch the gdbserver sources from gdb 7.2?

Cheers,

Marco

Visitor
huangbilly
Posts: 18
Registered: ‎06-29-2010
0

Re: Microblaze Native GDB Debugging

Hi Marco and Olivier,

 

The SETREGS/GETREGS error is due to the kernel not having the ptrace patch applied (as mentioned at http://fusion.phys.tue.nl/fpga/doku.php?id=microblaze_gdb#patching_the_kernel). 

 

The SIGILL exception is expected, this should dissappear with the kernel patch.  The SIGILL happens when a type of branch occurs in user mode.   It is key to have the ptrace patch as this is what allows the kernel to stop and continue programs at different points.  Without this the kernel cannot stop the program and you get the output you have seen.

 

It is true I plan to put the ptrace patch into the mainline but it will not happen for probably at least a month for two reasons: 1) i'm very busy, 2) Michal Simek the microblaze kernel maintainer has rightly indicated that it is a large patch that needs to be broken down and has some big changes so will take time to be patched into the mainline kernel.

 

In the mean time you have 3 options, 1) wait a long time for a mainline patch, 2) use the kernel on http://fusion.phys.tue.nl/fpga/doku.php?id=microblaze_gdb and patch that, 3) hack the patch to your kernel.

 

But just to say congratulations for getting gdb to run natively on the microblaze, that is a good achievement!

 

Cheers,

 

Billy.

 

Visitor
goudard.olivier
Posts: 8
Registered: ‎03-31-2011
0

Re: Microblaze Native GDB Debugging

Hello Marco,

 

Thanks for your answer. No I didn't use gdb sources but I used

 

http://www.ccfe.ac.uk/fpga/d/fpgaworkshop2011/linux-2.6.35-microblaze.tar.gz

 

to compile and run linux for microblaze with gdb included.

 

I agree that printf is not the best way but it can help ! However a good debugger is sometime necessary.

If you look at the new Billy's message the solution to our troubles is described.

I will let you know when it works and which one of the 3 solutions I finally applied

I am still fighting to patch the kernel at moment.

 

Thank you

Olivier

 

Regular Contributor
marco.hoefle@nanotronic.ch
Posts: 54
Registered: ‎10-05-2010
0

Re: Microblaze Native GDB Debugging

Hello Billy and Olivier,

according to this howto the kernel sources are already patched.

I verified it (all hunks are rejected).

 

So I am wondering why this behavior still occurs when using the kernel from http://www.ccfe.ac.uk/fpga/d/fpgaworkshop2011/linux-2.6.35-microblaze.tar.gz

 

Cheers,

Marco