[lldb-dev] add custom vendor commands

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Mon Oct 17 08:58:40 PDT 2016


> On Oct 13, 2016, at 2:24 AM, Giusti, Valentina via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hello all,
> 
> Background: 
> Intel CPUs that support MPX have a limited number of bound registers. For any program that has more objects than fit into these registers, the bounds must be kept elsewhere. For this purpose, Bounds Tables (BT) are stored in application memory: for each pointer there is a bound table entry with lower bound, upper bound, check pointer value.
> 
> It would be convenient for the user to be able to access the BT and possibly also manipulate it, through commands like: 'set/show mpx-bounds <pointer_name> <lower-bound-value> <upper-bound-value>'.
> 
> Is there a way to add customized commands for vendor features, such as this one?
> I have seen that CommandObjectCommands has a class to add commands interpreted by command interpreter scripts and an interface for command aliases, so I wonder if it would make sense to add something else for vendor commands. For example, I could create a new class CommandObjectVendor that allows vendors to create their own specific commands. In my case, for the MPX bound table, the commands could be:
> 	
> 	intel show mpx-bounds <pointer_name> <lower-bound-value> <upper-bound-value>
> 	intel set mpx-bounds  <pointer_name> <lower-bound-value> <upper-bound-value>
> 
> Thanks in advance for your help,
> 

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 command. 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.

Some questions for you:
- How do plan on detecting that you have an intel processor? 
- Do you need access to any process registers? If so, are these registers thread specific? Are these registers available currently on linux and MacOS?
- 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?

Let me know if you have any questions,

Greg Clayton

> - V.
> 
> 
> 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
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list