How to debug in emulator using gdb/Eclipse ? | developer.brewmp.com How to debug in emulator using gdb/Eclipse ? | developer.brewmp.com

Developer

How to debug in emulator using gdb/Eclipse ?

Hi All,

Anyone knows how i can run one BREW App in the simulator and debugs in the gdb (or using Eclipse calling the gdb) ?

Ive tried many options, many flags, but it doesnt work =/

I open the gdb console and i load the dll and cal 'run' . The simulator opens ok. When i define a breakpoit '-b' in a line there or in a function, and after this call the simulator, it stills doesnt work =/

anyone can helpme ?

the compiler (gcc) and debug (gdb), both are cygwin.
ive tried using mingW too, and it fails too.

the flags that ive used is:

For compiler (Cygwin GCC):
-O0 -g3 -Wall -c -fmessage-length=0
-O3 -Os -Wall -fno-exceptions -fshort-enums -fno-builtin
-DDEBUG=1 -W -Wall -fshort-enums -fno-builtin -O0 -g

For linker:
-g -shared -mt -mno-cygwin
-shared -nostdlib --entry=AEEMod_Load
-s -shared -static -nostdlib -g
ive tried this flag too -ggdb

Thanks.

Pedro Lages

Sorry but i donot think the Emulator / simulator will support dlls generated by non-Visual Studio compilers.

Sorry but i donot think the Emulator / simulator will support dlls generated by non-Visual Studio compilers.

gdb might be having problems finding the symbols for the dll, since the simulator is built without symbolic information.
add a hardcoded breakpoint into your app and see what gdb says about it, see if it can show a stack trace or variables.

gdb might be having problems finding the symbols for the dll, since the simulator is built without symbolic information.
add a hardcoded breakpoint into your app and see what gdb says about it, see if it can show a stack trace or variables.

