================
@@ -183,13 +183,21 @@ bool ProcessFreeBSDKernel::DoUpdateThreadList(ThreadList
&old_thread_list,
// from FreeBSD sys/param.h
constexpr size_t fbsd_maxcomlen = 19;
- // iterate through a linked list of all processes
- // allproc is a pointer to the first list element, p_list field
- // (found at offset_p_list) specifies the next element
+ // pid is in reverse order. Order it incrementally
+ std::vector<lldb::addr_t> process_addrs;
for (lldb::addr_t proc =
ReadPointerFromMemory(FindSymbol("allproc"), error);
proc != 0 && proc != LLDB_INVALID_ADDRESS;
proc = ReadPointerFromMemory(proc + offset_p_list, error)) {
+ process_addrs.push_back(proc);
+ }
+
+ // iterate through a linked list of all processes
+ // allproc is a pointer to the first list element, p_list field
+ // (found at offset_p_list) specifies the next element
+ for (auto proc_it = process_addrs.rbegin(); proc_it !=
process_addrs.rend();
----------------
DavidSpickett wrote:
Add a comment for emphasis here, like:
```
// Processes are in the linked list in descending PID order, so we must walk
them in reverse to get ascending PID order.
```
I know you already explained it, but the `r` of the `rbegin` can be easy to
miss for the casual reader.
https://github.com/llvm/llvm-project/pull/178306
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits