Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7dd836b
Add binary I/O header for sampling profiler
pablogsal Dec 15, 2025
83603c7
Add binary writer for sampling profiler
pablogsal Dec 15, 2025
7a58811
Add binary reader for sampling profiler
pablogsal Dec 15, 2025
e3ea7a4
Build: add binary I/O files to Unix build
pablogsal Dec 15, 2025
8931b4a
Build: add binary I/O files to Windows build
pablogsal Dec 15, 2025
18287f4
Add Python bindings for binary writer and reader
pablogsal Dec 15, 2025
1f7737e
Add BinaryCollector for sampling profiler
pablogsal Dec 15, 2025
2965eff
Add BinaryReader for sampling profiler replay
pablogsal Dec 15, 2025
427f846
Add --binary and replay command to sampling profiler CLI
pablogsal Dec 15, 2025
1437629
Update collector interface for binary replay support
pablogsal Dec 15, 2025
e75513b
Add tests for binary format
pablogsal Dec 15, 2025
a520ac1
Add internal documentation for binary format
pablogsal Dec 15, 2025
3ad7a3d
Document binary format and replay command
pablogsal Dec 15, 2025
cd4f412
Fix CI
pablogsal Dec 15, 2025
596af7f
Add NEWS entry
pablogsal Dec 15, 2025
1e2400b
Regen and simplify
pablogsal Dec 15, 2025
b90e37c
Merge upstream/main into file-output
pablogsal Dec 15, 2025
788c565
Speed up general case
pablogsal Dec 15, 2025
51b3b09
Small fixes
pablogsal Dec 20, 2025
81a8f2d
Merge branch 'main' into file-output
pablogsal Dec 20, 2025
0ccea49
Address Laszlo's review
pablogsal Dec 20, 2025
dfc0d31
More fixes from review
pablogsal Dec 20, 2025
b9fc778
Fixes and more tests
pablogsal Dec 20, 2025
191458a
Fix c analizer
pablogsal Dec 22, 2025
63c6f50
Update docs
pablogsal Dec 22, 2025
046fe55
Update cli
pablogsal Dec 22, 2025
f88c01f
Fixes
pablogsal Dec 22, 2025
ed63156
Merge upstream/main
pablogsal Dec 22, 2025
c880f85
Fix big endian
pablogsal Dec 22, 2025
ad7891c
Fix big endian
pablogsal Dec 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge upstream/main into file-output
Merged changes from upstream/main including:
- Subprocess enumeration functionality (get_child_pids, is_python_process)
- Various fixes and improvements

Combined with file-output branch features:
- Binary I/O writer and reader for profiling data
- Binary format export/replay support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
  • Loading branch information
pablogsal and claude committed Dec 15, 2025
commit b90e37c945d3b124cb57fac3e2ccd74c96c24cc0
7 changes: 6 additions & 1 deletion Lib/profiling/sampling/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,12 @@ def _handle_output(collector, args, pid, mode):
sort_mode, limit, not args.no_summary, mode
)
else:
filename = args.outfile or _generate_output_filename(args.format, pid)
# Export to file
if args.outfile and os.path.isdir(args.outfile):
# If outfile is a directory, generate filename inside it
filename = os.path.join(args.outfile, _generate_output_filename(args.format, pid))
else:
filename = args.outfile or _generate_output_filename(args.format, pid)
collector.export(filename)


Expand Down
2 changes: 1 addition & 1 deletion Modules/Setup.stdlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@MODULE__PICKLE_TRUE@_pickle _pickle.c
@MODULE__QUEUE_TRUE@_queue _queuemodule.c
@MODULE__RANDOM_TRUE@_random _randommodule.c
@MODULE__REMOTE_DEBUGGING_TRUE@_remote_debugging _remote_debugging/module.c _remote_debugging/object_reading.c _remote_debugging/code_objects.c _remote_debugging/frames.c _remote_debugging/frame_cache.c _remote_debugging/threads.c _remote_debugging/asyncio.c _remote_debugging/binary_io_writer.c _remote_debugging/binary_io_reader.c
@MODULE__REMOTE_DEBUGGING_TRUE@_remote_debugging _remote_debugging/module.c _remote_debugging/object_reading.c _remote_debugging/code_objects.c _remote_debugging/frames.c _remote_debugging/frame_cache.c _remote_debugging/threads.c _remote_debugging/asyncio.c _remote_debugging/binary_io_writer.c _remote_debugging/binary_io_reader.c _remote_debugging/subprocess.c
@MODULE__STRUCT_TRUE@_struct _struct.c

