diff options
Diffstat (limited to 'erts/etc')
-rw-r--r-- | erts/etc/common/erlexec.c | 66 | ||||
-rw-r--r-- | erts/etc/unix/cerl.src | 25 | ||||
-rw-r--r-- | erts/etc/unix/etp-commands.in | 149 | ||||
-rwxr-xr-x | erts/etc/unix/gcov-gen-html | 62 | ||||
-rw-r--r-- | erts/etc/win32/msys_tools/vc/cc.sh | 33 |
5 files changed, 273 insertions, 62 deletions
diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 8203c46a39..477a501876 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -255,7 +255,9 @@ static char* key_val_name = ERLANG_VERSION; /* Used by the registry * access functions. */ static char* boot_script = NULL; /* used by option -start_erl and -boot */ -static char* config_script = NULL; /* used by option -start_erl and -config */ +static char** config_scripts = NULL; /* used by option -start_erl and -config */ +static int config_script_cnt = 0; +static int got_start_erl = 0; static HANDLE this_module_handle; static int run_werl; @@ -392,6 +394,22 @@ add_extra_suffixes(char *prog) } #ifdef __WIN32__ +static void add_boot_config(void) +{ + int i; + if (boot_script) + add_args("-boot", boot_script, NULL); + for (i = 0; i < config_script_cnt; i++) { + add_args("-config", config_scripts[i], NULL); + } +} +# define ADD_BOOT_CONFIG add_boot_config() +#else +# define ADD_BOOT_CONFIG +#endif + + +#ifdef __WIN32__ __declspec(dllexport) int win_erlexec(int argc, char **argv, HANDLE module, int windowed) #else int main(int argc, char **argv) @@ -581,16 +599,6 @@ int main(int argc, char **argv) i = 1; -#ifdef __WIN32__ -#define ADD_BOOT_CONFIG \ - if (boot_script) \ - add_args("-boot", boot_script, NULL); \ - if (config_script) \ - add_args("-config", config_script, NULL); -#else -#define ADD_BOOT_CONFIG -#endif - get_home(); add_args("-home", home, NULL); @@ -610,7 +618,9 @@ int main(int argc, char **argv) case 'b': if (strcmp(argv[i], "-boot") == 0) { if (boot_script) - error("Conflicting -start_erl and -boot options"); + error("Conflicting -boot options"); + if (got_start_erl) + error("Conflicting -start_erl and -boot options"); if (i+1 >= argc) usage("-boot"); boot_script = strsave(argv[i+1]); @@ -634,11 +644,14 @@ int main(int argc, char **argv) } #ifdef __WIN32__ else if (strcmp(argv[i], "-config") == 0){ - if (config_script) + if (got_start_erl) error("Conflicting -start_erl and -config options"); if (i+1 >= argc) usage("-config"); - config_script = strsave(argv[i+1]); + config_script_cnt++; + config_scripts = erealloc(config_scripts, + config_script_cnt * sizeof(char*)); + config_scripts[config_script_cnt-1] = strsave(argv[i+1]); i++; } #endif @@ -1371,6 +1384,7 @@ strsave(char* string) static void get_start_erl_data(char *file) { + static char* a_config_script; int fp; char tmpbuffer[512]; char start_erl_data[512]; @@ -1381,7 +1395,7 @@ static void get_start_erl_data(char *file) char* tprogname; if (boot_script) error("Conflicting -start_erl and -boot options"); - if (config_script) + if (config_scripts) error("Conflicting -start_erl and -config options"); env = get_env("RELDIR"); if (env) @@ -1431,10 +1445,13 @@ static void get_start_erl_data(char *file) erts_snprintf(progname,strlen(tprogname) + 20,"%s -start_erl",tprogname); boot_script = emalloc(512); - config_script = emalloc(512); + a_config_script = emalloc(512); erts_snprintf(boot_script, 512, "%s/%s/start", reldir, otpstring); - erts_snprintf(config_script, 512, "%s/%s/sys", reldir, otpstring); + erts_snprintf(a_config_script, 512, "%s/%s/sys", reldir, otpstring); + config_scripts = &a_config_script; + config_script_cnt = 1; + got_start_erl = 1; } @@ -1673,9 +1690,9 @@ static char **build_args_from_string(char *string) for(;;) { switch (state) { case Start: - if (!*p) + if (!*p) goto done; - if (argc >= alloced - 1) { /* Make room for extra NULL */ + if (argc >= alloced - 2) { /* Make room for extra NULL and "--" */ argv = erealloc(argv, (alloced += 10) * sizeof(char *)); } cur_s = argc + argv; @@ -1764,11 +1781,14 @@ static char **build_args_from_string(char *string) } } done: - argv[argc] = NULL; /* Sure to be large enough */ if (!argc) { efree(argv); return NULL; } + argv[argc++] = "--"; /* Add a -- separator in order + for different from different environments + to effect each other */ + argv[argc++] = NULL; /* Sure to be large enough */ return argv; #undef ENSURE } @@ -2019,11 +2039,13 @@ initial_argv_massage(int *argc, char ***argv) argv_buf ab = {0}, xab = {0}; int ix, vix, ac; char **av; + char *sep = "--"; struct { int argc; char **argv; } avv[] = {{INT_MAX, NULL}, {INT_MAX, NULL}, {INT_MAX, NULL}, - {INT_MAX, NULL}, {INT_MAX, NULL}, {INT_MAX, NULL}}; + {INT_MAX, NULL}, {INT_MAX, NULL}, + {INT_MAX, NULL}, {INT_MAX, NULL}}; /* * The environment flag containing OTP release is intentionally * undocumented and intended for OTP internal use only. @@ -2043,6 +2065,8 @@ initial_argv_massage(int *argc, char ***argv) if (*argc > 1) { avv[vix].argc = *argc - 1; avv[vix++].argv = &(*argv)[1]; + avv[vix].argc = 1; + avv[vix++].argv = &sep; } av = build_args_from_env("ERL_FLAGS"); diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src index 8cfc2d549e..59de9bdec8 100644 --- a/erts/etc/unix/cerl.src +++ b/erts/etc/unix/cerl.src @@ -292,25 +292,38 @@ if [ "x$GDB" = "x" ]; then valgrind_log="$log_file_prefix$VALGRIND_LOG_DIR/$VALGRIND_LOGFILE_PREFIX$VALGRIND_LOGFILE_INFIX$EMU_NAME.log" fi fi - if [ "x$VALGRIND_MISC_FLAGS" = "x" ]; then - valgrind_misc_flags= - else - valgrind_misc_flags="$VALGRIND_MISC_FLAGS" + # Add default flags + vgflags=$VALGRIND_MISC_FLAGS + if [ "x${vgflags#*--show-possibly-lost}" = "x$vgflags" ]; then + vgflags="$vgflags --show-possibly-lost=no" + fi + if [ "x${vgflags#*--child-silent-after-fork}" = "x$vgflags" ]; then + vgflags="$vgflags --child-silent-after-fork=yes" + fi + if [ "x${vgflags#*--suppressions}" = "x$vgflags" ]; then + if [ "x$ERL_TOP" != "x" ]; then + vgflags="$vgflags --suppressions=$ERL_TOP/erts/emulator/valgrind/suppress.standard" + else + echo "No valgrind suppression file found in \$VALGRIND_MISC_FLAGS and \$ERL_TOP not set." + fi fi if which taskset > /dev/null && test -e /proc/cpuinfo; then # We only let valgrind utilize one core with "taskset 1" as it can be very slow # on multiple cores (especially with async threads). Valgrind only run one pthread # at a time anyway so there is no point letting it utilize more than one core. # Use $sched_arg to force all schedulers online to emulate multicore. - taskset1="taskset 1" ncpu=`cat /proc/cpuinfo | grep -w processor | wc -l` + # Choose a random core in order to not collide with any other valgrind + # run on the same machine. + taskset1=$((1 << (`shuf -i 1-$ncpu -n 1` - 1) )) + taskset1="taskset $taskset1" sched_arg="-S$ncpu:$ncpu" else taskset1= sched_arg= fi - exec $taskset1 valgrind $valgrind_xml $valgrind_log $valgrind_misc_flags $BINDIR/$EMU_NAME $sched_arg $emu_xargs "$@" + exec $taskset1 valgrind $valgrind_xml $valgrind_log $vgflags $BINDIR/$EMU_NAME $sched_arg $emu_xargs "$@" elif [ $run_rr = yes ]; then if [ $1 = replay ]; then diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index 730f0a0c64..8b6abb5336 100644 --- a/erts/etc/unix/etp-commands.in +++ b/erts/etc/unix/etp-commands.in @@ -37,7 +37,7 @@ document etp-help % - GDB command toolbox for analyzing core dumps from the % Erlang emulator (BEAM). % -% Should work for 32-bit erts-5.2/R9B, ... +% Should work for 32-bit and 64-bit unix gdb % % The commands are prefixed with: % etp: Acronym for erts-term-print @@ -55,7 +55,8 @@ document etp-help % Special commands for not really terms: % etp-mfa, etp-cp, etp-disasm, % etp-msgq, etpf-msgq, -% etp-stacktrace, etp-stackdump, etpf-stackdump, etp-dictdump +% etp-stacktrace, etp-stacktrace-emu, etp-stackdump, etp-stackdump-emu, +% etpf-stackdump, etp-dictdump % etp-process-info, etp-process-memory-info % etp-port-info, etp-port-state, etp-port-sched-flags % etp-heapdump, etp-offheapdump, etpf-offheapdump, @@ -1452,30 +1453,74 @@ end define etp-stack-preamble set $etp_stack_p = ($arg0)->stop set $etp_stack_end = ($arg0)->hend + if ($arg0)->state.counter & 0x8000 + printf "%%%%%% WARNING: The process is currently running, so c_p->stop will not be correct\r\n" + printf "%%%%%% Consider using %s-emu instead\r\n", $arg1 + end printf "%% Stacktrace (%u)\n", $etp_stack_end-$etp_stack_p if ($arg0)->i != 0 - etp-1 ((Eterm)($arg0)->i) 0 - printf " (I)\n" + printf "I: " + etp ((Eterm)($arg0)->i) + end + if ($arg0)->cp != 0 + printf "cp:" + etp ((Eterm)($arg0)->cp) end +end + +define etp-stack-preamble-emu + set $etp_stack_p = E + set $etp_stack_end = ($arg0)->hend + printf "%% Stacktrace (%u)\n", $etp_stack_end-$etp_stack_p + printf "I: " + etp ((BeamInstr)I) if ($arg0)->cp != 0 - etp-1 ((Eterm)($arg0)->cp) 0 - printf " (cp)\n" + printf "cp: " + etp ((Eterm)($arg0)->cp) end end +define etp-stacktrace-1 + set $etp_stack_stop = (Eterm*)($arg0) + set $etp_stack_send = (Eterm*)($arg1) + set $etp_stack_cnt = 0 + while $etp_stack_stop < $etp_stack_send + if ($etp_stack_stop[0] & 0x3) == 0x0 + # Continuation pointer + printf "%d: ", $etp_stack_cnt + etp $etp_stack_stop[0] + end + set $etp_stack_stop++ + set $etp_stack_cnt++ + end +end + +define etp-stacktrace-emu +# Args: Process* +# +# Non-reentrant +# + etp-stack-preamble-emu ($arg0) + etp-stacktrace-1 $etp_stack_p $etp_stack_end +end + +document etp-stacktrace-emu +%--------------------------------------------------------------------------- +% etp-stacktrace-emu Process* +% +% Take an Process* and print a stactrace for the process. +% This macro assumes that the current frame is the process_main frame +% and that E is not optimized out. +%--------------------------------------------------------------------------- +end + define etp-stacktrace # Args: Process* # # Non-reentrant # - etp-stack-preamble ($arg0) - while $etp_stack_p < $etp_stack_end - if ($etp_stack_p[0] & 0x3) == 0x0 - # Continuation pointer - etp $etp_stack_p[0] - end - set $etp_stack_p++ - end + etp-stack-preamble ($arg0) "etp-stacktrace" + etp-stacktrace-1 $etp_stack_p $etp_stack_end end document etp-stacktrace @@ -1488,16 +1533,48 @@ document etp-stacktrace %--------------------------------------------------------------------------- end +define etp-stackdump-1 + # Args: Eterm *stop, Eterm *hend + # + # Non-reentrant + # + set $etp_stackdump_stop = (Eterm*)($arg0) + set $etp_stackdump_send = (Eterm*)($arg1) + set $etp_stackdump_cnt = 0 + while $etp_stackdump_stop < $etp_stackdump_send + printf "%d: ", $etp_stackdump_cnt + etp $etp_stackdump_stop[0] + set $etp_stackdump_stop++ + set $etp_stackdump_cnt++ + end +end + +define etp-stackdump-emu +# Args: Process* +# +# Non-reentrant +# + etp-stack-preamble-emu ($arg0) + etp-stackdump-1 $etp_stack_p $etp_stack_end +end + +document etp-stacktrace-emu +%--------------------------------------------------------------------------- +% etp-stacktrace-emu Process* +% +% Take an Process* and print a stactdump for the process. +% This macro assumes that the current frame is the process_main frame +% and that E is not optimized out. +%--------------------------------------------------------------------------- +end + define etp-stackdump # Args: Process* # # Non-reentrant # - etp-stack-preamble ($arg0) - while $etp_stack_p < $etp_stack_end - etp $etp_stack_p[0] - set $etp_stack_p++ - end + etp-stack-preamble ($arg0) "etp-stackdump" + etp-stackdump-1 $etp_stack_p $etp_stack_end end document etp-stackdump @@ -2959,12 +3036,21 @@ define etp-fds end end +document etp-fds +%--------------------------------------------------------------------------- +% etp-fds +% +% Print the state of the fds currently in check_io. Only works in running systems. +%--------------------------------------------------------------------------- +end + define etp-disasm-1 - set $code_ptr = ((BeamInstr*)$arg0) - set $addr = *$code_ptr + set $code_ptr = ((BeamInstr*)($arg0)) + set $addr32 = (BeamInstr)(Uint32)*$code_ptr + set $addr64 = (BeamInstr)(Uint64)*$code_ptr set $i = 0 - while $i < (sizeof(opc) / sizeof(OpEntry)) - if $addr == beam_ops[$i] + while $i < num_instructions + if $addr32 == beam_ops[$i] || $addr64 == beam_ops[$i] printf "%s %d", opc[$i].name, opc[$i].sz set $next_i = $code_ptr + opc[$i].sz set $i += 4999 @@ -2974,6 +3060,11 @@ define etp-disasm-1 end define etp-disasm + if $argc == 1 + set $code_end = $arg0 + else + set $code_end = $arg1 + end etp-cp-func-info-1 $arg0 if $etp_cp_p == 0 printf "invalid argument" @@ -2982,7 +3073,7 @@ define etp-disasm printf ": " etp-disasm-1 $arg0 printf "\r\n" - while $next_i < ((BeamInstr*)$arg1) + while $next_i < ((BeamInstr*)$code_end) set $prev_i = $next_i etp-cp-func-info-1 $next_i etp-mfa-1 $etp_cp_p $cp_cp_p_offset @@ -2998,6 +3089,16 @@ define etp-disasm end end +document etp-disasm +%--------------------------------------------------------------------------- +% etp-fds BeamInstr* (BeamInstr*) +% +% Disassemble the instructions inbetween arg0 and arg1, +% if no second argument is given only the current +% instruction is printed. +%--------------------------------------------------------------------------- +end + ############################################################################ # # Timer Wheel diff --git a/erts/etc/unix/gcov-gen-html b/erts/etc/unix/gcov-gen-html new file mode 100755 index 0000000000..3fd9f1ca49 --- /dev/null +++ b/erts/etc/unix/gcov-gen-html @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +@ARGV == 2 or die "Usage: gcov-gen-html \$ERL_TOP <output directory>\n"; + +my $srcdir = shift @ARGV; +my $outdir = shift @ARGV; + +my $verbose = 1; +my $flavor = "smp"; + +# setup filenames and paths, observe geninfos --base-directory +# it needs a correct path just after the $geninfo + +my $lcov_path = ""; #/usr/local/bin/"; + +my $geninfo = $lcov_path . "geninfo --no-checksum --base-directory"; +my $genhtml = $lcov_path . "genhtml"; + +# src paths + +my $emu_src_path = "$srcdir/erts/emulator"; +my $elib_src_path = "$srcdir/erts/lib_src"; +my $pcre_src_path = "$emu_src_path"; +my $zlib_src_path = "$emu_src_path"; + +# obj paths + +my $emu_obj_path = <$emu_src_path/obj/*-linux-*/gcov/$flavor>; +my $elib_obj_path = <$elib_src_path/obj/*-linux-*/gcov>; +my $pcre_obj_path = <$emu_src_path/pcre/obj/*-linux-*/gcov>; +my $zlib_obj_path = <$emu_src_path/zlib/obj/*-linux-*/gcov>; + +# info files + +my $emu_info = "$srcdir/emulator-cover.info"; +my $elib_info = "$srcdir/elib-cover.info"; +my $pcre_info = "$srcdir/pcre-cover.info"; + +my $infofiles = "$emu_info $elib_info $pcre_info"; + +run("$geninfo $emu_src_path -o $emu_info $emu_obj_path"); +run("$geninfo $elib_src_path -o $elib_info $elib_obj_path"); +run("$geninfo $pcre_src_path -o $pcre_info $pcre_obj_path"); + +if (<$zlib_obj_path/*.o>) { + my $zlib_info = "$srcdir/zlib-cover.info"; + $infofiles .= " $zlib_info"; + run("$geninfo $zlib_src_path -o $zlib_info $zlib_obj_path"); +} + +run("$genhtml -o $outdir $infofiles"); + + + +sub run { + my $cmd = shift; + print STDERR "\nrun($cmd)\n" if $verbose > 0; + system("$cmd 2>&1") == 0 or die "\nCan't run \"$cmd\": $?"; +} diff --git a/erts/etc/win32/msys_tools/vc/cc.sh b/erts/etc/win32/msys_tools/vc/cc.sh index 2b0482e876..71af14b9b2 100644 --- a/erts/etc/win32/msys_tools/vc/cc.sh +++ b/erts/etc/win32/msys_tools/vc/cc.sh @@ -195,7 +195,6 @@ mkdir $TMPOBJDIR # Compile for x in $SOURCES; do - start_time=`date '+%s'` # Compile each source if [ $LINKING = false ]; then # We should have an output defined, which is a directory @@ -260,16 +259,28 @@ for x in $SOURCES; do else tail -n +2 $ERR_FILE >&2 if test $DEPENDENCIES = true; then - if test `grep -v $x $MSG_FILE | grep -c '#line'` != "0"; then - o=`echo $x | sed 's,.*/,,' | sed 's,\.cp*$,.o,'` - echo -n $o':' -# cat $MSG_FILE | grep '#line' | grep -v $x | awk -F\" '{printf("%s\n",$2)}' | sort -u | grep -v " " | xargs -n 1 win2msys_path.sh | awk '{printf("\\\n %s ",$0)}' - cat $MSG_FILE | grep '#line' | grep -v $x | awk -F\" '{printf("%s\n",$2)}' | sort -u | grep -v " " | sed 's,^\([A-Za-z]\):[\\/]*,/\1/,;s,\\\\*,/,g'| awk '{printf("\\\n %s ",$0)}' - echo - echo - after_sed=`date '+%s'` - echo Made dependencies for $x':' `expr $after_sed '-' $start_time` 's' >&2 - fi + perl -e ' +my $file = "'$x'"; +while (<>) { + next unless /^#line/; + next if /$file/o; + (undef,$_) = split(/\"/); + next if / /; + $all{$_} = 1; +} +foreach (sort keys %all) { + s@^([A-Za-z]):@/$1@; + s@\\\\@/@g; + push @f, "\\\n $_ "; +} +if (@f) { + my $oname = $file; + $oname =~ s@.*/@@; + $oname =~ s@[.]cp*@.o@; + print $oname, ":", @f; + print "\n\n"; + print STDERR "Made dependencies for $file\n"; +}' $MSG_FILE else cat $MSG_FILE fi |