Page MenuHomePhabricator

WIP, RFC: Add an example of how LLDB python plug-in could look like
Needs ReviewPublic

Authored by apolyakov on Apr 22 2019, 9:48 AM.

Details

Summary

This commit shows how LLDB python plug-in could look like.

Such an approach allows users to use LLDB for OS kernel debugging, for doing that they only need to implement two interfaces: OperatingSystemInterface and OSThread. As an example, this patch contains zephyr.py file with simple plug-in implementation for Zephyr OS, OS-specific files could live in OS' repository and evolve alongside it.

In the future, arch-specific code, e.g. arc.py, can be eliminated since LLDB already implements that functionality.

Remaining code can be upstreamed to LLDB with or without significant changes, the main idea of the review is to discuss these changes and the overall approach.

Diff Detail

Event Timeline

apolyakov created this revision.Apr 22 2019, 9:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2019, 9:48 AM
apolyakov edited the summary of this revision. (Show Details)Apr 22 2019, 10:50 AM
apolyakov edited the summary of this revision. (Show Details)

Not sure what functionality this really adds? It seems to just wrap the OS plug-in python class in a different way?

lldb/examples/python/lldb-os-plugin/arch/arc.py
15

We really shouldn't be using the "lldb.debugger" in the script, we would want this to be supplied to a function call. Top level code isn't always a great idea. If you import this module before the process is loaded "plugin.process.icd.hardware.registers" might not be available.

lldb/examples/python/lldb-os-plugin/core/cvalue.py
1–7

this is already in lldb.value in the lldb module. did you make additions to it? If so, modify that and remove this file

apolyakov marked an inline comment as done.Apr 22 2019, 11:35 AM

Not sure what functionality this really adds? It seems to just wrap the OS plug-in python class in a different way?

You are right, for now the patch doesn't add new functionality, but this approach allows us to extend LLDB in a more flexible way, for example, if someday LLDB supports CPU ID, we will be able to fetch it from OS threads without modifying client's code.

lldb/examples/python/lldb-os-plugin/arch/arc.py
15

Thanks, I will consider it.

lldb/examples/python/lldb-os-plugin/core/cvalue.py
1–7

Yes I did. For now it's here just for example of how it could be modified in comparison to lldb.value

labath resigned from this revision.Apr 23 2019, 1:24 AM

I don't have any opinions on os plugins.