From 99439b7b2a06109f8aa9ebcf299cd69813a1216f Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 14 Jul 2021 17:59:10 -0700 Subject: [PATCH] debugging fixes added "verbose" flag to seederd to allow for debugging added --enable-debug ./configure flag to disable optimizations --- configure.ac | 21 +++++++++++++++++++-- seederd/inc/main.h | 1 + seederd/src/main.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b4a4168..9a010ad 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,8 @@ if test -z "$INOTIFYWAIT"; then AC_MSG_ERROR("inotifywait required"); fi +AC_ARG_VAR(SEEDER_DOMAIN,[hostname from which seeder is serving]) + dnl disable memcheck if valgrind not found if test "x$enable_memcheck" != "xno"; then if test -z "$VALGRIND"; then @@ -48,10 +50,25 @@ else AC_MSG_RESULT(no) fi -AC_ARG_VAR(SEEDER_DOMAIN,[hostname from which seeder is serving]) - AM_CONDITIONAL([ENABLE_MEMCHECK],[test x$enable_memcheck = xyes]) +dnl Enable debug +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [use compiler flags and macros suited for debugging (default is no)])], + [enable_debug=$enableval], + [enable_debug=no]) + +AC_MSG_CHECKING([if debugging]) +if test x$enable_debug != xno; then + AC_MSG_RESULT(yes) + CFLAGS="-ggdb -O0" + CXXFLAGS="-ggdb -O0" +else + AC_MSG_RESULT(no) +fi + +AM_CONDITIONAL([ENABLE_DEBUG],[test x$enable_debug = xyes]) # Checks for programs. AC_PROG_CC diff --git a/seederd/inc/main.h b/seederd/inc/main.h index dcdcb49..5d2b81b 100644 --- a/seederd/inc/main.h +++ b/seederd/inc/main.h @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/seederd/src/main.cpp b/seederd/src/main.cpp index 35fb8d5..5604ebe 100644 --- a/seederd/src/main.cpp +++ b/seederd/src/main.cpp @@ -25,7 +25,35 @@ int setup_signal_handler() { return 1; } +static struct option long_options[] = { + {"verbose", no_argument, 0, 'v'}, + {0,0,0,0} +}; + int main(int argc, char **argv) try { + char c; + bool verbose_flag = false; + + while(1) { + int option_index = 0; + + if((c = getopt_long(argc,argv,"v",long_options,&option_index))==-1) { break; } + + switch(c) { + case 0: + break; + case 'v': + verbose_flag = true; + std::cerr << "verbose mode enabled" << std::endl; + + break; + case '?': + default: + std::cerr << "invalid option" << std::endl; + return EXIT_FAILURE; + } + } + if(setup_signal_handler()<0) { return EXIT_FAILURE; } std::cout << "creating required directories" << std::endl; @@ -40,7 +68,22 @@ int main(int argc, char **argv) try { settings.set_int(lt::settings_pack::active_limit,-1); settings.set_str(lt::settings_pack::listen_interfaces,"0.0.0.0:6881,[::]:6881"); settings.set_str(lt::settings_pack::user_agent,PACKAGE_STRING); -// settings.set_int(lt::settings_pack::alert_mask,(lt::alert::session_log_notification + lt::alert::torrent_log_notification)); + + if(verbose_flag) { + settings.set_int(lt::settings_pack::alert_mask, lt::alert::all_categories + & ~(lt::alert::dht_notification + + lt::alert::piece_progress_notification + + lt::alert::block_progress_notification + + lt::alert::progress_notification + + lt::alert::stats_notification + + lt::alert::session_log_notification + + lt::alert::torrent_log_notification + + lt::alert::peer_log_notification + + lt::alert::dht_log_notification + + lt::alert::picker_log_notification + )); + } + lt::session session(settings); init(session); -- 2.30.2