From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 9D3C61F453 for ; Wed, 30 Jan 2019 19:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733280AbfA3TvW (ORCPT ); Wed, 30 Jan 2019 14:51:22 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:32793 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbfA3TvN (ORCPT ); Wed, 30 Jan 2019 14:51:13 -0500 Received: by mail-ed1-f65.google.com with SMTP id p6so672090eds.0 for ; Wed, 30 Jan 2019 11:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=CV7WGoNKdqnK9FZ81EaPWncoNYCYEdobDJpYb9pm9hk=; b=LjRHosplq8cO7Sb8ABoOodHYbQijJElg4f8+w6I+SX8uIM5EdRs6KeE+RX8856fl4X JxDpHUxyRSPyEqXWyMYRK+F8xrnQN/ebSMIR3ZVfFQvl9B67kIcF4pUjwQ6atzov9SFl eYl0veF8E95r2xQ5VaoKvupAvTwCJIaFgoa2KwjmR1Wl5Fa3FWCYyheW5x0ObgT0Cnem 1Qy0pLJDtW4fZBqSQHYgG55H2g6kB2QdwFSHt2UghtAWBcihQkjoON5afmMr5fs/QOYr rchTlYU8jF53UW48GyHb2jcqakVrJkZoYAb+6veV7Q42aSSJZsPOdBf5YNcJEjQIHPtu jfkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=CV7WGoNKdqnK9FZ81EaPWncoNYCYEdobDJpYb9pm9hk=; b=JNPH+Cd1NtkT3oksG1Ax9V7S/4BoYySInPUxJ27xSMJzw2NOcE3eTVoUiv+azqdNWK Tp8MqwvyMjUMzUArMXprh1TrhSwvTgxpS7ZcuSm0iFjBXiz0KzsodbpTh1pEolAGzFIk K6w2ks8SFW5J0S3Drf1CbzwALP1Ogk1lfeZAJ+7+TbN7utORGdyYeU/0voPcFLuUCQa/ lTI3zkRIdtlnTU2x+pOw6QYX3EhHBwizhInUJfP60Wr+xXnGAb/duZfy++bspMbRQ5E3 aBQ1dB6y2ouB/QwRn9mJ/7/ufkrLphejlNlsNRsrehRUJuYuiBgMmyxvlk7upRgZC+cZ 9bWA== X-Gm-Message-State: AJcUuke0fejQ/XnItqyx8AJRetishTMThIAtORHpFLfTlG8MiEd9m5ik NQSjonGbi9u8W/ReZAxpStEGYyL6 X-Google-Smtp-Source: ALg8bN5EHMo445Ct9NvOH2GXsQXw/ecUyn4ddHo6bYWOL1f/YByWXyzEEcE4WpwEgPx0sUFOUpXkWA== X-Received: by 2002:a05:6402:1816:: with SMTP id g22mr32069710edy.191.1548877864854; Wed, 30 Jan 2019 11:51:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m13sm764567edd.2.2019.01.30.11.51.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 11:51:04 -0800 (PST) Date: Wed, 30 Jan 2019 11:51:04 -0800 (PST) X-Google-Original-Date: Wed, 30 Jan 2019 19:50:49 GMT Message-Id: In-Reply-To: References: From: "Jeff Hostetler via GitGitGadget" Subject: [PATCH v3 00/14] Trace2 tracing facility Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: jeffhost@microsoft.com, Junio C Hamano Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org V3 addresses: [] re-fix the trace2 tests using an inline environment variable rather than exporting and unsetting. [] overhaul the design document to include prototype declarations and more file format information. [] incorporate most of the suggestions from clang-format. [] add ability to trace to a unix domain socket. [] added forward declarations suggested by Ramsay. [] rebased onto current master to fixup conflict with sb/submodule-recursive-fetch-gets-the-tip that was merged yesterday. ---------------------------------------------------------------------------- V2 addresses: [] "jh/trace2" bad interaction with "js/vsts-ci" in "pu". [] coccinelle warnings in trace2/tr2_tgt_perf.c reported during CI testing. ---------------------------------------------------------------------------- This patch series contains a greatly refactored version of my original Trace2 series [1] from August 2018. A new design doc in Documentation/technical/api-trace2.txt (in the first commit) explains the relationship of Trace2 to the current tracing facility. Calls to the current tracing facility have not been changed, rather new trace2 calls have been added so that both continue to work in parallel for the time being. [1] https://public-inbox.org/git/pull.29.git.gitgitgadget@gmail.com/ Cc: gitster@pobox.comCc: peff@peff.netCc: jrnieder@gmail.com Derrick Stolee (1): pack-objects: add trace2 regions Jeff Hostetler (13): trace2: Documentation/technical/api-trace2.txt trace2: create new combined trace facility trace2: collect platform-specific process information trace2:data: add trace2 regions to wt-status trace2:data: add editor/pager child classification trace2:data: add trace2 sub-process classification trace2:data: add trace2 transport child classification trace2:data: add trace2 hook classification trace2:data: add trace2 instrumentation to index read/write trace2:data: add subverb to checkout command trace2:data: add subverb to reset command trace2:data: add subverb for rebase trace2: t/helper/test-trace2, t0210.sh, t0211.sh, t0212.sh Documentation/technical/api-trace2.txt | 1347 ++++++++++++++++++++++++ Makefile | 11 + builtin/am.c | 1 + builtin/checkout.c | 7 + builtin/pack-objects.c | 16 +- builtin/rebase.c | 17 + builtin/receive-pack.c | 4 + builtin/reset.c | 6 + builtin/submodule--helper.c | 9 +- builtin/worktree.c | 1 + cache.h | 1 + common-main.c | 13 +- compat/mingw.c | 11 +- compat/mingw.h | 3 +- compat/win32/ancestry.c | 101 ++ config.c | 2 + config.mak.uname | 2 + connect.c | 3 + editor.c | 1 + exec-cmd.c | 2 + git-compat-util.h | 7 + git.c | 65 ++ pager.c | 1 + read-cache.c | 51 +- remote-curl.c | 7 + repository.c | 2 + repository.h | 3 + run-command.c | 59 +- run-command.h | 13 +- sequencer.c | 2 + sh-i18n--envsubst.c | 3 + sub-process.c | 1 + submodule.c | 11 +- t/helper/test-parse-options.c | 3 + t/helper/test-tool.c | 4 + t/helper/test-tool.h | 1 + t/helper/test-trace2.c | 274 +++++ t/t0001-init.sh | 1 + t/t0210-trace2-normal.sh | 135 +++ t/t0210/scrub_normal.perl | 48 + t/t0211-trace2-perf.sh | 153 +++ t/t0211/scrub_perf.perl | 76 ++ t/t0212-trace2-event.sh | 234 ++++ t/t0212/parse_events.perl | 251 +++++ trace2.c | 807 ++++++++++++++ trace2.h | 380 +++++++ trace2/tr2_cfg.c | 90 ++ trace2/tr2_cfg.h | 19 + trace2/tr2_dst.c | 198 ++++ trace2/tr2_dst.h | 36 + trace2/tr2_sid.c | 67 ++ trace2/tr2_sid.h | 18 + trace2/tr2_tbuf.c | 32 + trace2/tr2_tbuf.h | 23 + trace2/tr2_tgt.h | 131 +++ trace2/tr2_tgt_event.c | 590 +++++++++++ trace2/tr2_tgt_normal.c | 325 ++++++ trace2/tr2_tgt_perf.c | 536 ++++++++++ trace2/tr2_tls.c | 164 +++ trace2/tr2_tls.h | 97 ++ trace2/tr2_verb.c | 30 + trace2/tr2_verb.h | 24 + transport-helper.c | 2 + transport.c | 1 + usage.c | 31 + wt-status.c | 24 +- 66 files changed, 6567 insertions(+), 21 deletions(-) create mode 100644 Documentation/technical/api-trace2.txt create mode 100644 compat/win32/ancestry.c create mode 100644 t/helper/test-trace2.c create mode 100755 t/t0210-trace2-normal.sh create mode 100644 t/t0210/scrub_normal.perl create mode 100755 t/t0211-trace2-perf.sh create mode 100644 t/t0211/scrub_perf.perl create mode 100755 t/t0212-trace2-event.sh create mode 100644 t/t0212/parse_events.perl create mode 100644 trace2.c create mode 100644 trace2.h create mode 100644 trace2/tr2_cfg.c create mode 100644 trace2/tr2_cfg.h create mode 100644 trace2/tr2_dst.c create mode 100644 trace2/tr2_dst.h create mode 100644 trace2/tr2_sid.c create mode 100644 trace2/tr2_sid.h create mode 100644 trace2/tr2_tbuf.c create mode 100644 trace2/tr2_tbuf.h create mode 100644 trace2/tr2_tgt.h create mode 100644 trace2/tr2_tgt_event.c create mode 100644 trace2/tr2_tgt_normal.c create mode 100644 trace2/tr2_tgt_perf.c create mode 100644 trace2/tr2_tls.c create mode 100644 trace2/tr2_tls.h create mode 100644 trace2/tr2_verb.c create mode 100644 trace2/tr2_verb.h base-commit: b5101f929789889c2e536d915698f58d5c5c6b7a Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-108%2Fjeffhostetler%2Fcore-trace2-2019-v0-v3 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-108/jeffhostetler/core-trace2-2019-v0-v3 Pull-Request: https://github.com/gitgitgadget/git/pull/108 Range-diff vs v2: 1: 1a90de9dab < -: ---------- trace2: Documentation/technical/api-trace2.txt -: ---------- > 1: 60b56d6a8f trace2: Documentation/technical/api-trace2.txt 2: ea39b76d31 ! 2: bfe2fe0bbe trace2: create new combined trace facility @@ -65,12 +65,10 @@ - update_clone_start_failure, - update_clone_task_finished, - suc); -+ run_processes_parallel_tr2(suc->max_jobs, -+ update_clone_get_next_task, ++ run_processes_parallel_tr2(suc->max_jobs, update_clone_get_next_task, + update_clone_start_failure, -+ update_clone_task_finished, -+ suc, -+ "submodule", "parallel/update"); ++ update_clone_task_finished, suc, "submodule", ++ "parallel/update"); /* * We saved the output and put it out all at once now. @@ -427,7 +425,7 @@ + * we skip this for Windows because the compat layer already + * has to emulate the execvp() call anyway. + */ -+ int exec_id = trace2_exec(file, (const char**)argv); ++ int exec_id = trace2_exec(file, (const char **)argv); +#endif + if (!execvp(file, argv)) @@ -493,8 +491,8 @@ + return run_command_v_opt_cd_env_tr2(argv, opt, dir, env, NULL); +} + -+int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, const char *const *env, -+ const char *tr2_class) ++int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, ++ const char *const *env, const char *tr2_class) { struct child_process cmd = CHILD_PROCESS_INIT; cmd.argv = argv; @@ -519,18 +517,15 @@ return 0; } + -+int run_processes_parallel_tr2(int n, -+ get_next_task_fn get_next_task, ++int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task, + start_failure_fn start_failure, -+ task_finished_fn task_finished, -+ void *pp_cb, -+ const char *tr2_category, -+ const char *tr2_label) ++ task_finished_fn task_finished, void *pp_cb, ++ const char *tr2_category, const char *tr2_label) +{ + int result; + -+ trace2_region_enter_printf(tr2_category, tr2_label, NULL, -+ "max:%d", ((n < 1) ? online_cpus() : n)); ++ trace2_region_enter_printf(tr2_category, tr2_label, NULL, "max:%d", ++ ((n < 1) ? online_cpus() : n)); + + result = run_processes_parallel(n, get_next_task, start_failure, + task_finished, pp_cb); @@ -539,7 +534,6 @@ + + return result; +} -+ diff --git a/run-command.h b/run-command.h --- a/run-command.h @@ -568,8 +562,8 @@ * To unset an environment variable use just "VAR". */ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env); -+int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, const char *const *env, -+ const char *tr2_class); ++int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, ++ const char *const *env, const char *tr2_class); /** * Execute the given command, sending "in" to its stdin, and capturing its @@ -577,13 +571,9 @@ start_failure_fn, task_finished_fn, void *pp_cb); -+int run_processes_parallel_tr2(int n, -+ get_next_task_fn, -+ start_failure_fn, -+ task_finished_fn, -+ void *pp_cb, -+ const char *tr2_category, -+ const char *tr2_label); ++int run_processes_parallel_tr2(int n, get_next_task_fn, start_failure_fn, ++ task_finished_fn, void *pp_cb, ++ const char *tr2_category, const char *tr2_label); #endif @@ -612,9 +602,9 @@ --- a/submodule.c +++ b/submodule.c @@ - /* default value, "--submodule-prefix" and its value are added later */ - calculate_changed_submodule_paths(r); + calculate_changed_submodule_paths(r, &spf.changed_submodule_names); + string_list_sort(&spf.changed_submodule_names); - run_processes_parallel(max_parallel_jobs, - get_next_submodule, - fetch_start_failure, @@ -727,9 +717,8 @@ + tgt_j; \ + j++, tgt_j = tr2_tgt_builtins[j]) + -+#define for_each_wanted_builtin(j, tgt_j) \ -+ for_each_builtin(j, tgt_j) \ -+ if (tr2_dst_trace_want(tgt_j->pdst)) ++#define for_each_wanted_builtin(j, tgt_j) \ ++ for_each_builtin(j, tgt_j) if (tr2_dst_trace_want(tgt_j->pdst)) + +/* + * Force (rather than lazily) initialize any of the requested @@ -745,7 +734,8 @@ + int j; + int sum = 0; + -+ for_each_builtin(j, tgt_j) { ++ for_each_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_init()) + sum++; + } @@ -763,7 +753,8 @@ + struct tr2_tgt *tgt_j; + int j; + -+ for_each_builtin(j, tgt_j) { ++ for_each_builtin(j, tgt_j) ++ { + tgt_j->pfn_term(); + } +} @@ -794,8 +785,9 @@ + * the trace output if someone calls die(), for example. + */ + tr2tls_pop_unwind_self(); -+ -+ for_each_wanted_builtin(j, tgt_j) { ++ ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_atexit) + tgt_j->pfn_atexit(us_elapsed_absolute, + tr2main_exit_code); @@ -821,7 +813,8 @@ + us_now = getnanotime() / 1000; + us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_signal) + tgt_j->pfn_signal(us_elapsed_absolute, signo); + } @@ -851,7 +844,8 @@ + /* + * Emit 'version' message on each active builtin target. + */ -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_version_fl) + tgt_j->pfn_version_fl(file, line); + } @@ -870,7 +864,8 @@ + if (!trace2_enabled) + return; + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_start_fl) + tgt_j->pfn_start_fl(file, line, argv); + } @@ -893,16 +888,18 @@ + us_now = getnanotime() / 1000; + us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_exit_fl) -+ tgt_j->pfn_exit_fl(file, line, us_elapsed_absolute, code); ++ tgt_j->pfn_exit_fl(file, line, us_elapsed_absolute, ++ code); + } + + return code; +} + -+void trace2_cmd_error_va_fl(const char *file, int line, -+ const char *fmt, va_list ap) ++void trace2_cmd_error_va_fl(const char *file, int line, const char *fmt, ++ va_list ap) +{ + struct tr2_tgt *tgt_j; + int j; @@ -914,7 +911,8 @@ + * We expect each target function to treat 'ap' as constant + * and use va_copy (because an 'ap' can only be walked once). + */ -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_error_va_fl) + tgt_j->pfn_error_va_fl(file, line, fmt, ap); + } @@ -928,7 +926,8 @@ + if (!trace2_enabled) + return; + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_command_path_fl) + tgt_j->pfn_command_path_fl(file, line, pathname); + } @@ -946,7 +945,8 @@ + tr2_verb_append_hierarchy(command_verb); + hierarchy = tr2_verb_get_hierarchy(); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_command_verb_fl) + tgt_j->pfn_command_verb_fl(file, line, command_verb, + hierarchy); @@ -962,15 +962,16 @@ + if (!trace2_enabled) + return; + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_command_subverb_fl) + tgt_j->pfn_command_subverb_fl(file, line, + command_subverb); + } +} + -+void trace2_cmd_alias_fl(const char *file, int line, -+ const char *alias, const char **argv) ++void trace2_cmd_alias_fl(const char *file, int line, const char *alias, ++ const char **argv) +{ + struct tr2_tgt *tgt_j; + int j; @@ -978,7 +979,8 @@ + if (!trace2_enabled) + return; + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_alias_fl) + tgt_j->pfn_alias_fl(file, line, alias, argv); + } @@ -992,8 +994,8 @@ + tr2_cfg_list_config_fl(file, line); +} + -+void trace2_cmd_set_config_fl(const char *file, int line, -+ const char *key, const char *value) ++void trace2_cmd_set_config_fl(const char *file, int line, const char *key, ++ const char *value) +{ + if (!trace2_enabled) + return; @@ -1018,15 +1020,15 @@ + cmd->trace2_child_id = tr2tls_locked_increment(&tr2_next_child_id); + cmd->trace2_child_us_start = us_now; + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_child_start_fl) + tgt_j->pfn_child_start_fl(file, line, + us_elapsed_absolute, cmd); + } +} + -+void trace2_child_exit_fl(const char *file, int line, -+ struct child_process *cmd, ++void trace2_child_exit_fl(const char *file, int line, struct child_process *cmd, + int child_exit_code) +{ + struct tr2_tgt *tgt_j; @@ -1040,24 +1042,25 @@ + + us_now = getnanotime() / 1000; + us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); -+ ++ + if (cmd->trace2_child_us_start) + us_elapsed_child = us_now - cmd->trace2_child_us_start; + else + us_elapsed_child = 0; -+ -+ for_each_wanted_builtin(j, tgt_j) { ++ ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_child_exit_fl) -+ tgt_j->pfn_child_exit_fl( -+ file, line, us_elapsed_absolute, -+ cmd->trace2_child_id, -+ cmd->pid, -+ child_exit_code, us_elapsed_child); ++ tgt_j->pfn_child_exit_fl(file, line, ++ us_elapsed_absolute, ++ cmd->trace2_child_id, cmd->pid, ++ child_exit_code, ++ us_elapsed_child); + } +} + -+int trace2_exec_fl(const char *file, int line, -+ const char *exe, const char **argv) ++int trace2_exec_fl(const char *file, int line, const char *exe, ++ const char **argv) +{ + struct tr2_tgt *tgt_j; + int j; @@ -1073,7 +1076,8 @@ + + exec_id = tr2tls_locked_increment(&tr2_next_exec_id); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_exec_fl) + tgt_j->pfn_exec_fl(file, line, us_elapsed_absolute, + exec_id, exe, argv); @@ -1095,16 +1099,15 @@ + us_now = getnanotime() / 1000; + us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_exec_result_fl) -+ tgt_j->pfn_exec_result_fl(file, line, -+ us_elapsed_absolute, -+ exec_id, code); ++ tgt_j->pfn_exec_result_fl( ++ file, line, us_elapsed_absolute, exec_id, code); + } +} + -+void trace2_thread_start_fl(const char *file, int line, -+ const char *thread_name) ++void trace2_thread_start_fl(const char *file, int line, const char *thread_name) +{ + struct tr2_tgt *tgt_j; + int j; @@ -1114,8 +1117,7 @@ + if (!trace2_enabled) + return; + -+ if (tr2tls_is_main_thread()) -+ { ++ if (tr2tls_is_main_thread()) { + /* + * We should only be called from the new thread's thread-proc, + * so this is technically a bug. But in those cases where the @@ -1123,7 +1125,7 @@ + * are built with threading disabled), we need to allow it. + * + * Convert this call to a region-enter so the nesting looks -+ * looks correct. ++ * correct. + */ + trace2_region_enter_printf_fl(file, line, NULL, NULL, NULL, + "thread-proc on main: %s", @@ -1136,7 +1138,8 @@ + + tr2tls_create_self(thread_name); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_thread_start_fl) + tgt_j->pfn_thread_start_fl(file, line, + us_elapsed_absolute); @@ -1154,16 +1157,16 @@ + if (!trace2_enabled) + return; + -+ if (tr2tls_is_main_thread()) -+ { ++ if (tr2tls_is_main_thread()) { + /* -+ * We should only be called from the exiting thread's thread-proc, -+ * so this is technically a bug. But in those cases where the -+ * main thread also runs the thread-proc function (or when we -+ * are built with threading disabled), we need to allow it. ++ * We should only be called from the exiting thread's ++ * thread-proc, so this is technically a bug. But in ++ * those cases where the main thread also runs the ++ * thread-proc function (or when we are built with ++ * threading disabled), we need to allow it. + * -+ * Convert this call to a region-leave so the nesting looks -+ * looks correct. ++ * Convert this call to a region-leave so the nesting ++ * looks correct. + */ + trace2_region_leave_printf_fl(file, line, NULL, NULL, NULL, + "thread-proc on main"); @@ -1181,7 +1184,8 @@ + tr2tls_pop_unwind_self(); + us_elapsed_thread = tr2tls_region_elasped_self(us_now); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_thread_exit_fl) + tgt_j->pfn_thread_exit_fl(file, line, + us_elapsed_absolute, @@ -1191,8 +1195,8 @@ + tr2tls_unset_self(); +} + -+void trace2_def_param_fl(const char *file, int line, -+ const char *param, const char *value) ++void trace2_def_param_fl(const char *file, int line, const char *param, ++ const char *value) +{ + struct tr2_tgt *tgt_j; + int j; @@ -1200,14 +1204,14 @@ + if (!trace2_enabled) + return; + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_param_fl) + tgt_j->pfn_param_fl(file, line, param, value); + } +} + -+void trace2_def_repo_fl(const char *file, int line, -+ struct repository *repo) ++void trace2_def_repo_fl(const char *file, int line, struct repository *repo) +{ + struct tr2_tgt *tgt_j; + int j; @@ -1220,15 +1224,15 @@ + + repo->trace2_repo_id = tr2tls_locked_increment(&tr2_next_repo_id); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_repo_fl) + tgt_j->pfn_repo_fl(file, line, repo); + } +} + +void trace2_region_enter_printf_va_fl(const char *file, int line, -+ const char *category, -+ const char *label, ++ const char *category, const char *label, + const struct repository *repo, + const char *fmt, va_list ap) +{ @@ -1250,59 +1254,53 @@ + * We expect each target function to treat 'ap' as constant + * and use va_copy. + */ -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_region_enter_printf_va_fl) + tgt_j->pfn_region_enter_printf_va_fl( -+ file, line, us_elapsed_absolute, -+ category, label, repo, fmt, ap); ++ file, line, us_elapsed_absolute, category, ++ label, repo, fmt, ap); + } + + tr2tls_push_self(us_now); +} + -+void trace2_region_enter_fl(const char *file, int line, -+ const char *category, -+ const char *label, -+ const struct repository *repo) ++void trace2_region_enter_fl(const char *file, int line, const char *category, ++ const char *label, const struct repository *repo) +{ -+ trace2_region_enter_printf_va_fl(file, line, -+ category, label, repo, ++ trace2_region_enter_printf_va_fl(file, line, category, label, repo, + NULL, NULL); +} + +void trace2_region_enter_printf_fl(const char *file, int line, -+ const char *category, -+ const char *label, ++ const char *category, const char *label, + const struct repository *repo, + const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); -+ trace2_region_enter_printf_va_fl(file, line, -+ category, label, repo, -+ fmt, ap); ++ trace2_region_enter_printf_va_fl(file, line, category, label, repo, fmt, ++ ap); + va_end(ap); +} + +#ifndef HAVE_VARIADIC_MACROS +void trace2_region_enter_printf(const char *category, const char *label, -+ const struct repository *repo, -+ const char *fmt, ...) ++ const struct repository *repo, const char *fmt, ++ ...) +{ + va_list ap; + + va_start(ap, fmt); -+ trace2_region_enter_printf_va_fl(NULL, 0, -+ category, label, repo, -+ fmt, ap); ++ trace2_region_enter_printf_va_fl(NULL, 0, category, label, repo, fmt, ++ ap); + va_end(ap); +} +#endif + +void trace2_region_leave_printf_va_fl(const char *file, int line, -+ const char *category, -+ const char *label, ++ const char *category, const char *label, + const struct repository *repo, + const char *fmt, va_list ap) +{ @@ -1325,67 +1323,59 @@ + * it lines up with the corresponding push/enter. + */ + us_elapsed_region = tr2tls_region_elasped_self(us_now); -+ ++ + tr2tls_pop_self(); + + /* + * We expect each target function to treat 'ap' as constant + * and use va_copy. + */ -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_region_leave_printf_va_fl) + tgt_j->pfn_region_leave_printf_va_fl( + file, line, us_elapsed_absolute, -+ us_elapsed_region, -+ category, label, repo, -+ fmt, ap); ++ us_elapsed_region, category, label, repo, fmt, ++ ap); + } +} + -+void trace2_region_leave_fl(const char *file, int line, -+ const char *category, -+ const char *label, -+ const struct repository *repo) ++void trace2_region_leave_fl(const char *file, int line, const char *category, ++ const char *label, const struct repository *repo) +{ -+ trace2_region_leave_printf_va_fl(file, line, -+ category, label, repo, ++ trace2_region_leave_printf_va_fl(file, line, category, label, repo, + NULL, NULL); +} + +void trace2_region_leave_printf_fl(const char *file, int line, -+ const char *category, -+ const char *label, ++ const char *category, const char *label, + const struct repository *repo, + const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); -+ trace2_region_leave_printf_va_fl(file, line, -+ category, label, repo, -+ fmt, ap); ++ trace2_region_leave_printf_va_fl(file, line, category, label, repo, fmt, ++ ap); + va_end(ap); +} + +#ifndef HAVE_VARIADIC_MACROS +void trace2_region_leave_printf(const char *category, const char *label, -+ const struct repository *repo, -+ const char *fmt, ...) ++ const struct repository *repo, const char *fmt, ++ ...) +{ + va_list ap; + + va_start(ap, fmt); -+ trace2_region_leave_printf_va_fl(NULL, 0, -+ category, label, repo, -+ fmt, ap); ++ trace2_region_leave_printf_va_fl(NULL, 0, category, label, repo, fmt, ++ ap); + va_end(ap); +} +#endif + -+void trace2_data_string_fl(const char *file, int line, -+ const char *category, -+ const struct repository *repo, -+ const char *key, ++void trace2_data_string_fl(const char *file, int line, const char *category, ++ const struct repository *repo, const char *key, + const char *value) +{ + struct tr2_tgt *tgt_j; @@ -1401,18 +1391,17 @@ + us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); + us_elapsed_region = tr2tls_region_elasped_self(us_now); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_data_fl) + tgt_j->pfn_data_fl(file, line, us_elapsed_absolute, -+ us_elapsed_region, -+ category, repo, key, value); ++ us_elapsed_region, category, repo, ++ key, value); + } +} + -+void trace2_data_intmax_fl(const char *file, int line, -+ const char *category, -+ const struct repository *repo, -+ const char *key, ++void trace2_data_intmax_fl(const char *file, int line, const char *category, ++ const struct repository *repo, const char *key, + intmax_t value) +{ + struct strbuf buf_string = STRBUF_INIT; @@ -1420,15 +1409,13 @@ + if (!trace2_enabled) + return; + -+ strbuf_addf(&buf_string, "%"PRIdMAX, value); ++ strbuf_addf(&buf_string, "%" PRIdMAX, value); + trace2_data_string_fl(file, line, category, repo, key, buf_string.buf); + strbuf_release(&buf_string); +} + -+void trace2_data_json_fl(const char *file, int line, -+ const char *category, -+ const struct repository *repo, -+ const char *key, ++void trace2_data_json_fl(const char *file, int line, const char *category, ++ const struct repository *repo, const char *key, + const struct json_writer *value) +{ + struct tr2_tgt *tgt_j; @@ -1444,16 +1431,17 @@ + us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); + us_elapsed_region = tr2tls_region_elasped_self(us_now); + -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_data_fl) + tgt_j->pfn_data_json_fl(file, line, us_elapsed_absolute, -+ us_elapsed_region, -+ category, repo, key, value); ++ us_elapsed_region, category, ++ repo, key, value); + } +} + -+void trace2_printf_va_fl(const char *file, int line, -+ const char *fmt, va_list ap) ++void trace2_printf_va_fl(const char *file, int line, const char *fmt, ++ va_list ap) +{ + struct tr2_tgt *tgt_j; + int j; @@ -1470,15 +1458,15 @@ + * We expect each target function to treat 'ap' as constant + * and use va_copy. + */ -+ for_each_wanted_builtin(j, tgt_j) { ++ for_each_wanted_builtin(j, tgt_j) ++ { + if (tgt_j->pfn_printf_va_fl) + tgt_j->pfn_printf_va_fl(file, line, us_elapsed_absolute, + fmt, ap); + } +} + -+void trace2_printf_fl(const char *file, int line, -+ const char *fmt, ...) ++void trace2_printf_fl(const char *file, int line, const char *fmt, ...) +{ + va_list ap; + @@ -1565,8 +1553,8 @@ + * + * Write an error message to the TRACE2 targets. + */ -+void trace2_cmd_error_va_fl(const char *file, int line, -+ const char *fmt, va_list ap); ++void trace2_cmd_error_va_fl(const char *file, int line, const char *fmt, ++ va_list ap); + +#define trace2_cmd_error_va(fmt, ap) \ + trace2_cmd_error_va_fl(__FILE__, __LINE__, (fmt), (ap)) @@ -1579,8 +1567,7 @@ + */ +void trace2_cmd_path_fl(const char *file, int line, const char *pathname); + -+#define trace2_cmd_path(p) \ -+ trace2_cmd_path_fl(__FILE__, __LINE__, (p)) ++#define trace2_cmd_path(p) trace2_cmd_path_fl(__FILE__, __LINE__, (p)) + +/* + * Emit a 'cmd_verb' event with the canonical name of the (usually) @@ -1589,8 +1576,7 @@ + */ +void trace2_cmd_verb_fl(const char *file, int line, const char *command_verb); + -+#define trace2_cmd_verb(v) \ -+ trace2_cmd_verb_fl(__FILE__, __LINE__, (v)) ++#define trace2_cmd_verb(v) trace2_cmd_verb_fl(__FILE__, __LINE__, (v)) + +/* + * Emit a 'cmd_subverb' event to further describe the command being run. @@ -1601,14 +1587,13 @@ +void trace2_cmd_subverb_fl(const char *file, int line, + const char *command_subverb); + -+#define trace2_cmd_subverb(sv) \ -+ trace2_cmd_subverb_fl(__FILE__, __LINE__, (sv)) ++#define trace2_cmd_subverb(sv) trace2_cmd_subverb_fl(__FILE__, __LINE__, (sv)) + +/* + * Emit an 'alias' expansion event. + */ -+void trace2_cmd_alias_fl(const char *file, int line, -+ const char *alias, const char **argv); ++void trace2_cmd_alias_fl(const char *file, int line, const char *alias, ++ const char **argv); + +#define trace2_cmd_alias(alias, argv) \ + trace2_cmd_alias_fl(__FILE__, __LINE__, (alias), (argv)) @@ -1630,8 +1615,7 @@ + */ +void trace2_cmd_list_config_fl(const char *file, int line); + -+#define trace2_cmd_list_config() \ -+ trace2_cmd_list_config_fl(__FILE__, __LINE__) ++#define trace2_cmd_list_config() trace2_cmd_list_config_fl(__FILE__, __LINE__) + +/* + * Emit a "def_param" event for the given config key/value pair IF @@ -1640,8 +1624,8 @@ + * Use this for new/updated config settings created/updated after + * trace2_cmd_list_config() is called. + */ -+void trace2_cmd_set_config_fl(const char *file, int line, -+ const char *key, const char *value); ++void trace2_cmd_set_config_fl(const char *file, int line, const char *key, ++ const char *value); + +#define trace2_cmd_set_config(k, v) \ + trace2_cmd_set_config_fl(__FILE__, __LINE__, (k), (v)) @@ -1656,14 +1640,12 @@ +void trace2_child_start_fl(const char *file, int line, + struct child_process *cmd); + -+#define trace2_child_start(cmd) \ -+ trace2_child_start_fl(__FILE__, __LINE__, (cmd)) ++#define trace2_child_start(cmd) trace2_child_start_fl(__FILE__, __LINE__, (cmd)) + +/* -+ * Emit a 'child_exit' event after the child process completes. ++ * Emit a 'child_exit' event after the child process completes. + */ -+void trace2_child_exit_fl(const char *file, int line, -+ struct child_process *cmd, ++void trace2_child_exit_fl(const char *file, int line, struct child_process *cmd, + int child_exit_code); + +#define trace2_child_exit(cmd, code) \ @@ -1678,11 +1660,10 @@ + * + * Returns the "exec_id". + */ -+int trace2_exec_fl(const char *file, int line, -+ const char *exe, const char **argv); ++int trace2_exec_fl(const char *file, int line, const char *exe, ++ const char **argv); + -+#define trace2_exec(exe, argv) \ -+ trace2_exec_fl(__FILE__, __LINE__, (exe), (argv)) ++#define trace2_exec(exe, argv) trace2_exec_fl(__FILE__, __LINE__, (exe), (argv)) + +/* + * Emit an 'exec_result' when possible. On Unix-derived systems, @@ -1705,7 +1686,7 @@ + * Thread names will be decorated with an instance number automatically. + */ +void trace2_thread_start_fl(const char *file, int line, -+ const char *thread_name); ++ const char *thread_name); + +#define trace2_thread_start(thread_name) \ + trace2_thread_start_fl(__FILE__, __LINE__, (thread_name)) @@ -1725,9 +1706,9 @@ + * Write a " = " pair describing some aspect of the + * run such as an important configuration setting or command line + * option that significantly changes command behavior. -+ */ -+void trace2_def_param_fl(const char *file, int line, -+ const char *param, const char *value); ++ */ ++void trace2_def_param_fl(const char *file, int line, const char *param, ++ const char *value); + +#define trace2_def_param(param, value) \ + trace2_def_param_fl(__FILE__, __LINE__, (param), (value)) @@ -1738,11 +1719,9 @@ + * + * Emits a 'worktree' event for this repo instance. + */ -+void trace2_def_repo_fl(const char *file, int line, -+ struct repository *repo); ++void trace2_def_repo_fl(const char *file, int line, struct repository *repo); + -+#define trace2_def_repo(repo) \ -+ trace2_def_repo_fl(__FILE__, __LINE__, repo) ++#define trace2_def_repo(repo) trace2_def_repo_fl(__FILE__, __LINE__, repo) + +/* + * Emit a 'region_enter' event for .