2011-02-02 17 views
13

Estoy tratando de realizar depuración de código nativo en mi HTC Desire para mi proyecto de Android. El proyecto está formado por una capa delgada de contenedor JNI y el fragmento principal en C++, compilado con ndk-build. La bandera de depuración está configurada, estoy ejecutando 2.2 en un HTC Desire y estoy trabajando con Ubuntu en mi PC.Android Native debug (ndk-gdb) en HTC Desire: ¿falla de ejecución?

Así que un --start NDK-BGF devuelve una llanura:

ERROR: Could not setup network redirection to gdbserver? 
    Maybe using --port=<port> to use a different TCP port might help? 

Esto es raro. Lo revisé en Internet y descubrí que es el error de mensaje erróneo causado por un error en ndk-gdb. Si me quedo NDK-BGF - empezar --verbose puedo obtener esta mal estado de error:

Android NDK installation path: /home/marco/dev/android-ndk 
Using specific adb command: /home/marco/dev/android-sdk//platform-tools/adb 
ADB version found: Android Debug Bridge version 1.0.26 
Using final ADB command: '/home/marco/dev/android-sdk//platform-tools/adb' 
Using auto-detected project path: . 
Found package name: com.marco83.siege 
ABIs targetted by application: armeabi 
Device API Level: 8 
Device CPU ABIs: armeabi-v7a armeabi 
Compatible device ABI: armeabi 
Found debuggable flag: true 
Found device gdbserver: /data/data/com.marco83.siege/lib/gdbserver 
Using gdb setup init: /home/marco/dev/siege_game/trunk/SiegeGameNative/libs/armeabi/gdb.setup 
Using toolchain prefix: /home/marco/dev/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- 
Using app out directory: /home/marco/dev/siege_game/trunk/SiegeGameNative/obj/local/armeabi 
Found data directory: 'run-as: Package 'com.marco83.siege' has corrupt installation' 
Found first launchable activity: .Main 
Launching activity: com.marco83.siege/.Main 
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb shell am start -n com.marco83.siege/.Main 
Starting: Intent { cmp=com.marco83.siege/.Main } 
Warning: Activity not started, its current task has been brought to the front 
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb shell sleep 2 
Found running PID: 844 
Launched gdbserver succesfully. 
Setup network redirection 
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb forward tcp:5039 localfilesystem:run-as: Package 'com.marco83.siege' has corrupt installation/debug-socket 
## COMMAND: /home/marco/dev/android-sdk//platform-tools/adb shell run-as com.marco83.siege lib/gdbserver +debug-socket --attach 844 
Android Debug Bridge version 1.0.26 

-d       - directs command to the only connected USB device 
           returns an error if more than one USB device is present. 
-e       - directs command to the only running emulator. 
           returns an error if more than one emulator is running. 
-s <serial number>   - directs command to the USB device or emulator with 
           the given serial number. Overrides ANDROID_SERIAL 
           environment variable. 
-p <product name or path>  - simple product name like 'sooner', or 
           a relative/absolute path to a product 
           out directory like 'out/target/product/sooner'. 
           If -p is not specified, the ANDROID_PRODUCT_OUT 
           environment variable is used, which must 
           be an absolute path. 
devices      - list all connected devices 
connect <host>[:<port>]  - connect to a device via TCP/IP 
           Port 5555 is used by default if no port number is specified. 
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device. 
           Port 5555 is used by default if no port number is specified. 
           Using this ocmmand with no additional arguments 
           will disconnect from all connected TCP/IP devices. 

