Author Topic: Using of arm-linux-androideabi-gdb  (Read 13292 times)

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Using of arm-linux-androideabi-gdb
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #1 on: August 10, 2014, 08:13:49 pm »
Have you setup your project for remote debugging? ( project -> properties -> debugger -> remote connection)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #2 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.
« Last Edit: August 10, 2014, 08:24:01 pm by SteelRat »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #3 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)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #4 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #5 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...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #6 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".

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #7 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #8 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #9 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #10 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #11 on: August 12, 2014, 09:30:59 am »
Are you trying to debug Java code and not C/C++?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #12 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #13 on: August 12, 2014, 10:17:26 pm »
Yes, I've not...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #14 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.

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #15 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #16 on: August 18, 2014, 08:27:23 pm »
Do you have an example command you want to execute which is not working?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #17 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using of arm-linux-androideabi-gdb
« Reply #18 on: August 18, 2014, 10:57:18 pm »
Fixed in SVN.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline SteelRat

  • Multiple posting newcomer
  • *
  • Posts: 45
  • Stainless
Re: Using of arm-linux-androideabi-gdb
« Reply #19 on: August 19, 2014, 10:41:41 am »
Thanks! =)