Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

Debugging Apps under Linux MMU

Altera_Forum
Honored Contributor II
2,031 Views

Well, I'm on to debugging apps under linux. 

 

I tried to follow (and adapt) the wiki directions for using gdb: 

http://www.nioswiki.com/operatingsystems/uclinux/debugapps 

 

I'm using the gdbserver and nios2-linux-gnu-gdb from the tarball on: http://www.nioswiki.com/linux 

 

I can run gdbserver on my board. When I run gdb on my host and execute the "target remote" command, it doesn't seem to have any idea about what is going on. It seems to think the program is already running. 

 

I have some questions about the DebugApps page, and how to apply it to Linux with MMU: 

  1. Is the "-elf2flt" option a compile option or a link option? And do I need it? 

  2. Where does the file "hello.gdb" come from? Is it generated by the compiler?
0 Kudos
9 Replies
Altera_Forum
Honored Contributor II
1,046 Views

Just one thing I already seem to know:  

-elf2flat is used only for the noMMU architecture. With an MMU you don't need it as the elf executable format is natively used. 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

 

--- Quote Start ---  

 

I'm using the gdbserver and nios2-linux-gnu-gdb from the tarball on: http://www.nioswiki.com/linux 

 

I have some questions about the DebugApps page, and how to apply it to Linux with MMU:
  1. Is the "-elf2flt" option a compile option or a link option? And do I need it? 

  2. Where does the file "hello.gdb" come from? Is it generated by the compiler?
 

--- Quote End ---  

 

 

Please use 'nios2-wrs-linux-gnu-gdb' in the directory '/home/***/nios2-linux/toolchain-mmu/x86-linux2/bin'. After the connection, 

(gdb) symbol-file <your program> (gdb) tb main (gdb) c (gdb) list <your program list> int main(.... (gdb) is a normal tour course of gdb. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

I have followed the guide of nioswiki about:"Debug user space " but I have some doubts. The first one is with this command: 

 

 

--- Quote Start ---  

set solib-absolute-prefix ~/nios2-linux/toolchain-mmu/x86-linux2/nios2-wrs-linux-gnu/libc 

--- Quote End ---  

I mean "nios2-wrs-linux-gnu" is the same as "nios2-linux-gnu"?, because I haven't found the folder "nios2-wrs-linux-gnu". 

 

The other problem that I met is when I have to generate the .gdb file. 

With the binary tool chain of nioswiki I have to use this command to create de .gdb file. 

 

 

--- Quote Start ---  

nios2-linux-uclibc-gcc -g VGA.c -o VGA -elf2flt 

--- Quote End ---  

But can I create .gdb file with the toolchain-mmu?. I have read that I have to compiled again my application with -g , I have checked with :"nios2-linux-gnu-gcc -g ..." but I didn't go. If someone can suggest me any ideas. 

 

Many thanks
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

 

--- Quote Start ---  

 

 

I have followed the guide of nioswiki about:"Debug user space " but I have some doubts. The first one is with this command: 

 

I mean "nios2-wrs-linux-gnu" is the same as "nios2-linux-gnu"?, because I haven't found the folder "nios2-wrs-linux-gnu". 

 

--- Quote End ---  

 

 

The command 

set solib-absolute-prefix ~/nios2-linux/toolchain-mmu/x86-linux2/nios2-wrs-linux-gnu/libc indicates the search path of dynamic-link libraries to 'gdb'. And you don't need to set this if you don't want to debug the inside of libraries. But you should have the folder 'nios2-wrs-linux-gnu'. Maybe something is wrong. 

 

 

--- Quote Start ---  

 

The other problem that I met is when I have to generate the .gdb file. 

With the binary tool chain of nioswiki I have to use this command to create de .gdb file. 

 

But can I create .gdb file with the toolchain-mmu?. I have read that I have to compiled again my application with -g , I have checked with :"nios2-linux-gnu-gcc -g ..." but I didn't go. If someone can suggest me any ideas. 

 

--- Quote End ---  

 

 

Don't worry about it. The executable 'elf' file has all debug information in it by typing 

nios2-wrs-linux-gnu-gcc -g -O0 -o <your_executable_file> <your_source_file>

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

Many thanks for the reply. These days I have been looking for the folder "nios2-wrs-linux-gnu" that you commented that I have to had.  

 

I have download and updated the tarball of 1.7GB of the nioswiki(uClinux with MMU) to be sure that I haven't erased something, and I haven't found this folder inside it. 

 

But in the web http://www.niosftp.com/pub/gnutools/ there is a folder(Maby I wrong but I think it is a cross-compiler) with the same name as you have commented . Both things the tarball and this folder have been uploaded in similar dates. 

 

Have you installed this folder after you installed the tarball ,if so do you recommend me to do it? 

 

Many Thanks
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

--- Quote Start ---  

 

Have you installed this folder after you installed the tarball ,if so do you recommend me to do it? 

 

--- Quote End ---  

 

 

I only followed the instruction of  

http://www.nioswiki.com/linux/downloading_linux_distribution 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

Many thanks Kazu for your patience
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

I would like to know why I have these errors when I try to debug. 

 

Program exited normally. (gdb) target remote 192.168.1.10:9999 Remote debugging using 192.168.1.10:9999 warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. 0x2aaa8784 in ?? () (gdb) break 9 Breakpoint 5 at 0x1550: file /home/garcia/Escritorio/nios2-linux/uClinux-dist/user/Switchos/Switchos.c, line 9. (gdb) c Continuing. Error while mapping shared library sections: "/lib/libc.so.6": not in executable format: File format not recognized. Error while mapping shared library sections: /lib/ld.so.1: No such file or directory. Error while reading shared library symbols: "/lib/libc.so.6": can't read symbols: File format not recognized.I know that I could debug although these errors, but I think that I have indicated the path of shared library with this command: 

 

set solib-absolute-prefix ~/Escritorio/nios2-linux/toolchain-mmu/x86-linux2/nios2-linux-gnu/libc/lib  

If someone can suggest me any clue about these errors, I work with Ubuntu 9.04 and uClinux with MMU. 

 

Many thanks
0 Kudos
Altera_Forum
Honored Contributor II
1,046 Views

Hi, 

 

I comment the solution that I have found for someone that could met with the same trouble. I write two commands in the archive .gdbinit, these are: 

 

 

set solib-absolute-prefix /home/garcia/Escritorio/nios2-linux/toolchain-mmu/x86-linux2/nios2-linux-gnu/libc/lib set solib-search-path /home/garcia/Escritorio/nios2-linux/toolchain-mmu/x86-linux2/nios2-linux-gnu/libc/lib
0 Kudos
Reply