make it possible to profile gotweb; tracey had the same diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
diff --git a/gotweb/Makefile.inc b/gotweb/Makefile.inc
index b892a27..f6a499d 100644
--- a/gotweb/Makefile.inc
+++ b/gotweb/Makefile.inc
@@ -17,3 +17,10 @@ WWWUSR ?= www
WWWGRP ?= www
CPPFLAGS += -DGOT_TMPDIR=${GOTWEB_TMP_DIR}
+
+.if defined(PROFILE)
+CPPFLAGS += -DPROFILE
+DEBUG = -O0 -pg -g -static
+.else
+DEBUG = -O0 -g
+.endif
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index eb1b093..2244e28 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -347,10 +347,11 @@ gw_blame(struct gw_trans *gw_trans)
char *age = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
@@ -424,10 +425,11 @@ gw_blob(struct gw_trans *gw_trans)
struct gw_header *header = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
@@ -477,10 +479,11 @@ gw_diff(struct gw_trans *gw_trans)
char *age = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
@@ -566,12 +569,13 @@ gw_index(struct gw_trans *gw_trans)
unsigned int prev_disp = 0, next_disp = 1, dir_c = 0;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil",
NULL) == -1) {
error = got_error_from_errno("pledge");
return error;
}
-
+#endif
error = gw_apply_unveil(gw_trans->gw_conf->got_repos_path);
if (error)
return error;
@@ -968,12 +972,13 @@ gw_commits(struct gw_trans *gw_trans)
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil",
NULL) == -1) {
error = got_error_from_errno("pledge");
goto done;
}
-
+#endif
error = gw_apply_unveil(gw_trans->gw_dir->path);
if (error)
goto done;
@@ -1191,12 +1196,13 @@ gw_briefs(struct gw_trans *gw_trans)
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil",
NULL) == -1) {
error = got_error_from_errno("pledge");
goto done;
}
-
+#endif
if (gw_trans->action != GW_SUMMARY) {
error = gw_apply_unveil(gw_trans->gw_dir->path);
if (error)
@@ -1448,9 +1454,10 @@ gw_summary(struct gw_trans *gw_trans)
char *age = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
error = gw_apply_unveil(gw_trans->gw_dir->path);
if (error)
goto done;
@@ -1610,9 +1617,10 @@ gw_tree(struct gw_trans *gw_trans)
char *age = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
@@ -1684,9 +1692,10 @@ gw_tags(struct gw_trans *gw_trans)
char *href_next = NULL, *href_prev = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");
@@ -1804,9 +1813,10 @@ gw_tag(struct gw_trans *gw_trans)
struct gw_header *header = NULL;
enum kcgi_err kerr = KCGI_OK;
+#ifndef PROFILE
if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
return got_error_from_errno("pledge");
-
+#endif
if ((header = gw_init_header()) == NULL)
return got_error_from_errno("malloc");