From c6053543f288f503b39e946ef58bfcd59f935b5f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Feb 2011 09:28:15 -0500 Subject: trace: add trace_vprintf This is a necessary cleanup to adding new types of trace functions. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 4a758babe..08b23b2ab 100644 --- a/cache.h +++ b/cache.h @@ -1067,6 +1067,7 @@ extern void alloc_report(void); /* trace.c */ __attribute__((format (printf, 1, 2))) extern void trace_printf(const char *format, ...); +extern void trace_vprintf(const char *format, va_list ap); __attribute__((format (printf, 2, 3))) extern void trace_argv_printf(const char **argv, const char *format, ...); extern void trace_repo_setup(const char *prefix); -- cgit v1.2.1 From 06796607ef557e8913f1797cca3c98ce4844c36c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Feb 2011 09:28:41 -0500 Subject: trace: refactor to support multiple env variables Right now you turn all tracing off and on with GIT_TRACE. To support new types of tracing without forcing the user to see all of them, we will soon support turning each tracing area on with GIT_TRACE_*. This patch lays the groundwork by providing an interface which does not assume GIT_TRACE. However, we still maintain the trace_printf interface so that existing callers do not need to be refactored. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 08b23b2ab..2ab1bf938 100644 --- a/cache.h +++ b/cache.h @@ -1067,7 +1067,7 @@ extern void alloc_report(void); /* trace.c */ __attribute__((format (printf, 1, 2))) extern void trace_printf(const char *format, ...); -extern void trace_vprintf(const char *format, va_list ap); +extern void trace_vprintf(const char *key, const char *format, va_list ap); __attribute__((format (printf, 2, 3))) extern void trace_argv_printf(const char **argv, const char *format, ...); extern void trace_repo_setup(const char *prefix); -- cgit v1.2.1 From 39bc5e4680a1ed7192968fbe9f5784ad56ecbd36 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Feb 2011 09:28:59 -0500 Subject: trace: factor out "do we want to trace" logic As we add more tracing areas, this will avoid repeated code. Technically, trace_printf already checks this and will avoid printing if the trace key is not set. However, callers may want to find out early whether or not tracing is enabled so they can avoid doing work in the common non-trace case. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 2ab1bf938..211d7bb26 100644 --- a/cache.h +++ b/cache.h @@ -1071,6 +1071,7 @@ extern void trace_vprintf(const char *key, const char *format, va_list ap); __attribute__((format (printf, 2, 3))) extern void trace_argv_printf(const char **argv, const char *format, ...); extern void trace_repo_setup(const char *prefix); +extern int trace_want(const char *key); /* convert.c */ /* returns 1 if *dst was used */ -- cgit v1.2.1 From 94b3b3746456949d834ec7bf454da3db4eb439cf Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Feb 2011 09:29:50 -0500 Subject: trace: add trace_strbuf If you happen to have a strbuf, it is a little more readable and a little more efficient to be able to print it directly instead of jamming it through the trace_printf interface. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 211d7bb26..3978112f5 100644 --- a/cache.h +++ b/cache.h @@ -1072,6 +1072,7 @@ __attribute__((format (printf, 2, 3))) extern void trace_argv_printf(const char **argv, const char *format, ...); extern void trace_repo_setup(const char *prefix); extern int trace_want(const char *key); +extern void trace_strbuf(const char *key, const struct strbuf *buf); /* convert.c */ /* returns 1 if *dst was used */ -- cgit v1.2.1 From bbc30f996380eacd71ca061675d5d0c5f21c45d2 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Feb 2011 09:30:19 -0500 Subject: add packet tracing debug code This shows a trace of all packets coming in or out of a given program. This can help with debugging object negotiation or other protocol issues. To keep the code changes simple, we operate at the lowest level, meaning we don't necessarily understand what's in the packets. The one exception is a packet starting with "PACK", which causes us to skip that packet and turn off tracing (since the gigantic pack data will not be interesting to read, at least not in the trace format). We show both written and read packets. In the local case, this may mean you will see packets twice (written by the sender and read by the receiver). However, for cases where the other end is remote, this allows you to see the full conversation. Packet tracing can be enabled with GIT_TRACE_PACKET=, where takes the same arguments as GIT_TRACE. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- cache.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 3978112f5..2e59aae17 100644 --- a/cache.h +++ b/cache.h @@ -1074,6 +1074,8 @@ extern void trace_repo_setup(const char *prefix); extern int trace_want(const char *key); extern void trace_strbuf(const char *key, const struct strbuf *buf); +void packet_trace_identity(const char *prog); + /* convert.c */ /* returns 1 if *dst was used */ extern int convert_to_git(const char *path, const char *src, size_t len, -- cgit v1.2.1