static void register_silenced_functions(void) { struct token *token; char *func; char name[256]; silenced_funcs = create_function_hashtable(500); if (option_project == PROJ_NONE) return; snprintf(name, 256, "%s.silenced_functions", option_project_str); token = get_tokens_file(name); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = alloc_string(show_ident(token->ident)); insert_func(silenced_funcs, func, INT_PTR(1)); token = token->next; } clear_token_alloc(); }
static void register_ignored_macros(void) { struct token *token; char *macro; char name[256]; if (option_project == PROJ_NONE) strcpy(name, "ignored_macros"); else snprintf(name, 256, "%s.ignored_macros", option_project_str); token = get_tokens_file(name); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; macro = alloc_string(show_ident(token->ident)); add_ptr_list(&__ignored_macros, macro); token = token->next; } clear_token_alloc(); }
static void register_no_return_funcs(void) { struct token *token; const char *func; char name[256]; if (option_project == PROJ_NONE) strcpy(name, "no_return_funcs"); else snprintf(name, 256, "%s.no_return_funcs", option_project_str); token = get_tokens_file(name); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = show_ident(token->ident); add_function_hook(func, &__match_nullify_path_hook, NULL); token = token->next; } clear_token_alloc(); }
static void register_shifters(void) { char filename[256]; struct token *token; char *name; int *val; snprintf(filename, sizeof(filename), "%s.bit_shifters", option_project_str); token = get_tokens_file(filename); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; name = alloc_string(show_ident(token->ident)); token = token->next; if (token_type(token) != TOKEN_NUMBER) return; val = malloc(sizeof(int)); *val = atoi(token->number); insert_struct(shifters, name, val); token = token->next; } clear_token_alloc(); }
char* logger:: format_header(const logger::msg& a_msg, char* a_buf, const char* a_end) { // Message mormat: Timestamp|Level|Ident|Category|Message|File:Line FunName // Write everything up to Message to the m_data: char* p = a_buf; // Write Timestamp if (timestamp_type() != stamp_type::NO_TIMESTAMP) { p += timestamp::format(timestamp_type(), a_msg.m_timestamp, p, a_end - p); *p++ = '|'; } // Write Level *p++ = logger::log_level_to_str(a_msg.m_level)[0]; *p++ = '|'; if (show_ident()) { p = stpncpy(p, ident().c_str(), ident().size()); *p++ = '|'; } if (show_thread()) { if (a_msg.m_thread_name[0] == '\0') { char* q = const_cast<char*>(a_msg.m_thread_name); itoa(a_msg.m_thread_id, q, 10); } p = stpcpy(p, a_msg.m_thread_name); *p++ = '|'; } if (show_category()) { if (!a_msg.m_category.empty()) p = stpncpy(p, a_msg.m_category.c_str(), a_msg.m_category.size()); *p++ = '|'; } return p; }
static void register_funcs_from_file(void) { struct token *token; const char *func; int arg; token = get_tokens_file("kernel.dma_funcs"); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = show_ident(token->ident); token = token->next; if (token_type(token) != TOKEN_NUMBER) return; arg = atoi(token->number); add_function_hook(func, &match_dma_func, INT_PTR(arg)); token = token->next; } clear_token_alloc(); }
static void register_returns_held_funcs(void) { struct token *token; const char *func; token = get_tokens_file("kernel.returns_held_funcs"); if (!token) return; if (token_type(token) != TOKEN_STREAMBEGIN) return; token = token->next; while (token_type(token) != TOKEN_STREAMEND) { if (token_type(token) != TOKEN_IDENT) return; func = show_ident(token->ident); return_implies_state(func, valid_ptr_min, valid_ptr_max, &match_returns_held, NULL); return_implies_state(func, 0, 0, &match_returns_null, NULL); token = token->next; } clear_token_alloc(); }
}; static bool report_class[I__COUNT] = { [0 ... (I__COUNT-1)] = true, [I_STRUCTDECL] = false, [I_UNIONDECL] = false, [I_ENUMDECL] = false, }; static bool all_files = false; static void report_symbol(struct symbol *sym, int class) { const char *ident = show_ident(sym->ident); const char *name = identclass_name[class]; if (!report_class[class]) return; assert(name != NULL); assert(sym != NULL); assert(ident != NULL); printf("%s:%d\t%s\t%s\n", stream_name(sym->pos.stream), sym->pos.line, name, ident); }