[lldb-dev] add custom vendor commands
Giusti, Valentina via lldb-dev
lldb-dev at lists.llvm.org
Wed Oct 19 00:55:33 PDT 2016
> On Oct 18, 2016, at 6:43 PM, Clayton, Greg <gclayton at apple.com> wrote:
> > On Oct 18, 2016, at 7:48 AM, Giusti, Valentina <valentina.giusti at intel.com>
> > Hi Greg,
> > Thanks a lot for your reply, please find below my answers.
> >> You can install new python commands that can do the job to work out
> >> the details.
> >> http://lldb.llvm.org/python-reference.html
> >> See the section named "CREATE A NEW LLDB COMMAND USING A PYTHON
> >> FUNCTION".
> >> You can basically install a new "intel" command and parse all of the
> >> options "show mpx-bounds ..." or "set mpx-bounds ..." from within this new
> >> You can use the public LLDB API to look through the process and do
> >> things. Let me know if you need any help with this. There is also a
> >> API to add custom commands from C++ plug-ins. Enrico Granata did this
> >> work and can answer more questions on that. Either way, both commands
> >> (python and C++ plug-ins) have access to the public API for LLDB, so
> >> the code you will write will use the same API. So I would stick with python for
> now to get things working.
> > I think I would rather start right away with the C++ approach. If I understand
> correctly, it means to create a specific Intel plugin under the directory
> source/Plugins and use the LLDB API to add the custom command.
> That is one way to do this, but any change you make will require a recompile of
> The only external plug-ins we currently have with LLDB are for adding
> commands. See the following code in our test suite where $(trunk) is the root of
> your LLDB checkout:
> This show you how to compile a C++ plug-in that will be loaded by LLDB if it is
> placed in the right plug-in location. So this would allow you to distribute a plug-
> in that can work with existing released LLDB in case you care to do so.
Thanks for mentioning this, I will keep it in mind. However I think I prefer to implement a builtin command.
> >> Some questions for you:
> >> - How do plan on detecting that you have an intel processor?
> > I thought of checking if the target architecture is either llvm::Triple::x86 or
> llvm::Triple::x86_64. Do you think there is a better approach to this?
> I guess just checking for the "BNDCFGU" register is what you will need to do?
Yeah, I can probably skip the arch checking step.
> >> - Do you need access to any process registers? If so, are these
> >> registers thread specific? Are these registers available currently on linux and
> > I only need to access the MPX configuration register, BNDCFGU. As far as I
> know, MacOS doesn't have MPX support, so I also didn't implement the MPX
> support for MacOS in LLDB, which means it is only available in Linux at the
> >> - How do you locate the BT? (or do you even need to?). Is there
> >> symbol? Can you extract all values in the bounds table once you locate it?
> > The bound tables are allocated contiguously in the process memory, starting
> from the Bound Directory address which is stored in the BNDCFGU register.
> Therefore, in the plugin I only need to access this register, do the appropriate
> calculations and then access the process memory to get the requested bound
> table entry.
> Great. This sounds easy to do. Just decide if you prefer a built in command or to
> create an external command shared library plug-in and you are all set to go!
Seems so, thanks!
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
More information about the lldb-dev