[Lldb-commits] [PATCH] D33035: Tool for using Intel(R) Processor Trace hardware feature

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 10 09:13:23 PDT 2017


clayborg added a comment.

Much better on the API with Swig. Just a few inlined questions around GetRawBytes.



================
Comment at: tools/intel-features/intel-pt/PTDecoder.h:54-55
+
+  // Get raw bytes of the instruction
+  const uint8_t *GetRawBytes() const;
+
----------------
In the python version of this function, this should return a python string that contains the bytes or return None of there is nothing. Is that how it currently works? One alternate way of doing this is doing what we do with lldb::SBProcess:
```
  size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error);

```

In python, we use a type map to detect the args "void *buf, size_t size", and we turn this into:

```
def ReadMemory(self, addr, error):
    return # Python string with bytes from read memory
```

So one option would be to change GetRawBytes() into:

```
size_t GetRawBytes(void *buf, size_t size) const;
```

The return value is now many bytes were filled in. If "buf" is NULL or "size" is zero, you can return the length that you would need as the return value.

And have the python version be:

```
def GetRawBytes(self):
    return # bytes in a python string or None
```



================
Comment at: tools/intel-features/intel-pt/PTDecoder.h:58
+  // Get size of raw bytes of the instruction
+  uint8_t GetRawBytesSize() const;
+
----------------
This might not be needed if GetRawBytes is changed to:
```
size_t GetRawBytes(void *buf, size_t size) const;
```




https://reviews.llvm.org/D33035





More information about the lldb-commits mailing list