diff options
Diffstat (limited to 'erts/etc')
-rw-r--r-- | erts/etc/common/erlexec.c | 84 | ||||
-rw-r--r-- | erts/etc/unix/cerl.src | 27 | ||||
-rw-r--r-- | erts/etc/unix/etp-commands.in | 478 | ||||
-rwxr-xr-x | erts/etc/unix/gcov-gen-html | 62 | ||||
-rw-r--r-- | erts/etc/unix/to_erl.c | 2 | ||||
-rw-r--r-- | erts/etc/win32/msys_tools/vc/cc.sh | 33 | ||||
-rw-r--r-- | erts/etc/win32/msys_tools/vc/ld.sh | 5 |
7 files changed, 508 insertions, 183 deletions
diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 23bbb86333..477a501876 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -174,7 +174,6 @@ static char *plusz_val_switches[] = { "dbbl", "dntgc", "ebwt", - "tma", NULL }; @@ -256,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; @@ -393,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) @@ -409,7 +426,6 @@ int main(int argc, char **argv) int process_args = 1; int print_args_exit = 0; int print_qouted_cmd_exit = 0; - erts_cpu_info_t *cpuinfo = NULL; char* emu_name; #ifdef __WIN32__ @@ -468,8 +484,6 @@ int main(int argc, char **argv) /* * Construct the path of the executable. */ - cpuinfo = erts_cpu_info_create(); - #if defined(__WIN32__) && defined(WIN32_ALWAYS_DEBUG) emu_type = "debug"; #endif @@ -527,9 +541,6 @@ int main(int argc, char **argv) i++; } - erts_cpu_info_destroy(cpuinfo); - cpuinfo = NULL; - if (malloc_lib) { if (strcmp(malloc_lib, "libc") != 0) usage("+MYm"); @@ -588,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); @@ -617,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]); @@ -641,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 @@ -663,15 +669,6 @@ int main(int argc, char **argv) } break; - case 'i': - if (strcmp(argv[i], "-instr") == 0) { - add_Eargs("-Mim"); - add_Eargs("true"); - } - else - add_arg(argv[i]); - break; - case 'e': if (strcmp(argv[i], "-extra") == 0) { process_args = 0; @@ -820,10 +817,8 @@ int main(int argc, char **argv) case '+': switch (argv[i][1]) { - case '#': case 'a': case 'A': - case 'b': case 'C': case 'e': case 'i': @@ -1389,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]; @@ -1399,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) @@ -1449,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; } @@ -1691,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; @@ -1782,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 } @@ -2037,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. @@ -2061,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 bcd64d242e..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 @@ -320,7 +333,7 @@ if [ "x$GDB" = "x" ]; then if [ "$1" = "-p" ]; then echo 'set $etp_rr_run_until_beam = 1' >> $cmdfile fi - cat $ROOTDIR/erts/etc/unix/etp-commands.in >> $cmdfile + cat $ROOTDIR/erts/etc/unix/etp-commands >> $cmdfile exec rr replay -x $cmdfile $* elif [ $1 = ps ]; then shift diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index bb7b1a73f5..20809d61e8 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, @@ -132,14 +133,14 @@ define etp-1 if (($arg0) & 0x3) == 1 # Cons pointer if $etp_flat - printf "<etpf-cons %#x>", ($arg0) + printf "<etpf-cons %p>", (($arg0)-1) else etp-list-1 ($arg0) ($arg1) end else if (($arg0) & 0x3) == 2 if $etp_flat - printf "<etpf-boxed %#x>", ($arg0) + printf "<etpf-boxed %p>", (($arg0)-2) else etp-boxed-1 ($arg0) ($arg1) end @@ -187,7 +188,7 @@ define etp-list-1 # Reentrant # if (($arg0) & 0x3) != 0x1 - printf "#NotCons<%#x>", ($arg0) + printf "#NotCons<%p>", ($arg0) else # Cons pointer if $etp_chart @@ -210,7 +211,7 @@ define etp-list-printable-1 # Returns: $etp_list_printable # if (($arg0) & 0x3) != 0x1 - printf "#NotCons<%#x>", ($arg0) + printf "#NotCons<%p>", ($arg0) else # Loop to check if it is a printable string set $etp_list_p = ($arg0) @@ -272,7 +273,7 @@ define etp-list-2 # Reentrant # if (($arg0) & 0x3) != 0x1 - printf "#NotCons<%#x>", ($arg0) + printf "#NotCons<%p>", ($arg0) else # Cons pointer if ($arg1) >= $etp_max_depth @@ -307,7 +308,7 @@ define etpf-cons # Reentrant capable # if ((Eterm)($arg0) & 0x3) != 0x1 - printf "#NotCons<%#x>", ($arg0) + printf "#NotCons<%p>", ($arg0) else # Cons pointer set $etp_flat = 1 @@ -336,13 +337,13 @@ define etp-boxed-1 # Reentrant # if (($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", ($arg0) + printf "#NotBoxed<%p>", ($arg0) else if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3) != 0x0 if $etp_chart etp-chart-entry-1 (($arg0)&~0x3) ($arg1) 1 end - printf "#BoxedError<%#x>", ($arg0) + printf "#BoxedError<%p>", ($arg0) else if $etp_chart etp-chart-entry-1 (($arg0)&~0x3) ($arg1) \ @@ -390,10 +391,10 @@ define etp-boxed-immediate-1 # Non-reentrant # if (($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", ($arg0) + printf "#NotBoxed<%p>", ($arg0) else if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3) != 0x0 - printf "#BoxedError<%#x>", ($arg0) + printf "#BoxedError<%p>", ($arg0) else set $etp_boxed_immediate_p = (Eterm*)(($arg0) & ~0x3) set $etp_boxed_immediate_h = ($etp_boxed_immediate_p[0] >> 2) & 0xF @@ -438,12 +439,12 @@ define etp-boxed-immediate-1 while $etp_boxed_immediate_arity > 0 set $etp_boxed_immediate_p++ if $etp_boxed_immediate_arity > 1 - printf "%#x,", *$etp_boxed_immediate_p + printf "%p,", *$etp_boxed_immediate_p else - printf "%#x", *$etp_boxed_immediate_p + printf "%p", *$etp_boxed_immediate_p if ($etp_boxed_immediate_h == 0xA) set $etp_boxed_immediate_p++ - printf ":%#x", *$etp_boxed_immediate_p + printf ":%p", *$etp_boxed_immediate_p end printf ">" end @@ -558,7 +559,7 @@ define etp-immediate-1 # Reentrant capable # if (($arg0) & 0x3) != 0x3 - printf "#NotImmediate<%#x>", ($arg0) + printf "#NotImmediate<%p>", ($arg0) else if (($arg0) & 0xF) == 0x3 etp-pid-1 ($arg0) @@ -580,7 +581,7 @@ define etp-immediate-1 if (($arg0) == $etp_nil) printf "[]" else - printf "#UnknownImmediate<%#x>", ($arg0) + printf "#UnknownImmediate<%p>", ($arg0) end end end @@ -598,7 +599,7 @@ define etp-atom-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3f) != 0xb - printf "#NotAtom<%#x>", ($arg0) + printf "#NotAtom<%p>", ($arg0) else set $etp_atom_1_ap = (Atom*)erts_atom_table.seg_table[(Eterm)($arg0)>>16][((Eterm)($arg0)>>6)&0x3FF] set $etp_atom_1_i = ($etp_atom_1_ap)->len @@ -652,7 +653,7 @@ define etp-char-1 # Non-reentrant # if (($arg0) < 0) || (0377 < ($arg0)) - printf "#NotChar<%#x>", ($arg0) + printf "#NotChar<%p>", ($arg0) else if ($arg0) == ($arg1) printf "\\%c", ($arg0) @@ -787,7 +788,7 @@ define etp-pid-1 # Internal pid printf "<0.%u.%u>", $etp_pid_data & 0x7fff, ($etp_pid_data >> 15) & 0x1fff else - printf "#NotPid<%#x>", ($arg0) + printf "#NotPid<%p>", ($arg0) end end @@ -797,11 +798,11 @@ define etp-extpid-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", (Eterm)($arg0) + printf "#NotBoxed<%p>", (Eterm)($arg0) else set $etp_extpid_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3) if ($etp_extpid_1_p->header & 0x3f) != 0x30 - printf "#NotExternalPid<%#x>", $etp_extpid_1_p->header + printf "#NotExternalPid<%p>", $etp_extpid_1_p->header else ## External pid set $etp_extpid_1_number = $etp_extpid_1_p->data.ui[0]&0x7fff @@ -812,7 +813,7 @@ define etp-extpid-1 set $etp_extpid_1_node = $etp_extpid_1_np->sysname if ($etp_extpid_1_node & 0x3f) != 0xb # Should be an atom - printf "#ExternalPidError<%#x>", ($arg0) + printf "#ExternalPidError<%p>", ($arg0) else if $etp_extpid_1_dep == erts_this_dist_entry printf "<0:" @@ -847,7 +848,7 @@ define etp-port-1 # Internal port printf "#Port<0.%u>", $etp_port_data else - printf "#NotPort<%#x>", ($arg0) + printf "#NotPort<%p>", ($arg0) end end @@ -857,11 +858,11 @@ define etp-extport-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", (Eterm)($arg0) + printf "#NotBoxed<%p>", (Eterm)($arg0) else set $etp_extport_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3) if ($etp_extport_1_p->header & 0x3F) != 0x34 - printf "#NotExternalPort<%#x>", $etp_extport_1->header + printf "#NotExternalPort<%p>", $etp_extport_1->header else ## External port set $etp_extport_1_number = $etp_extport_1_p->data.ui[0]&0x3ffff @@ -871,7 +872,7 @@ define etp-extport-1 set $etp_extport_1_node = $etp_extport_1_np->sysname if ($etp_extport_1_node & 0x3f) != 0xb # Should be an atom - printf "#ExternalPortError<%#x>", ($arg0) + printf "#ExternalPortError<%p>", ($arg0) else if $etp_extport_1_dep == erts_this_dist_entry printf "#Port<0:" @@ -893,15 +894,15 @@ define etp-bignum-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", (Eterm)($arg0) + printf "#NotBoxed<%p>", (Eterm)($arg0) else set $etp_bignum_1_p = (Eterm*)((Eterm)($arg0) & ~0x3) if ($etp_bignum_1_p[0] & 0x3b) != 0x08 - printf "#NotBignum<%#x>", $etp_bignum_1_p[0] + printf "#NotBignum<%p>", $etp_bignum_1_p[0] else set $etp_bignum_1_i = ($etp_bignum_1_p[0] >> 6) if $etp_bignum_1_i < 1 - printf "#BignumError<%#x>", (Eterm)($arg0) + printf "#BignumError<%p>", (Eterm)($arg0) else if $etp_bignum_1_p[0] & 0x04 printf "-" @@ -932,11 +933,11 @@ define etp-float-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", (Eterm)($arg0) + printf "#NotBoxed<%p>", (Eterm)($arg0) else set $etp_float_1_p = (Eterm*)((Eterm)($arg0) & ~0x3) if ($etp_float_1_p[0] & 0x3f) != 0x18 - printf "#NotFloat<%#x>", $etp_float_1_p[0] + printf "#NotFloat<%p>", $etp_float_1_p[0] else printf "%f", *(double*)($etp_float_1_p+1) end @@ -951,14 +952,14 @@ define etp-ref-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", (Eterm)($arg0) + printf "#NotBoxed<%p>", (Eterm)($arg0) else set $etp_ref_1_p = (ErtsORefThing *)((Eterm)($arg0) & ~0x3) if ($etp_ref_1_p->header & 0x3b) != 0x10 - printf "#NotRef<%#x>", $etp_ref_1_p->header + printf "#NotRef<%p>", $etp_ref_1_p->header else if $etp_ref_1_p->header != etp_ref_header && $etp_ref_1_p->header != etp_magic_ref_header - printf "#InternalRefError<%#x>", ($arg0) + printf "#InternalRefError<%p>", ($arg0) else set $etp_magic_ref = 0 set $etp_ref_1_i = 3 @@ -998,11 +999,11 @@ define etp-extref-1 # Non-reentrant # if ((Eterm)($arg0) & 0x3) != 0x2 - printf "#NotBoxed<%#x>", (Eterm)($arg0) + printf "#NotBoxed<%p>", (Eterm)($arg0) else set $etp_extref_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3) if ($etp_extref_1_p->header & 0x3F) != 0x38 - printf "#NotExternalRef<%#x>", $etp_extref_1->header + printf "#NotExternalRef<%p>", $etp_extref_1->header else ## External ref set $etp_extref_1_nump = (Uint32 *) 0 @@ -1041,7 +1042,7 @@ define etp-extref-1 end end if $etp_extref_1_error - printf "#ExternalRefError<%#x>", ($arg0) + printf "#ExternalRefError<%p>", ($arg0) else set $etp_extref_1_i-- while $etp_extref_1_i >= 0 @@ -1166,7 +1167,7 @@ define etp-cp-1 if *(Eterm*)($etp_cp) == beam_return_to_trace[0] printf "#Cp<return to trace>" else - printf "#Cp<%#x>", $etp_cp + printf "#Cp<%p>", $etp_cp end end end @@ -1452,28 +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 - etp-1 ((Eterm)($arg0)->i) 0 - printf " (I)\n" + if ($arg0)->i != 0 + printf "I: " + etp ((Eterm)($arg0)->i) + end if ($arg0)->cp != 0 - etp-1 ((Eterm)($arg0)->cp) 0 - printf " (cp)\n" + 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 + 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 @@ -1486,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 @@ -1741,7 +1820,7 @@ define etp-term-dump-pid # Internal pid printf "| <0.%04u.%03u> ", $etp_pid_data & 0x7fff, ($etp_pid_data >> 15) & 0x1fff else - printf "| #NotPid<%#x> ", ($arg0) + printf "| #NotPid<%p> ", ($arg0) end end @@ -1789,7 +1868,7 @@ define etp-pix2proc # Args: Eterm # set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[((int) $arg0)]) - printf "(Process *) %p\n", $proc + printf "(Process*)%p\n", $proc end define etp-pid2proc-1 @@ -1803,7 +1882,7 @@ define etp-pid2proc # Args: Eterm # etp-pid2proc-1 $arg0 - printf "(Process *) %p\n", $proc + printf "(Process*)%p\n", $proc end define etp-proc-state-int @@ -2083,12 +2162,12 @@ define etp-process-info-int printf "\n Flags: " etp-proc-flags $etp_proc if $proxy_process != 0 - printf " Pointer: (Process *) %p\n", $etp_proc + printf " Pointer: (Process*)%p\n", $etp_proc printf " *** PROXY process struct *** refer to: \n" etp-pid2proc-1 $etp_proc->common.id etp-process-info $proc else - if (*(((Uint32 *) &($etp_proc->state))) & 0x4) == 0 + if (*(((Uint32 *) &($etp_proc->state))) & 0x800) == 0 if ($etp_proc->common.u.alive.reg) printf " Registered name: " etp-1 $etp_proc->common.u.alive.reg->name @@ -2096,7 +2175,7 @@ define etp-process-info-int end end printf " Current function: " - if ($etp_proc->current) + if ($etp_proc->current && !($etp_proc->state.counter & 0x800)) etp-1 $etp_proc->current->module printf ":" etp-1 $etp_proc->current->function @@ -2133,7 +2212,7 @@ define etp-process-info-int end printf " Parent: " etp-1 ((Eterm)($etp_proc->parent)) - printf "\n Pointer: (Process *) %p\n", $etp_proc + printf "\n Pointer: (Process*)%p\n", $etp_proc end if ($arg1) etp-sigqs $etp_proc @@ -2156,6 +2235,43 @@ document etp-process-info %--------------------------------------------------------------------------- end +define etp-processes-free-runq-int + set $runq_prio = 0 + while $runq_prio < 3 + set $runq_proc = ($arg0)->procs.prio[$runq_prio].first + while $runq_proc != 0 + if $runq_proc->state.counter & 0x400 + printf "---\n" + printf " Pix: FREE -> run_queue %p\n", ($arg0) + etp-process-info-int $runq_proc ($arg1) + end + set $runq_proc = $runq_proc->next + end + set $runq_prio++ + end +end + +define etp-processes-free-de-int + set $de_ix = 0 + set $de = ($arg0) + while $de + set $susp = $de->suspended + set $susp_curr = $susp + set $first_loop = 1 + while $susp_curr != 0 && (($susp_curr != $susp) || $first_loop) + if ($susp_curr->u.pid & 0x3) == 0 + printf "---\n" + printf " Pix: FREE " + etp $de->sysname + etp-process-info-int $susp_curr->u.pid ($arg2) + end + set $first_loop = 0 + set $susp_curr = $susp_curr->next + end + set $de = $de->next + end +end + define etp-processes-int if (!erts_initialized) printf "No processes, since system isn't initialized!\n" @@ -2176,11 +2292,36 @@ define etp-processes-int set $proc_cnt-- end if $proc_ix == $proc_printile - printf "--- %d%% (%d / %d) searched\n", $proc_printile / $proc_decentile * 10, $proc_ix, $proc_max_ix + printf "--- %d%% (%d / %d) searched, looking for %d more\n", $proc_printile / $proc_decentile * 10, $proc_ix, $proc_max_ix, $proc_cnt set $proc_printile += $proc_decentile end set $proc_ix++ end + + ## We should also check for any FREE processes that are running + ## They can be found in esdp->current_process, dep->suspendees and + ## runq. Running FREE processes are processes that either are yielding + ## when exiting or running on a dirty scheduler while having exited. + set $sched_ix = 0 + while $sched_ix < erts_no_schedulers + set $sched_data = &erts_aligned_scheduler_data[$sched_ix].esd + if $sched_data->current_process != 0 + if $sched_data->current_process.state.counter & 0x400 + printf "---\n" + printf " Pix: FREE -> scheduler %d\n", $sched_ix+1 + etp-process-info-int $sched_data->current_process ($arg0) + end + end + etp-processes-free-runq-int $sched_data->run_queue ($arg0) + set $sched_ix++ + end + etp-processes-free-runq-int &erts_aligned_run_queues[erts_no_run_queues].runq ($arg0) + etp-processes-free-runq-int &erts_aligned_run_queues[erts_no_run_queues+1].runq ($arg0) + etp-processes-free-de-int erts_hidden_dist_entries erts_no_of_hidden_dist_entries ($arg0) + etp-processes-free-de-int erts_visible_dist_entries erts_no_of_visible_dist_entries ($arg0) + etp-processes-free-de-int erts_pending_dist_entries erts_no_of_pending_dist_entries ($arg0) + etp-processes-free-de-int erts_not_connected_dist_entries erts_no_of_not_connected_dist_entries ($arg0) + etp-processes-free-de-int erts_this_dist_entry 1 ($arg0) printf "---\n", end end @@ -2237,9 +2378,9 @@ define etp-process-memory-info end printf " " etp-1 $etp_pmem_proc->common.id - printf ": (Process *) %p ", $etp_pmem_proc + printf ": (Process*)%p ", $etp_pmem_proc if $proxy_process != 0 - printf "(Process *) %p ", $etp_pmem_proc + printf "(Process*)%p ", $etp_pmem_proc printf " *** PROXY process struct *** refer to next: \n" etp-pid2proc-1 $etp_pmem_proc->common.id printf " -" @@ -2313,7 +2454,7 @@ define etp-pix2port # Args: Eterm # set $port = (Port *) *((UWord *) &erts_port.r.o.tab[((int) $arg0)]) - printf "(Port *) %p\n", $port + printf "(Port*)%p\n", $port end define etp-id2port-1 @@ -2327,7 +2468,7 @@ define etp-id2port # Args: Eterm # etp-id2port-1 $arg0 - printf "(Port *) %p\n", $port + printf "(Port*)%p\n", $port end define etp-port-sched-flags-int @@ -2501,7 +2642,7 @@ define etp-port-info printf " Connected: " set $connected = *(((Eterm *) &(((Port *) $etp_pinfo_port)->connected))) etp-1 $connected - printf "\n Pointer: (Port *) %p\n", $etp_pinfo_port + printf "\n Pointer: (Port*)%p\n", $etp_pinfo_port end document etp-port-info @@ -2851,7 +2992,7 @@ define etp-scheduler-info-internal printf " Sleep Info Flags:" set $ssi_flags = *((Uint32 *) &$sched_data->ssi->flags) etp-ssi-flags $ssi_flags - printf " Pointer: (ErtsSchedulerData *) %p\n", $sched_data + printf " Pointer: (ErtsSchedulerData*)%p\n", $sched_data end define etp-run-queue-info-internal @@ -2884,7 +3025,7 @@ define etp-run-queue-info-internal end set $rq_flags = *((Uint32 *) &($runq->flags)) etp-rq-flags-int $rq_flags - printf " Pointer: (ErtsRunQueue *) %p\n", $runq + printf " Pointer: (ErtsRunQueue*)%p\n", $runq end define etp-fds @@ -2895,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 @@ -2910,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" @@ -2918,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 @@ -2934,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 @@ -2961,7 +3126,7 @@ define etp-timer-wheel printf "\n" while 1 printf "- Timeout pos: %ld\n", $tmr->timeout_pos - printf " Pointer: (ErtsTWheelTimer *) %p\n", $tmr + printf " Pointer: (ErtsTWheelTimer*)%p\n", $tmr set $tmr = $tmr->next if ($tmr == $tiw->w[$ix]) loop_break @@ -2991,7 +3156,7 @@ define etp-timer-wheel printf "\n" while 1 printf "- Timeout pos: %ld\n", $tmr->timeout_pos - printf " Pointer: (ErtsTWheelTimer *) %p\n", $tmr + printf " Pointer: (ErtsTWheelTimer*)%p\n", $tmr set $tmr = $tmr->next if ($tmr == $tiw->w[$ix]) loop_break @@ -3260,7 +3425,7 @@ define etp-offheapdump set $etp_offheapdump_p = $etp_offheapdump_p->next set $etp_offheapdump_i++ else - printf "#TaggedPtr<%#x>", $etp_offheapdump_p + printf "#TaggedPtr<%p>", $etp_offheapdump_p set $etp_offheapdump_p = 0 end end @@ -3299,12 +3464,12 @@ define etp-search-heaps # # Non-reentrant # - printf "%% Search all (<%u) process heaps for ", erts_max_processes + printf "%% Search all (<%u) process heaps for ", erts_proc.r.o.max set $etp_flat = 1 etp-1 ($arg0) 0 set $etp_flat = 0 printf ":...\n" - etp-search-heaps-1 ((Eterm*)((Eterm)($arg0)&~3)) + etp-search-heaps-1 ((Eterm*)((Eterm)($arg0)&~(Eterm)3)) end define etp-search-heaps-1 @@ -3312,8 +3477,8 @@ define etp-search-heaps-1 # # Non-reentrant # - set $etp_search_heaps_q = erts_max_processes / 10 - set $etp_search_heaps_r = erts_max_processes % 10 + set $etp_search_heaps_q = erts_proc.r.o.max / 10 + set $etp_search_heaps_r = erts_proc.r.o.max % 10 set $etp_search_heaps_t = 10 set $etp_search_heaps_m = $etp_search_heaps_q if $etp_search_heaps_r > 0 @@ -3323,7 +3488,7 @@ define etp-search-heaps-1 set $etp_search_heaps_i = 0 set $etp_search_heaps_found = 0 while $etp_search_heaps_i < erts_proc.r.o.max - set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[$proc_ix]) + set $proc = (Process *) *((UWord *) &erts_proc.r.o.tab[$etp_search_heaps_i]) if $proc if ($proc->heap <= ($arg0)) && \ (($arg0) < $proc->hend) @@ -3340,7 +3505,7 @@ define etp-search-heaps-1 while $etp_search_heaps_p && ($etp_search_heaps_cnt < $etp_max_depth) set $etp_search_heaps_cnt++ if (&($etp_search_heaps_p->mem) <= ($arg0)) && \ - (($arg0) < &($etp_search_heaps_p->mem)+$etp_search_heaps_p->size) + (($arg0) < &($etp_search_heaps_p->mem)+$etp_search_heaps_p->used_size) printf "process_tab[%d]->mbuf(%d)+%d\n", \ $etp_search_heaps_i, $etp_search_heaps_cnt, \ ($arg0)-&($etp_search_heaps_p->mem) @@ -3636,8 +3801,8 @@ define etp-overlapped-heaps # Non-reentrant # printf "%% Dumping heap addresses to \"etp-commands.bin\"\n" - set $etp_overlapped_heaps_q = erts_max_processes / 10 - set $etp_overlapped_heaps_r = erts_max_processes % 10 + set $etp_overlapped_heaps_q = erts_proc.r.o.max / 10 + set $etp_overlapped_heaps_r = erts_proc.r.o.max % 10 set $etp_overlapped_heaps_t = 10 set $etp_overlapped_heaps_m = $etp_overlapped_heaps_q if $etp_overlapped_heaps_r > 0 @@ -3663,7 +3828,7 @@ define etp-overlapped-heaps append binary value etp-commands.bin 'p' append binary value etp-commands.bin 's' append binary value etp-commands.bin '\0' - while $etp_overlapped_heaps_i < erts_max_processes + while $etp_overlapped_heaps_i < erts_proc.r.o.max if process_tab[$etp_overlapped_heaps_i] append binary value etp-commands.bin \ (Eterm)$etp_overlapped_heaps_i @@ -3804,7 +3969,7 @@ define etp-chart-entry-1 append binary value etp-commands.bin (Eterm)(($arg2)*sizeof(Eterm)) append binary value etp-commands.bin (Eterm)$etp_chart_id append binary value etp-commands.bin (Eterm)($arg1) -# printf "<dumped %#x %lu %lu %lu>", ($arg0)&~0x3, \ +# printf "<dumped %p %lu %lu %lu>", ($arg0)&~0x3, \ # (Eterm)(($arg2)*sizeof(Eterm)), (Eterm)$etp_chart_id, (Eterm)($arg1) end @@ -3828,22 +3993,79 @@ end # ETS table debug # +define etp-ets-tab-status-int +# Args: +# +# Non-reentrant + if ($arg0 & 0x1) + printf "priv" + end + if ($arg0 & 0x2) + printf "prot" + end + if ($arg0 & 0x4) + printf "pub" + end + if ($arg0 & 0x8) + printf "|del" + end + if ($arg0 & 0x10) + printf "|set" + end + if ($arg0 & 0x20) + printf "|bag" + end + if ($arg0 & 0x40) + printf "|dbag" + end + if ($arg0 & 0x80) + printf "|oset" + end + if ($arg0 & 0x100) + printf "|caoset" + end + if ($arg0 & 0x200) + printf "|flocked" + end + if ($arg0 & 0x400) + printf "|fread" + end + if ($arg0 & 0x800) + printf "|named" + end + if ($arg0 & 0x1000) + printf "|busy" + end +end + define etp-ets-tables # Args: # # Non-reentrant - printf "%% Dumping < %lu ETS tables\n", (unsigned long)db_max_tabs - while $etp_ets_tables_i < db_max_tabs - if (meta_main_tab[$etp_ets_tables_i].u.next_free & 3) == 0 - printf "%% %d:", $etp_ets_tables_i - etp-1 ((Eterm)(meta_main_tab[$etp_ets_tables_i].u.tb->common.id)) 0 + set $sched_ix = 0 + while $sched_ix < erts_no_schedulers + set $ets_tabs = &erts_aligned_scheduler_data[$sched_ix].esd.ets_tables + set $no_ets_tabs = *(unsigned long *)&($ets_tabs->count) + printf "\n%% %lu ETS tables created on scheduler %lu...\n\n", $no_ets_tabs, (unsigned long)$sched_ix+1 + set $ets_tab = $ets_tabs->clist + set $first_ets_tab = $ets_tab + while $ets_tab + set $refn = &((ErtsMagicBinary *)$ets_tab->common->btid)->refn + printf "%% " + etp-1 $ets_tab->common.the_name 0 + printf " #Ref<0.%u.%u.%u> ", (unsigned)$refn[2], (unsigned)$refn[1], (unsigned)$refn[0] + etp-1 $ets_tab->common.owner 0 printf " " - etp-1 ((Eterm)(meta_main_tab[$etp_ets_tables_i].u.tb->common.owner)) 0 - printf "\n" + etp-ets-tab-status-int $ets_tab->common.status + printf " (DbTable*)%p\n", $ets_tab + if $ets_tab->common.all.next == $first_ets_tab + set $ets_tab = (DbTable *) 0 + else + set $ets_tab = $ets_tab->common.all.next + end end - set $etp_ets_tables_i++ + set $sched_ix++ end - set $etp_ets_tables_i = 0 end document etp-ets-tables @@ -4060,14 +4282,6 @@ define etp-block-size-1 set $etp_blk_sz = ($arg0)->bhdr & ~7 else # Allocated block - if !$etp_MBC_ABLK_SZ_MASK - if etp_arch_bits == 64 - set $etp_MBC_ABLK_OFFSET_SHIFT = (64 - 24) - else - set $etp_MBC_ABLK_OFFSET_SHIFT = (32 - 9) - end - set $etp_MBC_ABLK_SZ_MASK = ((UWord)1 << $etp_MBC_ABLK_OFFSET_SHIFT) - 1 - 7 - end set $etp_blk_sz = ($arg0)->bhdr & $etp_MBC_ABLK_SZ_MASK end end @@ -4082,14 +4296,7 @@ define etp-block2mbc-1 set $etp_mbc = ($arg0)->u.carrier else # Allocated block - if !$etp_MBC_ABLK_OFFSET_SHIFT - if etp_arch_bits == 64 - set $etp_MBC_ABLK_OFFSET_SHIFT = (64 - 24) - else - set $etp_MBC_ABLK_OFFSET_SHIFT = (32 - 9) - end - end - set $etp_mbc = (Carrier_t*) ((((UWord)($arg0) >> 18) - (($arg0)->bhdr >> $etp_MBC_ABLK_OFFSET_SHIFT)) << 18) + set $etp_mbc = (Carrier_t*) ((((UWord)($arg0) >> 18) - ((($arg0)->bhdr & $etp_MBC_ABLK_OFFSET_MASK) >> $etp_MBC_ABLK_OFFSET_SHIFT)) << 18) end end @@ -4133,7 +4340,7 @@ document etp-smp-atomic %--------------------------------------------------------------------------- end -define etp-carrier-blocks +define etp-carrier-blocks-1 set $etp_crr = (Carrier_t*) $arg0 etp-smp-atomic $etp_crr->allctr $etp_alc set $etp_alc = (Allctr_t*)($etp_alc & ~7) @@ -4145,12 +4352,6 @@ define etp-carrier-blocks set $etp_fblk_cnt = 0 set $etp_aborted = 0 - if $argc == 2 - set $etp_be_silent = $arg1 - else - set $etp_be_silent = 0 - end - while 1 if !$etp_be_silent etp-block $etp_blk @@ -4173,6 +4374,12 @@ define etp-carrier-blocks printf "ERROR: Missing PREV_FREE_BLK_HDR_FLG (2) in block at %#lx\n", $etp_blk set $etp_error_cnt = $etp_error_cnt + 1 end + else + # Prev is ALLOCATED + if ($etp_blk->bhdr & 2) + printf "ERROR: Invalid PREV_FREE_BLK_HDR_FLG (2) set in block at %#lx\n", $etp_blk + set $etp_error_cnt = $etp_error_cnt + 1 + end end end if $etp_blk->bhdr & 1 @@ -4210,13 +4417,31 @@ define etp-carrier-blocks end end -document etp-carrier-blocks +define etp-carrier-print + set $etp_be_silent = 0 + etp-carrier-blocks-1 $arg0 +end + +document etp-carrier-print +%--------------------------------------------------------------------------- +% Print all memory blocks in carrier +% Args: (Carrier_t*) +%--------------------------------------------------------------------------- +end + +define etp-carrier-check + set $etp_be_silent = 1 + etp-carrier-blocks-1 $arg0 +end + +document etp-carrier-check %--------------------------------------------------------------------------- -% Check and (maybe) print all memory blocks in carrier -% Args: (Carrier_t*) [1=be_silent] +% Check all memory blocks in carrier +% Args: (Carrier_t*) %--------------------------------------------------------------------------- end + define etp-address-to-beam-opcode set $etp_i = 0 set $etp_min_diff = ((UWord)1 << (sizeof(UWord)*8 - 1)) @@ -4348,9 +4573,14 @@ define etp-init set $etp_arch64 = (sizeof(void *) == 8) if $etp_arch64 set $etp_nil = 0xfffffffffffffffb + set $etp_MBC_ABLK_OFFSET_BITS = 23 else set $etp_nil = 0xfffffffb + set $etp_MBC_ABLK_OFFSET_BITS = 8 end + set $etp_MBC_ABLK_OFFSET_SHIFT = (sizeof(UWord)*8 - 1 - $etp_MBC_ABLK_OFFSET_BITS) + set $etp_MBC_ABLK_OFFSET_MASK = ((((UWord)1 << $etp_MBC_ABLK_OFFSET_BITS) - 1) << $etp_MBC_ABLK_OFFSET_SHIFT) + set $etp_MBC_ABLK_SZ_MASK = ((UWord)1 << $etp_MBC_ABLK_OFFSET_SHIFT) - 1 - 7 set $etp_flat = 0 set $etp_chart_id = 0 set $etp_chart = 0 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/unix/to_erl.c b/erts/etc/unix/to_erl.c index ed4fe12e8b..1448980f77 100644 --- a/erts/etc/unix/to_erl.c +++ b/erts/etc/unix/to_erl.c @@ -415,7 +415,7 @@ int main(int argc, char **argv) if (len) { #ifdef DEBUG - (void)write(1, buf, len); + write_all(1, buf, len); #endif if (write_all(wfd, buf, len) != len) { fprintf(stderr, "Error in writing to FIFO.\n"); 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 diff --git a/erts/etc/win32/msys_tools/vc/ld.sh b/erts/etc/win32/msys_tools/vc/ld.sh index 8917251f51..22184faf76 100644 --- a/erts/etc/win32/msys_tools/vc/ld.sh +++ b/erts/etc/win32/msys_tools/vc/ld.sh @@ -178,7 +178,10 @@ if [ "$RES" = "0" -a -f "$CMANIFEST" ]; then RES=$? if [ "$RES" != "0" ]; then REMOVE=`echo "$OUTPUTRES" | sed 's,\\\;[12]$,,g'` - CREMOVE=`cygpath $REMOVE` + CREMOVE=`win2msys_path.sh $REMOVE` + ## If Defender or Search are enabled, they will lock just created files + ## and then mt will fail :/ + echo "If you get this error, make sure Windows Defender AND Windows Search is disabled">>/tmp/link.exe.${p}.1 rm -f "$CREMOVE" fi rm -f "$CMANIFEST" |