Skip to content

Commit 8dce9b9

Browse files
committed
---
yaml --- r: 3035 b: refs/heads/master c: 1d1010c h: refs/heads/master i: 3033: f4c6ad6 3031: d368d6b v: v3
1 parent 3013f38 commit 8dce9b9

File tree

3 files changed

+58
-20
lines changed

3 files changed

+58
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 8876e2c29e0509b530648156e919b355b49c2dd8
2+
refs/heads/master: 1d1010cac090e1b2d79500e32144a2e87c39e13e

trunk/src/rt/rust.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
120120
// indent-tabs-mode: nil
121121
// c-basic-offset: 4
122122
// buffer-file-coding-system: utf-8-unix
123-
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
123+
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
124124
// End:
125125
//

trunk/src/rt/rust_log.cpp

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ size_t parse_logging_spec(char* spec, log_directive* dirs) {
176176
}
177177

178178
void update_module_map(const mod_entry* map, log_directive* dirs,
179-
size_t n_dirs) {
179+
size_t n_dirs, size_t *n_matches) {
180180
for (const mod_entry* cur = map; cur->name; cur++) {
181181
size_t level = default_log_level, longest_match = 0;
182182
for (size_t d = 0; d < n_dirs; d++) {
@@ -187,18 +187,28 @@ void update_module_map(const mod_entry* map, log_directive* dirs,
187187
}
188188
}
189189
*cur->state = level;
190+
(*n_matches)++;
190191
}
191192
}
192193

193194
void update_crate_map(const cratemap* map, log_directive* dirs,
194-
size_t n_dirs) {
195+
size_t n_dirs, size_t *n_matches) {
195196
// First update log levels for this crate
196-
update_module_map(map->entries, dirs, n_dirs);
197+
update_module_map(map->entries, dirs, n_dirs, n_matches);
197198
// Then recurse on linked crates
198199
// FIXME this does double work in diamond-shaped deps. could keep
199200
// a set of visited addresses, if it turns out to be actually slow
200201
for (size_t i = 0; map->children[i]; i++) {
201-
update_crate_map(map->children[i], dirs, n_dirs);
202+
update_crate_map(map->children[i], dirs, n_dirs, n_matches);
203+
}
204+
}
205+
206+
void print_crate_log_map(const cratemap* map) {
207+
for (const mod_entry* cur = map->entries; cur->name; cur++) {
208+
printf(" %s\n", cur->name);
209+
}
210+
for (size_t i = 0; map->children[i]; i++) {
211+
print_crate_log_map(map->children[i]);
202212
}
203213
}
204214

@@ -218,33 +228,61 @@ size_t log_rt_kern;
218228
size_t log_rt_backtrace;
219229

220230
static const mod_entry _rt_module_map[] =
221-
{{"rt::mem", &log_rt_mem},
222-
{"rt::comm", &log_rt_comm},
223-
{"rt::task", &log_rt_task},
224-
{"rt::dom", &log_rt_dom},
225-
{"rt::trace", &log_rt_trace},
226-
{"rt::cache", &log_rt_cache},
227-
{"rt::upcall", &log_rt_upcall},
228-
{"rt::timer", &log_rt_timer},
229-
{"rt::gc", &log_rt_gc},
230-
{"rt::stdlib", &log_rt_stdlib},
231-
{"rt::kern", &log_rt_kern},
232-
{"rt::backtrace", &log_rt_backtrace},
231+
{{"::rt::mem", &log_rt_mem},
232+
{"::rt::comm", &log_rt_comm},
233+
{"::rt::task", &log_rt_task},
234+
{"::rt::dom", &log_rt_dom},
235+
{"::rt::trace", &log_rt_trace},
236+
{"::rt::cache", &log_rt_cache},
237+
{"::rt::upcall", &log_rt_upcall},
238+
{"::rt::timer", &log_rt_timer},
239+
{"::rt::gc", &log_rt_gc},
240+
{"::rt::stdlib", &log_rt_stdlib},
241+
{"::rt::kern", &log_rt_kern},
242+
{"::rt::backtrace", &log_rt_backtrace},
233243
{NULL, NULL}};
234244

235245
void update_log_settings(void* crate_map, char* settings) {
236246
char* buffer = NULL;
237247
log_directive dirs[256];
238248
size_t n_dirs = 0;
249+
239250
if (settings) {
251+
252+
if (strcmp(settings, "::help") == 0 ||
253+
strcmp(settings, "?") == 0) {
254+
printf("\nCrate log map:\n\n");
255+
print_crate_log_map((const cratemap*)crate_map);
256+
printf("\n");
257+
exit(1);
258+
}
259+
240260
size_t buflen = strlen(settings) + 1;
241261
buffer = (char*)malloc(buflen);
242262
strncpy(buffer, settings, buflen);
243263
n_dirs = parse_logging_spec(buffer, &dirs[0]);
244264
}
245265

246-
update_module_map(_rt_module_map, &dirs[0], n_dirs);
247-
update_crate_map((const cratemap*)crate_map, &dirs[0], n_dirs);
266+
size_t n_matches = 0;
267+
update_module_map(_rt_module_map, &dirs[0], n_dirs, &n_matches);
268+
update_crate_map((const cratemap*)crate_map, &dirs[0],
269+
n_dirs, &n_matches);
270+
271+
if (n_matches < n_dirs) {
272+
printf("warning: got %d RUST_LOG specs, enabled %d flags.",
273+
n_dirs, n_matches);
274+
}
248275

249276
free(buffer);
250277
}
278+
279+
//
280+
// Local Variables:
281+
// mode: C++
282+
// fill-column: 78;
283+
// indent-tabs-mode: nil
284+
// c-basic-offset: 4
285+
// buffer-file-coding-system: utf-8-unix
286+
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
287+
// End:
288+
//

0 commit comments

Comments
 (0)