android-rs-glue icon indicating copy to clipboard operation
android-rs-glue copied to clipboard

Debugging a panic?

Open remexre opened this issue 8 years ago • 4 comments

$ adb logcat | grep RustAndroidGlueStdouterr
01-16 10:47:43.490  9610  9625 D RustAndroidGlueStdouterr: Entering android_main
01-16 10:47:43.490  9610  9625 D RustAndroidGlueStdouterr: Creating application thread
01-16 10:47:43.492  9610  9626 D RustAndroidGlueStdouterr: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotSupported', ../src/libcore/result.rs:837
01-16 10:47:43.492  9610  9626 D RustAndroidGlueStdouterr: note: Run with `RUST_BACKTRACE=1` for a backtrace.

Is there a way to either get the backtrace, or run gdb/lldb remotely?

remexre avatar Jan 16 '17 16:01 remexre

You can do something like std::env::set_var("RUSTC_BACKTRACE", "1") to get a backtrack on the logs.

It's probably possible to plug gdb in but I'm not familiar with that.

tomaka avatar Jan 16 '17 18:01 tomaka

btw, backtraces are broken on android for a long time

ozkriff avatar Jul 27 '17 06:07 ozkriff

It seems unwinding backtraces still broken :(

katyo avatar Jan 01 '20 14:01 katyo

I got backtraces to kind of work, but using android's built in stack straces

Backtrace example

RustAndroidGlueStdouterr: thread '<unnamed>' panicked at 'explicit panic', src\drawable\terrain.rs:91:17
RustAndroidGlueStdouterr: stack backtrace:
RustAndroidGlueStdouterr:    0: <unknown>
RustAndroidGlueStdouterr:    1: <unknown>
RustAndroidGlueStdouterr:    2: <unknown>
RustAndroidGlueStdouterr:    3: <unknown>
RustAndroidGlueStdouterr:    4: <unknown>
RustAndroidGlueStdouterr:    5: <unknown>
RustAndroidGlueStdouterr:    6: <unknown>
RustAndroidGlueStdouterr:    7: <unknown>
RustAndroidGlueStdouterr:    8: <unknown>
RustAndroidGlueStdouterr:    9: <unknown>
RustAndroidGlueStdouterr:   10: <unknown>
RustAndroidGlueStdouterr:   11: <unknown>
RustAndroidGlueStdouterr:   12: <unknown>
RustAndroidGlueStdouterr:   13: <unknown>
RustAndroidGlueStdouterr:   14: <unknown>
RustAndroidGlueStdouterr: fatal runtime error: failed to initiate panic, error 9
libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 3163 (rust.Trees), pid 3116 (rust.Trees)
crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
/system/bin/tombstoned: received crash request for pid 3163
crash_dump32: performing dump of process 3116 (target tid = 3163)
DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
DEBUG   : Build fingerprint: 'google/walleye/walleye:10/QQ1A.191205.008/5974827:user/release-keys'
DEBUG   : Revision: 'MP1'
DEBUG   : ABI: 'arm'
DEBUG   : Timestamp: 2020-01-01 14:40:14-0500
DEBUG   : pid: 3116, tid: 3163, name: rust.Trees  >>> rust.Trees <<<
DEBUG   : uid: 10284
DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
DEBUG   :     r0  00000000  r1  00000c5b  r2  00000006  r3  c77c9a30
DEBUG   :     r4  c77c9a44  r5  c77c9a28  r6  00000c2c  r7  0000016b
DEBUG   :     r8  c77c9a40  r9  c77c9a30  r10 c77c9a60  r11 c77c9a50
DEBUG   :     ip  00000c5b  sp  c77c9a00  lr  f14a62a3  pc  f14a62b6
DEBUG   :
DEBUG   : backtrace:
DEBUG   :       #00 pc 0005f2b6  /apex/com.android.runtime/lib/bionic/libc.so (abort+166) (BuildId: 68c87e04526a60689ecb5deb329804a0)
DEBUG   :       #01 pc 000ea07f  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (std::sys::unix::abort_internal::ha9c945fef06434ab+2)
DEBUG   :       #02 pc 000ea06f  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (std::sys_common::util::abort::h70260f83d3dabfb8+42)
DEBUG   :       #03 pc 000ea037  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (rust_panic+50)
DEBUG   :       #04 pc 000e9805  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (std::panicking::rust_panic_with_hook::h73d7e71d825ee71c+500)
DEBUG   :       #05 pc 000fa96b  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (std::panicking::begin_panic::h4fe3dfe9759e8a5e+58)
DEBUG   :       #06 pc 0002ceb5  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (source::drawable::terrain::generate_points::ha520c74641089c53+296)
DEBUG   :       #07 pc 0002cca9  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (source::drawable::terrain::Terrain::new::hcd823b6e00ffd038+36)
DEBUG   :       #08 pc 000147b9  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (source::drawable::world::World::new::h06416ab0f7944a2f+448)
DEBUG   :       #09 pc 000434e9  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (_$LT$source..App$u20$as$u20$android_base..app_implementor..AppImpl$GT$::new::he2212f77493ea915+784)
DEBUG   :       #10 pc 00060107  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (android_base::app_container::AppContainer$LT$T$GT$::init::hd5dc0be95f3e899a+342)
DEBUG   :       #11 pc 000437ed  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (source::main::he441a37b75c522d3+96)
DEBUG   :       #12 pc 0003abd7  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (Trees::main::he908a5e58c611f0b+2)
DEBUG   :       #13 pc 0005a919  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (Trees::android_main::_$u7b$$u7b$closure$u7d$$u7d$::h8fb6f3d7270c27ae+4)
DEBUG   :       #14 pc 000623e3  /data/app/rust.Trees-uMYcLm6BurI74hGZ_dJ9ug==/lib/arm/libTrees.so (cargo_apk_injected_glue::android_main2::main_thread::h19fb8c3d14adb2c9+14)
DEBUG   :       #15 pc 000a6093  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: 68c87e04526a60689ecb5deb329804a0)
DEBUG   :       #16 pc 00060763  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: 68c87e04526a60689ecb5deb329804a0)
ActivityTaskManager:   Force finishing activity rust.Trees/android.app.NativeActivity
Here's my `Cargo.toml`:
[package]
name = "trees"
version = "0.1.0"
authors = ["OptimisticPeach <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
android_base = {path = "../android_rs_base/"}
android_glue = {git = "https://github.com/rust-windowing/android-rs-glue"}
piston = "0.49.0"
piston2d-graphics = "0.35.0"
piston2d-opengl_graphics = {path = "../opengl_graphics"}
cgmath = "0.17.0"
image = "0.22.1"
piston-texture = "0.8.0"
noise = "0.6.0"
matrices = {path = "../matrices"}

[patch.crates-io] # Winit uses an old version which is incompatible with the new cargo apk
android_glue = {git = "https://github.com/rust-windowing/android-rs-glue"}

[lib]
name = "source"
path = "src/lib.rs"

[[bin]]
name = "Trees"
path = "src/main.rs"

[profile.release]
lto = true
debug = true

[profile.dev]
lto = true

[package.metadata.android]

# The Java package name for your application.
# Hyphens are converted to underscores.
package_name = "com.optimistic_peach.trees"

# The user-friendly name for your app, as displayed in the applications menu.
label = "Trees"

# Path to your application's res/ folder. See `examples/use_icon/res`.
res = "res"

# Virtual path your application's icon for any mipmap level. See `examples/use_icon/icon`.
icon = "@mipmap/ic_launcher"

# The target Android API level.
# It defaults to 18 because this is the minimum supported by rustc.
# (target_sdk_version and min_sdk_version default to the value of "android_version")
android_version = 29
target_sdk_version = 29
min_sdk_version = 26

assets = "assets"

# Specifies the array of targets to build for.
# Defaults to "arm-linux-androideabi".
# Other possible targets include "aarch64-linux-android",
# "armv7-linux-androideabi", "i686-linux-android" and "x86_64-linux-android".
build_targets = [ "armv7-linux-androideabi" ] #, "aarch64-linux-android", "i686-linux-android", "x86_64-linux-android" ]

# The maximum supported OpenGL ES version , as claimed by the manifest. Defaults to 2.0.
# See https://developer.android.com/guide/topics/graphics/opengl.html#manifest
opengles_version_major = 3
opengles_version_minor = 2


# Adds extra arbitrary XML attributes to the <application> tag in the manifest.
# See https://developer.android.com/guide/topics/manifest/application-element.html
[package.metadata.android.application_attributes]
"android:hardwareAccelerated" = "true"

# Adds extra arbitrary XML attributes to the <activity> tag in the manifest.
# See https://developer.android.com/guide/topics/manifest/activity-element.html
[package.metadata.android.activity_attributes]
"android:screenOrientation" = "unspecified"
"android:uiOptions" = "none"

This backtrace is somewhat readable, but it lacks more debug information (Like lines and files).


On a separate note this is still not good; I generally use cargo apk run --release because my app happens to be unbearably slow on debug, and even with

[profile.release]
debug = true

I still don't get debug info at all.

OptimisticPeach avatar Jan 01 '20 19:01 OptimisticPeach