As far as I know, debuggers work based on system calls like ptrace in linux, which will block the tracee and then tracer get informations from tracee's memory. It means, if I want to use a debugger to debug the main thread in an android app process, it will block the main thread and wait for my operations, which may easily cause main thread ANR in few seconds. So I am confused about is it really possible to debug the main thread in android app process and how?
Asked
Active
Viewed 135 times
1 Answers
0
Correct, ADP uses ptrace and blocks the main thread and this causes the application to slow down slightly while in debug mode. If you do step by step debugging the thread you put your breakpoint in will be halted completely. For general debugging purposes this should not be an issue. Testing how smooth an application runs should be done in run mode and not in debug mode.

AKroell
- 622
- 4
- 18
-
Thanks for your answer.But if I can't debug step by step,it seems the debugger doesn't value a lot because I can check other information just inserting LOGs into my code. – xjtulk Jul 28 '16 at 09:44
-
Of course, but that would pollute your code with a big number of console logs which have to be cleaned up after. I guess it's personal preference. In addition to not having to write LOGs you are able to look at the state of each object and it's members in detail for every step in the execution. AND it allows you to make sure methods are executed in the right order. – AKroell Jul 28 '16 at 10:06