<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lldb/source/Plugins/ScriptInterpreter/Python, branch users/mingmingl-llvm/samplefdo-profile-format</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] Introduce ScriptedFrame affordance (#149622)</title>
<updated>2025-09-04T22:07:11+00:00</updated>
<author>
<name>Med Ismail Bennani</name>
<email>ismail@bennani.ma</email>
</author>
<published>2025-09-04T22:07:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=84b56202fbe150e06f92c855107489e08cc17bcd'/>
<id>84b56202fbe150e06f92c855107489e08cc17bcd</id>
<content type='text'>
This patch introduces a new scripting affordance in lldb:
`ScriptedFrame`.

This allows user to produce mock stackframes in scripted threads and
scripted processes from a python script.

With this change, StackFrame can be synthetized from different sources:
- Either from a dictionary containing a load address, and a frame index,
  which is the legacy way.
- Or by creating a ScriptedFrame python object.

One particularity of synthezising stackframes from the ScriptedFrame
python object, is that these frame have an optional PC, meaning that
they don't have a report a valid PC and they can act as shells that just
contain static information, like the frame function name, the list of
variables or registers, etc. It can also provide a symbol context.

rdar://157260006

Signed-off-by: Med Ismail Bennani &lt;ismail@bennani.ma&gt;

Signed-off-by: Med Ismail Bennani &lt;ismail@bennani.ma&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch introduces a new scripting affordance in lldb:
`ScriptedFrame`.

This allows user to produce mock stackframes in scripted threads and
scripted processes from a python script.

With this change, StackFrame can be synthetized from different sources:
- Either from a dictionary containing a load address, and a frame index,
  which is the legacy way.
- Or by creating a ScriptedFrame python object.

One particularity of synthezising stackframes from the ScriptedFrame
python object, is that these frame have an optional PC, meaning that
they don't have a report a valid PC and they can act as shells that just
contain static information, like the frame function name, the list of
variables or registers, etc. It can also provide a symbol context.

rdar://157260006

Signed-off-by: Med Ismail Bennani &lt;ismail@bennani.ma&gt;

Signed-off-by: Med Ismail Bennani &lt;ismail@bennani.ma&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Use (only) PyImport_AppendInittab to patch readline (#153329)</title>
<updated>2025-08-14T18:47:48+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-14T18:47:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b62b65a95f2b5e79e90f3f957e7a52ec50c5fe31'/>
<id>b62b65a95f2b5e79e90f3f957e7a52ec50c5fe31</id>
<content type='text'>
The current implementation tries to (1) patch the existing readline
module definition if it's already present in the inittab and (2) append
our patched readline module to the inittab. The former (1) uses the
non-stable Python API and I can't find a situation where this is
necessary. 

We do this work before initialization, so for the readline
module to exist, it either needs to be added by Python itself (which
doesn't seem to be the case), or someone would have had to have added it
without initializing.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The current implementation tries to (1) patch the existing readline
module definition if it's already present in the inittab and (2) append
our patched readline module to the inittab. The former (1) uses the
non-stable Python API and I can't find a situation where this is
necessary. 

We do this work before initialization, so for the readline
module to exist, it either needs to be added by Python itself (which
doesn't seem to be the case), or someone would have had to have added it
without initializing.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Use PyThread_get_thread_ident instead of accessing PyThreadState (#153460)</title>
<updated>2025-08-14T17:41:49+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-14T17:41:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ac0ad5093ab451a36ea9ed34b0d3d461e759f4ea'/>
<id>ac0ad5093ab451a36ea9ed34b0d3d461e759f4ea</id>
<content type='text'>
Use `PyThread_get_thread_ident`, which is part of the Stable API,
instead of accessing a member of the PyThreadState, which is opaque when
using the Stable API.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use `PyThread_get_thread_ident`, which is part of the Stable API,
instead of accessing a member of the PyThreadState, which is opaque when
using the Stable API.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Support the Python stable C API in PythonString::AsUTF8 (#152599)</title>
<updated>2025-08-08T20:57:58+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-08T20:57:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=412ea0b675522fd161382d5ce437e51f0505337a'/>
<id>412ea0b675522fd161382d5ce437e51f0505337a</id>
<content type='text'>
This conditionally reimplements PythonString::AsUTF8 using
PyUnicode_AsUTF8String instead of PyUnicode_AsUTF8AndSize.

PyUnicode_AsUTF8AndSize caches the UTF-8 representation of the string in
the Unicode object, which makes it more efficient and ties the lifetime
of the data to the Python string. However, it was only added to the
Stable API in Python 3.10. Older versions that want to use the Stable
API must use PyUnicode_AsUTF8String in combination with ConstString.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This conditionally reimplements PythonString::AsUTF8 using
PyUnicode_AsUTF8String instead of PyUnicode_AsUTF8AndSize.

PyUnicode_AsUTF8AndSize caches the UTF-8 representation of the string in
the Unicode object, which makes it more efficient and ties the lifetime
of the data to the Python string. However, it was only added to the
Stable API in Python 3.10. Older versions that want to use the Stable
API must use PyUnicode_AsUTF8String in combination with ConstString.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Only use PyConfig when LLDB_EMBED_PYTHON_HOME is enabled (#152588)</title>
<updated>2025-08-08T16:49:43+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-08T16:49:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bcdc80828bcb94922db6e5b8f1c0935b2f5a67e2'/>
<id>bcdc80828bcb94922db6e5b8f1c0935b2f5a67e2</id>
<content type='text'>
PyConfig and friends are not part of the stable API. We could switch
back to Py_SetPythonHome, which has been deprecated, but still part of
the stable API. For now, limit the use of PyConfig to when
LLDB_EMBED_PYTHON_HOME is enabled, which essentially means Windows.
Changing the order doesn't seem to matter.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PyConfig and friends are not part of the stable API. We could switch
back to Py_SetPythonHome, which has been deprecated, but still part of
the stable API. For now, limit the use of PyConfig to when
LLDB_EMBED_PYTHON_HOME is enabled, which essentially means Windows.
Changing the order doesn't seem to matter.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Eliminate (_)Py_IsFinalizing (NFC) (#152226)</title>
<updated>2025-08-06T16:06:54+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-06T16:06:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3686e5b52f2a02c1c19050479d1dd0fd9d1dd4f8'/>
<id>3686e5b52f2a02c1c19050479d1dd0fd9d1dd4f8</id>
<content type='text'>
Looking at the implementation of `pylifecycle.c` in cpython, finalizing
and initialized are set at the same time. Therefore we can eliminate the
call to `Py_IsFinalizing` and only check `Py_IsInitialized`, which is
part of the stable API.

I converted the check to an assert and confirmed that during my test
suite runs, we never got into the if block. Because we check before
taking the lock, there is an opportunity for a race, but that exact same
race exists with the original code.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Looking at the implementation of `pylifecycle.c` in cpython, finalizing
and initialized are set at the same time. Therefore we can eliminate the
call to `Py_IsFinalizing` and only check `Py_IsInitialized`, which is
part of the stable API.

I converted the check to an assert and confirmed that during my test
suite runs, we never got into the if block. Because we check before
taking the lock, there is an opportunity for a race, but that exact same
race exists with the original code.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Workaround omission of PyBUF_READ in the stable API (#152214)</title>
<updated>2025-08-06T02:21:36+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-06T02:21:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7b8dea265e72c3037b6b1e54d5ab51b7e14f328b'/>
<id>7b8dea265e72c3037b6b1e54d5ab51b7e14f328b</id>
<content type='text'>
PyMemoryView_FromMemory is part of stable ABI but the flag constants
such as PyBUF_READ are not. This was fixed in Python 3.11 [1], but still
requires this workaround when using older versions.

[1] https://github.com/python/cpython/issues/98680</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PyMemoryView_FromMemory is part of stable ABI but the flag constants
such as PyBUF_READ are not. This was fixed in Python 3.11 [1], but still
requires this workaround when using older versions.

[1] https://github.com/python/cpython/issues/98680</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Drop PY_MINOR_VERSION &gt;= 3 check (NFC)</title>
<updated>2025-08-05T23:21:22+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-05T23:19:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4c2d56318fec16d1d5241cd91d38b59cb65bce83'/>
<id>4c2d56318fec16d1d5241cd91d38b59cb65bce83</id>
<content type='text'>
The minimum supported Python version is now 3.8, so there's no supported
configuration where the minor version is less than 3.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The minimum supported Python version is now 3.8, so there's no supported
configuration where the minor version is less than 3.
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Use Python Bytes instead of Buffer for Binary I/O (NFC) (#152031)</title>
<updated>2025-08-05T17:58:59+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-05T17:58:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=12da87bef12d9545775a5c375cfc22904ca4602d'/>
<id>12da87bef12d9545775a5c375cfc22904ca4602d</id>
<content type='text'>
Binary I/O (also called buffered I/O) expects bytes-like objects and
produces bytes objects [1]. Switch from using a Python buffer to using
Python bytes to read the data. This eliminates calls to functions that
aren't part of the Python stable C API.

[1] https://docs.python.org/3/library/io.html#binary-i-o</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Binary I/O (also called buffered I/O) expects bytes-like objects and
produces bytes objects [1]. Switch from using a Python buffer to using
Python bytes to read the data. This eliminates calls to functions that
aren't part of the Python stable C API.

[1] https://docs.python.org/3/library/io.html#binary-i-o</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Reimplement PythonObject::Dump using the limited API (#152055)</title>
<updated>2025-08-05T15:17:01+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-08-05T15:17:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c4f7d8744ac54bc1ede754e8d10655fb86b47f25'/>
<id>c4f7d8744ac54bc1ede754e8d10655fb86b47f25</id>
<content type='text'>
This reimplements `PythonObject::Dump` using functions that are part of
the limited API, instead of using `PyObject_Print`, which is not.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reimplements `PythonObject::Dump` using functions that are part of
the limited API, instead of using `PyObject_Print`, which is not.</pre>
</div>
</content>
</entry>
</feed>
