Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: SteelRat on August 10, 2014, 08:03:11 pm

Title: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 10, 2014, 08:03:11 pm
Trying to debug Android app. Application was built by C::B with modified "Arm Compiler" adapted for Android.
In the shell i can connect to remote "gdbserver" and at least kill app. C::B can connect too, but it can't do anything. And i can't start debug without typing something in "Project->Set program's arguments...". Yes, for C::B it's just shared library, but i don't need to set any executable for it when debugging Android.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 10, 2014, 08:13:49 pm
Have you setup your project for remote debugging? ( project -> properties -> debugger -> remote connection)
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 10, 2014, 08:19:45 pm
Yes, it connects. I'm using IP: localhost Port: 5039 with checked "Connect with extened-remote". I suspect that some things are works. gdbserver stops by unknown reason (may be breakpoint was set) and then i click "Continue" and application runs, but C::B still thinks that app is paused - step buttons are active.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 10, 2014, 08:50:44 pm
Can you post the full log from the debugger (you should enable it in the Settings -> Debugger)
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 10, 2014, 09:41:37 pm
I ran gdbserver, app stops. Then i ran debug in C::B and app continues. You can see it in last line of log. By the way, my source code is above project's dir, in ../../src relative to C::B project. And i still don't know what to do with "Program's arguments".
Code
Building to ensure sources are up-to-date
Selecting target:
Android Debug
Adding source dir: /home/steelrat/projects/gipe/build/cbp/
Adding source dir: /home/steelrat/projects/gipe/
Adding source dir: /home/steelrat/projects/kangoo/build/cbp/
Adding source dir: /home/steelrat/projects/kangoo/
Adding file: libcroger_d.so
Changing directory to: /home/steelrat/projects/kangoo/bin
Set variable: LD_LIBRARY_PATH=.:/home/steelrat/projects/gipe/lib:/home/steelrat/projects/gipe/deps/minizip:/home/steelrat/development/android/ndk/sources/sfml/lib/armeabi:/home/steelrat/projects/gipe/lib/android/armeabi:/home/steelrat/development/android/ndk/sources/lua/lib/armeabi:/home/steelrat/development/android/ndk/sources/oolua/lib/armeabi:/home/steelrat/development/android/ndk/sources/box2d/lib/armeabi:/home/steelrat/development/android/ndk/sources/minizip/lib/armeabi:

[debug]Command-line: /home/steelrat/development/android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb -nx -fullname  -quiet  -args libcroger_d.so
[debug]Working dir : /home/steelrat/projects/kangoo/bin

Starting debugger: /home/steelrat/development/android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb -nx -fullname  -quiet  -args libcroger_d.so
done

[debug]libcroger_d.so: No such file or directory.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Connecting to remote target
Setting breakpoints

[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android".
[debug]For bug reporting instructions, please see:
[debug]<http://source.android.com/source/report-bugs.html>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]No symbol table is loaded.  Use the "file" command.
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]No symbol table is loaded.  Use the "file" command.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory /home/steelrat/projects/gipe/build/cbp/
[debug]Source directories searched: /home/steelrat/projects/gipe/build/cbp:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory /home/steelrat/projects/gipe/
[debug]Source directories searched: /home/steelrat/projects/gipe:/home/steelrat/projects/gipe/build/cbp:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory /home/steelrat/projects/kangoo/build/cbp/
[debug]Source directories searched: /home/steelrat/projects/kangoo/build/cbp:/home/steelrat/projects/gipe:/home/steelrat/projects/gipe/build/cbp:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory /home/steelrat/projects/kangoo/
[debug]Source directories searched: /home/steelrat/projects/kangoo:/home/steelrat/projects/kangoo/build/cbp:/home/steelrat/projects/gipe:/home/steelrat/projects/gipe/build/cbp:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> target extended-remote tcp:localhost:5039
[debug]Remote debugging using tcp:localhost:5039
[debug]0x400caa90 in ?? ()
[debug]>>>>>>cb_gdb:

Connected

[debug]> continue

In ?? () ()

[debug]> continue
[debug]Continuing.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 10, 2014, 10:03:44 pm
You've not set any breakpoints, so your app should just run to completion.
What are you expecting to happen?

The program's arguments should be ignored when remote debugging...
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 11, 2014, 08:01:00 am
I tried to set breakpoints before by C::B. Then i cleared them. And i think that one of them was stored in gdbserver's cache, can it be? I expect that C::B debugs android's app as usual executable. But now works only "continue".
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 11, 2014, 08:56:12 am
I don't think there is any gdbserver cache.

After you press debug does your app runs normally on your android?
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 11, 2014, 09:08:20 am
My actions:
1. I'm starting shell script that kills app on Android and starts it.
 a. Receiving PID of app's process.
 b. Starting gdbserver on android, attaching it to received PID.
2. Starting remote debugging in C::B. To this moment app's is already in paused state. When i did first times - there was no pause. It appears when i tried to set breakpoints in C::B and then i remoed all breakpoints.   :-\

As you see it take pretty much of time, when breakpoint in "main" is missed already.
I'm planning to set eternal loop in the very begining. Something like this:
Code
int i = 0;
while (i == 0)
{
};
Then i'll write in "Additional GDB commands->After connection" set var i = 1.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 11, 2014, 10:05:15 pm
Hm, why are you using localhost as host?
Are you using some kind of emulator?
Have you tried to use gdb directly to see if the problem is cause by C::B or gdb?
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 12, 2014, 08:46:28 am
Well, answer is simple - i don't know correct way to do it. I'm using real device connected via USB in Ubuntu 14.04. I'm used Eclipse for NDK before, there was no problems with it, but i HATE Eclipse. =) Eclipse's GUI and functional is overloaded and slow.
So i began to try debugging with C::B. Now i even think to write C::B plugin like ADT for Eclipse...
I tried to use gdb directly and it works, there no symbols loaded but it can pause/continue and kill app.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 12, 2014, 09:30:59 am
Are you trying to debug Java code and not C/C++?
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 12, 2014, 12:51:43 pm
You've never programmed Android. =) I'm using ONLY C++. Ok, not only, Lua is used for scripts.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 12, 2014, 10:17:26 pm
Yes, I've not...
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 13, 2014, 09:35:11 pm
Now debugger reacts on C::B commands, thanks to "set sysroot to $(NDK)/platforms/$(#NDK.target)/arch-arm" =)
There are other problems now. But i think it's not C::B's problems.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 17, 2014, 03:15:32 pm
Does C::B expand variables in project's Debugger options? I mean "Additional GDB commands". As i see now - it does not. Is it bug?
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 18, 2014, 08:27:23 pm
Do you have an example command you want to execute which is not working?
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 18, 2014, 08:44:52 pm
Code
set sysroot $(NDK)/platforms/$(#NDK.target)/arch-arm
or any other command.
Where $(NDK) - system's variable and $(#NDK.xxx) - C::B's global variable. It is perfectly works everywhere in project's properties except "Additional GDB commands".
Then, from GDB console, i'm calling "show sysroot" and it prints "$(NDK)/platforms/$(#NDK.target)/arch-arm" without any changes.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: oBFusCATed on August 18, 2014, 10:57:18 pm
Fixed in SVN.
Title: Re: Using of arm-linux-androideabi-gdb
Post by: SteelRat on August 19, 2014, 10:41:41 am
Thanks! =)