diff options
Diffstat (limited to 'erts/etc')
-rw-r--r-- | erts/etc/common/Makefile.in | 11 | ||||
-rw-r--r-- | erts/etc/common/ct_run.c | 11 | ||||
-rw-r--r-- | erts/etc/common/dialyzer.c | 12 | ||||
-rw-r--r-- | erts/etc/common/erlc.c | 16 | ||||
-rw-r--r-- | erts/etc/common/erlexec.c | 124 | ||||
-rw-r--r-- | erts/etc/common/escript.c | 25 | ||||
-rw-r--r-- | erts/etc/common/etc_common.h | 65 | ||||
-rw-r--r-- | erts/etc/common/inet_gethost.c | 4 | ||||
-rw-r--r-- | erts/etc/common/typer.c | 12 | ||||
-rw-r--r-- | erts/etc/unix/cerl.src | 23 | ||||
-rw-r--r-- | erts/etc/unix/dyn_erl.c | 8 | ||||
-rw-r--r-- | erts/etc/unix/etp-commands.in | 387 | ||||
-rw-r--r-- | erts/etc/unix/run_erl.c | 4 |
13 files changed, 372 insertions, 330 deletions
diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in index 5b1b9119ce..1f35cef669 100644 --- a/erts/etc/common/Makefile.in +++ b/erts/etc/common/Makefile.in @@ -56,7 +56,7 @@ ERTS_INCL = -I$(ERL_TOP)/erts/include \ CC = @CC@ WFLAGS = @WFLAGS@ -CFLAGS = @CFLAGS@ @DEFS@ $(TYPE_FLAGS) @WFLAGS@ -I$(SYSDIR) -I$(EMUDIR) \ +CFLAGS = @CFLAGS@ @DEFS@ $(TYPE_FLAGS) @WFLAGS@ -I$(SYSOSDIR) -I$(EMUDIR) -I. \ -I$(COMSYSDIR) $(ERTS_INCL) -DOTP_SYSTEM_VERSION=\"$(SYSTEM_VSN)\" LD = @LD@ LIBS = @LIBS@ @@ -69,9 +69,9 @@ endif ifeq ($(TARGET),win32) ifeq ($(TYPE),debug) -CFLAGS = $(subst -O2,-g,@CFLAGS@ @DEFS@ $(TYPE_FLAGS) @WFLAGS@ -I$(SYSDIR) \ - -I$(EMUDIR) -I$(COMSYSDIR) $(ERTS_INCL) \ - -DOTP_SYSTEM_VERSION=\"$(SYSTEM_VSN)\") +CFLAGS = $(subst -O2,-g,@CFLAGS@ @DEFS@ $(TYPE_FLAGS) @WFLAGS@ -I$(SYSOSDIR) \ + -I$(EMUDIR) -I$(COMSYSDIR) $(ERTS_INCL) \ + -DOTP_SYSTEM_VERSION=\"$(SYSTEM_VSN)\") LDFLAGS += -g endif endif @@ -81,7 +81,8 @@ OBJDIR = $(ERL_TOP)/erts/obj$(TYPEMARKER)/$(TARGET) EMUDIR = $(ERL_TOP)/erts/emulator/beam COMSYSDIR = $(ERL_TOP)/erts/emulator/sys/common EMUOSDIR = $(ERL_TOP)/erts/emulator/@ERLANG_OSTYPE@ -SYSDIR = $(ERL_TOP)/erts/emulator/sys/@ERLANG_OSTYPE@ +SYSDIR = $(ERL_TOP)/erts/emulator/sys/common +SYSOSDIR = $(ERL_TOP)/erts/emulator/sys/@ERLANG_OSTYPE@ DRVDIR = $(ERL_TOP)/erts/emulator/drivers/@ERLANG_OSTYPE@ UXETC = ../unix WINETC = ../win32 diff --git a/erts/etc/common/ct_run.c b/erts/etc/common/ct_run.c index 6639c83778..efa7ac3493 100644 --- a/erts/etc/common/ct_run.c +++ b/erts/etc/common/ct_run.c @@ -20,16 +20,7 @@ /* * Purpose: Common Test front-end. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "sys.h" -#ifdef __WIN32__ -#include <winbase.h> -#endif - -#include <ctype.h> +#include "etc_common.h" #define NO 0 #define YES 1 diff --git a/erts/etc/common/dialyzer.c b/erts/etc/common/dialyzer.c index c8d977f6de..b45d5c7ca7 100644 --- a/erts/etc/common/dialyzer.c +++ b/erts/etc/common/dialyzer.c @@ -20,16 +20,8 @@ /* * Purpose: Dialyzer front-end. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "sys.h" -#ifdef __WIN32__ -#include <winbase.h> -#endif -#include <ctype.h> +#include "etc_common.h" #define NO 0 #define YES 1 @@ -263,7 +255,7 @@ int main(int argc, char** argv) } PUSH("+B"); - PUSH2("-boot", "start_clean"); + PUSH2("-boot", "no_dot_erlang"); PUSH3("-run", "dialyzer", "plain_cl"); PUSH("-extra"); diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c index cbbd2a37cd..aa99c69100 100644 --- a/erts/etc/common/erlc.c +++ b/erts/etc/common/erlc.c @@ -20,19 +20,7 @@ /* * Purpose: Common compiler front-end. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "sys.h" -#ifdef __WIN32__ -#include <winbase.h> -/* FIXE ME config_win32.h? */ -#define HAVE_STRERROR 1 -#define snprintf _snprintf -#endif - -#include <ctype.h> +#include "etc_common.h" #define NO 0 #define YES 1 @@ -246,7 +234,7 @@ int main(int argc, char** argv) PUSH("+A0"); PUSH("-noinput"); PUSH2("-mode", "minimal"); - PUSH2("-boot", "start_clean"); + PUSH2("-boot", "no_dot_erlang"); PUSH3("-s", "erl_compile", "compile_cmdline"); PUSH("-extra"); diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 793cb532b3..21a3f40c97 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -23,14 +23,9 @@ * additions required for Windows NT. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "etc_common.h" -#include "sys.h" #include "erl_driver.h" -#include <stdlib.h> -#include <stdarg.h> #include "erl_misc_utils.h" #ifdef __WIN32__ @@ -84,6 +79,7 @@ static const char plusM_au_allocs[]= { static char *plusM_au_alloc_switches[] = { "as", "asbcst", + "atags", "acul", "acnl", "acfml", @@ -134,6 +130,8 @@ static char *plusM_other_switches[] = { /* +s arguments with values */ static char *pluss_val_switches[] = { "bt", + "bwtdcpu", + "bwtdio", "bwt", "cl", "ct", @@ -141,6 +139,8 @@ static char *pluss_val_switches[] = { "fwi", "tbt", "wct", + "wtdcpu", + "wtdio", "wt", "ws", "ss", @@ -197,9 +197,7 @@ void error(char* format, ...); * Local functions. */ -#if !defined(ERTS_HAVE_SMP_EMU) || !defined(ERTS_HAVE_PLAIN_EMU) static void usage_notsup(const char *switchname, const char *alt); -#endif static char **build_args_from_env(char *env_var); static char **build_args_from_string(char *env_var); static void initial_argv_massage(int *argc, char ***argv); @@ -247,7 +245,7 @@ static int verbose = 0; /* If non-zero, print some extra information. */ static int start_detached = 0; /* If non-zero, the emulator should be * started detached (in the background). */ -static int start_smp_emu = 0; /* Start the smp emulator. */ +static int start_smp_emu = 1; /* Start the smp emulator. */ static const char* emu_type = 0; /* Type of emulator (lcnt, valgrind, etc) */ #ifdef __WIN32__ @@ -470,10 +468,6 @@ int main(int argc, char **argv) * Construct the path of the executable. */ cpuinfo = erts_cpu_info_create(); - /* '-smp auto' is default */ -#ifdef ERTS_HAVE_SMP_EMU - start_smp_emu = 1; -#endif #if defined(__WIN32__) && defined(WIN32_ALWAYS_DEBUG) emu_type = "debug"; @@ -505,23 +499,13 @@ int main(int argc, char **argv) i++; smp_enable: ; -#if !defined(ERTS_HAVE_SMP_EMU) - usage_notsup("-smp enable", ""); -#endif } else if (strcmp(argv[i+1], "disable") == 0) { i++; smp_disable: -#ifdef ERTS_HAVE_PLAIN_EMU - start_smp_emu = 0; -#else usage_notsup("-smp disable", " Use \"+S 1\" instead."); -#endif } else { smp: ; -#if !defined(ERTS_HAVE_SMP_EMU) - usage_notsup("-smp", ""); -#endif } } else if (strcmp(argv[i], "-smpenable") == 0) { goto smp_enable; @@ -560,19 +544,44 @@ int main(int argc, char **argv) } else { add_Eargs(emu); /* argv[0] = erl or cerl */ } - /* - * Add the bindir to the path (unless it is there already). - */ + + /* Add the bindir to the front of the PATH, and remove all subsequent + * occurrences to avoid ballooning it on repeated up/downgrades. */ s = get_env("PATH"); - if (!s) { - erts_snprintf(tmpStr, sizeof(tmpStr), "%s" PATHSEP "%s" DIRSEP "bin", bindir, rootdir); - } else if (strstr(s, bindir) == NULL) { - erts_snprintf(tmpStr, sizeof(tmpStr), "%s" PATHSEP "%s" DIRSEP "bin" PATHSEP "%s", bindir, - rootdir, s); + + if (s == NULL) { + erts_snprintf(tmpStr, sizeof(tmpStr), + "%s" PATHSEP "%s" DIRSEP "bin" PATHSEP, bindir, rootdir); + } else if (strstr(s, rootdir) == NULL) { + erts_snprintf(tmpStr, sizeof(tmpStr), + "%s" PATHSEP "%s" DIRSEP "bin" PATHSEP "%s", bindir, rootdir, s); } else { - erts_snprintf(tmpStr, sizeof(tmpStr), "%s", s); + const char *bindir_slug, *bindir_slug_index; + int bindir_slug_length; + const char *in_index; + char *out_index; + + erts_snprintf(tmpStr, sizeof(tmpStr), "%s" PATHSEP, bindir); + + bindir_slug = strsave(tmpStr); + bindir_slug_length = strlen(bindir_slug); + + out_index = &tmpStr[bindir_slug_length]; + in_index = s; + + while ((bindir_slug_index = strstr(in_index, bindir_slug))) { + int block_length = (bindir_slug_index - in_index); + + memcpy(out_index, in_index, block_length); + + in_index = bindir_slug_index + bindir_slug_length; + out_index += block_length; + } + + strcpy(out_index, in_index); } + free_env_val(s); set_env("PATH", tmpStr); @@ -834,6 +843,28 @@ int main(int argc, char **argv) add_Eargs(argv[i+1]); i++; break; + case 'I': + if (argv[i][2] == 'O' && (argv[i][3] == 't' || argv[i][3] == 'p')) { + if (argv[i][4] != '\0') + goto the_default; + argv[i][0] = '-'; + add_Eargs(argv[i]); + add_Eargs(argv[i+1]); + i++; + break; + } + if (argv[i][2] == 'O' && argv[i][3] == 'P' && + (argv[i][4] == 't' || argv[i][4] == 'p')) { + if (argv[i][5] != '\0') + goto the_default; + argv[i][0] = '-'; + add_Eargs(argv[i]); + add_Eargs(argv[i+1]); + i++; + break; + } + usage(argv[i]); + break; case 'S': if (argv[i][2] == 'P') { if (argv[i][3] != '\0') @@ -889,8 +920,8 @@ int main(int argc, char **argv) case 'c': argv[i][0] = '-'; if (argv[i][2] == '\0' && i+1 < argc) { - if (sys_strcmp(argv[i+1], "true") == 0 - || sys_strcmp(argv[i+1], "false") == 0) { + if (strcmp(argv[i+1], "true") == 0 + || strcmp(argv[i+1], "false") == 0) { add_Eargs(argv[i]); add_Eargs(argv[i+1]); i++; @@ -1162,15 +1193,6 @@ usage_aux(void) #ifdef __WIN32__ "[-start_erl [datafile]] " #endif - "[-smp [auto" -#ifdef ERTS_HAVE_SMP_EMU - "|enable" -#endif -#ifdef ERTS_HAVE_PLAIN_EMU - "|disable" -#endif - "]" - "] " "[-make] [-man [manopts] MANPAGE] [-x] [-emu_args] [-start_epmd BOOLEAN] " "[-args_file FILENAME] [+A THREADS] [+a SIZE] [+B[c|d|i]] [+c [BOOLEAN]] " "[+C MODE] [+h HEAP_SIZE_OPTION] [+K BOOLEAN] " @@ -1191,14 +1213,12 @@ usage(const char *switchname) usage_aux(); } -#if !defined(ERTS_HAVE_SMP_EMU) || !defined(ERTS_HAVE_PLAIN_EMU) static void usage_notsup(const char *switchname, const char *alt) { fprintf(stderr, "Argument \'%s\' not supported.%s\n", switchname, alt); usage_aux(); } -#endif static void usage_format(char *format, ...) @@ -2197,18 +2217,18 @@ static WCHAR *utf8_to_utf16(unsigned char *bytes) res = target = emalloc((num + 1) * sizeof(WCHAR)); while (*bytes) { if (((*bytes) & ((unsigned char) 0x80)) == 0) { - unipoint = (Uint) *bytes; + unipoint = (unsigned int) *bytes; ++bytes; } else if (((*bytes) & ((unsigned char) 0xE0)) == 0xC0) { unipoint = - (((Uint) ((*bytes) & ((unsigned char) 0x1F))) << 6) | - ((Uint) (bytes[1] & ((unsigned char) 0x3F))); + (((unsigned int) ((*bytes) & ((unsigned char) 0x1F))) << 6) | + ((unsigned int) (bytes[1] & ((unsigned char) 0x3F))); bytes += 2; } else if (((*bytes) & ((unsigned char) 0xF0)) == 0xE0) { unipoint = - (((Uint) ((*bytes) & ((unsigned char) 0xF))) << 12) | - (((Uint) (bytes[1] & ((unsigned char) 0x3F))) << 6) | - ((Uint) (bytes[2] & ((unsigned char) 0x3F))); + (((unsigned int) ((*bytes) & ((unsigned char) 0xF))) << 12) | + (((unsigned int) (bytes[1] & ((unsigned char) 0x3F))) << 6) | + ((unsigned int) (bytes[2] & ((unsigned char) 0x3F))); if (unipoint > 0xFFFF) { unipoint = (unsigned int) '?'; } @@ -2227,7 +2247,7 @@ static WCHAR *utf8_to_utf16(unsigned char *bytes) static int put_utf8(WCHAR ch, unsigned char *target, int sz, int *pos) { - Uint x = (Uint) ch; + unsigned int x = (unsigned int) ch; if (x < 0x80) { if (*pos >= sz) { return -1; diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c index 9cd5dd3fab..c84e63ad7c 100644 --- a/erts/etc/common/escript.c +++ b/erts/etc/common/escript.c @@ -20,16 +20,8 @@ /* * Purpose: escript front-end. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include "sys.h" -#ifdef __WIN32__ -#include <winbase.h> -#endif - -#include <ctype.h> +#include "etc_common.h" static int debug = 0; /* Bit flags for debug printouts. */ @@ -147,15 +139,6 @@ get_env(char *key) } static void -free_env_val(char *value) -{ -#ifdef __WIN32__ - if (value) - efree(value); -#endif -} - -static void set_env(char *key, char *value) { #ifdef __WIN32__ @@ -430,7 +413,6 @@ main(int argc, char** argv) int eargv_size; int eargc_base; /* How many arguments in the base of eargv. */ char* emulator; - char* env; char* basename; char* def_emu_lookup_path; char scriptname[PMAX]; @@ -512,7 +494,7 @@ main(int argc, char** argv) } /* Determine path to emulator */ - emulator = env = get_env("ESCRIPT_EMULATOR"); + emulator = get_env("ESCRIPT_EMULATOR"); if (emulator == NULL) { emulator = get_default_emulator(def_emu_lookup_path); @@ -526,10 +508,9 @@ main(int argc, char** argv) */ PUSH(emulator); - free_env_val(env); PUSH("+B"); - PUSH2("-boot", "start_clean"); + PUSH2("-boot", "no_dot_erlang"); PUSH("-noshell"); /* diff --git a/erts/etc/common/etc_common.h b/erts/etc/common/etc_common.h new file mode 100644 index 0000000000..3f26064a9e --- /dev/null +++ b/erts/etc/common/etc_common.h @@ -0,0 +1,65 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 2017. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * %CopyrightEnd% + */ +/* + * Purpose: common includes for all etc programs + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if !defined(__WIN32__) +# include <dirent.h> +# include <limits.h> +# include <sys/stat.h> +# include <sys/types.h> +# include <unistd.h> +#else +# include <windows.h> +# include <io.h> +# include <winbase.h> +# include <process.h> +#endif + +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + +/* + * Make sure that MAXPATHLEN is defined. + */ +#ifndef MAXPATHLEN +# ifdef PATH_MAX +# define MAXPATHLEN PATH_MAX +# else +# define MAXPATHLEN 2048 +# endif +#endif + +#include "erl_printf.h" + +#ifdef __WIN32__ +/* FIXE ME config_win32.h? */ +#define HAVE_STRERROR 1 +#define snprintf _snprintf +#endif diff --git a/erts/etc/common/inet_gethost.c b/erts/etc/common/inet_gethost.c index b746487668..4fc7a93348 100644 --- a/erts/etc/common/inet_gethost.c +++ b/erts/etc/common/inet_gethost.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1998-2017. All Rights Reserved. + * Copyright Ericsson AB 1998-2018. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1770,7 +1770,7 @@ static int worker_loop(void) } #elif defined(HAVE_GETIPNODEBYNAME) /*#ifdef HAVE_GETADDRINFO */ DEBUGF(5,("Starting getipnodebyname(%s)",data)); - he = getipnodebyname(data, AF_INET6, AI_DEFAULT, &error_num); + he = getipnodebyname(data, AF_INET6, 0, &error_num); if (he) { free_he = 1; error_num = 0; diff --git a/erts/etc/common/typer.c b/erts/etc/common/typer.c index 6bae9f96b7..f13135d883 100644 --- a/erts/etc/common/typer.c +++ b/erts/etc/common/typer.c @@ -20,16 +20,8 @@ /* * Purpose: Typer front-end. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "sys.h" -#ifdef __WIN32__ -#include <winbase.h> -#endif -#include <ctype.h> +#include "etc_common.h" #define NO 0 #define YES 1 @@ -185,7 +177,7 @@ main(int argc, char** argv) } PUSH("+B"); - PUSH2("-boot", "start_clean"); + PUSH2("-boot", "no_dot_erlang"); PUSH3("-run", "typer", "start"); PUSH("-extra"); diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src index 862d6eb1d4..9dd8d85abe 100644 --- a/erts/etc/unix/cerl.src +++ b/erts/etc/unix/cerl.src @@ -143,29 +143,6 @@ while [ $# -gt 0 ]; do shift unset DISPLAY ;; - "-smp") - shift - if [ $# -le 0 ]; then - eeargs_add -smp - else - case $1 in - disable) - shift - eeargs_add -smpdisable - ;; - enable) - shift - eeargs_add -smp - ;; - *) - eeargs_add -smp - esac - fi - ;; - "-smpdisable") - shift - eeargs_add -smpdisable - ;; "-lcnt") shift cargs="$cargs -lcnt" diff --git a/erts/etc/unix/dyn_erl.c b/erts/etc/unix/dyn_erl.c index d6d2201648..5c7c3cad38 100644 --- a/erts/etc/unix/dyn_erl.c +++ b/erts/etc/unix/dyn_erl.c @@ -22,13 +22,7 @@ * This is a C version of the erl Bourne shell script */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "sys.h" -#include <stdlib.h> -#include <stdarg.h> +#include "etc_common.h" #define BOOL int #define TRUE 1 diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index 8f70f879d5..5b89621733 100644 --- a/erts/etc/unix/etp-commands.in +++ b/erts/etc/unix/etp-commands.in @@ -2,7 +2,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 2005-2017. All Rights Reserved. +# Copyright Ericsson AB 2005-2018. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1232,6 +1232,141 @@ end # Commands for special term bunches. # +define etp-sig-int + set $etp_sig_is_message = 0 + set $etp_sig_tag = ($arg0)->m[0] + if ($etp_sig_tag & 0x3) != 0 || $etp_sig_tag == etp_the_non_value + set $etp_sig_is_message = !0 + # A message + if $etp_sig_tag != etp_the_non_value + etp-1 $etp_sig_tag 0 + else + print "!ENCODED-DIST-MSG" + end + if ($arg0)->m[1] != $etp_nil + printf " @token= " + etp-1 ($arg0)->m[1] 0 + end + printf " @from= " + etp-1 ($arg0)->m[2] 0 + else + if ($etp_sig_tag & 0x3f) != 0x30 + print "!INVALID-SIGNAL" + else + set $etp_sig_op = (($etp_sig_tag >> 6) & 0xff) + set $etp_sig_type = (($etp_sig_tag >> 14) & 0xff) + if $etp_sig_op == 0 + printf "!EXIT[%d]", $etp_sig_type + else + if $etp_sig_op == 1 + printf "!EXIT-LINKED[%d]", $etp_sig_type + else + if $etp_sig_op == 2 + printf "!MONITOR-DOWN[%d]", $etp_sig_type + else + if $etp_sig_op == 3 + printf "!MONITOR[%d]", $etp_sig_type + else + if $etp_sig_op == 4 + printf "!DEMONITOR[%d]", $etp_sig_type + else + if $etp_sig_op == 5 + printf "!LINK[%d]", $etp_sig_type + else + if $etp_sig_op == 6 + printf "!UNLINK[%d]", $etp_sig_type + else + if $etp_sig_op == 7 + printf "!GROUP-LEADER[%d]", $etp_sig_type + else + if $etp_sig_op == 8 + printf "!TRACE-CHANGE-STATE[%d]", $etp_sig_type + else + if $etp_sig_op == 9 + printf "!PERSISTENT-MONITOR-MESSAGE[%d]", $etp_sig_type + else + if $etp_sig_op == 10 + printf "!IS-ALIVE[%d]", $etp_sig_type + else + if $etp_sig_op == 11 + printf "!PROCESS-INFO[%d]", $etp_sig_type + else + if $etp_sig_op == 12 + printf "!SYNC-SUSPEND[%d]", $etp_sig_type + else + if $etp_sig_op == 13 + printf "!RPC[%d]", $etp_sig_type + end + end + end + end + end + end + end + end + end + end + end + end + end + end + end + end +end + + +define etp-sigq-int +# Args: ErlMessageQueue* +# +# Non-reentrant +# + set $etp_sig = ($arg0) + set $etp_sig_save = ($arg1) + set $etp_sig_save_last = ($arg2) + set $etp_sigq_msig_len = 0 + set $etp_sigq_nmsig_len = 0 + + printf " [" + while $etp_sig != (void *) 0 + set $etp_sig_next = $etp_sig->next + if $etp_sig != ($arg0) + printf " " + end + etp-sig-int $etp_sig + if $etp_sig_is_message + set $etp_sigq_msig_len++ + else + set $etp_sigq_nmsig_len++ + end + if $etp_sig_next + printf "," + end + if $etp_sig_save && *$etp_sig_save == $etp_sig + printf " %% <== SAVE" + else + if $etp_sig_save_last && *$etp_sig_save_last == $etp_sig + printf " %% <== SAVED_LAST" + end + end + if $etp_sig_next + printf "\n" + end + set $etp_sig = $etp_sig_next + end + printf "]\n\n" + printf " Message signals: %d\n", $etp_sigq_msig_len + printf " Non-message signals: %d\n\n", $etp_sigq_nmsig_len +end + +define etp-sigqs + printf " --- Inner signal queue (message queue) ---\n" + etp-sigq-int ($arg0)->sig_qs.first ($arg0)->sig_qs.save ($arg0)->sig_qs.saved_last + printf " --- Middle signal queue ---\n" + etp-sigq-int ($arg0)->sig_qs.cont ($arg0)->sig_qs.save ($arg0)->sig_qs.saved_last + printf " --- Outer queue ---\n" + etp-sigq-int ($arg0)->sig_inq.first ($arg0)->sig_qs.save ($arg0)->sig_qs.saved_last +end + define etp-msgq # Args: ErlMessageQueue* # @@ -1290,7 +1425,7 @@ document etp-msgq % Sequential trace tokens are included in comments and % the current match position in the queue is marked '<='. % -% A process's message queue is process_tab[i]->msg. +% A process's message queue is process_tab[i]->sig_qs. %--------------------------------------------------------------------------- end @@ -1693,7 +1828,7 @@ define etp-proc-state-int printf "dirty-cpu-proc | " end if ($arg0 & 0x2000000) - printf "on-heap-msgq | " + printf "sig-q | " end if ($arg0 & 0x1000000) printf "off-heap-msgq | " @@ -1714,10 +1849,10 @@ define etp-proc-state-int printf "active-sys | " end if ($arg0 & 0x80000) - printf "trapping-exit | " + printf "sig-in-q | " end if ($arg0 & 0x40000) - printf "bound | " + printf "sys-tasks | " end if ($arg0 & 0x20000) printf "garbage-collecting | " @@ -1735,7 +1870,7 @@ define etp-proc-state-int printf "active | " end if ($arg0 & 0x1000) - printf "pending-exit | " + printf "unused | " end if ($arg0 & 0x800) printf "exiting | " @@ -1819,160 +1954,21 @@ document etp-proc-state % Print state of process %--------------------------------------------------------------------------- end -define etp-proc-state-int + +define etp-proc-flags-int # Args: int # - if ($arg0 & 0x80000000) - printf "GARBAGE<0x80000000> | " - end - if ($arg0 & 0x40000000) - printf "dirty-running-sys | " - end - if ($arg0 & 0x20000000) - printf "dirty-running | " - end - if ($arg0 & 0x10000000) - printf "dirty-active-sys | " + if ($arg0 & ~0xfffffff) + printf "GARBAGE<%x> ", ($arg0 & ~0x1ffffff) end if ($arg0 & 0x8000000) - printf "dirty-io-proc | " + printf "trap-exit " end if ($arg0 & 0x4000000) - printf "dirty-cpu-proc | " + printf "local-sigs-only " end if ($arg0 & 0x2000000) - printf "on-heap-msgq | " - end - if ($arg0 & 0x1000000) - printf "off-heap-msgq | " - end - if ($arg0 & 0x800000) - printf "delayed-sys | " - end - if ($arg0 & 0x400000) - printf "proxy | " - set $proxy_process = 1 - else - set $proxy_process = 0 - end - if ($arg0 & 0x200000) - printf "running-sys | " - end - if ($arg0 & 0x100000) - printf "active-sys | " - end - if ($arg0 & 0x80000) - printf "trapping-exit | " - end - if ($arg0 & 0x40000) - printf "bound | " - end - if ($arg0 & 0x20000) - printf "garbage-collecting | " - end - if ($arg0 & 0x10000) - printf "suspended | " - end - if ($arg0 & 0x8000) - printf "running | " - end - if ($arg0 & 0x4000) - printf "in-run-queue | " - end - if ($arg0 & 0x2000) - printf "active | " - end - if ($arg0 & 0x1000) - printf "pending-exit | " - end - if ($arg0 & 0x800) - printf "exiting | " - end - if ($arg0 & 0x400) - printf "free | " - end - if ($arg0 & 0x200) - printf "in-prq-low | " - end - if ($arg0 & 0x100) - printf "in-prq-normal | " - end - if ($arg0 & 0x80) - printf "in-prq-high | " - end - if ($arg0 & 0x40) - printf "in-prq-max | " - end - if ($arg0 & 0x30) == 0x0 - printf "prq-prio-max | " - else - if ($arg0 & 0x30) == 0x10 - printf "prq-prio-high | " - else - if ($arg0 & 0x30) == 0x20 - printf "prq-prio-normal | " - else - printf "prq-prio-low | " - end - end - end - if ($arg0 & 0xc) == 0x0 - printf "usr-prio-max | " - else - if ($arg0 & 0xc) == 0x4 - printf "usr-prio-high | " - else - if ($arg0 & 0xc) == 0x8 - printf "usr-prio-normal | " - else - printf "usr-prio-low | " - end - end - end - if ($arg0 & 0x3) == 0x0 - printf "act-prio-max\n" - else - if ($arg0 & 0x3) == 0x1 - printf "act-prio-high\n" - else - if ($arg0 & 0x3) == 0x2 - printf "act-prio-normal\n" - else - printf "act-prio-low\n" - end - end - end -end - -document etp-proc-state-int -%--------------------------------------------------------------------------- -% etp-proc-state-int int -% -% Print state of process state value -%--------------------------------------------------------------------------- -end - - -define etp-proc-state -# Args: Process* -# - set $state_int = *(((Uint32 *) &(((Process *) $arg0)->state))) - etp-proc-state-int $state_int -end - -document etp-proc-state -%--------------------------------------------------------------------------- -% etp-proc-state Process* -% -% Print state of process -%--------------------------------------------------------------------------- -end - -define etp-proc-flags-int -# Args: int -# - if ($arg0 & ~0x1ffffff) - printf "GARBAGE<%x> ", ($arg0 & ~0x1ffffff) + printf "hibernated " end if ($arg0 & 0x1000000) printf "dirty-minor-gc " @@ -2076,7 +2072,7 @@ document etp-proc-flags %--------------------------------------------------------------------------- end -define etp-process-info +define etp-process-info-int # Args: Process* # printf " Pid: " @@ -2131,14 +2127,25 @@ define etp-process-info end printf " Mbuf size: %ld\n", $etp_proc->mbuf_sz if (etp_smp_compiled) - printf " Msgq len: %ld (inner=%ld, outer=%ld)\n", ($etp_proc->msg.len + $etp_proc->msg_inq.len), $etp_proc->msg.len, $etp_proc->msg_inq.len + printf " Msgq len: %ld (inner=%ld, outer=%ld)\n", ($etp_proc->sig_qs.len + $etp_proc->sig_inq.len), $etp_proc->sig_qs.len, $etp_proc->sig_inq.len else - printf " Msgq len: %d\n", $etp_proc->msg.len + printf " Msgq len: %d\n", $etp_proc->sig_qs.len end printf " Parent: " - etp-1 $etp_proc->parent + etp-1 ((Eterm)($etp_proc->parent)) printf "\n Pointer: (Process *) %p\n", $etp_proc end + if ($arg1) + etp-sigqs $etp_proc + end +end + +define etp-process-info + etp-process-info-int ($arg0) 0 +end + +define etp-process-info-x + etp-process-info-int ($arg0) !0 end document etp-process-info @@ -2149,22 +2156,24 @@ document etp-process-info %--------------------------------------------------------------------------- end -define etp-processes +define etp-processes-int if (!erts_initialized) printf "No processes, since system isn't initialized!\n" else set $proc_ix = 0 set $proc_max_ix = erts_proc.r.o.max set $proc_tab = erts_proc.r.o.tab + set $proc_cnt = erts_proc.vola.tile.count.counter set $invalid_proc = &erts_invalid_process set $proc_decentile = $proc_max_ix / 10 set $proc_printile = $proc_decentile - while $proc_ix < $proc_max_ix + while $proc_ix < $proc_max_ix && $proc_cnt > 0 set $proc = (Process *) *((UWord *) ($proc_tab + $proc_ix)) if ($proc != ((Process *) 0) && $proc != $invalid_proc) printf "---\n" printf " Pix: %d\n", $proc_ix - etp-process-info $proc + etp-process-info-int $proc ($arg0) + 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 @@ -2176,6 +2185,14 @@ define etp-processes end end +define etp-processes + etp-processes-int 0 +end + +define etp-processes-x + etp-processes-int !0 +end + document etp-processes %--------------------------------------------------------------------------- % etp-processes @@ -2236,9 +2253,9 @@ define etp-process-memory-info end printf "] [Mbuf: %5ld", $etp_pmem_proc->mbuf_sz if (etp_smp_compiled) - printf " | %3ld (%3ld | %3ld)", ($etp_pmem_proc->msg.len + $etp_pmem_proc->msg_inq.len), $etp_pmem_proc->msg.len, $etp_pmem_proc->msg_inq.len + printf " | %3ld (%3ld | %3ld)", ($etp_pmem_proc->sig_qs.len + $etp_pmem_proc->sig_inq.len), $etp_pmem_proc->sig_qs.len, $etp_pmem_proc->sig_inq.len else - printf " | %3ld", $etp_pmem_proc->msg.len + printf " | %3ld", $etp_pmem_proc->sig_qs.len end printf "] " if ($etp_pmem_proc->i) @@ -2316,40 +2333,46 @@ end define etp-port-sched-flags-int # Args: int # - if ($arg0 & 0x1) + if ($arg0 & (1 << 0)) printf " in-run-queue" end - if ($arg0 & 0x2) + if ($arg0 & (1 << 1)) printf " executing" end - if ($arg0 & 0x4) + if ($arg0 & (1 << 2)) printf " have-tasks" end - if ($arg0 & 0x8) + if ($arg0 & (1 << 3)) printf " exited" end - if ($arg0 & 0x10) + if ($arg0 & (1 << 4)) printf " busy-port" end - if ($arg0 & 0x20) + if ($arg0 & (1 << 5)) printf " busy-port-q" end - if ($arg0 & 0x40) + if ($arg0 & (1 << 6)) printf " chk-unset-busy-port-q" end - if ($arg0 & 0x80) + if ($arg0 & (1 << 7)) printf " have-busy-tasks" end - if ($arg0 & 0x100) + if ($arg0 & (1 << 8)) printf " have-nosuspend-tasks" end - if ($arg0 & 0x200) + if ($arg0 & (1 << 9)) printf " parallelism" end - if ($arg0 & 0x400) + if ($arg0 & (1 << 10)) printf " force-sched" end - if ($arg0 & 0xfffff800) + if ($arg0 & (1 << 11)) + printf " exiting" + end + if ($arg0 & (1 << 12)) + printf " exec-imm" + end + if ($arg0 & 0xffffc000) printf " GARBAGE" end printf "\n" @@ -2496,10 +2519,11 @@ define etp-ports set $port_ix = 0 set $port_max_ix = erts_port.r.o.max set $port_tab = erts_port.r.o.tab + set $port_cnt = erts_proc.vola.tile.count.counter set $invalid_port = &erts_invalid_port set $port_decentile = $port_max_ix / 10 set $port_printile = $port_decentile - while $port_ix < $port_max_ix + while $port_ix < $port_max_ix && $port_cnt > 0 set $port = (Port *) *((UWord *) ($port_tab + $port_ix)) if ($port != ((Port *) 0) && $port != $invalid_port) if (*(((Uint32 *) &(((Port *) $port)->state))) & 0x100) == 0 @@ -2507,6 +2531,7 @@ define etp-ports printf "---\n" printf " Pix: %d\n", $port_ix etp-port-info $port + set $port_cnt-- end end if $port_ix == $port_printile @@ -2850,6 +2875,14 @@ define etp-run-queue-info-internal printf " Pointer: (ErtsRunQueue *) %p\n", $runq end +define etp-fds + if $_exitsignal == -1 + call erts_check_io_debug(0) + else + printf "Not yet implemented for core files" + end +end + define etp-disasm-1 set $code_ptr = ((BeamInstr*)$arg0) set $addr = *$code_ptr @@ -3682,7 +3715,7 @@ define etp-chart # Non-reentrant etp-chart-start ($arg0) set ($arg0) = ($arg0) - etp-msgq (($arg0)->msg) + etp-msgq (($arg0)->sig_qs) etp-stackdump ($arg0) etp-dictdump (($arg0)->dictionary) etp-dictdump (($arg0)->debug_dictionary) @@ -4314,6 +4347,10 @@ document etp-init %--------------------------------------------------------------------------- end +define hook-run + set $_exitsignal = -1 +end + etp-init help etp-init etp-show diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c index 81a0036c99..725343d701 100644 --- a/erts/etc/unix/run_erl.c +++ b/erts/etc/unix/run_erl.c @@ -627,12 +627,14 @@ static void pass_on(pid_t childpid) status("Pty master read; "); #endif if ((len = sf_read(mfd, buf, BUFSIZ)) <= 0) { + int saved_errno = errno; sf_close(rfd); if(wfd) sf_close(wfd); sf_close(mfd); unlink(fifo1); unlink(fifo2); if (len < 0) { + errno = saved_errno; if(errno == EIO) ERROR0(LOG_ERR,"Erlang closed the connection."); else @@ -1342,10 +1344,12 @@ static int sf_open(const char *path, int type, mode_t mode) { return fd; } + static int sf_close(int fd) { /* "close() should not be retried after an EINTR" */ return close(fd); } + /* Extract any control sequences that are ment only for run_erl * and should not be forwarded to the pty. */ |