Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: 不能调试其它进程么? #3

Open
wbo4958 opened this issue Jun 29, 2017 · 13 comments
Open

Q: 不能调试其它进程么? #3

wbo4958 opened this issue Jun 29, 2017 · 13 comments

Comments

@wbo4958
Copy link

wbo4958 commented Jun 29, 2017

今晚上试着调试下inputsurfaceflinger

但是怎么都不成功!

猜想: inputsurfaceflinger 运行在system_process, 而博文的是调试一个app进程的 ,垃圾回收机制运行于JVM中,所以能调试??

而如果想调试一些其它的比较 Media/SurfaceFlinger这些module 貌似不行了??

@tiann
Copy link
Owner

tiann commented Jun 30, 2017

可以。

说出具体问题

@wbo4958
Copy link
Author

wbo4958 commented Jun 30, 2017

赞!

我还是用博主的那个Debug工程,然后

1. 设置了两个断点

(lldb) br s -n dispatchOnceInnerLocked
Breakpoint 2: where = libinputflinger.so`android::InputDispatcher::dispatchOnceInnerLocked(long long*), address = 0xa7f6d724
(lldb) br s -n processEventsLocked
Breakpoint 3: where = libinputflinger.so`android::InputReader::processEventsLocked(android::RawEvent const*, unsigned int), address = 0xa7f76534

2. 加入 libinputflinger.so 并且源码映射, 这些应该都没有问题

3. 查看下断点

(lldb) br list 2
2: name = 'dispatchOnceInnerLocked', locations = 1, resolved = 1, hit count = 0
  2.1: where = libinputflinger.so`android::InputDispatcher::dispatchOnceInnerLocked(long long*) at InputDispatcher.cpp:259, address = 0xa7f6d724, resolved, hit count = 0 

(lldb) br list 3
3: name = 'processEventsLocked', locations = 1, resolved = 1, hit count = 0
  3.1: where = libinputflinger.so`android::InputReader::processEventsLocked(android::RawEvent const*, unsigned int) at InputReader.cpp:379, address = 0xa7f76534, resolved, hit count = 0 

这些也没什么问题。

4. resume program(F8)

这时也没什么问题。。

接着我触摸屏幕想触发断点,点击里面的DEBUG button, 但是程序没有停下下, 更别说看到inputflinger的源码了。

@tiann
Copy link
Owner

tiann commented Jun 30, 2017

你调试的哪个进程?

@wbo4958
Copy link
Author

wbo4958 commented Jun 30, 2017

直接在Android Studio上调试的,App进程,

@wbo4958
Copy link
Author

wbo4958 commented Jun 30, 2017

所以这里应该选择 system_process进程? 但是这个怎么选呢?这是个问题!

@tiann
Copy link
Owner

tiann commented Jun 30, 2017

那就对了,你明知道inputsurfaceflinger是运行在system_process进程的,却在app进程下断点,咋可能断呢?

仔细看看这篇文章 如何调适Android Framework ,文章重点强调这个了已经。

@wbo4958
Copy link
Author

wbo4958 commented Jun 30, 2017

恩, 用 Android Studio 调试 Android java framework是可以的,但是这个貌似不能调试 native的代码吧,比如 inputflinger.

我现在是想调试 native的 framework,比如 inputflinger.

现在我不通过 android studio,直接在通过 "无源码调试" 是可以调试 system_server的.

@tiann
Copy link
Owner

tiann commented Jun 30, 2017

可以,选进程的时候选native。

@wbo4958
Copy link
Author

wbo4958 commented Jun 30, 2017

image

在attach debugger to android process 后 选择system_process后, 提示如下错误了

6/30/2017
4:28 PM	RuntimeException: Cannot find module by package name

我一般是新建 remote 并选择8700端口, 并在DDMS 里选择调试进程,这样是可以调试 system_process的。

@wbo4958
Copy link
Author

wbo4958 commented Jul 3, 2017

补充: lldb可以调试system_server native code,如libinputflinger.so了,也能正确显示源码了,非常棒,要是 android studio 也能调试 system_server native code就完美了。

@tiann
Copy link
Owner

tiann commented Jul 6, 2017

Android Studio目前有bug:https://issuetracker.google.com/issues/37124749
坐等修复

@Youlor
Copy link

Youlor commented Jul 13, 2017

您好,非常感谢!我已经可以调试java层源码了,但是在尝试调试native层时出现错误:RuntimeException: Cannot find module by package name。看您的回复说这是个bug,那请问有什么别的办法可以调试吗?比如我想调试dalivk部分的源码。谢谢!

@tiann
Copy link
Owner

tiann commented Jul 14, 2017

@Youlor 看文章和楼上的回复。IDE的bug仅限于你在本App需要调试别的进程的代码,如果是dalvik那么就是运行在你自己进程的,这个是没问题的。调试别的进程,可以直接用LLDB,文中也已经说明了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants