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

lldbDataFormatters: fix type error in StringRef printer #82554

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arichardson
Copy link
Member

It appears we cannot use keyword arguments for GetPointeeData() and instead have to rely on positional arguments.

Traceback (most recent call last):
  File ".../llvm-project/llvm/utils/lldbDataFormatters.py", line 245, in StringRefSummaryProvider
    data = valobj.GetChildAtIndex(0).GetPointeeData(item_count=length)
TypeError: GetPointeeData() got an unexpected keyword argument 'item_count'

It appears we cannot use keyword arguments for GetPointeeData() and instead
have to rely on positional arguments.

```
Traceback (most recent call last):
  File ".../llvm-project/llvm/utils/lldbDataFormatters.py", line 245, in StringRefSummaryProvider
    data = valobj.GetChildAtIndex(0).GetPointeeData(item_count=length)
TypeError: GetPointeeData() got an unexpected keyword argument 'item_count'
```
@adrian-prantl
Copy link
Collaborator

The patch is clearly semantically equivalent to the existing code and correct. But @JDevlieghere why wouldn't the keyword argument work?

@adrian-prantl
Copy link
Collaborator

@JDevlieghere
Copy link
Member

This should work (and does work locally for me). The only explanation I can think of is that this is being called with (older) bindings that don't have the variable names, but it seems to have been like this forever.

What version of LLDB and Python are you using? If you know where the Python bindings live, it would be great to look at the signature of the function. For me it looks like this:

    def GetPointeeData(self, item_idx=0, item_count=1):
       ...

@arichardson
Copy link
Member Author

This should work (and does work locally for me). The only explanation I can think of is that this is being called with (older) bindings that don't have the variable names, but it seems to have been like this forever.

What version of LLDB and Python are you using? If you know where the Python bindings live, it would be great to look at the signature of the function. For me it looks like this:

    def GetPointeeData(self, item_idx=0, item_count=1):
       ...

I am using LLDB bundled with CLion, I will see if I can find the Python bindings.

@arichardson
Copy link
Member Author

I see the following in ~/.local/share/JetBrains/Toolbox/apps/clion/bin/lldb/linux/x64/lib/python3.8/site-packages/lldb/__init__.py:16674: def GetPointeeData(self, *args) -> "lldb::SBData":.

I will file an issue with Jetbrains to see if they can adjust their bindings generation to emit named arguments.

@arichardson
Copy link
Member Author

Reported to Jetbrains as https://youtrack.jetbrains.com/issue/CPP-37686 (@broadwaylamb not sure if you're the right person to investigate this?)

@broadwaylamb
Copy link
Contributor

Reported to Jetbrains as https://youtrack.jetbrains.com/issue/CPP-37686 (@broadwaylamb not sure if you're the right person to investigate this?)

Not quite, but I'm sure folks from the CLion team will do their best :)

Thank you for creating the ticket btw.

@arichardson
Copy link
Member Author

It sounds like this has been fixed in CLion 2024.1. I'm not sure if we should still merge this for older versions or just close it.

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

Successfully merging this pull request may close these issues.

None yet

4 participants