/
githubmirror
/
strace
Обзор
Документация
Войти
/
githubmirror
/
strace
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/print_fields.c
362 строки
6 KB
Gabi Falk
Colorize call-style decoder output separately from syscall names
25 июн 2026, 11:00
25 июн 2026, 11:00
b7da157
Код
Авторство
О чём код?
/* * Copyright (c) 2016-2017 Dmitry V. Levin <ldv@strace.io> * Copyright (c) 2017-2026 The strace developers. * All rights reserved. * * SPDX-License-Identifier: LGPL-2.1-or-later */ #include "defs.h" #include "print_fields.h" void tprint_struct_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("{"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_struct_next(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(", "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_struct_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("}"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_union_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("{"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_union_next(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(", "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_union_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("}"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_array_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("["); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_array_next(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(", "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_array_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("]"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_array_index_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("["); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_array_index_equal(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("]="); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprints_arg_begin(const char *name) { STRACE_PRINT_COLOR_SEQ(COLOR_SYSCALL); STRACE_PRINTF("%s", name); STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("("); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_arg_next(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(", "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_arg_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(")"); STRACE_PRINT_COLOR_SEQ(COLOR_RESET); } void tprints_arg_name_unconditionally(const char *name) { STRACE_PRINT_COLOR_SEQ(COLOR_ARGNAME); STRACE_PRINTF("%s", name); STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("="); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprints_arg_next_name_unconditionally(const char *name) { tprint_arg_next(); tprints_arg_name_unconditionally(name); } void tprints_arg_name(const char *name) { if (Nflag) tprints_arg_name_unconditionally(name); } void tprints_arg_next_name(const char *name) { tprint_arg_next(); tprints_arg_name(name); } void tprints_fn_begin(const char *name) { STRACE_PRINT_COLOR_SEQ(COLOR_CALL); STRACE_PRINTF("%s", name); STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("("); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_fn_next(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(", "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_fn_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(")"); STRACE_PRINT_COLOR_SEQ(COLOR_RESET); } void tprint_bitset_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("["); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_bitset_next(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(" "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_bitset_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("]"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_comment_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_COMMENT); STRACE_PRINTS(" /* "); } void tprint_comment_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_COMMENT); STRACE_PRINTS(" */"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_indirect_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("["); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_indirect_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("]"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_attribute_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("["); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_attribute_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("]"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_associated_info_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("<"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_associated_info_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(">"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_more_data_follows(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("..."); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_value_changed(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(" => "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_alternative_value(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS(" or "); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_unavailable(void) { STRACE_PRINT_COLOR_SEQ(COLOR_ERROR); STRACE_PRINTS("???"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_flags_or(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("|"); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_newline(void) { STRACE_PRINT_COLOR_SEQ(COLOR_RESET); STRACE_PRINTS("\n"); } void tprints_field_name(const char *name) { STRACE_PRINT_COLOR_SEQ(COLOR_ARGNAME); STRACE_PRINTF("%s", name); STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("="); STRACE_PRINT_COLOR_SEQ(COLOR_ARGVAL); } void tprint_sysret_begin(void) { STRACE_PRINT_COLOR_SEQ(COLOR_PUNCT); STRACE_PRINTS("="); STRACE_PRINT_COLOR_SEQ(COLOR_RESET); } void tprints_sysret_next(const char *name) { STRACE_PRINT_COLOR_SEQ(COLOR_RESET); tprint_space(); if (color_is_enabled && name) { if (!strcmp(name, "error") || !strcmp(name, "errno") || !strcmp(name, "strerror")) { STRACE_PRINT_COLOR_SEQ(COLOR_ERROR); return; } } STRACE_PRINT_COLOR_SEQ(COLOR_RETVAL); } void tprints_sysret_string(const char *name, const char *str) { tprints_sysret_next(name); STRACE_PRINTF("(%s)", str); } void tprint_sysret_end(void) { STRACE_PRINT_COLOR_SEQ(COLOR_RESET); }