Here is the complete example that work for me.
My environment:
1. gcc --version
gcc (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
2. gdb --version
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
3. BREW 3.1.4
I've got the follwoing:
1. Created the directory for my project (let's say "MyExample")
2. Copied helloworld.c, helloworld.mif from BREW 3.1.4 examples
3. Copied AEEAppGen.c, AEEModGen.c from BREW 3.1.4 src directory
4. Run the batch file attached.
Note: it has 2 tricks related to '-mno-cygwin' linker flag:
1. If you will see linker error about dllcrt2.o, copy it from your cygwin folder (C:\Utils\Cygwin\lib\mingw in my case) to this applet folder (i.e. current dir)
2. To prevent linker error about '-lmingw32', I had added
-L"C:\Utils\Cygwin\lib\mingw" option to the linker command line.
5. Run GDB with the following command line (current dir is MyExample):
gdb "c:\Program Files\BREW 3.1.4\sdk\bin\BREW_Simulator.exe"
6.Execute the follwing commands:
dll-symbols -now helloworld/helloworld.dll
b AEEMod_Load
run
7. After simulator startup, change its Applet directory to MyExample. You should see HelloWorld icon/text
8. Select this item and press OK on the simulator window
9. You should see debugger hit breakpoint
Breakpoint 1, AEEMod_Load (pIShell=0x1e00050, ph=0x5a6ff8, ppMod=0x1e133a4)
at AEEModGen.c:138
138 return AEEStaticMod_New(sizeof(AEEMod),pIShell,ph,ppMod,NULL,NULL);
BTW, you also should see debug messages from BREW simulator/applications
10. Set one more breakpoint:
(gdb) b HelloWorld_HandleEvent
Breakpoint 2 at 0x2601234: file helloworld.c, line 208.
11. Continue:
(gdb) c
12. See how this breakpoint hits
You can examine data
Dmitry

Here is the complete example that work for me.
My environment:
1. gcc --version
gcc (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
2. gdb --version
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
3. BREW 3.1.4
I've got the follwoing:
1. Created the directory for my project (let's say "MyExample")
2. Copied helloworld.c, helloworld.mif from BREW 3.1.4 examples
3. Copied AEEAppGen.c, AEEModGen.c from BREW 3.1.4 src directory
4. Run the batch file attached.
Note: it has 2 tricks related to '-mno-cygwin' linker flag:
1. If you will see linker error about dllcrt2.o, copy it from your cygwin folder (C:\Utils\Cygwin\lib\mingw in my case) to this applet folder (i.e. current dir)
2. To prevent linker error about '-lmingw32', I had added
-L"C:\Utils\Cygwin\lib\mingw" option to the linker command line.
5. Run GDB with the following command line (current dir is MyExample):
gdb "c:\Program Files\BREW 3.1.4\sdk\bin\BREW_Simulator.exe"
6.Execute the follwing commands:
dll-symbols -now helloworld/helloworld.dll
b AEEMod_Load
run
7. After simulator startup, change its Applet directory to MyExample. You should see HelloWorld icon/text
8. Select this item and press OK on the simulator window
9. You should see debugger hit breakpoint
Breakpoint 1, AEEMod_Load (pIShell=0x1e00050, ph=0x5a6ff8, ppMod=0x1e133a4)
at AEEModGen.c:138
138 return AEEStaticMod_New(sizeof(AEEMod),pIShell,ph,ppMod,NULL,NULL);
BTW, you also should see debug messages from BREW simulator/applications
10. Set one more breakpoint:
(gdb) b HelloWorld_HandleEvent
Breakpoint 2 at 0x2601234: file helloworld.c, line 208.
11. Continue:
(gdb) c
12. See how this breakpoint hits
You can examine data
Dmitry

Well, forgot attachment. Simce it is a small bat, here its content
set BREWDIR="C:\Program Files\BREW 3.1.4\sdk\inc"
gcc -O0 -g3 -Wall -DAEE_SIMULATOR -D_DEBUG -I%BREWDIR% -c -fmessage-length=0 -o helloworld/helloworld.o helloworld.c
gcc -O0 -g3 -Wall -DAEE_SIMULATOR -D_DEBUG -I%BREWDIR% -c -fmessage-length=0 -o helloworld/AEEAppGen.o AEEAppGen.c
gcc -O0 -g3 -Wall -DAEE_SIMULATOR -D_DEBUG -I%BREWDIR% -c -fmessage-length=0 -o helloworld/AEEModGen.o AEEModGen.c
gcc -g -mt -shared -mno-cygwin -L"C:\Utils\Cygwin\lib\mingw" -Wl,-Map -Wl,helloworld/helloworld.map helloworld/helloworld.o helloworld/AEEAppGen.o helloworld/AEEModGen.o -o helloworld/helloworld.dll

Well, forgot attachment. Simce it is a small bat, here its content
set BREWDIR="C:\Program Files\BREW 3.1.4\sdk\inc"
gcc -O0 -g3 -Wall -DAEE_SIMULATOR -D_DEBUG -I%BREWDIR% -c -fmessage-length=0 -o helloworld/helloworld.o helloworld.c
gcc -O0 -g3 -Wall -DAEE_SIMULATOR -D_DEBUG -I%BREWDIR% -c -fmessage-length=0 -o helloworld/AEEAppGen.o AEEAppGen.c
gcc -O0 -g3 -Wall -DAEE_SIMULATOR -D_DEBUG -I%BREWDIR% -c -fmessage-length=0 -o helloworld/AEEModGen.o AEEModGen.c
gcc -g -mt -shared -mno-cygwin -L"C:\Utils\Cygwin\lib\mingw" -Wl,-Map -Wl,helloworld/helloworld.map helloworld/helloworld.o helloworld/AEEAppGen.o helloworld/AEEModGen.o -o helloworld/helloworld.dll

Dmitry,
could explain why you've included options
-mno-cygwin -L"C:\Utils\Cygwin\lib\mingw"
-Wl,-Map -Wl,helloworld/helloworld.map helloworld/helloworld.o
for linker.
I've build my brew dll in almost the same manner you did. However, when I try to debug it with gdb my breakpoints are skipped and I can't put a breakpoint on AEEMod_Load. :rolleyes:
hope you will share your ideas on that matter!

Dmitry,
could explain why you've included options
-mno-cygwin -L"C:\Utils\Cygwin\lib\mingw"
-Wl,-Map -Wl,helloworld/helloworld.map helloworld/helloworld.o
for linker.
I've build my brew dll in almost the same manner you did. However, when I try to debug it with gdb my breakpoints are skipped and I can't put a breakpoint on AEEMod_Load. :rolleyes:
hope you will share your ideas on that matter!