<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lldb/test/API/python_api, branch users/mingmingl-llvm/spr/sdpglobalvariable</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[lldb] Check the command string in TestCommandInterepterPrintCallback</title>
<updated>2025-02-04T18:42:08+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-02-04T18:26:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=53d6e59b594639417cdbfcfa2d18cea64acb4009'/>
<id>53d6e59b594639417cdbfcfa2d18cea64acb4009</id>
<content type='text'>
Now that we store the command in the CommandReturnObject (#125132) we
can check the command in the print callback.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that we store the command in the CommandReturnObject (#125132) we
can check the command in the print callback.
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Support CommandInterpreter print callbacks (#125006)</title>
<updated>2025-02-04T17:01:08+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-02-04T17:01:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=97f6e533865c66ea08840be78154099180293094'/>
<id>97f6e533865c66ea08840be78154099180293094</id>
<content type='text'>
Xcode uses a pseudoterminal for the debugger console.

- The upside of this apporach is that it means that it can rely on
LLDB's IOHandlers for multiline and script input.
- The downside of this approach is that the command output is printed to
the PTY and you don't get a SBCommandReturnObject. Adrian added support
for inline diagnostics (#110901) and we'd like to access those from the
IDE.

This patch adds support for registering a callback in the command
interpreter that gives access to the `(SB)CommandReturnObject` right
before it will be printed. The callback implementation can choose
whether it likes to handle printing the result or defer to lldb. If the
callback indicated it handled the result, the command interpreter will
skip printing the result.

We considered a few other alternatives to solve this problem:

- The most obvious one is using `HandleCommand`, which returns a
`SBCommandReturnObject`. The problem with this approach is the multiline
input mentioned above. We would need a way to tell the IDE that it
should expect multiline input, which isn't known until LLDB starts
handling the command.
- To address the multiline issue,we considered exposing (some of the)
IOHandler machinery through the SB API. To solve this particular issue,
that would require reimplementing a ton of logic that already exists
today in the CommandInterpeter. Furthermore that seems like overkill
compared to the proposed solution.

rdar://141254310</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Xcode uses a pseudoterminal for the debugger console.

- The upside of this apporach is that it means that it can rely on
LLDB's IOHandlers for multiline and script input.
- The downside of this approach is that the command output is printed to
the PTY and you don't get a SBCommandReturnObject. Adrian added support
for inline diagnostics (#110901) and we'd like to access those from the
IDE.

This patch adds support for registering a callback in the command
interpreter that gives access to the `(SB)CommandReturnObject` right
before it will be printed. The callback implementation can choose
whether it likes to handle printing the result or defer to lldb. If the
callback indicated it handled the result, the command interpreter will
skip printing the result.

We considered a few other alternatives to solve this problem:

- The most obvious one is using `HandleCommand`, which returns a
`SBCommandReturnObject`. The problem with this approach is the multiline
input mentioned above. We would need a way to tell the IDE that it
should expect multiline input, which isn't known until LLDB starts
handling the command.
- To address the multiline issue,we considered exposing (some of the)
IOHandler machinery through the SB API. To solve this particular issue,
that would require reimplementing a ton of logic that already exists
today in the CommandInterpeter. Furthermore that seems like overkill
compared to the proposed solution.

rdar://141254310</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Store the command in the CommandReturnObject (#125132)</title>
<updated>2025-02-04T16:55:30+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-02-04T16:55:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=906eeeda833b30fb7fdc3b7586de34b65d575b45'/>
<id>906eeeda833b30fb7fdc3b7586de34b65d575b45</id>
<content type='text'>
As suggested in #125006. Depending on which PR lands first, I'll update
`TestCommandInterepterPrintCallback.py` to check that the
`CommandReturnObject` passed to the callback has the correct command.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As suggested in #125006. Depending on which PR lands first, I'll update
`TestCommandInterepterPrintCallback.py` to check that the
`CommandReturnObject` passed to the callback has the correct command.</pre>
</div>
</content>
</entry>
<entry>
<title>[LLDB] Add SBProgress so Python scripts can also report progress (#119052)</title>
<updated>2025-01-17T20:00:31+00:00</updated>
<author>
<name>Jacob Lalonde</name>
<email>jalalonde@fb.com</email>
</author>
<published>2025-01-17T20:00:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6b048aeaf837e0e16fece94610f0871d17cefe4c'/>
<id>6b048aeaf837e0e16fece94610f0871d17cefe4c</id>
<content type='text'>
Recently I've been working on a lot of internal Python tooling, and in
certain cases I want to report async to the script over DAP. Progress.h
already handles this, so I've exposed Progress via the SB API so Python
scripts can also update progress objects.

I actually have no idea how to test this, so I just wrote a [toy command
to test
it](https://gist.github.com/Jlalond/48d85e75a91f7a137e3142e6a13d0947)


![image](https://github.com/user-attachments/assets/7317cbb8-9145-4fdb-bacf-9864bf50c467)

I also copied the first section of the extensive Progress.h class
documentation to the docstrings.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Recently I've been working on a lot of internal Python tooling, and in
certain cases I want to report async to the script over DAP. Progress.h
already handles this, so I've exposed Progress via the SB API so Python
scripts can also update progress objects.

I actually have no idea how to test this, so I just wrote a [toy command
to test
it](https://gist.github.com/Jlalond/48d85e75a91f7a137e3142e6a13d0947)


![image](https://github.com/user-attachments/assets/7317cbb8-9145-4fdb-bacf-9864bf50c467)

I also copied the first section of the extensive Progress.h class
documentation to the docstrings.</pre>
</div>
</content>
</entry>
<entry>
<title>[LLDB] Make the thread list for SBSaveCoreOptions iterable (#122541)</title>
<updated>2025-01-16T19:49:02+00:00</updated>
<author>
<name>Jacob Lalonde</name>
<email>jalalonde@fb.com</email>
</author>
<published>2025-01-16T19:49:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=06edefac10f4481bdd458c0362d9a305f6a1ce6a'/>
<id>06edefac10f4481bdd458c0362d9a305f6a1ce6a</id>
<content type='text'>
This patch adds the ability to get a thread at a give index, based on
insertion order, for SBSaveCore Options. This is primarily to benefit
scripts using SBSaveCore, and remove the need to have both options and a
second collection if your script is tracking what threads need to be
saved. Such as if you want to collect the source of all the threads to
be saved after the Core is generated.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds the ability to get a thread at a give index, based on
insertion order, for SBSaveCore Options. This is primarily to benefit
scripts using SBSaveCore, and remove the need to have both options and a
second collection if your script is tracking what threads need to be
saved. Such as if you want to collect the source of all the threads to
be saved after the Core is generated.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Add lookup by name to SBValue through new member property (#118814)</title>
<updated>2024-12-09T18:48:28+00:00</updated>
<author>
<name>Dave Lee</name>
<email>davelee.com@gmail.com</email>
</author>
<published>2024-12-09T18:48:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=53fd724b256e1ccfcb04c90f7740f54e1801986d'/>
<id>53fd724b256e1ccfcb04c90f7740f54e1801986d</id>
<content type='text'>
Introduces a `member` property to `SBValue`. This property provides pythonic access to a
value's members, by name. The expression `value.member["name"]` will be an alternate
form form of writing `value.GetChildMemberWithName("name")`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Introduces a `member` property to `SBValue`. This property provides pythonic access to a
value's members, by name. The expression `value.member["name"]` will be an alternate
form form of writing `value.GetChildMemberWithName("name")`.</pre>
</div>
</content>
</entry>
<entry>
<title>Make SBMemoryRegionInfoList iterable with Python SWIG (#117358)</title>
<updated>2024-12-03T18:29:12+00:00</updated>
<author>
<name>Luke Riddle</name>
<email>35970909+lukejriddle@users.noreply.github.com</email>
</author>
<published>2024-12-03T18:29:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2a1a02461a8d4ae9f560a4215fe85a1f085b4d82'/>
<id>2a1a02461a8d4ae9f560a4215fe85a1f085b4d82</id>
<content type='text'>
This PR fixes a simple SWIG issue with SBMemoryRegionInfoList not being
iterable out-of-the-box. This is mostly because of limitations to the
`lldb_iter` function, which doesn't allow for specifying arguments to
the size / iter functions passed.

Before:
```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
&gt;&gt;&gt; for region in lldb.process.GetMemoryRegions():
...   print(region)
...
Traceback (most recent call last):
  File "&lt;console&gt;", line 1, in &lt;module&gt;
  File "/opt/llvm/stable/Toolchains/llvm-sand.xctoolchain/usr/lib/python3.10/site-packages/lldb/__init__.py", line 114, in lldb_iter
    yield elem(i)
TypeError: SBMemoryRegionInfoList.GetMemoryRegionAtIndex() missing 1 required positional argument: 'region_info'
```

After:
```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
&gt;&gt;&gt; for region in lldb.process.GetMemoryRegions():
...   print(region)
... 
[0x0000000000200000-0x00000000002cf000 R--]
[0x00000000002cf000-0x0000000000597000 R-X]
[0x0000000000597000-0x00000000005ad000 R--]
[0x00000000005ad000-0x00000000005b1000 RW-]
[0x00000000005b1000-0x0000000000b68000 RW-]
[0x000000007fff7000-0x000000008fff7000 RW-]
[0x000002008fff7000-0x000010007fff8000 RW-]
[0x0000503000000000-0x0000503000010000 RW-]
[0x0000503e00000000-0x0000503e00010000 RW-]
[0x0000504000000000-0x0000504000010000 RW-]
[0x0000504e00000000-0x0000504e00010000 RW-]
[0x000050d000000000-0x000050d000010000 RW-]
[0x000050de00000000-0x000050de00010000 RW-]
[0x000050e000000000-0x000050e000010000 RW-]
[0x000050ee00000000-0x000050ee00010000 RW-]
[0x0000511000000000-0x0000511000010000 RW-]
[0x0000511e00000000-0x0000511e00010000 RW-]
[0x0000513000000000-0x0000513000010000 RW-]
...
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR fixes a simple SWIG issue with SBMemoryRegionInfoList not being
iterable out-of-the-box. This is mostly because of limitations to the
`lldb_iter` function, which doesn't allow for specifying arguments to
the size / iter functions passed.

Before:
```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
&gt;&gt;&gt; for region in lldb.process.GetMemoryRegions():
...   print(region)
...
Traceback (most recent call last):
  File "&lt;console&gt;", line 1, in &lt;module&gt;
  File "/opt/llvm/stable/Toolchains/llvm-sand.xctoolchain/usr/lib/python3.10/site-packages/lldb/__init__.py", line 114, in lldb_iter
    yield elem(i)
TypeError: SBMemoryRegionInfoList.GetMemoryRegionAtIndex() missing 1 required positional argument: 'region_info'
```

After:
```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
&gt;&gt;&gt; for region in lldb.process.GetMemoryRegions():
...   print(region)
... 
[0x0000000000200000-0x00000000002cf000 R--]
[0x00000000002cf000-0x0000000000597000 R-X]
[0x0000000000597000-0x00000000005ad000 R--]
[0x00000000005ad000-0x00000000005b1000 RW-]
[0x00000000005b1000-0x0000000000b68000 RW-]
[0x000000007fff7000-0x000000008fff7000 RW-]
[0x000002008fff7000-0x000010007fff8000 RW-]
[0x0000503000000000-0x0000503000010000 RW-]
[0x0000503e00000000-0x0000503e00010000 RW-]
[0x0000504000000000-0x0000504000010000 RW-]
[0x0000504e00000000-0x0000504e00010000 RW-]
[0x000050d000000000-0x000050d000010000 RW-]
[0x000050de00000000-0x000050de00010000 RW-]
[0x000050e000000000-0x000050e000010000 RW-]
[0x000050ee00000000-0x000050ee00010000 RW-]
[0x0000511000000000-0x0000511000010000 RW-]
[0x0000511e00000000-0x0000511e00010000 RW-]
[0x0000513000000000-0x0000513000010000 RW-]
...
```</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Support true/false in ValueObject::SetValueFromCString (#115780)</title>
<updated>2024-11-13T05:18:22+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2024-11-13T05:18:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4714215efb0486682feaa3a99162e80a934be8f9'/>
<id>4714215efb0486682feaa3a99162e80a934be8f9</id>
<content type='text'>
Support "true" and "false" (and "YES" and "NO" in Objective-C) in
ValueObject::SetValueFromCString.

Fixes #112597</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Support "true" and "false" (and "YES" and "NO" in Objective-C) in
ValueObject::SetValueFromCString.

Fixes #112597</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Disable TestCancelAttach for Windows host (#115619)</title>
<updated>2024-11-11T08:40:01+00:00</updated>
<author>
<name>Dmitry Vasilyev</name>
<email>dvassiliev@accesssoftek.com</email>
</author>
<published>2024-11-11T08:40:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1277bea4311692d3bd3d1a6566ec1011d3e72f65'/>
<id>1277bea4311692d3bd3d1a6566ec1011d3e72f65</id>
<content type='text'>
See #115618 for details.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See #115618 for details.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Fix API test for file redirection to existing files (#114119)</title>
<updated>2024-10-30T21:00:40+00:00</updated>
<author>
<name>Wanyi</name>
<email>kusmour@gmail.com</email>
</author>
<published>2024-10-30T21:00:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f7c36d2f88e05a1747fa7916ad2fefdd9d459a55'/>
<id>f7c36d2f88e05a1747fa7916ad2fefdd9d459a55</id>
<content type='text'>
API test failed for remote platform in
[#112657](https://github.com/llvm/llvm-project/pull/112657)

Previously when putting files onto remote platform, I used `platform
file write -d &lt;data&gt;` which actually required a `platform file open
&lt;path&gt;` first in order to obtain a file descriptor.
eg. in file
[TestGDBRemotePlatformFile.py](https://github.com/llvm/llvm-project/blob/94e7d9c0bfe517507ea08b00fb00c32fb2837a82/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py#L24-L32)
To fix this, use the `platform put-file` method, which is used in the
`redirect_stdin` from this test already.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
API test failed for remote platform in
[#112657](https://github.com/llvm/llvm-project/pull/112657)

Previously when putting files onto remote platform, I used `platform
file write -d &lt;data&gt;` which actually required a `platform file open
&lt;path&gt;` first in order to obtain a file descriptor.
eg. in file
[TestGDBRemotePlatformFile.py](https://github.com/llvm/llvm-project/blob/94e7d9c0bfe517507ea08b00fb00c32fb2837a82/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py#L24-L32)
To fix this, use the `platform put-file` method, which is used in the
`redirect_stdin` from this test already.</pre>
</div>
</content>
</entry>
</feed>
