2011-02-02 14 views
13

Próbuję wykonać natywne debugowanie kodu w moim telefonie HTC Desire dla mojego projektu Android. Projekt składa się z cienkiej warstwy opakowania JNI i głównej części w C++, skompilowanej przy użyciu ndk-build. Flaga debuggable jest ustawiona, ja pracuję 2.2 na HTC Desire i pracuję z Ubuntu na moim komputerze.Android Natywne debugowanie (ndk-gdb) w HTC Desire: run-as fault?

Więc zwykły NDK-gdb --start zwraca:

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

To jest dziwne. Sprawdziłem w Internecie i odkryłem, że jest to błąd nieprawidłowego komunikatu spowodowany przez lukę w ndk-gdb. Jeśli uruchomię NDK-gdb - start --verbose mogę uzyskać to pomieszane błąd:

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 

które, jak widać, jak podano tutaj: http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/ spowodowany jest mieszanką różnych wyjść jednoczesnych; rzeczywisty błąd powinno być

Package 'xxxxx' has corrupt installation 

Dalsze badania w tym błędzie wskazał mi: http://osdir.com/ml/android-ndk/2010-08/msg00263.html

gdzie ten sam błąd został zgłoszony, a oni mówią, że nie jest to możliwe do debugowania natywnie na pragnienie. Problem polega na tym, że run-as nie może uzyskać dostępu do folderu/data.

Jakieś rozwiązanie inne niż rootowanie/flashowanie telefonu? Dlaczego dostęp/dane do run-as? Myślałem o naiwnym rozwiązaniu, w którym kopiuję pakiet (objs, libs, ...) do łatwiej dostępnej lokalizacji (jak na karcie SD) i mówię debuggerowi, aby zamiast tego miał dostęp do tej lokalizacji - czy jest to wykonalne?

Dzięki Marco

EDIT: Aktualizacja: I zakorzenione telefon używając unrevoked3. Nawet jeśli ustawię chmod 0777 data (który jest prawdopodobnie bardzo niebezpieczny), pojawia się ten sam błąd. Jak podano w drugim łączu w poście, run-as sprawdza, czy dane są dostępne. Jak uzyskać dostęp do kodu źródłowego "run-as"? Czy można ją przekompilować i przesłać zmodyfikowaną wersję, która obejmie kontrolę? (ponieważ mogę ustawić/dane mogą być odczytywane przez wszystkich w każdym razie)

Odpowiedz

3

Mam ten sam problem z moim HTC Legend. Moje obejście:

  1. uzyskać dostęp korzeń
  2. uzyskać PID aplikacji chcesz debugować: ps | grep your_app_package
  3. prowadzony przez serwer gdb:/data/data/your_app_package/lib/gdbserver: 5039 --attach PID

w nowym terminalu

  1. adb forward tcp: 5039 tcp: 5039
  2. adb pull system/bin/app_process project_path/obj/local/armeabi/app_process
  3. adb pull system/bin/libc.so /project_path/obj/local/armeabi/libc.so

Teraz możesz połączyć się z gdbserverb (http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/#more-23 pomiń kroki z ndk-gdb).

PS: Nie zapomnij skompilować kod z następujących flag

LOCAL_CFLAGS: = -g #Debugowanie

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

+0

Dzięki, spróbuję, że najszybciej i poinformujemy, czy to działa! – Marco83

+0

Widzę ten sam problem na Nexus One i Xoom. Oba mają ustawione uprawnienia katalogów/data na 771, co oznacza, że ​​nawet sprawdzenie istnienia gdbserver na urządzeniu (które robi ndb-gdb) nie będzie działać. –

1

potknął w tym wątku: http://code.google.com/p/android/issues/detail?id=16391

Rozwiązany problem z uruchomieniem, ponieważ dla mnie, ndk-gdb działa teraz poprawnie.

+0

Podsumowując: run-as na Androidzie pre-v4.0 ma błąd, który zakłada, że ​​baza danych pakietów ma mniej niż 8 KB. Na wielu urządzeniach, szczególnie tych z dużą ilością wstępnie zainstalowanych crapware, baza danych pakietów ma już ponad 8 KB. Jeśli nazwa twojego pakietu zostanie dodana do bazy danych poza pierwszymi 8 KB, run-as nie będzie w stanie go znaleźć i otrzyma komunikat o błędzie "Pakiet" X "ma uszkodzoną instalację. – bleater

0

Kiedyś otrzymywałem ten problem, dopóki nie zmieniłem nazwy pakietu na 4 zagnieżdżone zamiast 3. Nie wiem, dlaczego to jest problem (wysłałem już e-mail do programistów), ale jeśli nazwa twojego pakietu to tylko a.b.c debugger java działa. W przypadku rodzimego debugowania musi to być postać a.b.c.d.

4

naprawiłem ten problem dla HTC Desire S (2.3.3) przez zmianę Dostęp & własności dla katalogu '/ data/data':

Przed Fix:

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

W trybie administratora :

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

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

Również dyrektor/danych może wymagać zmiany.

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

Znaleziono tę dyskusję: https://groups.google.com/forum/#!msg/android-ndk/cubyLmLNTXQ/wGRopPum69cJ. Użytkownik Ratamovic przeanalizował kod "run-as" i stwierdził, że używa 'check_data_path', która wywołuje' check_directory_ownership', która w swoim porządku ma następujący komentarz do opisu: _Ta funkcja służy do sprawdzenia ścieżki katalogu danych dla bezpieczeństwa. Sprawdzamy, czy każdy podkatalog jest własnością użytkownika "systemowego" i istnieje i nie jest dowiązaniem symbolicznym. Sprawdzamy również, czy pełna ścieżka do katalogu jest należycie własnością ID użytkownika._ –

+0

... oczywiście wymaga oczywiście, aby urządzenie było zrootowane. –

0

Ścieżka/powinna/być prawidłowe (zarówno "dane" katalogi są 771 i : System, katalog danych App jest 755 i posiadaniu przez "app_" konta).

0

potrzeba u S-kolei na S-off (firmware)

do gier dostępnych 3 układ S się

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

///

do Qualcomm układ S-off

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

Mam 2 telefony HTC, Sensation-off, One X s-on

Sensacja może korzystać z debugowania ndk, ale One X nie może.

tutaj jest zdjęcie po lewej jest Sensation, prawo to jeden X

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

Powiązane problemy