From 81291afa3fe2ac6d859a8078fda914a4781280be Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:44:14 -0500 Subject: [PATCH 01/25] Revert "pack-objects: add trace2 regions" This reverts commit d5c1e3b80b8806f596b0ba28d971f5d1922274ab. --- builtin/pack-objects.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 5a87bb909f00e7..507d381153511d 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -33,7 +33,6 @@ #include "object-store.h" #include "dir.h" #include "midx.h" -#include "trace2.h" #define IN_PACK(obj) oe_in_pack(&to_pack, obj) #define SIZE(obj) oe_size(&to_pack, obj) @@ -3479,7 +3478,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } } - trace2_region_enter("pack-objects", "enumerate-objects", the_repository); prepare_packing_data(&to_pack); if (progress) @@ -3494,20 +3492,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (include_tag && nr_result) for_each_ref(add_ref_tag, NULL); stop_progress(&progress_state); - trace2_region_leave("pack-objects", "enumerate-objects", the_repository); if (non_empty && !nr_result) return 0; - if (nr_result) { - trace2_region_enter("pack-objects", "prepare-pack", the_repository); + if (nr_result) prepare_pack(window, depth); - trace2_region_leave("pack-objects", "prepare-pack", the_repository); - } - - trace2_region_enter("pack-objects", "write-pack-file", the_repository); write_pack_file(); - trace2_region_leave("pack-objects", "write-pack-file", the_repository); - if (progress) fprintf_ln(stderr, _("Total %"PRIu32" (delta %"PRIu32")," From b837111feec001b37c77abefb1263b3d26bbbd0e Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:41:58 -0500 Subject: [PATCH 02/25] Revert "gvfs:trace2: add trace2 tracing around read_object_process" This reverts commit e15d3e9795a2c4f28af1b78f4857bc3a1e14b4c0. --- sha1-file.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/sha1-file.c b/sha1-file.c index 4f829e8c608db5..d0ea83fb1e3132 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -745,8 +745,6 @@ static int read_object_process(const struct object_id *oid) start = getnanotime(); - trace2_region_enter("subprocess", "read_object", the_repository); - if (!subprocess_map_initialized) { subprocess_map_initialized = 1; hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp, @@ -763,16 +761,13 @@ static int read_object_process(const struct object_id *oid) if (subprocess_start(&subprocess_map, &entry->subprocess, cmd, start_read_object_fn)) { free(entry); - err = -1; - goto leave_region; + return -1; } } process = &entry->subprocess.process; - if (!(CAP_GET & entry->supported_capabilities)) { - err = -1; - goto leave_region; - } + if (!(CAP_GET & entry->supported_capabilities)) + return -1; sigchain_push(SIGPIPE, SIG_IGN); @@ -821,10 +816,6 @@ static int read_object_process(const struct object_id *oid) trace_performance_since(start, "read_object_process"); -leave_region: - trace2_region_leave_printf("subprocess", "read_object", the_repository, - "result %d", err); - return err; } From 089a0c7e64450f5e41e29d1f060f6a98d003c9ff Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:42:19 -0500 Subject: [PATCH 03/25] Revert "gvfs:trace2: add region/data events for status deserialization" This reverts commit c7f9cb3355cb0d802af7fb593f2b0e692caf672e. --- wt-status-deserialize.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/wt-status-deserialize.c b/wt-status-deserialize.c index 8647ed3ab23cbb..23b2f69798bb8a 100644 --- a/wt-status-deserialize.c +++ b/wt-status-deserialize.c @@ -725,18 +725,15 @@ static int try_deserialize_read_from_file(const struct wt_status *cmd_s, enum wt_status_deserialize_wait dw, struct wt_status *des_s) { - int k = 0; - int limit; + int k, limit; int result = DESERIALIZE_ERR; /* * For "fail" or "no", try exactly once to read the status cache. * Return an error if the file is stale. */ - if (dw == DESERIALIZE_WAIT__FAIL || dw == DESERIALIZE_WAIT__NO) { - result = try_deserialize_read_from_file_1(cmd_s, path, des_s); - goto done; - } + if (dw == DESERIALIZE_WAIT__FAIL || dw == DESERIALIZE_WAIT__NO) + return try_deserialize_read_from_file_1(cmd_s, path, des_s); /* * Wait for the status cache file to refresh. Wait duration can @@ -761,12 +758,6 @@ static int try_deserialize_read_from_file(const struct wt_status *cmd_s, sleep_millisec(100); } -done: - trace2_data_string("status", the_repository, "deserialize/path", path); - trace2_data_intmax("status", the_repository, "deserialize/polled", k); - trace2_data_string("status", the_repository, "deserialize/result", - ((result == DESERIALIZE_OK) ? "ok" : "reject")); - trace_printf_key(&trace_deserialize, "wait polled=%d result=%d '%s'", k, result, path); @@ -792,8 +783,6 @@ int wt_status_deserialize(const struct wt_status *cmd_s, struct wt_status des_s; int result; - trace2_region_enter("status", "deserialize", the_repository); - if (path && *path && strcmp(path, "0")) { result = try_deserialize_read_from_file(cmd_s, path, dw, &des_s); } else { @@ -804,14 +793,8 @@ int wt_status_deserialize(const struct wt_status *cmd_s, * term, since we cannot read stdin multiple times. */ result = wt_deserialize_fd(cmd_s, &des_s, 0); - - trace2_data_string("status", the_repository, "deserialize/path", "STDIN"); - trace2_data_string("status", the_repository, "deserialize/result", - ((result == DESERIALIZE_OK) ? "ok" : "reject")); } - trace2_region_leave("status", "deserialize", the_repository); - if (result == DESERIALIZE_OK) { wt_status_get_state(&des_s.state, des_s.branch && !strcmp(des_s.branch, "HEAD")); From eebf43af34fca1b5bd2c4b16b9479b325696e6d2 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:42:28 -0500 Subject: [PATCH 04/25] Revert "trace2: instrument reading and writing the index" This reverts commit 918f51b866678888b826fb6fbb222cc8b2c04fe4. --- read-cache.c | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/read-cache.c b/read-cache.c index df50a8b727c0a6..8db8dc7b4f8ca9 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2237,14 +2237,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) load_index_extensions(&p); } munmap((void *)mmap, mmap_size); - - /* - * TODO trace2: replace "the_repository" with the actual repo instance - * that is associated with the given "istate". - */ - trace2_data_intmax("index", the_repository, "read/version", istate->version); - trace2_data_intmax("index", the_repository, "read/cache_nr", istate->cache_nr); - return istate->cache_nr; unmap: @@ -2276,17 +2268,9 @@ int read_index_from(struct index_state *istate, const char *path, if (istate->initialized) return istate->cache_nr; - /* - * TODO trace2: replace "the_repository" with the actual repo instance - * that is associated with the given "istate". - */ - trace2_region_enter_printf("index", "do_read_index", the_repository, - "%s", path); trace_performance_enter(); ret = do_read_index(istate, path, 0); trace_performance_leave("read cache %s", path); - trace2_region_leave_printf("index", "do_read_index", the_repository, - "%s", path); split_index = istate->split_index; if (!split_index || is_null_oid(&split_index->base_oid)) { @@ -2302,11 +2286,7 @@ int read_index_from(struct index_state *istate, const char *path, base_oid_hex = oid_to_hex(&split_index->base_oid); base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex); - trace2_region_enter_printf("index", "shared/do_read_index", the_repository, - "%s", base_path); ret = do_read_index(split_index->base, base_path, 1); - trace2_region_leave_printf("index", "shared/do_read_index", the_repository, - "%s", base_path); if (!oideq(&split_index->base_oid, &split_index->base->oid)) die("broken index, expect %s in %s, got %s", base_oid_hex, base_path, @@ -3017,14 +2997,6 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, istate->timestamp.sec = (unsigned int)st.st_mtime; istate->timestamp.nsec = ST_MTIME_NSEC(st); trace_performance_since(start, "write index, changed mask = %x", istate->cache_changed); - - /* - * TODO trace2: replace "the_repository" with the actual repo instance - * that is associated with the given "istate". - */ - trace2_data_intmax("index", the_repository, "write/version", istate->version); - trace2_data_intmax("index", the_repository, "write/cache_nr", istate->cache_nr); - return 0; } @@ -3044,18 +3016,7 @@ static int commit_locked_index(struct lock_file *lk) static int do_write_locked_index(struct index_state *istate, struct lock_file *lock, unsigned flags) { - int ret; - - /* - * TODO trace2: replace "the_repository" with the actual repo instance - * that is associated with the given "istate". - */ - trace2_region_enter_printf("index", "do_write_index", the_repository, - "%s", lock->tempfile->filename.buf); - ret = do_write_index(istate, lock->tempfile, 0); - trace2_region_leave_printf("index", "do_write_index", the_repository, - "%s", lock->tempfile->filename.buf); - + int ret = do_write_index(istate, lock->tempfile, 0); if (ret) return ret; if (flags & COMMIT_LOCK) @@ -3149,13 +3110,7 @@ static int write_shared_index(struct index_state *istate, int ret; move_cache_to_base_index(istate); - - trace2_region_enter_printf("index", "shared/do_write_index", - the_repository, "%s", (*temp)->filename.buf); ret = do_write_index(si->base, *temp, 1); - trace2_region_enter_printf("index", "shared/do_write_index", - the_repository, "%s", (*temp)->filename.buf); - if (ret) return ret; ret = adjust_shared_perm(get_tempfile_path(*temp)); From 2dc5fabf38ed9c0d88a8e2c7812d490cf0bbc5ef Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:42:36 -0500 Subject: [PATCH 05/25] Revert "trace2: add child classification for transport processes" This reverts commit d83778f2ee71c5e57c4ba7a6a6c4131fefc1300f. --- connect.c | 3 --- transport-helper.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/connect.c b/connect.c index 75202e81a23157..d72772a36d01ff 100644 --- a/connect.c +++ b/connect.c @@ -1255,7 +1255,6 @@ struct child_process *git_connect(int fd[2], const char *url, conn = NULL; } else if (protocol == PROTO_GIT) { conn = git_connect_git(fd, hostandport, path, prog, version, flags); - conn->trace2_child_class = "transport/git"; } else { struct strbuf cmd = STRBUF_INIT; const char *const *var; @@ -1298,11 +1297,9 @@ struct child_process *git_connect(int fd[2], const char *url, strbuf_release(&cmd); return NULL; } - conn->trace2_child_class = "transport/ssh"; fill_ssh_args(conn, ssh_host, port, version, flags); } else { transport_check_allowed("file"); - conn->trace2_child_class = "transport/file"; if (version > 0) { argv_array_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d", version); diff --git a/transport-helper.c b/transport-helper.c index fa78a8788568ab..35199e50a03e95 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -129,8 +129,6 @@ static struct child_process *get_helper(struct transport *transport) argv_array_pushf(&helper->env_array, "%s=%s", GIT_DIR_ENVIRONMENT, get_git_dir()); - helper->trace2_child_class = helper->args.argv[0]; /* "remote-" */ - code = start_command(helper); if (code < 0 && errno == ENOENT) die(_("unable to find remote helper for '%s'"), data->name); From 39fa7147cea0620a066f6c01bb24c3c0fc271975 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:42:44 -0500 Subject: [PATCH 06/25] Revert "trace2: classify some child processes" This reverts commit 95597bd7fc7d9d2bae5e9c74b7df601851ffa3ad. --- editor.c | 1 - pager.c | 1 - sub-process.c | 1 - 3 files changed, 3 deletions(-) diff --git a/editor.c b/editor.c index 71547674ab4e88..c985eee1f9d1c7 100644 --- a/editor.c +++ b/editor.c @@ -78,7 +78,6 @@ static int launch_specified_editor(const char *editor, const char *path, p.argv = args; p.env = env; p.use_shell = 1; - p.trace2_child_class = "editor"; if (start_command(&p) < 0) return error("unable to start editor '%s'", editor); diff --git a/pager.c b/pager.c index 1c82a868ee0a7d..bdc75d0b4fad5b 100644 --- a/pager.c +++ b/pager.c @@ -103,7 +103,6 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager) argv_array_push(&pager_process->args, pager); pager_process->use_shell = 1; setup_pager_env(&pager_process->env_array); - pager_process->trace2_child_class = "pager"; } void setup_pager(void) diff --git a/sub-process.c b/sub-process.c index 3f4af935557c5e..8d2a1707cfe1a7 100644 --- a/sub-process.c +++ b/sub-process.c @@ -88,7 +88,6 @@ int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, co process->out = -1; process->clean_on_exit = 1; process->clean_on_exit_handler = subprocess_exit_handler; - process->trace2_child_class = "subprocess"; err = start_command(process); if (err) { From fed71620077909a1f06289e75fcd7a9047d57500 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:42:52 -0500 Subject: [PATCH 07/25] Revert "trace2: add trace2 tracing of major regions in wt-status" This reverts commit 00bac7b6f6783136105196822334f4549b55df5f. --- wt-status.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/wt-status.c b/wt-status.c index 682186ed76b47a..955cfa6c638ca7 100644 --- a/wt-status.c +++ b/wt-status.c @@ -749,29 +749,16 @@ static int has_unmerged(struct wt_status *s) void wt_status_collect(struct wt_status *s) { - trace2_region_enter("status", "worktrees", the_repository); wt_status_collect_changes_worktree(s); - trace2_region_leave("status", "worktrees", the_repository); - - if (s->is_initial) { - trace2_region_enter("status", "initial", the_repository); + if (s->is_initial) wt_status_collect_changes_initial(s); - trace2_region_leave("status", "initial", the_repository); - } else { - trace2_region_enter("status", "index", the_repository); + else wt_status_collect_changes_index(s); - trace2_region_leave("status", "index", the_repository); - } - - trace2_region_enter("status", "untracked", the_repository); wt_status_collect_untracked(s); - trace2_region_leave("status", "untracked", the_repository); - trace2_region_enter("status", "committable", the_repository); wt_status_get_state(&s->state, s->branch && !strcmp(s->branch, "HEAD")); if (s->state.merge_in_progress && !has_unmerged(s)) s->committable = 1; - trace2_region_leave("status", "committable", the_repository); } void wt_status_collect_free_buffers(struct wt_status *s) From 095fc201d03a5561006e1940983170e45185253d Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 21 Dec 2018 11:43:10 -0500 Subject: [PATCH 08/25] Revert "trace2: create new combined trace facility" This reverts commit 1354d7301ec3bc08f7d1495518500a4f13a713d9. --- Makefile | 9 - cache.h | 1 - common-main.c | 5 +- compat/mingw.c | 2 - compat/mingw.h | 3 +- config.c | 2 - exec-cmd.c | 10 +- git-compat-util.h | 7 - git.c | 45 +-- remote-curl.c | 7 - repository.c | 2 - repository.h | 3 - run-command.c | 32 +- run-command.h | 10 +- sh-i18n--envsubst.c | 3 - t/helper/test-tool.c | 3 - trace2.c | 743 ---------------------------------------- trace2.h | 353 ------------------- trace2/tr2_cfg.c | 92 ----- trace2/tr2_cfg.h | 23 -- trace2/tr2_dst.c | 87 ----- trace2/tr2_dst.h | 34 -- trace2/tr2_sid.c | 69 ---- trace2/tr2_sid.h | 22 -- trace2/tr2_tbuf.c | 17 - trace2/tr2_tbuf.h | 19 - trace2/tr2_tgt.h | 119 ------- trace2/tr2_tgt_event.c | 531 ---------------------------- trace2/tr2_tgt_normal.c | 320 ----------------- trace2/tr2_tgt_perf.c | 530 ---------------------------- trace2/tr2_tls.c | 170 --------- trace2/tr2_tls.h | 99 ------ usage.c | 31 -- 33 files changed, 12 insertions(+), 3391 deletions(-) delete mode 100644 trace2.c delete mode 100644 trace2.h delete mode 100644 trace2/tr2_cfg.c delete mode 100644 trace2/tr2_cfg.h delete mode 100644 trace2/tr2_dst.c delete mode 100644 trace2/tr2_dst.h delete mode 100644 trace2/tr2_sid.c delete mode 100644 trace2/tr2_sid.h delete mode 100644 trace2/tr2_tbuf.c delete mode 100644 trace2/tr2_tbuf.h delete mode 100644 trace2/tr2_tgt.h delete mode 100644 trace2/tr2_tgt_event.c delete mode 100644 trace2/tr2_tgt_normal.c delete mode 100644 trace2/tr2_tgt_perf.c delete mode 100644 trace2/tr2_tls.c delete mode 100644 trace2/tr2_tls.h diff --git a/Makefile b/Makefile index 9e2a349c9106ef..37c6bc9d76fb97 100644 --- a/Makefile +++ b/Makefile @@ -1000,15 +1000,6 @@ LIB_OBJS += tempfile.o LIB_OBJS += thread-utils.o LIB_OBJS += tmp-objdir.o LIB_OBJS += trace.o -LIB_OBJS += trace2.o -LIB_OBJS += trace2/tr2_cfg.o -LIB_OBJS += trace2/tr2_dst.o -LIB_OBJS += trace2/tr2_sid.o -LIB_OBJS += trace2/tr2_tbuf.o -LIB_OBJS += trace2/tr2_tgt_event.o -LIB_OBJS += trace2/tr2_tgt_normal.o -LIB_OBJS += trace2/tr2_tgt_perf.o -LIB_OBJS += trace2/tr2_tls.o LIB_OBJS += trailer.o LIB_OBJS += transport.o LIB_OBJS += transport-helper.o diff --git a/cache.h b/cache.h index cf849fe505cd59..dfed668e0dbdd1 100644 --- a/cache.h +++ b/cache.h @@ -9,7 +9,6 @@ #include "gettext.h" #include "convert.h" #include "trace.h" -#include "trace2.h" #include "string-list.h" #include "pack-revindex.h" #include "hash.h" diff --git a/common-main.c b/common-main.c index bfea45c18d82f3..3728f66b4cce80 100644 --- a/common-main.c +++ b/common-main.c @@ -31,9 +31,6 @@ int main(int argc, const char **argv) * onto stdin/stdout/stderr in the child processes we spawn. */ sanitize_stdfds(); - restore_sigpipe_to_default(); - - trace2_initialize(argv); git_resolve_executable_dir(argv[0]); @@ -43,5 +40,7 @@ int main(int argc, const char **argv) attr_start(); + restore_sigpipe_to_default(); + return cmd_main(argc, argv); } diff --git a/compat/mingw.c b/compat/mingw.c index 53ad239cf03faa..29c6c2cae9b444 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1959,7 +1959,6 @@ static int try_shell_exec(const char *cmd, char *const *argv) int status; if (waitpid(pid, &status, 0) < 0) status = 255; - trace2_exec_result(status); exit(status); } pid = 1; /* indicate that we tried but failed */ @@ -1980,7 +1979,6 @@ int mingw_execv(const char *cmd, char *const *argv) return -1; if (waitpid(pid, &status, 0) < 0) status = 255; - trace2_exec_result(status); exit(status); } return -1; diff --git a/compat/mingw.h b/compat/mingw.h index e391497e8d10c4..ea46b647f18835 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -165,7 +165,8 @@ static inline int fcntl(int fd, int cmd, ...) errno = EINVAL; return -1; } - +/* bash cannot reliably detect negative return codes as failure */ +#define exit(code) exit((code) & 0xff) #define sigemptyset(x) (void)0 static inline int sigaddset(sigset_t *set, int signum) { return 0; } diff --git a/config.c b/config.c index 95d3613702cf9b..5b39c3ef51131b 100644 --- a/config.c +++ b/config.c @@ -2709,8 +2709,6 @@ int git_config_set_gently(const char *key, const char *value) void git_config_set(const char *key, const char *value) { git_config_set_multivar(key, value, NULL, 0); - - trace2_cmd_set_config(key, value); } /* diff --git a/exec-cmd.c b/exec-cmd.c index 640003564e611c..4f81f443105f07 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -209,8 +209,6 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0) return -1; } - trace2_cmd_path(buf->buf); - return 0; } @@ -330,22 +328,16 @@ const char **prepare_git_cmd(struct argv_array *out, const char **argv) int execv_git_cmd(const char **argv) { struct argv_array nargv = ARGV_ARRAY_INIT; - int err; prepare_git_cmd(&nargv, argv); trace_argv_printf(nargv.argv, "trace: exec:"); - trace2_exec("git", (const char **)nargv.argv); /* execvp() can only ever return if it fails */ sane_execvp("git", (char **)nargv.argv); - err = errno; - trace_printf("trace: exec failed: %s\n", strerror(err)); - trace2_exec_result(err); + trace_printf("trace: exec failed: %s\n", strerror(errno)); argv_array_clear(&nargv); - - errno = err; return -1; } diff --git a/git-compat-util.h b/git-compat-util.h index e7aa57730911e7..e6be418b4ee2f2 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1291,13 +1291,6 @@ struct fscache; extern int cmd_main(int, const char **); -/* - * Intercept all calls to exit() and route them to trace2 to - * optionally emit a message before calling the real exit(). - */ -int trace2_cmd_exit_fl(const char *file, int line, int code); -#define exit(code) exit(trace2_cmd_exit_fl(__FILE__, __LINE__, (code))) - /* * You can mark a stack variable with UNLEAK(var) to avoid it being * reported as a leak by tools like LSAN or valgrind. The argument diff --git a/git.c b/git.c index 1ac52320a424a1..a46643848a070c 100644 --- a/git.c +++ b/git.c @@ -149,20 +149,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) git_set_exec_path(cmd + 1); else { puts(git_exec_path()); - trace2_cmd_verb("_query_"); exit(0); } } else if (!strcmp(cmd, "--html-path")) { puts(system_path(GIT_HTML_PATH)); - trace2_cmd_verb("_query_"); exit(0); } else if (!strcmp(cmd, "--man-path")) { puts(system_path(GIT_MAN_PATH)); - trace2_cmd_verb("_query_"); exit(0); } else if (!strcmp(cmd, "--info-path")) { puts(system_path(GIT_INFO_PATH)); - trace2_cmd_verb("_query_"); exit(0); } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) { use_pager = 1; @@ -291,7 +287,6 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) (*argv)++; (*argc)--; } else if (skip_prefix(cmd, "--list-cmds=", &cmd)) { - trace2_cmd_verb("_query_"); if (!strcmp(cmd, "parseopt")) { struct string_list list = STRING_LIST_INIT_DUP; int i; @@ -339,14 +334,9 @@ static int handle_alias(int *argcp, const char ***argv) commit_pager_choice(); child.use_shell = 1; - child.trace2_child_class = "shell_alias"; argv_array_push(&child.args, alias_string + 1); argv_array_pushv(&child.args, (*argv) + 1); - trace2_cmd_alias(alias_command, child.args.argv); - trace2_cmd_list_config(); - trace2_cmd_verb("_run_shell_alias_"); - ret = run_command(&child); if (ret >= 0) /* normal exit */ exit(ret); @@ -381,9 +371,6 @@ static int handle_alias(int *argcp, const char ***argv) /* insert after command name */ memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp); - trace2_cmd_alias(alias_command, new_argv); - trace2_cmd_list_config(); - *argv = new_argv; *argcp += count - 1; @@ -496,8 +483,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) die("pre-command hook aborted command"); trace_argv_printf(argv, "trace: built-in: git"); - trace2_cmd_verb(p->cmd); - trace2_cmd_list_config(); validate_cache_entries(&the_index); exit_code = status = p->fn(argc, argv, prefix); @@ -755,34 +740,23 @@ static void execv_dashed_external(const char **argv) cmd.clean_on_exit = 1; cmd.wait_after_clean = 1; cmd.silent_exec_failure = 1; - cmd.trace2_child_class = "dashed"; if (run_pre_command_hook(cmd.args.argv)) die("pre-command hook aborted command"); trace_argv_printf(cmd.args.argv, "trace: exec:"); - trace2_exec(NULL, cmd.args.argv); /* * If we fail because the command is not found, it is * OK to return. Otherwise, we just pass along the status code, * or our usual generic code if we were not even able to exec * the program. - * - * If the child process ran and we are now going to exit, emit a - * generic string as our trace2 command verb to indicate that we - * launched a dashed command. */ exit_code = status = run_command(&cmd); - trace2_exec_result(status); - if (status >= 0) { - trace2_cmd_verb("_run_dashed_"); + if (status >= 0) exit(status); - } - else if (errno != ENOENT) { - trace2_cmd_verb("_run_dashed_"); + else if (errno != ENOENT) exit(128); - } run_post_command_hook(); } @@ -809,15 +783,6 @@ static int run_argv(int *argcp, const char ***argv) struct argv_array args = ARGV_ARRAY_INIT; int i; - /* - * The current process is committed to launching a - * child process to run the command named in (**argv) - * and exiting. Log a generic string as the trace2 - * command verb to indicate this. Note that the child - * process will log the actual verb when it runs. - */ - trace2_cmd_verb("_run_git_alias_"); - if (get_super_prefix()) die("%s doesn't support --super-prefix", **argv); @@ -833,8 +798,8 @@ static int run_argv(int *argcp, const char ***argv) * if we fail because the command is not found, it is * OK to return. Otherwise, we just pass along the status code. */ - i = run_command_v_opt_tr2(args.argv, RUN_SILENT_EXEC_FAILURE | - RUN_CLEAN_ON_EXIT, "git_alias"); + i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE | + RUN_CLEAN_ON_EXIT); if (i >= 0 || errno != ENOENT) exit(i); die("could not execute builtin %s", **argv); @@ -965,5 +930,5 @@ int cmd_main(int argc, const char **argv) fprintf(stderr, _("failed to run command '%s': %s\n"), cmd, strerror(errno)); - return trace2_cmd_exit(1); + return 1; } diff --git a/remote-curl.c b/remote-curl.c index 8950b5c383f1b2..1220dffcdc57a1 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1340,13 +1340,6 @@ int cmd_main(int argc, const char **argv) string_list_init(&options.deepen_not, 1); string_list_init(&options.push_options, 1); - /* - * Just report "remote-curl" here (folding all the various aliases - * ("git-remote-http", "git-remote-https", and etc.) here since they - * are all just copies of the same actual executable. - */ - trace2_cmd_verb("remote-curl"); - remote = remote_get(argv[1]); if (argc > 2) { diff --git a/repository.c b/repository.c index a84055ed1d9e3d..5dd148671811b3 100644 --- a/repository.c +++ b/repository.c @@ -113,8 +113,6 @@ static int repo_init_gitdir(struct repository *repo, const char *gitdir) void repo_set_worktree(struct repository *repo, const char *path) { repo->worktree = real_pathdup(path, 1); - - trace2_def_repo(repo); } static int read_and_verify_repository_format(struct repository_format *format, diff --git a/repository.h b/repository.h index 97b03846ba544a..9f16c42c1ed04a 100644 --- a/repository.h +++ b/repository.h @@ -90,9 +90,6 @@ struct repository { /* Repository's current hash algorithm, as serialized on disk. */ const struct git_hash_algo *hash_algo; - /* A unique-id for tracing purposes. */ - int trace2_repo_id; - /* Configurations */ /* Indicate if a repository has a different 'commondir' from 'gitdir' */ diff --git a/run-command.c b/run-command.c index d51250dbf7b339..f8a7f733718378 100644 --- a/run-command.c +++ b/run-command.c @@ -713,7 +713,6 @@ int start_command(struct child_process *cmd) cmd->err = fderr[0]; } - trace2_child_start(cmd); trace_run_command(cmd); fflush(NULL); @@ -928,8 +927,6 @@ int start_command(struct child_process *cmd) #endif if (cmd->pid < 0) { - trace2_child_exit(cmd, -1); - if (need_in) close_pair(fdin); else if (cmd->in) @@ -968,16 +965,13 @@ int start_command(struct child_process *cmd) int finish_command(struct child_process *cmd) { int ret = wait_or_whine(cmd->pid, cmd->argv[0], 0); - trace2_child_exit(cmd, ret); child_process_clear(cmd); return ret; } int finish_command_in_signal(struct child_process *cmd) { - int ret = wait_or_whine(cmd->pid, cmd->argv[0], 1); - trace2_child_exit(cmd, ret); - return ret; + return wait_or_whine(cmd->pid, cmd->argv[0], 1); } @@ -999,18 +993,7 @@ int run_command_v_opt(const char **argv, int opt) return run_command_v_opt_cd_env(argv, opt, NULL, NULL); } -int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class) -{ - return run_command_v_opt_cd_env_tr2(argv, opt, NULL, NULL, tr2_class); -} - int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env) -{ - 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) { struct child_process cmd = CHILD_PROCESS_INIT; cmd.argv = argv; @@ -1022,7 +1005,6 @@ int run_command_v_opt_cd_env_tr2(const char **argv, int opt, const char *dir, co cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0; cmd.dir = dir; cmd.env = env; - cmd.trace2_child_class = tr2_class; return run_command(&cmd); } @@ -1866,15 +1848,6 @@ int run_processes_parallel(int n, int output_timeout = 100; int spawn_cap = 4; struct parallel_processes pp; - /* - * TODO Currently all callers of run_processes_parallel() - * are in the submodule code, so hard-coding the category - * is OK for now. Later, pass in category to this function. - */ - const char *category = "submodule"; - - trace2_region_enter_printf(category, "run_pp", NULL, - "max:%d", ((n < 1) ? online_cpus() : n)); pp_init(&pp, n, get_next_task, start_failure, task_finished, pp_cb); while (1) { @@ -1904,8 +1877,5 @@ int run_processes_parallel(int n, } pp_cleanup(&pp); - - trace2_region_leave(category, "run_pp", NULL); - return 0; } diff --git a/run-command.h b/run-command.h index 36576d790fde68..b17abb44a43722 100644 --- a/run-command.h +++ b/run-command.h @@ -10,11 +10,6 @@ struct child_process { struct argv_array args; struct argv_array env_array; pid_t pid; - - int trace2_child_id; - uint64_t trace2_child_us_start; - const char *trace2_child_class; - /* * Using .in, .out, .err: * - Specify 0 for no redirections (child inherits stdin, stdout, @@ -80,15 +75,12 @@ extern int run_hook_argv(const char *const *env, const char *name, #define RUN_USING_SHELL 16 #define RUN_CLEAN_ON_EXIT 32 int run_command_v_opt(const char **argv, int opt); -int run_command_v_opt_tr2(const char **argv, int opt, const char *tr2_class -); + /* * env (the environment) is to be formatted like environ: "VAR=VALUE". * 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); /** * Execute the given command, sending "in" to its stdin, and capturing its diff --git a/sh-i18n--envsubst.c b/sh-i18n--envsubst.c index 2296ba1a2d6361..09c6b445b96312 100644 --- a/sh-i18n--envsubst.c +++ b/sh-i18n--envsubst.c @@ -14,7 +14,6 @@ */ #include "git-compat-util.h" -#include "trace2.h" /* Substitution of environment variables in shell format strings. Copyright (C) 2003-2007 Free Software Foundation, Inc. @@ -68,8 +67,6 @@ cmd_main (int argc, const char *argv[]) /* Default values for command line options. */ /* unsigned short int show_variables = 0; */ - trace2_cmd_verb("sh-i18n--envsubst"); - switch (argc) { case 1: diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index cfb46a720ea919..52304d0748ce52 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -1,6 +1,5 @@ #include "git-compat-util.h" #include "test-tool.h" -#include "trace2.h" struct test_cmd { const char *name; @@ -81,8 +80,6 @@ int cmd_main(int argc, const char **argv) if (!strcmp(cmds[i].name, argv[1])) { argv++; argc--; - trace2_cmd_verb(cmds[i].name); - trace2_cmd_list_config(); return cmds[i].fn(argc, argv); } } diff --git a/trace2.c b/trace2.c deleted file mode 100644 index c9844bc742e597..00000000000000 --- a/trace2.c +++ /dev/null @@ -1,743 +0,0 @@ -#include "cache.h" -#include "config.h" -#include "json-writer.h" -#include "quote.h" -#include "run-command.h" -#include "sigchain.h" -#include "thread-utils.h" -#include "version.h" -#include "trace2/tr2_cfg.h" -#include "trace2/tr2_dst.h" -#include "trace2/tr2_sid.h" -#include "trace2/tr2_tgt.h" -#include "trace2/tr2_tls.h" - -static int trace2_enabled; - -static int tr2_next_child_id; /* modify under lock */ -static int tr2_next_repo_id = 1; /* modify under lock. zero is reserved */ - -/* - * A table of the builtin TRACE2 targets. Each of these may be independently - * enabled or disabled. Each TRACE2 API will try to write an event to *each* - * of the enabled targets. - */ -static struct tr2_tgt *tr2_tgt_builtins[] = -{ - &tr2_tgt_normal, - &tr2_tgt_perf, - &tr2_tgt_event, - NULL -}; - -#define for_each_builtin(j, tgt_j) \ - for (j = 0, tgt_j = tr2_tgt_builtins[j]; \ - 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)) - -/* - * Force (rather than lazily) initialize any of the requested - * builtin TRACE2 targets at startup (and before we've seen an - * actual TRACE2 event call) so we can see if we need to setup - * the TR2 and TLS machinery. - * - * Return the number of builtin targets enabled. - */ -static int tr2_tgt_want_builtins(void) -{ - struct tr2_tgt *tgt_j; - int j; - int sum = 0; - - for_each_builtin(j, tgt_j) { - if (tgt_j->pfn_init()) - sum++; - } - - return sum; -} - -/* - * Properly terminate each builtin target. Give each target - * a chance to write a summary event and/or flush if necessary - * and then close the fd. - */ -static void tr2_tgt_disable_builtins(void) -{ - struct tr2_tgt *tgt_j; - int j; - - for_each_builtin(j, tgt_j) { - tgt_j->pfn_term(); - } -} - -/***************************************************************** - * TODO remove this section header - *****************************************************************/ - -static int tr2main_exit_code; - -/* - * Our atexit routine should run after everything has finished. - * - * Note that events generated here might not actually appear if - * we are writing to fd 1 or 2 and our atexit routine runs after - * the pager's atexit routine (since it closes them to shutdown - * the pipes). - */ -static void tr2main_atexit_handler(void) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - /* - * Clear any unbalanced regions so that our atexit message - * does not appear nested. This improves the appearance of - * the trace output if someone calls die(), for example. - */ - tr2tls_pop_unwind_self(); - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_atexit) - tgt_j->pfn_atexit(us_elapsed_absolute, - tr2main_exit_code); - } - - tr2_tgt_disable_builtins(); - - tr2tls_release(); - tr2_sid_release(); - tr2_cfg_free_patterns(); - - trace2_enabled = 0; -} - -static void tr2main_signal_handler(int signo) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_signal) - tgt_j->pfn_signal(us_elapsed_absolute, signo); - } - - sigchain_pop(signo); - raise(signo); -} - -/***************************************************************** - * TODO remove this section header - *****************************************************************/ - -void trace2_initialize_fl(const char *file, int line, const char **argv) -{ - struct tr2_tgt *tgt_j; - int j; - - if (trace2_enabled) - return; - - if (!tr2_tgt_want_builtins()) - return; - trace2_enabled = 1; - - tr2_sid_get(); - - atexit(tr2main_atexit_handler); - sigchain_push(SIGPIPE, tr2main_signal_handler); - tr2tls_init(); - - /* - * Emit 'version' and 'start' messages on each active builtin target. - */ - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_version_fl) - tgt_j->pfn_version_fl(file, line); - if (tgt_j->pfn_start_fl) - tgt_j->pfn_start_fl(file, line, argv); - } -} - -int trace2_cmd_exit_fl(const char *file, int line, int code) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - code &= 0xff; - - if (!trace2_enabled) - return code; - - tr2main_exit_code = code; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_exit_fl) - 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) -{ - struct tr2_tgt *tgt_j; - int j; - - if (!trace2_enabled) - return; - - /* - * 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) { - if (tgt_j->pfn_error_va_fl) - tgt_j->pfn_error_va_fl(file, line, fmt, ap); - } -} - -void trace2_cmd_path_fl(const char *file, int line, const char *pathname) -{ - struct tr2_tgt *tgt_j; - int j; - - if (!trace2_enabled) - return; - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_command_path_fl) - tgt_j->pfn_command_path_fl(file, line, pathname); - } -} - -void trace2_cmd_verb_fl(const char *file, int line, const char *command_verb) -{ - struct tr2_tgt *tgt_j; - int j; - - if (!trace2_enabled) - return; - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_command_verb_fl) - tgt_j->pfn_command_verb_fl(file, line, command_verb); - } -} - -void trace2_cmd_alias_fl(const char *file, int line, - const char *alias, const char **argv) -{ - struct tr2_tgt *tgt_j; - int j; - - if (!trace2_enabled) - return; - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_alias_fl) - tgt_j->pfn_alias_fl(file, line, alias, argv); - } -} - -void trace2_cmd_list_config_fl(const char *file, int line) -{ - if (!trace2_enabled) - return; - - tr2_cfg_list_config_fl(file, line); -} - -void trace2_cmd_set_config_fl(const char *file, int line, - const char *key, const char *value) -{ - if (!trace2_enabled) - return; - - tr2_cfg_set_fl(file, line, key, value); -} - -void trace2_child_start_fl(const char *file, int line, - struct child_process *cmd) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - 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) { - 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, - int child_exit_code) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - uint64_t us_elapsed_child; - - if (!trace2_enabled) - return; - - 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) { - if (tgt_j->pfn_child_exit_fl) - tgt_j->pfn_child_exit_fl( - file, line, us_elapsed_absolute, - cmd->trace2_child_id, - child_exit_code, us_elapsed_child); - } -} - -void trace2_exec_fl(const char *file, int line, - const char *exe, const char **argv) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - for_each_wanted_builtin(j, tgt_j) { - if (tgt_j->pfn_exec_fl) - tgt_j->pfn_exec_fl(file, line, us_elapsed_absolute, - exe, argv); - } -} - -void trace2_exec_result_fl(const char *file, int line, int code) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - 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, - code); - } -} - -void trace2_thread_start_fl(const char *file, int line, - const char *thread_name) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - if (!trace2_enabled) - return; - - 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 - * 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-enter so the nesting looks - * looks correct. - */ - trace2_region_enter_printf_fl(file, line, NULL, NULL, NULL, - "thread-proc on main: %s", - thread_name); - return; - } - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - tr2tls_create_self(thread_name); - - 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); - } -} - -void trace2_thread_exit_fl(const char *file, int line) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - uint64_t us_elapsed_thread; - - if (!trace2_enabled) - return; - - 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. - * - * Convert this call to a region-leave so the nesting looks - * looks correct. - */ - trace2_region_leave_printf_fl(file, line, NULL, NULL, NULL, - "thread-proc on main"); - return; - } - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - /* - * Clear any unbalanced regions and then get the relative time - * for the outer-most region (which we pushed when the thread - * started). This gives us the run time of the thread. - */ - tr2tls_pop_unwind_self(); - us_elapsed_thread = tr2tls_region_elasped_self(us_now); - - 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, - us_elapsed_thread); - } - - tr2tls_unset_self(); -} - -void trace2_def_param_fl(const char *file, int line, - const char *param, const char *value) -{ - struct tr2_tgt *tgt_j; - int j; - - if (!trace2_enabled) - return; - - 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) -{ - struct tr2_tgt *tgt_j; - int j; - - if (!trace2_enabled) - return; - - if (repo->trace2_repo_id) - return; - - repo->trace2_repo_id = tr2tls_locked_increment(&tr2_next_repo_id); - - 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 struct repository *repo, - const char *fmt, va_list ap) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - /* - * Print the region-enter message at the current nesting - * (indentation) level and then push a new level. - * - * We expect each target function to treat 'ap' as constant - * and use va_copy. - */ - 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); - } - - 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) -{ - 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 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); - 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, ...) -{ - va_list ap; - - va_start(ap, fmt); - 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 struct repository *repo, - const char *fmt, va_list ap) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - uint64_t us_elapsed_region; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - /* - * Get the elapsed time in the current region before we - * pop it off the stack. Pop the stack. And then print - * the perf message at the new (shallower) level so that - * 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) { - 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); - } -} - -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, - NULL, NULL); -} - -void trace2_region_leave_printf_fl(const char *file, int line, - 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); - 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, ...) -{ - va_list ap; - - va_start(ap, fmt); - 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, - const char *value) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - uint64_t us_elapsed_region; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - us_elapsed_region = tr2tls_region_elasped_self(us_now); - - 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); - } -} - -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; - - if (!trace2_enabled) - return; - - strbuf_addf(&buf_string, "%"PRIdMAX, value); - trace2_data_string_fl(file, line, category, repo, key, buf_string.buf); - strbuf_release(&buf_string); -} - -void trace2_printf_va_fl(const char *file, int line, - const char *fmt, va_list ap) -{ - struct tr2_tgt *tgt_j; - int j; - uint64_t us_now; - uint64_t us_elapsed_absolute; - - if (!trace2_enabled) - return; - - us_now = getnanotime() / 1000; - us_elapsed_absolute = tr2tls_absolute_elapsed(us_now); - - /* - * We expect each target function to treat 'ap' as constant - * and use va_copy. - */ - 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, ...) -{ - va_list ap; - - va_start(ap, fmt); - trace2_printf_va_fl(file, line, fmt, ap); - va_end(ap); -} - -#ifndef HAVE_VARIADIC_MACROS -void trace2_printf(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - trace2_printf_va_fl(NULL, 0, fmt, ap); - va_end(ap); -} -#endif diff --git a/trace2.h b/trace2.h deleted file mode 100644 index 8cb75a57305307..00000000000000 --- a/trace2.h +++ /dev/null @@ -1,353 +0,0 @@ -#ifndef TRACE2_H -#define TRACE2_H - -struct child_process; -struct repository; - -/* - * The public TRACE2 routines are grouped into the following groups: - * - * [] trace2_initialize -- initialization. - * [] trace2_cmd_* -- emit command/control messages. - * [] trace2_child* -- emit child start/stop messages. - * [] trace2_exec* -- emit exec start/stop messages. - * [] trace2_thread* -- emit thread start/stop messages. - * [] trace2_def* -- emit definition/parameter mesasges. - * [] trace2_region* -- emit region nesting messages. - * [] trace2_data* -- emit region/thread/repo data messages. - * [] trace2_printf* -- legacy trace[1] messages. - */ - - -/* - * Initialize TRACE2 tracing facility if any of the builtin TRACE2 - * targets are enabled in the environment. Emits 'version' and - * 'start' events. - * - * Cleanup/Termination is handled automatically by a registered - * atexit() routine. - */ -void trace2_initialize_fl(const char *file, int line, const char **argv); - -#define trace2_initialize(argv) trace2_initialize_fl(__FILE__, __LINE__, argv) - -/* - * Emit an 'exit' event. - * - * Write the exit-code that will be passed to exit() or returned - * from main(). - * - * Use this prior to actually calling exit(). - * See "#define exit()" in git-compat-util.h - */ -int trace2_cmd_exit_fl(const char *file, int line, int code); - -#define trace2_cmd_exit(code) (trace2_cmd_exit_fl(__FILE__, __LINE__, (code))) - -/* - * Emit an 'error' event. - * - * 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); - -#define trace2_cmd_error_va(fmt, ap) \ - trace2_cmd_error_va_fl(__FILE__, __LINE__, (fmt), (ap)) - -/* - * Emit a 'pathname' event with the canonical pathname of the current process - * This gives post-processors a simple field to identify the command without - * having to parse the argv. For example, to distinguish invocations from - * installed versus debug executables. - */ -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)) - -/* - * Emit a 'cmd_verb' event with the canonical name of the (usually) - * builtin command. This gives post-processors a simple field - * to identify the command verb without having to parse the argv. - */ -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)) - -/* - * Emit an 'alias' expansion event. - */ -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)) - -/* - * Emit one or more 'def_param' events for "interesting" configuration - * settings. - * - * The environment variable "GIT_TR2_CONFIG_PARAMS" can be set to a - * list of patterns considered important. For example: - * - * GIT_TR2_CONFIG_PARAMS="core.*,remote.*.url" - * - * Note: this routine does a read-only iteration on the config data - * (using read_early_config()), so it must not be called until enough - * of the process environment has been established. This includes the - * location of the git and worktree directories, expansion of any "-c" - * and "-C" command line options, and etc. - */ -void trace2_cmd_list_config_fl(const char *file, int 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 - * we consider the key to be "interesting". - * - * 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); - -#define trace2_cmd_set_config(k, v) \ - trace2_cmd_set_config_fl(__FILE__, __LINE__, (k), (v)) - -/* - * Emit a 'child_start' event prior to spawning a child process. - * - * Before calling optionally set "cmd->trace2_child_class" to a string - * describing the type of the child process. For example, "editor" or - * "pager". - */ -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)) - -/* - * Emit a 'child_exit' event after the child process completes. - */ -void trace2_child_exit_fl(const char *file, int line, - struct child_process *cmd, - int child_exit_code); - -#define trace2_child_exit(cmd, code) \ - trace2_child_exit_fl(__FILE__, __LINE__, (cmd), (code)) - -/* - * Emit an 'exec' event prior to calling one of exec(), execv(), - * execvp(), and etc. On Unix-derived systems, this will be the - * last event emitted for the current process, unless the exec - * fails. On Windows, exec() behaves like 'child_start' and a - * waitpid(), so additional events may be emitted. - */ -void 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)) - -/* - * Emit an 'exec_result' when possible. On Unix-derived systems, - * this should be called after exec() returns (which only happens - * when there is an error starting the new process). On Windows, - * this should be called after the waitpid(). - */ -void trace2_exec_result_fl(const char *file, int line, int code); - -#define trace2_exec_result(code) \ - trace2_exec_result_fl(__FILE__, __LINE__, (code)) - -/* - * Emit a 'thread_start' event. This must be called from inside the - * thread-proc to set up the trace2 TLS data for the thread. - * - * Thread names should be descriptive, like "preload_index". - * Thread names will be decorated with an instance number automatically. - */ -void trace2_thread_start_fl(const char *file, int line, - const char *thread_name); - -#define trace2_thread_start(thread_name) \ - trace2_thread_start_fl(__FILE__, __LINE__, (thread_name)) - -/* - * Emit a 'thread_exit' event. This must be called from inside the - * thread-proc to report thread-specific data and cleanup TLS data - * for the thread. - */ -void trace2_thread_exit_fl(const char *file, int line); - -#define trace2_thread_exit() trace2_thread_exit_fl(__FILE__, __LINE__) - -/* - * Emit a 'param' event. - * - * 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); - -#define trace2_def_param(param, value) \ - trace2_def_param_fl(__FILE__, __LINE__, (param), (value)) - -/* - * Tell trace2 about a newly instantiated repo object and assign - * a trace2-repo-id to be used in subsequent activity events. - * - * Emits a 'worktree' event for this repo instance. - */ -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) - -/* - * Emit a 'region_enter' event for .