From bb400d5d61e9febcb181b82f189c2ae44e19ccf4 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Mon, 8 Aug 2022 08:37:51 -0500 Subject: [PATCH] Remove unused funcs + messages for excluding system lib (#133) - instead of filtering system library opaquely, generate info messages - remove unused are_file_include_exclude_lists_empty() - remove unused module_constraint free func - remove unused routine_counstraint free func --- source/bin/omnitrace/details.cpp | 471 ----------------------- source/bin/omnitrace/fwd.hpp | 9 - source/bin/omnitrace/module_function.cpp | 6 +- source/bin/omnitrace/omnitrace.cpp | 28 +- 4 files changed, 7 insertions(+), 507 deletions(-) diff --git a/source/bin/omnitrace/details.cpp b/source/bin/omnitrace/details.cpp index 4a1bbe1551..249a7819be 100644 --- a/source/bin/omnitrace/details.cpp +++ b/source/bin/omnitrace/details.cpp @@ -34,7 +34,6 @@ static int error_print = 0; strset_t get_whole_function_names() { -#if 1 return strset_t{ "sem_init", "sem_destroy", "sem_open", "sem_close", "sem_post", "sem_wait", "sem_getvalue", "sem_clockwait", "sem_timedwait", "sem_trywait", "sem_unlink", @@ -60,466 +59,6 @@ get_whole_function_names() "ncclSend", "ncclRecv", "ncclGather", "ncclScatter", "ncclAllToAll", "ncclAllToAllv" }; -#else - // should hopefully be removed soon - return strset_t{ "a64l", - "advance", - "aio_return", - "aio_return64", - "argp_error", - "argp_failure", - "argp_help", - "argp_parse", - "argp_state_help", - "argp_usage", - "argz_add", - "argz_add_sep", - "argz_append", - "argz_count", - "argz_create", - "argz_create_sep", - "argz_delete", - "argz_extract", - "argz_insert", - "argz_next", - "argz_replace", - "argz_stringify", - "atexit", - "atof", - "atoi", - "atol", - "atoll", - "atomic_flag_clear_explicit", - "atomic_flag_test_and_set_explicit", - "authdes_create", - "authdes_getucred", - "authdes_pk_create", - "authnone_create", - "authunix_create", - "authunix_create_default", - "backtrace", - "backtrace_symbols", - "backtrace_symbols_fd", - "bindresvport", - "bindtextdomain", - "bind_textdomain_codeset", - "bsearch", - "btowc", - "c16rtomb", - "callrpc", - "canonicalize_file_name", - "catclose", - "catgets", - "catopen", - "cfmakeraw", - "cfsetspeed", - "chflags", - "clearerr", - "clearerr_unlocked", - "clnt_broadcast", - "clnt_create", - "clnt_pcreateerror", - "clnt_perrno", - "clnt_perror", - "clntraw_create", - "clnt_spcreateerror", - "clnt_sperrno", - "clnt_sperror", - "clnttcp_create", - "clntudp_bufcreate", - "clntudp_create", - "clntunix_create", - "confstr", - "daemon", - "des_setparity", - "div", - "dlopen", - "dlsym", - "dlerror", - "dladdr", - "dlinfo", - "dlvsym", - "dlmopen", - "dl_iterate_phdr", - "dysize", - "endutxent", - "envz_add", - "envz_entry", - "envz_get", - "envz_merge", - "envz_remove", - "envz_strip", - "ether_aton", - "ether_hostton", - "ether_line", - "ether_ntoa", - "ether_ntohost", - "execl", - "execle", - "execlp", - "execv", - "execvp", - "execvpe", - "explicit_bzero", - "fattach", - "fclose", - "fdetach", - "fdopen", - "feof_unlocked", - "ferror_unlocked", - "fflush", - "fflush_unlocked", - "fgetpos", - "fgets", - "fgets_unlocked", - "fgetws", - "fgetws_unlocked", - "_fini", - "fini", - "fmemopen", - "fopen", - "fopen64", - "fopencookie", - "fork", - "fork_alias", - "fork_compat", - "fputc_unlocked", - "fputs", - "fputs_unlocked", - "fputwc_unlocked", - "fputws", - "fputws_unlocked", - "fread", - "fread_unlocked", - "fsetpos", - "fsetpos64", - "ftell", - "fwrite", - "fwrite_unlocked", - "getdelim", - "getgrouplist", - "gethostbyname2", - "getmntent", - "getmsg", - "getnetname", - "getopt_long", - "getopt_long_only", - "getpmsg", - "getpublickey", - "gets", - "getsecretkey", - "glob_pattern_p", - "gnu_dev_major", - "gnu_dev_makedev", - "gnu_dev_minor", - "gnu_get_libc_release", - "gnu_get_libc_version", - "group_member", - "gtty", - "hcreate", - "hdestroy", - "herror", - "host2netname", - "hsearch", - "hstrerror", - "htons", - "iconv", - "iconv_close", - "iconv_open", - "inet6_opt_append", - "inet6_opt_find", - "inet6_opt_finish", - "inet6_opt_get_val", - "inet6_opt_init", - "inet6_option_alloc", - "inet6_option_append", - "inet6_option_find", - "inet6_option_init", - "inet6_option_next", - "inet6_option_space", - "inet6_opt_next", - "inet6_opt_set_val", - "inet6_rth_add", - "inet6_rth_getaddr", - "inet6_rth_init", - "inet6_rth_reverse", - "inet6_rth_segments", - "inet6_rth_space", - "inet_addr", - "inet_aton", - "inet_lnaof", - "inet_makeaddr", - "inet_netof", - "inet_network", - "inet_nsap_addr", - "inet_nsap_ntoa", - "inet_ntoa", - "inet_ntop", - "inet_pton", - "_init", - "init", - "initgroups", - "initstate", - "insque", - "iruserok", - "iruserok_af", - "key_decryptsession", - "key_decryptsession_pk", - "key_encryptsession", - "key_encryptsession_pk", - "key_gendes", - "key_get_conv", - "key_secretkey_is_set", - "key_setnet", - "key_setsecret", - "l64a", - "lchmod", - "lckpwdf", - "lfind", - "llabs", - "lldiv", - "localeconv", - "lockf", - "lsearch", - "mbrtoc16", - "mbrtoc32", - "mcheck", - "mcheck_check_all", - "mcheck_pedantic", - "mkdtemp", - "mkdtemp64", - "mkostemp", - "mkostemp64", - "mkostemps", - "mkostemps64", - "mkstemp", - "mkstemp64", - "mkstemps", - "mkstemps64", - "mktemp", - "mktemp64", - "moncontrol", - "monstartup", - "mprobe", - "mtrace", - "muntrace", - "nanosleep", - "netname2host", - "netname2user", - "nl_langinfo", - "nl_langinfo_l", - "ntohs", - "parse_printf_format", - "passwd2des", - "pclose", - "perror", - "pmap_getmaps", - "pmap_getport", - "pmap_rmtcall", - "pmap_set", - "pmap_unset", - "popen", - "printf_size", - "printf_size_info", - "psiginfo", - "psignal", - "putchar", - "putchar_unlocked", - "putc_unlocked", - "putenv", - "putgrent", - "putmsg", - "putpmsg", - "putpwent", - "puts", - "putsgent", - "putspent", - "pututxline", - "putw", - "putwc", - "putwchar", - "putwchar_unlocked", - "putwc_unlocked", - "rcmd", - "rcmd_af", - "reallocarray", - "realpath", - "re_comp", - "re_compile_fastmap", - "re_compile_pattern", - "re_exec", - "regcomp", - "regerror", - "regexec", - "register_printf_modifier", - "register_printf_type", - "registerrpc", - "re_match", - "re_match_2", - "remque", - "re_search", - "re_search_2", - "re_set_registers", - "re_set_syntax", - "revoke", - "rexec", - "rexec_af", - "rpmatch", - "rresvport", - "rresvport_af", - "ruserok", - "ruserok_af", - "ruserpass", - "secure_getenv", - "seed48", - "setbuffer", - "setstate", - "setvbuf", - "sgetsgent", - "sgetspent", - "sigcancel_handler", - "sighandler_setxid", - "sstk", - "step", - "stty", - "svcerr_auth", - "svcerr_decode", - "svcerr_noproc", - "svcerr_noprog", - "svcerr_progvers", - "svcerr_systemerr", - "svcerr_weakauth", - "svc_exit", - "svcfd_create", - "svc_getreq", - "svc_getreq_common", - "svc_getreq_poll", - "svc_getreqset", - "svcraw_create", - "svc_register", - "svc_run", - "svc_sendreply", - "svctcp_create", - "svcudp_bufcreate", - "svcudp_create", - "svcudp_enablecache", - "svcunix_create", - "svcunixfd_create", - "svc_unregister", - "swab", - "tcgetsid", - "tdelete", - "tdestroy", - "tempnam", - "textdomain", - "tfind", - "thrd_create", - "thrd_current", - "thrd_detach", - "thrd_equal", - "thrd_exit", - "thrd_join", - "thrd_sleep", - "thrd_yield", - "tmpnam", - "tolower", - "toupper", - "towctrans", - "towctrans_l", - "tr_break", - "tsearch", - "tss_create", - "tss_delete", - "tss_get", - "tss_set", - "ttyslot", - "twalk", - "twalk_r", - "tzset", - "ulckpwdf", - "ungetc", - "ungetwc", - "unwind_stop", - "updwtmpx", - "user2netname", - "utmpname", - "utmpxname", - "vlimit", - "vtimes", - "wait", - "wait3", - "waitpid", - "wordexp", - "xdecrypt", - "xdr_accepted_reply", - "xdr_array", - "xdr_authdes_cred", - "xdr_authdes_verf", - "xdr_authunix_parms", - "xdr_bool", - "xdr_bytes", - "xdr_callhdr", - "xdr_callmsg", - "xdr_char", - "xdr_cryptkeyarg", - "xdr_cryptkeyarg2", - "xdr_cryptkeyres", - "xdr_des_block", - "xdr_double", - "xdr_enum", - "xdr_float", - "xdr_getcredres", - "xdr_hyper", - "xdr_int", - "xdr_int16_t", - "xdr_int64_t", - "xdr_int8_t", - "xdr_keybuf", - "xdr_key_netstarg", - "xdr_key_netstres", - "xdr_keystatus", - "xdr_longlong_t", - "xdrmem_create", - "xdr_netnamestr", - "xdr_netobj", - "xdr_opaque", - "xdr_opaque_auth", - "xdr_pmap", - "xdr_pmaplist", - "xdr_pointer", - "xdr_quad_t", - "xdrrec_create", - "xdrrec_endofrecord", - "xdrrec_eof", - "xdrrec_skiprecord", - "xdr_reference", - "xdr_rejected_reply", - "xdr_replymsg", - "xdr_rmtcall_args", - "xdr_rmtcallres", - "xdr_short", - "xdr_sizeof", - "xdrstdio_create", - "xdr_string", - "xdr_u_char", - "xdr_u_hyper", - "xdr_u_int", - "xdr_uint16_t", - "xdr_uint64_t", - "xdr_uint8_t", - "xdr_u_long", - "xdr_u_longlong_t", - "xdr_union", - "xdr_unixcred", - "xdr_u_quad_t", - "xdr_u_short", - "xdr_vector", - "xdr_void", - "xdr_wrapstring", - "xencrypt", - "xprt_register", - "xprt_unregister" }; -#endif } //======================================================================================// @@ -565,16 +104,6 @@ get_name(module_t* _module) return _v.at(_module); } -//======================================================================================// -// -// For selective instrumentation (unused) -// -bool -are_file_include_exclude_lists_empty() -{ - return true; -} - namespace { std::string diff --git a/source/bin/omnitrace/fwd.hpp b/source/bin/omnitrace/fwd.hpp index a33b32ab13..43b7c9e5db 100644 --- a/source/bin/omnitrace/fwd.hpp +++ b/source/bin/omnitrace/fwd.hpp @@ -249,15 +249,6 @@ consume_parameters(T&&...) //======================================================================================// -extern "C" -{ - bool are_file_include_exclude_lists_empty(); - bool module_constraint(const char* fname); - bool routine_constraint(const char* fname); -} - -//======================================================================================// - strset_t get_whole_function_names(); diff --git a/source/bin/omnitrace/module_function.cpp b/source/bin/omnitrace/module_function.cpp index 39a3f4b458..b0f13d02f4 100644 --- a/source/bin/omnitrace/module_function.cpp +++ b/source/bin/omnitrace/module_function.cpp @@ -350,7 +350,7 @@ module_function::is_module_constrained() const return true; }; - if(module_constraint(function_name.c_str())) return true; + if(module->isSystemLib()) return _report("Excluding", "system library", 3); // always instrument these modules if(module_name == "DEFAULT_MODULE" || module_name == "LIBRARY_MODULE") @@ -413,8 +413,6 @@ module_function::is_routine_constrained() const return true; }; - if(routine_constraint(function_name.c_str())) return true; - auto npos = std::string::npos; if(function_name.find("omnitrace") != npos) { @@ -428,7 +426,7 @@ module_function::is_routine_constrained() const } static std::regex exclude( - "(omnitrace|tim::|N3tim|MPI_Init|MPI_Finalize|dyninst|tm_clones)", regex_opts); + "(omnitrace|tim::|MPI_Init|MPI_Finalize|dyninst|DYNINST|tm_clones)", regex_opts); static std::regex exclude_printf("(|v|f)printf$", regex_opts); static std::regex exclude_cxx( "(std::_Sp_counted_base|std::(use|has)_facet|std::locale|::sentry|^std::_|::_(M|" diff --git a/source/bin/omnitrace/omnitrace.cpp b/source/bin/omnitrace/omnitrace.cpp index 962210a6d5..0ee942c23a 100644 --- a/source/bin/omnitrace/omnitrace.cpp +++ b/source/bin/omnitrace/omnitrace.cpp @@ -457,7 +457,8 @@ main(int argc, char** argv) parser .add_argument( { "-L", "--library" }, - "Libraries with instrumentation routines (default: \"libomnitrace\")") + TIMEMORY_JOIN("", "Libraries with instrumentation routines (default: \"", + inputlib.front(), "\")")) .action([&inputlib](parser_t& p) { inputlib = p.get("library"); }); parser .add_argument({ "-m", "--main-function" }, @@ -1184,7 +1185,7 @@ main(int argc, char** argv) { for(auto* itr : *app_functions) { - if(itr->getModule() && !itr->getModule()->isSystemLib()) + if(itr->getModule()) { functions.emplace(itr); modules.emplace(itr->getModule()); @@ -1214,9 +1215,8 @@ main(int argc, char** argv) if(parse_all_modules && app_modules && !app_modules->empty()) { for(auto* itr : *app_modules) - { - if(!itr->isSystemLib()) modules.emplace(itr); - } + modules.emplace(itr); + verbprintf(2, "Adding the procedures from %zu modules found in the app image...\n", modules.size()); @@ -2269,24 +2269,6 @@ query_instr(procedure_t* funcToInstr, procedure_loc_t traceLoc, flow_graph_t* cf return { _n, _t }; } -//======================================================================================// -// Constraints for instrumentation. Returns true for those modules that -// shouldn't be instrumented. -bool -module_constraint(const char*) -{ - return false; -} - -//======================================================================================// -// Constraint for routines. The constraint returns true for those routines that -// should not be instrumented. -bool -routine_constraint(const char*) -{ - return false; -} - namespace { //======================================================================================//