# build supports subinterpreters
Expand Down
4 changes: 0 additions & 4 deletions Modules/_remote_debugging/_remote_debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
extern "C" {
#endif

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef Py_BUILD_CORE_BUILTIN
# ifndef Py_BUILD_CORE_MODULE
# define Py_BUILD_CORE_MODULE 1
Expand Down
151 changes: 150 additions & 1 deletion Modules/_remote_debugging/clinic/module.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions Modules/_remote_debugging/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,8 +1647,75 @@ _remote_debugging_zstd_available_impl(PyObject *module)
return PyBool_FromLong(binary_io_zstd_available());
}

/* ============================================================================
* MODULE-LEVEL FUNCTIONS
* ============================================================================ */

/*[clinic input]
_remote_debugging.get_child_pids

pid: int
Process ID of the parent process
*
recursive: bool = True
If True, return all descendants (children, grandchildren, etc.).
If False, return only direct children.

Get all child process IDs of the given process.

Returns a list of child process IDs. Returns an empty list if no children
are found.

This function provides a snapshot of child processes at a moment in time.
Child processes may exit or new ones may be created after the list is returned.

Raises:
OSError: If unable to enumerate processes
NotImplementedError: If not supported on this platform
[clinic start generated code]*/

static PyObject *
_remote_debugging_get_child_pids_impl(PyObject *module, int pid,
int recursive)
/*[clinic end generated code: output=1ae2289c6b953e4b input=3395cbe7f17066c9]*/
{
return enumerate_child_pids((pid_t)pid, recursive);
}

/*[clinic input]
_remote_debugging.is_python_process

pid: int

Check if a process is a Python process.
[clinic start generated code]*/

static PyObject *
_remote_debugging_is_python_process_impl(PyObject *module, int pid)
/*[clinic end generated code: output=22947dc8afcac362 input=13488e28c7295d84]*/
{
proc_handle_t handle;

if (_Py_RemoteDebug_InitProcHandle(&handle, pid) < 0) {
PyErr_Clear();
Py_RETURN_FALSE;
}

uintptr_t runtime_start_address = _Py_RemoteDebug_GetPyRuntimeAddress(&handle);
_Py_RemoteDebug_CleanupProcHandle(&handle);

if (runtime_start_address == 0) {
PyErr_Clear();
Py_RETURN_FALSE;
}

Py_RETURN_TRUE;
}

static PyMethodDef remote_debugging_methods[] = {
_REMOTE_DEBUGGING_ZSTD_AVAILABLE_METHODDEF
_REMOTE_DEBUGGING_GET_CHILD_PIDS_METHODDEF
_REMOTE_DEBUGGING_IS_PYTHON_PROCESS_METHODDEF
{NULL, NULL, 0, NULL},
};

Expand Down
1 change: 1 addition & 0 deletions PCbuild/_remote_debugging.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<ClCompile Include="..\Modules\_remote_debugging\asyncio.c" />
<ClCompile Include="..\Modules\_remote_debugging\binary_io_writer.c" />
<ClCompile Include="..\Modules\_remote_debugging\binary_io_reader.c" />
<ClCompile Include="..\Modules\_remote_debugging\subprocess.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Modules\_remote_debugging\_remote_debugging.h" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/_remote_debugging.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<ClCompile Include="..\Modules\_remote_debugging\binary_io_reader.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Modules\_remote_debugging\subprocess.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Modules\_remote_debugging\_remote_debugging.h">
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.