Skip to content

Commit 6c49d27

Browse files
committed
examples/c: fix profile example indentation
Fix indentation that got mixed up. Signed-off-by: Andrii Nakryiko <[email protected]>
1 parent c1afaee commit 6c49d27

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

examples/c/profile.c

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,31 @@ static struct blaze_symbolizer *symbolizer;
3737

3838
static void print_frame(const char *name, uintptr_t input_addr, uintptr_t addr, uint64_t offset, const blaze_symbolize_code_info* code_info)
3939
{
40-
// If we have an input address we have a new symbol.
41-
if (input_addr != 0) {
42-
printf("%016lx: %s @ 0x%lx+0x%lx", input_addr, name, addr, offset);
43-
if (code_info != NULL && code_info->dir != NULL && code_info->file != NULL) {
44-
printf(" %s/%s:%u\n", code_info->dir, code_info->file, code_info->line);
45-
} else if (code_info != NULL && code_info->file != NULL) {
46-
printf(" %s:%u\n", code_info->file, code_info->line);
47-
} else {
48-
printf("\n");
49-
}
50-
} else {
51-
printf("%16s %s", "", name);
52-
if (code_info != NULL && code_info->dir != NULL && code_info->file != NULL) {
53-
printf("@ %s/%s:%u [inlined]\n", code_info->dir, code_info->file, code_info->line);
54-
} else if (code_info != NULL && code_info->file != NULL) {
55-
printf("@ %s:%u [inlined]\n", code_info->file, code_info->line);
56-
} else {
57-
printf("[inlined]\n");
58-
}
59-
}
40+
/* If we have an input address we have a new symbol. */
41+
if (input_addr != 0) {
42+
printf("%016lx: %s @ 0x%lx+0x%lx", input_addr, name, addr, offset);
43+
if (code_info != NULL && code_info->dir != NULL && code_info->file != NULL) {
44+
printf(" %s/%s:%u\n", code_info->dir, code_info->file, code_info->line);
45+
} else if (code_info != NULL && code_info->file != NULL) {
46+
printf(" %s:%u\n", code_info->file, code_info->line);
47+
} else {
48+
printf("\n");
49+
}
50+
} else {
51+
printf("%16s %s", "", name);
52+
if (code_info != NULL && code_info->dir != NULL && code_info->file != NULL) {
53+
printf("@ %s/%s:%u [inlined]\n", code_info->dir, code_info->file, code_info->line);
54+
} else if (code_info != NULL && code_info->file != NULL) {
55+
printf("@ %s:%u [inlined]\n", code_info->file, code_info->line);
56+
} else {
57+
printf("[inlined]\n");
58+
}
59+
}
6060
}
6161

6262
static void show_stack_trace(__u64 *stack, int stack_sz, pid_t pid)
6363
{
64-
const struct blaze_symbolize_inlined_fn* inlined;
64+
const struct blaze_symbolize_inlined_fn* inlined;
6565
const struct blaze_syms *syms;
6666
const struct blaze_sym *sym;
6767
int i, j;
@@ -73,15 +73,17 @@ static void show_stack_trace(__u64 *stack, int stack_sz, pid_t pid)
7373
.type_size = sizeof(src),
7474
.pid = pid,
7575
};
76+
7677
syms = blaze_symbolize_process_abs_addrs(symbolizer, &src, (const uintptr_t *)stack, stack_sz);
7778
} else {
7879
struct blaze_symbolize_src_kernel src = {
7980
.type_size = sizeof(src),
8081
};
82+
8183
syms = blaze_symbolize_kernel_abs_addrs(symbolizer, &src, (const uintptr_t *)stack, stack_sz);
8284
}
8385

84-
if (syms == NULL) {
86+
if (!syms) {
8587
printf(" failed to symbolize addresses: %s\n", blaze_err_str(blaze_err_last()));
8688
return;
8789
}
@@ -92,13 +94,13 @@ static void show_stack_trace(__u64 *stack, int stack_sz, pid_t pid)
9294
continue;
9395
}
9496

95-
sym = &syms->syms[i];
96-
print_frame(sym->name, stack[i], sym->addr, sym->offset, &sym->code_info);
97+
sym = &syms->syms[i];
98+
print_frame(sym->name, stack[i], sym->addr, sym->offset, &sym->code_info);
9799

98-
for (j = 0; j < sym->inlined_cnt; j++) {
99-
inlined = &sym->inlined[j];
100-
print_frame(sym->name, 0, 0, 0, &inlined->code_info);
101-
}
100+
for (j = 0; j < sym->inlined_cnt; j++) {
101+
inlined = &sym->inlined[j];
102+
print_frame(sym->name, 0, 0, 0, &inlined->code_info);
103+
}
102104
}
103105

104106
blaze_syms_free(syms);

0 commit comments

Comments
 (0)