Skip to content

Commit f8dfa70

Browse files
jeffhostetlerdscho
authored andcommitted
Merge pull request #28 from jeffhostetler/gvfs-trace2-v1
(Experimental) Trace2 base plus GVFS extensions
2 parents e73a1c1 + c0dd2dd commit f8dfa70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3492
-21
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,15 @@ LIB_OBJS += tempfile.o
10031003
LIB_OBJS += thread-utils.o
10041004
LIB_OBJS += tmp-objdir.o
10051005
LIB_OBJS += trace.o
1006+
LIB_OBJS += trace2.o
1007+
LIB_OBJS += trace2/tr2_cfg.o
1008+
LIB_OBJS += trace2/tr2_dst.o
1009+
LIB_OBJS += trace2/tr2_sid.o
1010+
LIB_OBJS += trace2/tr2_tbuf.o
1011+
LIB_OBJS += trace2/tr2_tgt_event.o
1012+
LIB_OBJS += trace2/tr2_tgt_normal.o
1013+
LIB_OBJS += trace2/tr2_tgt_perf.o
1014+
LIB_OBJS += trace2/tr2_tls.o
10061015
LIB_OBJS += trailer.o
10071016
LIB_OBJS += transport.o
10081017
LIB_OBJS += transport-helper.o

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "gettext.h"
1010
#include "convert.h"
1111
#include "trace.h"
12+
#include "trace2.h"
1213
#include "string-list.h"
1314
#include "pack-revindex.h"
1415
#include "hash.h"

common-main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ int main(int argc, const char **argv)
3131
* onto stdin/stdout/stderr in the child processes we spawn.
3232
*/
3333
sanitize_stdfds();
34+
restore_sigpipe_to_default();
35+
36+
trace2_initialize(argv);
3437

3538
git_resolve_executable_dir(argv[0]);
3639

@@ -40,7 +43,5 @@ int main(int argc, const char **argv)
4043

4144
attr_start();
4245

43-
restore_sigpipe_to_default();
44-
4546
return cmd_main(argc, argv);
4647
}

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,7 @@ static int try_shell_exec(const char *cmd, char *const *argv)
19581958
int status;
19591959
if (waitpid(pid, &status, 0) < 0)
19601960
status = 255;
1961+
trace2_exec_result(status);
19611962
exit(status);
19621963
}
19631964
pid = 1; /* indicate that we tried but failed */
@@ -1978,6 +1979,7 @@ int mingw_execv(const char *cmd, char *const *argv)
19781979
return -1;
19791980
if (waitpid(pid, &status, 0) < 0)
19801981
status = 255;
1982+
trace2_exec_result(status);
19811983
exit(status);
19821984
}
19831985
return -1;

compat/mingw.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ static inline int fcntl(int fd, int cmd, ...)
146146
errno = EINVAL;
147147
return -1;
148148
}
149-
/* bash cannot reliably detect negative return codes as failure */
150-
#define exit(code) exit((code) & 0xff)
149+
151150
#define sigemptyset(x) (void)0
152151
static inline int sigaddset(sigset_t *set, int signum)
153152
{ return 0; }

config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,6 +2706,8 @@ int git_config_set_gently(const char *key, const char *value)
27062706
void git_config_set(const char *key, const char *value)
27072707
{
27082708
git_config_set_multivar(key, value, NULL, 0);
2709+
2710+
trace2_cmd_set_config(key, value);
27092711
}
27102712

27112713
/*

connect.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,7 @@ struct child_process *git_connect(int fd[2], const char *url,
12551255
conn = NULL;
12561256
} else if (protocol == PROTO_GIT) {
12571257
conn = git_connect_git(fd, hostandport, path, prog, version, flags);
1258+
conn->trace2_child_class = "transport/git";
12581259
} else {
12591260
struct strbuf cmd = STRBUF_INIT;
12601261
const char *const *var;
@@ -1297,9 +1298,11 @@ struct child_process *git_connect(int fd[2], const char *url,
12971298
strbuf_release(&cmd);
12981299
return NULL;
12991300
}
1301+
conn->trace2_child_class = "transport/ssh";
13001302
fill_ssh_args(conn, ssh_host, port, version, flags);
13011303
} else {
13021304
transport_check_allowed("file");
1305+
conn->trace2_child_class = "transport/file";
13031306
if (version > 0) {
13041307
argv_array_pushf(&conn->env_array, GIT_PROTOCOL_ENVIRONMENT "=version=%d",
13051308
version);

editor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static int launch_specified_editor(const char *editor, const char *path,
7878
p.argv = args;
7979
p.env = env;
8080
p.use_shell = 1;
81+
p.trace2_child_class = "editor";
8182
if (start_command(&p) < 0)
8283
return error("unable to start editor '%s'", editor);
8384

exec-cmd.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0)
209209
return -1;
210210
}
211211

212+
trace2_cmd_path(buf->buf);
213+
212214
return 0;
213215
}
214216

@@ -328,16 +330,22 @@ const char **prepare_git_cmd(struct argv_array *out, const char **argv)
328330
int execv_git_cmd(const char **argv)
329331
{
330332
struct argv_array nargv = ARGV_ARRAY_INIT;
333+
int err;
331334

332335
prepare_git_cmd(&nargv, argv);
333336
trace_argv_printf(nargv.argv, "trace: exec:");
337+
trace2_exec("git", (const char **)nargv.argv);
334338

335339
/* execvp() can only ever return if it fails */
336340
sane_execvp("git", (char **)nargv.argv);
337341

338-
trace_printf("trace: exec failed: %s\n", strerror(errno));
342+
err = errno;
343+
trace_printf("trace: exec failed: %s\n", strerror(err));
344+
trace2_exec_result(err);
339345

340346
argv_array_clear(&nargv);
347+
348+
errno = err;
341349
return -1;
342350
}
343351

git-compat-util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,13 @@ struct fscache;
12871287

12881288
extern int cmd_main(int, const char **);
12891289

1290+
/*
1291+
* Intercept all calls to exit() and route them to trace2 to
1292+
* optionally emit a message before calling the real exit().
1293+
*/
1294+
int trace2_cmd_exit_fl(const char *file, int line, int code);
1295+
#define exit(code) exit(trace2_cmd_exit_fl(__FILE__, __LINE__, (code)))
1296+
12901297
/*
12911298
* You can mark a stack variable with UNLEAK(var) to avoid it being
12921299
* reported as a leak by tools like LSAN or valgrind. The argument

0 commit comments

Comments
 (0)