Author Topic: Debugging OpenXcom in Android Studio... how to show the line numbers?  (Read 5204 times)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8595
    • View Profile
Hi there,

any Android developer out there?

I finally managed to start debugging openxcom in native mode, using LLDB, on android emulator... however, when an exception is thrown, I see only which class and method are related to the exception (plus call stack)... but no line numbers.

This is obviously a big problem, since methods like Map::drawTerrain are huge and I cannot add a log output after each line!?

Is it somehow possible to convince Android Studio to show me the line(s) where it crashed?
(Also, it would be nice to be able to jump directly to source code... but I guess I could live without that, if they at least told me the line number)

Please help.

Offline Yankes

  • Commander
  • *****
  • Posts: 3192
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #1 on: April 12, 2017, 11:40:49 am »
I think is possible that LLDB do not have path to src files and can't show it. Wen I use gdb (debugger from gcc) it show line numbers without problems.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8595
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #2 on: April 13, 2017, 05:52:57 pm »
I think is possible that LLDB do not have path to src files and can't show it. Wen I use gdb (debugger from gcc) it show line numbers without problems.

Thanks, looks like the ndkbuild-based approach didn't recognize the source files... I've upgraded to cmake-based build and the source is now properly displayed.

Btw. the crash was on the cursor rendering, which is different in OXCE from OXC... why exactly?
And could you look if the code is actually correct?
I got invalid frame reference in CURSOR.PCK for some reason, see attached screenshot.

Offline Yankes

  • Commander
  • *****
  • Posts: 3192
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #3 on: April 13, 2017, 06:15:21 pm »
`_animFrame` count up to near million, this now is frame number that some simple frame index repeater. One way to fix it is add `%` that will limit values.
Btw I do not recognize this part of code you show, form what branch exactly it is?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8595
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #4 on: April 14, 2017, 12:59:20 pm »
`_animFrame` count up to near million, this now is frame number that some simple frame index repeater. One way to fix it is add `%` that will limit values.
Btw I do not recognize this part of code you show, form what branch exactly it is?

You're right again, it's not OXCE, its the Android modifications made by sfalexrog...
... unfortunately I don't know exactly what was the idea behind this change, not sure how I should fix it.. any ideas?

Here's the change in my branch: https://github.com/MeridianOXC/OpenXcom/commit/010eb6925520852b17605a6bb6d04fd44549d4b4#diff-cd335154e65aaeb27bdbd88e7d6f14f6

Here's the original: https://github.com/sfalexrog/OpenXcom/commit/ea133a177cad93014d0dccd8f89367806025631d

Help appreciated.

Offline Yankes

  • Commander
  • *****
  • Posts: 3192
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #5 on: April 15, 2017, 02:24:05 pm »
Probably eases way to fix it is change `_animFrame / 2` to `(_animFrame / 2) % 4` this will yeld same value range as in OXC.
I don't know it result will be any sane but at leas same as in OXC.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8595
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #6 on: April 15, 2017, 03:56:47 pm »
Great, seems to work just fine.

I used '7 + halfAnimFrame' at the end instead, which does the same thing.

As far as I can say, the first playable OXCE+ for Android is alive :)

Offline Yankes

  • Commander
  • *****
  • Posts: 3192
    • View Profile
Re: Debugging OpenXcom in Android Studio... how to show the line numbers?
« Reply #7 on: April 15, 2017, 04:35:56 pm »
great :)