From: Derrick Stolee <stolee@gmail.com>
To: Matthew John Cheetham via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: gitster@pobox.com, johannes.schindelin@gmx.de,
Matthew John Cheetham <mjcheetham@outlook.com>
Subject: Re: [PATCH 3/4] trace2: refactor Windows process ancestry trace2 event
Date: Mon, 9 Feb 2026 09:41:28 -0500 [thread overview]
Message-ID: <1a282a1c-866e-49fc-b396-014921135cc4@gmail.com> (raw)
In-Reply-To: <7ccd0a9a6d89decaa5856494a184c71bc0d678e9.1770307510.git.gitgitgadget@gmail.com>
On 2/5/2026 11:05 AM, Matthew John Cheetham via GitGitGadget wrote:
> diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
...
> #include "../../json-writer.h"
Are we able to delete this after your change?
> pid = GetCurrentProcessId();
> while (find_pid(pid, hSnapshot, &pe32)) {
> - /* Only report parents. Omit self from the JSON output. */
> + /* Only report parents. Omit self from the output. */
> if (nr_pids)
> - jw_array_string(jw, pe32.szExeFile);
> + strvec_push(names, pe32.szExeFile);
>
> /* Check for cycle in snapshot. (Yes, it happened.) */
> for (k = 0; k < nr_pids; k++)
> if (pid == pid_list[k]) {
> - jw_array_string(jw, "(cycle)");
> + strvec_push(names, "(cycle)");
> return;
> }
>
> if (nr_pids == NR_PIDS_LIMIT) {
> - jw_array_string(jw, "(truncated)");
> + strvec_push(names, "(truncated)");
> return;
> }
Nice replacement of JSON with strvec logic.
> @@ -105,24 +101,14 @@ static void get_processes(struct json_writer *jw, HANDLE hSnapshot)
> }
>
> /*
> - * Emit JSON data for the current and parent processes. Individual
> - * trace2 targets can decide how to actually print it.
> + * Collect the list of parent process names.
> */
> -static void get_ancestry(void)
> +static void get_ancestry(struct strvec *names)
> {
> HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
>
> if (hSnapshot != INVALID_HANDLE_VALUE) {
> - struct json_writer jw = JSON_WRITER_INIT;
> -
> - jw_array_begin(&jw, 0);
> - get_processes(&jw, hSnapshot);
> - jw_end(&jw);
> -
> - trace2_data_json("process", the_repository, "windows/ancestry",
> - &jw);
> -
> - jw_release(&jw);
> + get_processes(names, hSnapshot);
> CloseHandle(hSnapshot);
Nice simplification!
> void trace2_collect_process_info(enum trace2_process_info_reason reason)
> {
> + struct strvec names = STRVEC_INIT;
> +
> if (!trace2_is_enabled())
> return;
>
> switch (reason) {
> case TRACE2_PROCESS_INFO_STARTUP:
> get_is_being_debugged();
> - get_ancestry();
> + get_ancestry(&names);
> + if (names.nr) {
> + struct json_writer jw = JSON_WRITER_INIT;
> + jw_array_begin(&jw, 0);
> + for (size_t i = 0; i < names.nr; i++)
> + jw_array_string(&jw, names.v[i]);
> + jw_end(&jw);
> + trace2_data_json("process", the_repository,
> + "windows/ancestry", &jw);
> + jw_release(&jw);
Ah, you still have JSON logic at this point.
I see that in your next patch you export the names vector itself _and_
this older JSON version. We should consider a future where we drop this
JSON altogether, but it's nice to have both for a few versions so tool
makers have time to respond.
Thanks,
-Stolee
next prev parent reply other threads:[~2026-02-09 14:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 16:05 [PATCH 0/4] trace2: add macOS and Windows process ancestry tracing Matthew John Cheetham via GitGitGadget
2026-02-05 16:05 ` [PATCH 1/4] trace2: add macOS " Matthew John Cheetham via GitGitGadget
2026-02-09 14:36 ` Derrick Stolee
2026-02-09 15:13 ` Matthew John Cheetham
2026-02-10 4:15 ` Derrick Stolee
2026-02-05 16:05 ` [PATCH 2/4] build: include procinfo.c impl for macOS Matthew John Cheetham via GitGitGadget
2026-02-09 14:37 ` Derrick Stolee
2026-02-05 16:05 ` [PATCH 3/4] trace2: refactor Windows process ancestry trace2 event Matthew John Cheetham via GitGitGadget
2026-02-09 14:41 ` Derrick Stolee [this message]
2026-02-05 16:05 ` [PATCH 4/4] trace2: emit cmd_ancestry data for Windows Matthew John Cheetham via GitGitGadget
2026-02-05 16:19 ` Kristoffer Haugsbakk
2026-02-09 14:42 ` Derrick Stolee
2026-02-09 14:48 ` [PATCH 0/4] trace2: add macOS and Windows process ancestry tracing Derrick Stolee
2026-02-09 17:05 ` Junio C Hamano
2026-02-13 19:54 ` [PATCH v2 0/6] " Matthew John Cheetham via GitGitGadget
2026-02-13 19:54 ` [PATCH v2 1/6] trace2: add macOS " Matthew John Cheetham via GitGitGadget
2026-02-13 19:54 ` [PATCH v2 2/6] build: include procinfo.c impl for macOS Matthew John Cheetham via GitGitGadget
2026-02-13 20:34 ` Junio C Hamano
2026-02-13 19:54 ` [PATCH v2 3/6] trace2: refactor Windows process ancestry trace2 event Matthew John Cheetham via GitGitGadget
2026-02-13 20:36 ` Junio C Hamano
2026-02-13 19:54 ` [PATCH v2 4/6] trace2: emit cmd_ancestry data for Windows Matthew John Cheetham via GitGitGadget
2026-02-13 20:52 ` Junio C Hamano
2026-02-13 19:54 ` [PATCH v2 5/6] test-tool: extend trace2 helper with 400ancestry Matthew John Cheetham via GitGitGadget
2026-02-13 19:55 ` [PATCH v2 6/6] t0213: add trace2 cmd_ancestry tests Matthew John Cheetham via GitGitGadget
2026-02-14 0:30 ` [PATCH v2 0/6] trace2: add macOS and Windows process ancestry tracing Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a282a1c-866e-49fc-b396-014921135cc4@gmail.com \
--to=stolee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=mjcheetham@outlook.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox