QEMU & Syborg Debugging
From Symbian Developer Community
The Symbian Virtual Platform (SVP) allows stop-mode debugging of Symbian ROM images running on a PC in the QEMU emulator.
Contents |
Preconditions
You require a Symbian image which boots on the Symbian Virtual Platform as described here
You'll need Carbide.c++, which you get as part of the ADT or PDT.
Install the GDB hardware debugger plug-in
- In the Carbide.c++ select Help -> Software Updates -> Find and Install...
- Select Search for new features to install and click Next
- Click New Remote Site... and set:
- Name: CDT
- URL: "http://download.eclipse.org/tools/cdt/releases/ganymede"
- Click OK and then Finish
- Expand the CDT item. Now now you should see CDT Main Features and CDT Optional Features. Expand the CDT Optional Features menu. Tick Eclipse C/C++ GDB Hardware Debugging <version number> and click Next
- Accept the terms of the license agreement and click Next and then Finish
- Click Install All on the verification screen
- Click Yes and wait for Carbide.c++ to restart
Note: You may have to change the release name from "ganymede" in step 3, depending on the version of Eclipse that the your Carbide.c++ release is based on. This is the correct version for at least ADT 1.0 and PDT 1.0 - 1.3.
Download and install ARM-ELF tools
- Download and run the GNUARM GCC-4.3 toolchain from here: http://www.gnuarm.org/bu-2.19_gcc-4.3.2-c-c++_nl-1.16.0_gi-6.8.exe
Install elf4rom
ELF4ROM creates symbol and debug information for your ROM image. Copy elf4rom.zip from your Symbian syborg environment \sf\adaptation\qemu\docs\wiki\ELF4ROM.doc (Yes, the zip file is indeed embedded in a Word document!). Extract the content to a local directory. The Word document (ELF4ROM.doc) contains comprehensive documentation.
Debug Setup
Create an ELF file from your Symbian ROM image
Example:
cd \sf\os\kernelhwsrv\kernel\eka\rombuild elf4rom.exe -i SYBORGARMV5D.IMG -l SYBORGARMV5D.log -o SYBORGARMV5D.elf -p 0x0 -d _SYBORG_EKERN.EXE _SYBORG_KASYBORG.DLL _SYBORG_ESERIAL.PDD _SYBORG_EKEYB.DLL
- This example assumes that the location of elf4rom.exe as been added to path environment variable
- SYBORGARMV5D.log is used here, if you didn't explicitly rename it when you built the ROM it'll be called ROMBUILD.log
- The resulting ELF file in the is SYBORGARMV5D.elf
Read more about elf4rom usage in \sf\adaptation\qemu\docs\wiki\ELF4ROM.doc
Create a Makefile project in Carbide.c++
- Create a new directory under your Carbide workspace directory and copy your elf file to the directory
- Start Carbide.c++ (if not already running)
- Create a new C++ makefile project. File -> New -> Project
- Tick the Show All Wizards checkbox and select C++ -> C++ Project
- Click Next and agree to turn on hidden UI feature
- Type the directory in which your elf file is located to the Project name field
- Select Makefile Project and in the toolchains box select MinGW GCC
- Click Next and then Finish
- Right-click the project you just created in Project Explorer view and select Properties
- Expand C/C++ Build and click Settings. In the Binary parser window un-tick PE Windows Parser and tick GNU Elf Parser
- Select the GNU Elf Parser option to make the commands addr2line and c++filt visible. Change addr2line to arm-elf-addr2line and c++filt to arm-elf-c++filt. (NOTE: If you dont have the directory of your arm-elf tools defined in your path you must give the full path for these executables.)
- Click OK
You should now be able to to explore the contents of your ELF file in the Project Explorer view of your eclipse environment. To test the environment navigate to syborg_keyboard.cpp and add a break point to DKeyboardPs2Soc::Isr() method. (Note: Depending on configuration, you may get to navigate the elf file by symbol rather than filename - need to investigate what causes this - in this case, you'll have to select the mangled symbol name, right click and select add breakpoint).
Create a debug configuration
- In the eclipse UI click Run -> Debug Configurations. Having installed gdbjtag as described above you should see a GDB Hardware Debugging option in Debug Configurations window
- Right-click GDB Hardware Debugging and click New
- In the resulting menu choose Main tab
- Give a good name to your configuration
- Select the project you created in the Project box
- Type your ELF file name in the C/C++ Application box
- Select Disable Auto Build
- Select the Debugger tab
- Type arm-elf-gdb in the GDB Command box
- Un-tick Use remote target
- Select the Startup tab and type tar rem localhost:1234 in the Run Commands box
- Click Close
Start your debug session
- Start simulation
- Start a command prompt and change to the directory for the Carbide workspace project you just created - the one your elf file is located in
- Start your QEMU syborg Symbian simulation.Example: <path to your build environment>\symbian-qemu-0.9.1\bin\arm-none-symbian-elf-qemu-system.exe -M <path to your build environment>\sf\adaptation\qemu\baseport\syborg\syborg.dtb -kernel SYBORGARMV5D.elf -S -s
- At this point the QEMU Symbian simulation window should appear (with QEMU [Stopped] label on it)
- Connect debugger to simulation
- In your eclipse UI click Run -> Debug Configurations
- Now you should have your Debug configuration visible in the "Debug Configurations" dialog - if not, select it from the list
- Press Debug in the bottom right of the dialog
- If your eclipse perspective is not switched automatically to Debug click Window -> Open Perspective -> Debug
- You don't need to worry about possible error "No symbol "new" in current context." visible in the Console window
- In the "Console" window enter "c" (or you can click the green arrow in the IDE to continue debugging - this will give an error the first time but work properly after that)
- Now you should have your Symbian simulation booted up
- Enter a keypress to your Symbian window and you should hit to a previously added breakpoint in DKeyboardPs2Soc::Isr method
Debug Notes
- Be carefull with your path environment variable setup. For example it seemed to cause problems if eclipse was able to found previous gdb installation (like http://downloads.sourceforge.net/mingw/gdb-6.6.tar.bz2).
- Read more about debugging from your Symbian syborg environment \sf\os\QEMU\docs\wiki\Stop-mode Debugging.doc
Mapping a directory on the host OS to the QEMU S: drive
A very useful feature of QEMU is the ability to map a directory on the host OS to the S: drive.
To do this create a directory called svphostfs in the root of the drive from which QEMU is run. For example, if QEMU is run from the C: drive create C:\svphostfs.
Files can be copied to the S: drive in the emulated Symbian OS environment and they will appear here. This makes retrieval of logs very straightforward.
Additionally you can copy files to the mapped directory (i.e. 'svphostfs') and then copy them to the appropriate location in the Symbian OS instance. You can even create a directory 'svphostfs\sys\bin' and copy binaries there to make them usable in the Symbian OS. This feature reduces much of the need for building ROM images.
Comments
Contents |
Davidcrookes said…
Markw said…
Hi David,
I haven't had a more complex rom than a text shell to test this with yet. I did notice that you can set breakpoints in source without expanding the ELF in the project explorer. Not sure if that helps.
When I have time to play with a full UI ROM I'll see if I can reproduce - that may not be for a couple of weeks I'm afraid, so please report back if you fix it in the mean time.
--Markw 19:14, 5 January 2010 (UTC)
Davidcrookes said…
Hi Mark,
I've not solved the problem but I suspect I've identified something like it. I grabbed lots of source from the eclipse-cdt project and although I've not proved it, I found in the "old" source the following FAQ, dev.eclipse.org:/cvsroot/tools/org.eclipse.cdt/old/cdt-home/user/faq.html#troubleshooting_20
“Whenever I build the project, the eclipse hangs (gets "stuck"). I need to kill a process named: "c++ filt" to restart it. Why? There was a bug in the old version of c++filt that did not flush its output when it finishes (this same problem happens with addr2line). CDT is waiting for the answer from c++filt. You need get a new version of c++filt to fix the problem.”
I don't actually see the source in my project view, and was relying on the elf file to set initial breakpoints.
--Davidcrookes 11:55, 6 January 2010 (UTC)
Markw said…
Sounds like you've indentified the component with the problem. Regarding source in the project view, IIRC, I found I could just open source files from the correct location and set breakpoints in them, even though they didn't appear within the project in the IDE. That might only be the case if c++filt is working of course...
--Markw 11:11, 7 January 2010 (UTC)
Davidcrookes said…
Some more notes. 1. I don’t know about anyone else, but internally here, we’ve noticed that the section above:
“Create a Makefile project in Carbide.c++…11. Select the GNU Elf Parser option to…"...
doesn’t quite work for us. One can set the new tools <gnuarmpath>\arm-elf\addr2line but this setting seems to revert for us (carbide 2.1). I cheated here by copying my gnuarmpath’s exes to the default names of addr2line.exe and c++filt.exe in the same path.
2. Regarding my problem of expanding the ELF, if you take the advice of the old Eclipse-CDT FAQ, and kill c++filt, then you will see Carbide become responsive again, and interestingly some parts of the ELF file symbols are displayed and can have a breakpoint toggled on them. This breakpoint would break when execution occurs, but I have been finding that stepping was not predictable and didn’t seem to allow step-in effectively.
3. I tried to open source files directly , and Carbide would allow me to toggle breakpoints pre-execution anyhow, but it transpires that this never works. When I tried this, executions would fail, carbide reporting that the ELF and GDB had exited with code 35584. This looks like to be arm-elf-gdb failing, in my view. The reason I say this is because I enabled gdb verbosity (Run->Debug configs -> Debugger tab -> Verbose console mode) and the exit seems to occur when the breakpoint in the source file is set using gdb’s commands. I discovered arm-elf-gdb.exe.stackdump files were being left around. I started to suspect that this may be to do with the fact that the gnuarm tools recommended use cygwin and so my system’s cygwin1.dll is being used here. I am upgraded to cygwin 1.7.1. The gnuarm pages show links to cygwin 1.5.x source.
While investigating these issues I was examining whether the binutils were upto date and noticed that there is a gnuarm derivative project, YAGARTO, http://yagarto.de/ This version avoids cygwin and presumably uses mingw or some such. Installing the instance yagarto-bu-2.20_gcc-4.4.2-c-c++_nl-1.18.0_gdb-7.0.1_20091223.exe (look at http://www.yagarto.de/index.html#download) and getting rid of gnuarm from paths, and reconfiguring everything to use the binutils in the yagarto installation, along with removing cygwin from the path seemed to give much better results now.
I still hit the “c++filt hang” problem, but on killing that, the ELF file symbols that are shown are now de-mangled. Also, open a source file, inserting a breakpoint, is working when I launch an execution. I’ve been stepping into browserng.exe functions ok, as long as I have the symbol data in the ELF.
So I think a step forward.
--Davidcrookes 17:01, 7 January 2010 (UTC)
Paulb said…
For Run Mode debugging with Carbide, see http://developer.symbian.org/wiki/index.php/Carbide.c%2B%2B_Run_mode_Debugging_of_Qemu_using_TRK
--Paulb 21:35, 14 January 2010 (UTC)
Sign in to comment…


I have a found a problem perhaps worth noting. I got this going on a customer environment, as described above although I had problems with paths, where originally my path contained \epoc32\gcc\bin. This was picked up by Carbide and when carbide used addr2line or c++filt, these programs would use the cygwin1.dll found in \epoc32\gcc\bin. This would cause a silent failure in Carbide for me, but noticeable when running these tools myself on the command line.
When I got this going, it was using a udeb version of eshell.exe in the config file used with elf4rom. However, I am more interested in debugging browserng.exe in my rom. When I try the same process with a udeb version of this executable, an unsolved problem occurs. I can open the project but in the project explorer view, when I attempt to expand/open the ELF file binary (syborg_001.OBEYFILE.elf for me), Carbide becomes non-responsive and hangs. I’ve not waited beyond 30 mins or so but Windows task manager shows Carbide/addr2line/c++filt as running but using no CPU. Addr2line has memory usage of ~0.75GB. The ELF file in this use case is ~275MB in size, versus ~100MB for the eshell experiment. I suspect that the binary parsers are barfing somehow here for too big a use case.
I’ve not worked out how I can diagnose what happens here yet. Suggestions more than welcome.
--Davidcrookes 12:30, 5 January 2010 (UTC)