device commands: 
    adb push <local> <remote> - copy file/dir to device 
    adb pull <remote> [<local>] - copy file/dir from device 
    adb sync [ <directory> ]  - copy host->device only if changed 
           (-l means list but don't copy) 
           (see 'adb help all') 
    adb shell     - run remote shell interactively 
    adb shell <command>   - run remote shell command 
    adb emu <command>   - run emulator console command 
    adb logcat [ <filter-spec> ] - View device log 
    adb forward <local> <remote> - forward socket connections 
           forward specs are one of: 
            tcp:<port> 
            localabstract:<unix domain socket name> 
            localreserved:<unix domain socket name> 
            localfilesystem:<unix domain socket name> 
            dev:<character device name> 
            jdwp:<process pid> (remote only) 
    adb jdwp      - list PIDs of processes hosting a JDWP transport 
    adb install [-l] [-r] [-s] <file> - push this package file to the device and install it 
           ('-l' means forward-lock the app) 
           ('-r' means reinstall the app, keeping its data) 
           ('-s' means install on SD card instead of internal storage) 
    adb uninstall [-k] <package> - remove this app package from the device 
           ('-k' means keep the data and cache directories) 
    adb bugreport    - return all information from the device 
           that should be included in a bug report. 

    adb help      - show this help message 
    adb version     - show version num 

DATAOPTS: 
(no option)     - don't touch the data partition 
    -w       - wipe the data partition 
    -d       - flash the data partition 

scripting: 
    adb wait-for-device   - block until device is online 
    adb start-server    - ensure that there is a server running 
    adb kill-server    - kill the server if it is running 
    adb get-state    - prints: offline | bootloader | device 
    adb get-serialno    - prints: <serial-number> 
    adb status-window   - continuously print device status for a specified device 
    adb remount     - remounts the /system partition on the device read-write 
    adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program 
    adb reboot-bootloader  - reboots the device into the bootloader 
    adb root      - restarts the adbd daemon with root permissions 
    adb usb      - restarts the adbd daemon listening on USB 
    adb tcpip <port>    - restarts the adbd daemon listening on TCP on the specified port 
networking: 
    adb ppp <tty> [parameters] - Run PPP over USB. 
Note: you should not automatically start a PPP connection. 
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 
[parameters] - Eg. defaultroute debug dump local notty usepeerdns 

adb sync notes: adb sync [ <directory> ] 
    <localdir> can be interpreted in several ways: 

    - If <directory> is not specified, both /system and /data partitions will be updated. 

    - If it is "system" or "data", only the corresponding partition 
    is updated. 

environmental variables: 
    ADB_TRACE     - Print debug information. A comma separated list of the following values 
           1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp 
    ANDROID_SERIAL    - The serial number to connect to. -s takes priority over this if given. 
    ANDROID_LOG_TAGS    - When used with the logcat option, only these debug tags are printed. 
ERROR: Could not setup network redirection to gdbserver? 
     Maybe using --port=<port> to use a different TCP port might help? 
[email protected]:~/dev/siege_game/trunk/SiegeGameNative$ run-as: Package 'com.marco83.siege' has corrupt installation 

que, como se puede ver y como se informó aquí: http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/ es causada por una combinación de diferentes salidas simultáneas; el error real debería ser

Package 'xxxxx' has corrupt installation 

La investigación adicional en este error me señaló a: http://osdir.com/ml/android-ndk/2010-08/msg00263.html

donde se informa que el mismo error, y dicen que no es posible depurar de forma nativa en Deseo. El problema es que run-as no puede acceder a la carpeta/data.

¿Alguna solución que no sea rootear/flashear el teléfono? ¿Por qué el run-as acceso/datos? Estaba pensando en una solución ingenua en la que copie el paquete (objs, libs, ...) en una ubicación accesible más fácil (como en la tarjeta SD) y le digo al depurador que acceda a esa ubicación: ¿es factible?

Gracias Marco

EDIT: Actualización: Me arraigado el teléfono usando unrevoked3. Incluso si configuro chmod 0777 data (que probablemente sea EXTREMADAMENTE peligroso), obtengo el mismo error. Como se informó en el segundo enlace en la publicación, run-as está comprobando si se puede acceder a/data. ¿Cómo puedo acceder al código fuente run-as? ¿Es posible volver a compilarlo y cargar una versión modificada que funcione alrededor de este cheque? (dado que puedo configurar/datos para que todos puedan leerlo de todos modos)

Respuesta

3

Tiene el mismo problema con mi HTC Legend. Mi solución:

  1. conseguir acceso root
  2. la EIP de aplicación que desea depurar: ps | grep your_app_package
  3. servidor GDB
  4. de ejecución:/data/data/your_app_package/lib/gdbserver: 5039 --attach PID

en la nueva terminal de

  1. ADB TCP hacia adelante: 5039 tcp: 5039
  2. sistema de tracción adb/bin/app_process project_path/obj/local/armeabi/app_process
  3. sistema de tracción adb/bin/libc.so /project_path/obj/local/armeabi/libc.so

Ahora puede conectarse a gdbserverb (http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/#more-23 pasos de omisión con ndk-gdb).

PS: No se olvide compilar el código con banderas siguientes

LOCAL_CFLAGS: = -g #debug

LOCAL_LDFLAGS: = -Wl, -Mapa, xxx.map #create mapa fil

+0

Gracias, voy a tratar de que lo antes posible y le permiten saber si funciona! – Marco83

+0

Estoy viendo el mismo problema en Nexus One y Xoom. Ambos tienen los permisos de/data directory establecidos en 771, lo que significa que incluso la comprobación de la existencia de gdbserver en el dispositivo (lo que hace ndb-gdb) no funcionará. –

1

Stumbled en este hilo: http://code.google.com/p/android/issues/detail?id=16391

Solucionado el problema de ejecución para mí, ndk-gdb ahora funciona correctamente.

+0

Para resumir: run-as en Android pre-v4.0 tiene un error que asume que la base de datos de paquetes tiene menos de 8 KB de longitud. En muchos dispositivos, particularmente aquellos con muchos crapware preinstalados, la base de datos de paquetes ya supera los 8 KB. Si el nombre de su paquete se agrega a la base de datos más allá de los primeros 8KB, run-as no podrá encontrarlo, y rescatará con el error "Package 'X' tiene una instalación dañada. – bleater

0

Solía ​​tener este problema, hasta que cambié el nombre del paquete por 4 anidado en lugar de 3. No sé por qué es un problema (ya envié un correo electrónico a los desarrolladores) pero si el nombre del paquete es a.b.c solamente el depurador de Java funciona. Para la depuración nativa, debe tener el formato a.b.c.d.

4

me fijo este problema para un HTC Desire S (2.3.3) cambiando el acceso & la propiedad para el directorio '/ data/data':

Antes de la revisión:

ls -l /data 
(...) 
drwxrwxrwx root  root    2012-03-03 19:07 data 

En modo root :

chmod 771 /data/data 
chown system.system /data/data 

ls -l /data 
(...) 
drwxrwx--x system system   2012-03-03 19:07 data 

También puede ser necesario cambiar el/data director.

chmod 771 /data 
chown system.system /data 
+2

Encontró esta discusión: https://groups.google.com/forum/#!msg/android-ndk/cubyLmLNTXQ/wGRopPum69cJ. El usuario Ratamovic analizó el código 'run-as' y descubrió que usa' check_data_path' que llama 'check_directory_ownership', que en su orden tiene la siguiente descripción comment: _Esta función se usa para verificar la ruta del directorio de datos por seguridad. Verificamos que cada subdirectorio sea propiedad del usuario del 'sistema' y exista y no sea un enlace simbólico. También verificamos que la ruta completa del directorio sea propiedad del ID del usuario. –

+0

... obviamente requiere que el dispositivo esté rooteado, por supuesto. –

0

La ruta/debe/ser correcto (ambos directorios "datos" son 771 y sistema: el sistema, el directorio de datos de la aplicación es 755 y es propiedad de un "app_" cuenta).

0

necesidad de u s-en turno de s-off (firmware)

para Tegra 3 chip de s-off

http://bbs.angeeks.com/thread-2598143-1-1.html

///

para Qualcomm chip de s-off

bbs.htc.com/cn/thread-11592-1-1.html

Tengo 2 teléfonos HTC, Sensation s-off, One X s-on

Sensation puede usar ndk debug, pero One X no puede.

aquí es foto de la izquierda es la sensación, a la derecha es un X

https://plus.google.com/photos/106185541018774360364/albums/6156448731748249457/6156448735435939234?banner=pwa&sort=1&pid=6156448735435939234&oid=106185541018774360364

Cuestiones relacionadas