diff options
Diffstat (limited to 'lib/tools')
-rw-r--r-- | lib/tools/c_src/erl_memory.c | 73 | ||||
-rw-r--r-- | lib/tools/emacs/erlang-eunit.el | 4 | ||||
-rw-r--r-- | lib/tools/emacs/erlang-start.el | 2 | ||||
-rw-r--r-- | lib/tools/emacs/erlang.el | 40 | ||||
-rw-r--r-- | lib/tools/src/cover.erl | 44 | ||||
-rw-r--r-- | lib/tools/src/tags.erl | 4 | ||||
-rw-r--r-- | lib/tools/test/cover_SUITE.erl | 37 | ||||
-rw-r--r-- | lib/tools/test/cover_SUITE_data/otp_11439/t.erl | 11 | ||||
-rw-r--r-- | lib/tools/test/eprof_SUITE_data/eed.erl | 8 |
9 files changed, 144 insertions, 79 deletions
diff --git a/lib/tools/c_src/erl_memory.c b/lib/tools/c_src/erl_memory.c index 86e84723b1..c4e126a7b1 100644 --- a/lib/tools/c_src/erl_memory.c +++ b/lib/tools/c_src/erl_memory.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 2003-2012. All Rights Reserved. + * Copyright Ericsson AB 2003-2013. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in @@ -30,6 +30,7 @@ # undef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # include <windows.h> +typedef int socklen_t; #else # if defined(__linux__) && defined(__GNUC__) # define _GNU_SOURCE 1 @@ -149,11 +150,11 @@ typedef struct { typedef struct em_buffer_ { struct em_buffer_ *next; int write; - usgnd_int_8 *data; - usgnd_int_8 *data_end; - usgnd_int_8 *end; + char *data; + char *data_end; + char *end; size_t size; - usgnd_int_8 start[EM_DEFAULT_BUF_SZ]; + char start[EM_DEFAULT_BUF_SZ]; } em_buffer; typedef struct { @@ -173,7 +174,7 @@ typedef struct { } em_buf_queue; typedef struct { - usgnd_int_8 *ptr; + char *ptr; size_t size; } em_area; @@ -460,7 +461,7 @@ enqueue(em_state *state, em_buf_queue *queue, size_t min_size) bsize = min_size; buf = (em_buffer *) (*state->alloc)(sizeof(em_buffer) - + (sizeof(usgnd_int_8) + + (sizeof(char) * (bsize-EM_DEFAULT_BUF_SZ))); if (buf) { buf->size = bsize; @@ -595,12 +596,12 @@ get_next_write_area(em_area *area, em_state *state, em_buf_queue *queue, \* */ static INLINE size_t -write_str(usgnd_int_8 **dstpp, char *srcp) +write_str(char **dstpp, char *srcp) { size_t i = 0; if (dstpp) while (srcp[i]) - *((*dstpp)++) = (usgnd_int_8) srcp[i++]; + *((*dstpp)++) = srcp[i++]; else while (srcp[i]) i++; return i; @@ -608,7 +609,7 @@ write_str(usgnd_int_8 **dstpp, char *srcp) static size_t -write_strings(usgnd_int_8 **ptr, +write_strings(char **ptr, char **strings, char *first_line_prefix, char *line_prefix, @@ -640,10 +641,10 @@ write_strings(usgnd_int_8 **ptr, } static size_t -write_title(usgnd_int_8 **bufp, size_t *overflow, size_t width, char *str) +write_title(char **bufp, size_t *overflow, size_t width, char *str) { size_t i, sz, ws; - usgnd_int_8 *p, *endp; + char *p, *endp; /* * Writes at least one '|' character at the beginning. @@ -689,16 +690,16 @@ write_title(usgnd_int_8 **bufp, size_t *overflow, size_t width, char *str) *(p++) = '|'; while (ws > 1) { ws--; - *(p++) = (usgnd_int_8) ' '; + *(p++) = ' '; } i = 0; while (str[i] && (overflow || p < endp)) - *(p++) = (usgnd_int_8) str[i++]; + *(p++) = str[i++]; while (ws) { ws--; - *(p++) = (usgnd_int_8) ' '; + *(p++) = ' '; } ASSERT(overflow || p == endp); @@ -708,7 +709,7 @@ write_title(usgnd_int_8 **bufp, size_t *overflow, size_t width, char *str) } static size_t -write_obj_sub_titles(em_state *state, usgnd_int_8 **bufp, size_t *overflow) +write_obj_sub_titles(em_state *state, char **bufp, size_t *overflow) { size_t field_width = state->output.field_width; size_t size = write_title(bufp, overflow, field_width, "size"); @@ -733,12 +734,12 @@ write_obj_sub_titles(em_state *state, usgnd_int_8 **bufp, size_t *overflow) } static size_t -write_header(em_state *state, usgnd_int_8 *ptr, int trunc) +write_header(em_state *state, char *ptr, int trunc) { #define MIN_LTEXT_SZ 18 #define HEADER_EOL_STR "|\n" - usgnd_int_8 *p; - usgnd_int_8 **pp; + char *p; + char **pp; int i; size_t overflow; size_t *ofp; @@ -855,7 +856,7 @@ write_header(em_state *state, usgnd_int_8 *ptr, int trunc) } static INLINE void -write_mem_info(em_state *state, usgnd_int_8 **p, em_mem_info *mi) +write_mem_info(em_state *state, char **p, em_mem_info *mi) { int fw = state->output.field_width - 1; *p += sprintf(*p, "%*" USGND_INT_MAX_FSTR " ", fw, mi->size); @@ -894,7 +895,7 @@ write_mem_info(em_state *state, usgnd_int_8 **p, em_mem_info *mi) } static INLINE void -write_max_ever_mem_info(em_state *state, usgnd_int_8 **p, em_mem_info *mi) +write_max_ever_mem_info(em_state *state, char **p, em_mem_info *mi) { int fw = state->output.field_width - 1; *p += sprintf(*p, "%*" USGND_INT_MAX_FSTR " ", fw, mi->max_ever_size); @@ -913,13 +914,13 @@ static void print_string(em_state *state, char *str) { em_area area = {NULL, 0}; - usgnd_int_8 *p; + char *p; /* Get area */ get_next_write_area(&area,state,&state->output.queue,write_str(NULL,str)); - p = (usgnd_int_8 *) area.ptr; + p = area.ptr; area.size = write_str(&p, str); /* Leave area */ @@ -938,7 +939,7 @@ print_emu_arg(em_state *state) struct hostent *hp; struct in_addr iaddr; usgnd_int_16 port; - int saddr_size = sizeof(saddr); + socklen_t saddr_size = sizeof(saddr); size_t size; char *format = "> Emulator command line argument: +Mit %s\n"; @@ -996,7 +997,7 @@ print_emu_arg(em_state *state) } static size_t -write_allocator_info(em_state *state, usgnd_int_8 *ptr) +write_allocator_info(em_state *state, char *ptr) { usgnd_int_32 aix, i, j; char *header = "> Allocator information:\n"; @@ -1008,8 +1009,8 @@ write_allocator_info(em_state *state, usgnd_int_8 *ptr) char **strings; size_t strings_size; size_t max_line_size = 80; - usgnd_int_8 *p = ptr; - usgnd_int_8 **pp = ptr ? &p : NULL; + char *p = ptr; + char **pp = ptr ? &p : NULL; strings_size = state->trace_info.max_block_type_ix + 1; if (strings_size < state->trace_info.max_allocator_ix + 1) @@ -1140,7 +1141,7 @@ static void print_main_footer(em_state *state) { em_area area = {NULL, 0}; - usgnd_int_8 *p; + char *p; int i; char *stop_str = "> Trace stopped\n"; @@ -1248,7 +1249,7 @@ print_main_footer(em_state *state) static void print_info(em_state *state, usgnd_int_32 secs, char *extra) { - usgnd_int_8 *p; + char *p; int i; size_t size; em_area area = {NULL, 0}; @@ -1913,7 +1914,7 @@ error_msg(int res, char *msg) #if EMEM_d_SWITCH static size_t -write_output_filename(usgnd_int_8 *ptr, +write_output_filename(char *ptr, char *dirname, char *nodename, char *hostname, @@ -1921,8 +1922,8 @@ write_output_filename(usgnd_int_8 *ptr, char *pid) { size_t sz = 0; - usgnd_int_8 *p = ptr; - usgnd_int_8 **pp = ptr ? &p : NULL; + char *p = ptr; + char **pp = ptr ? &p : NULL; sz += write_str(pp, dirname); if (pp) *((*pp)++) = DIR_SEP_CHAR; sz++; @@ -2246,7 +2247,7 @@ process_trace(em_state *state) if (!area.size) return EM_TRUNCATED_TRACE_ERROR; res = emtp_parse(state->trace_state, - &area.ptr, &area.size, + (usgnd_int_8 **)&area.ptr, &area.size, NULL, 0, NULL); if (res == EMTP_HEADER_PARSED) break; @@ -2277,7 +2278,7 @@ process_trace(em_state *state) while (area.size) { ops_len = EM_NO_OF_OPS; res = emtp_parse(state->trace_state, - &area.ptr, &area.size, + (usgnd_int_8 **)&area.ptr, &area.size, ops, sizeof(emtp_operation), &ops_len); if (res < 0) return res; @@ -2555,7 +2556,7 @@ init_connection(em_state *state) SOCKET lsock; SOCKET sock = INVALID_SOCKET; struct sockaddr_in my_addr; - int oth_addr_len; + socklen_t oth_addr_len; struct sockaddr_in oth_addr; #ifdef __WIN32__ WORD wVersionRequested = MAKEWORD(2,0); @@ -2738,7 +2739,7 @@ output_thread_func(void *arg) error_msg(EIO, "Output queue"); } if (fwrite((void *) area.ptr, - sizeof(usgnd_int_8), + sizeof(char), area.size, state->output.stream) != area.size) { disconnect_queue_reader(&state->output.queue); diff --git a/lib/tools/emacs/erlang-eunit.el b/lib/tools/emacs/erlang-eunit.el index f2c0db67dd..0adeff1a02 100644 --- a/lib/tools/emacs/erlang-eunit.el +++ b/lib/tools/emacs/erlang-eunit.el @@ -40,6 +40,10 @@ This is useful, reducing the save-compile-load-test cycle to one keychord.") (defvar erlang-eunit-recent-info '((mode . nil) (module . nil) (test . nil) (cover . nil)) "Info about the most recent running of an EUnit test representation.") +(defvar erlang-error-regexp-alist + '(("^\\([^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" . (1 2))) + "*Patterns for matching Erlang errors.") + ;;; ;;; Switch between src/EUnit test buffers ;;; diff --git a/lib/tools/emacs/erlang-start.el b/lib/tools/emacs/erlang-start.el index e1dc86621e..76e0575e68 100644 --- a/lib/tools/emacs/erlang-start.el +++ b/lib/tools/emacs/erlang-start.el @@ -52,7 +52,7 @@ ;; ;; To set the variable you can use the following command: ;; M-x set-variable RET debug-on-error RET t RET - + ;;; Code: ;; diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index 624042204c..c395d22356 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -697,6 +697,7 @@ resulting regexp is surrounded by \\_< and \\_>." "char" "cons" "deep_string" + "iodata" "iolist" "maybe_improper_list" "module" @@ -708,6 +709,7 @@ resulting regexp is surrounded by \\_< and \\_>." "nonempty_list" "nonempty_improper_list" "nonempty_maybe_improper_list" + "nonempty_string" "no_return" "pos_integer" "string" @@ -1025,7 +1027,7 @@ behaviour.") (defvar erlang-mode-syntax-table nil "Syntax table in use in Erlang-mode buffers.") - + (defvar erlang-skel-file "erlang-skels" "The type of erlang-skeletons that should be used, default @@ -1272,7 +1274,7 @@ Unfortunately, XEmacs hasn't got support for a special Font Lock syntax table. The effect is that `apply' in the atom `foo_apply' will be highlighted as a bif.") - + ;;; Avoid errors while compiling this file. ;; `eval-when-compile' is not defined in Emacs 18. We define it as a @@ -1321,7 +1323,7 @@ Lock syntax table. The effect is that `apply' in the atom (require 'tempo) (require 'compile)))) - + (defun erlang-version () "Return the current version of Erlang mode." (interactive) @@ -1516,7 +1518,7 @@ Other commands: (set (make-local-variable 'outline-level) (lambda () 1)) (set (make-local-variable 'add-log-current-defun-function) 'erlang-current-defun)) - + (defun erlang-font-lock-init () "Initialize Font Lock for Erlang mode." (or erlang-font-lock-syntax-table @@ -1686,7 +1688,7 @@ plus variables, macros and records." (font-lock-mode 1) (funcall (symbol-function 'font-lock-fontify-buffer))) - + (defun erlang-menu-init () "Init menus for Erlang mode. @@ -1905,7 +1907,7 @@ Example: The new menu is returned. No guarantee is given that the original menu is left unchanged." (delq entry items)) - + ;; Man code: (defun erlang-man-init () @@ -2228,7 +2230,7 @@ For example: After installing the line, kill and restart Emacs, or restart Erlang mode with the command `M-x erlang-mode RET'."))) - + ;; Skeleton code: ;; This code is based on the package `tempo' which is part of modern @@ -2349,7 +2351,7 @@ The first character of DD is space if the value is less than 10." (erlang-string-to-int (substring date 8 10)) (substring date 4 7) (substring date -4)))) - + ;; Indentation code: (defun erlang-indent-command (&optional whole-exp) @@ -3132,7 +3134,7 @@ commands." (skip-chars-backward " \t") (max (if (bolp) 0 (1+ (current-column))) comment-column))))) - + ;;; Erlang movement commands ;; All commands below work as movement commands. I.e. if the point is @@ -3336,7 +3338,7 @@ With negative argument go towards the beginning of the buffer." (forward-sexp 1) (buffer-substring start (point))))) - + ;;; Miscellaneous (defun erlang-fill-paragraph (&optional justify) @@ -3445,7 +3447,7 @@ at the end." (error "Can't clone argument list")) (insert args) (set-mark p))) - + ;;; Information retrieval functions. (defun erlang-buffer-substring (beg end) @@ -3772,7 +3774,7 @@ exported function." (store-match-data old-match-data) (member (cons name arity) exports)))) - + ;;; Check module name ;; The function `write-file', bound to C-x C-w, calls @@ -3835,7 +3837,7 @@ This function is normally placed in the hook `local-write-file-hooks'." ;; Must return nil since it is added to `local-write-file-hook'. nil) - + ;;; Electric functions. (defun erlang-electric-semicolon (&optional arg) @@ -4229,7 +4231,7 @@ This function is designed to be a member of a criteria list." (erlang-skip-blank) (looking-at "end[^_a-zA-Z0-9]"))) - + ;; Erlang tags support which is aware of erlang modules. ;; ;; Not yet implemented under XEmacs. (Hint: The Emacs 19 etags @@ -4539,7 +4541,7 @@ Tags can be given on the forms `tag', `module:', `module:tag'." (or default (error "There is no default tag")) spec))))) - + ;; Search tag functions which are aware of Erlang modules. The tactic ;; is to store new search functions into the local variables of the ;; TAGS buffers. The variables are restored directly after the @@ -4715,7 +4717,7 @@ for a tag on the form `module:tag'." (string= mod (erlang-get-module-from-file-name (file-of-tag))))))) - + ;;; Tags completion, Emacs 19 `etags' specific. ;;; ;;; The basic idea is to create a second completion table `erlang-tags- @@ -4834,7 +4836,7 @@ about Erlang modules." ;; Only the first one will be stored in the table. (intern (concat module ":") table)))))) table)) - + ;;; ;;; Prepare for other methods to run an Erlang slave process. ;;; @@ -4916,7 +4918,7 @@ future, a new shell on an already running host will be started." (call-interactively erlang-next-error-function)) - + ;;; ;;; Erlang Shell Mode -- Major mode used for Erlang shells. ;;; @@ -5052,7 +5054,7 @@ Selects Comint or Compilation mode command as appropriate." (define-key map "\M-\C-m" 'compile-goto-error) (unless inferior-erlang-use-cmm (define-key map "\C-x`" 'erlang-next-error))) - + ;;; ;;; Inferior Erlang -- Run an Erlang shell as a subprocess. ;;; diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl index bf21aa6b48..13d9aefb0c 100644 --- a/lib/tools/src/cover.erl +++ b/lib/tools/src/cover.erl @@ -255,16 +255,7 @@ compile_directory(Dir, Options) when is_list(Dir), is_list(Options) -> end. compile_modules(Files,Options) -> - Options2 = lists:filter(fun(Option) -> - case Option of - {i, Dir} when is_list(Dir) -> true; - {d, _Macro} -> true; - {d, _Macro, _Value} -> true; - export_all -> true; - _ -> false - end - end, - Options), + Options2 = filter_options(Options), compile_modules(Files,Options2,[]). compile_modules([File|Files], Options, Result) -> @@ -273,6 +264,17 @@ compile_modules([File|Files], Options, Result) -> compile_modules([],_Opts,Result) -> reverse(Result). +filter_options(Options) -> + lists:filter(fun(Option) -> + case Option of + {i, Dir} when is_list(Dir) -> true; + {d, _Macro} -> true; + {d, _Macro, _Value} -> true; + export_all -> true; + _ -> false + end + end, + Options). %% compile_beam(ModFile) -> Result | {error,Reason} %% ModFile - see compile/1 @@ -622,8 +624,9 @@ main_process_loop(State) -> Compiled0 = State#main_state.compiled, case get_beam_file(Module,BeamFile0,Compiled0) of {ok,BeamFile} -> + UserOptions = get_compile_options(Module,BeamFile), {Reply,Compiled} = - case do_compile_beam(Module,BeamFile,[]) of + case do_compile_beam(Module,BeamFile,UserOptions) of {ok, Module} -> remote_load_compiled(State#main_state.nodes, [{Module,BeamFile}]), @@ -1421,12 +1424,23 @@ get_abstract_code(Module, Beam) -> end. get_source_info(Module, Beam) -> + Compile = get_compile_info(Module, Beam), + case lists:keyfind(source, 1, Compile) of + { source, _ } = Tuple -> [Tuple]; + false -> [] + end. + +get_compile_options(Module, Beam) -> + Compile = get_compile_info(Module, Beam), + case lists:keyfind(options, 1, Compile) of + {options, Options } -> filter_options(Options); + false -> [] + end. + +get_compile_info(Module, Beam) -> case beam_lib:chunks(Beam, [compile_info]) of {ok, {Module, [{compile_info, Compile}]}} -> - case lists:keyfind(source, 1, Compile) of - { source, _ } = Tuple -> [Tuple]; - false -> [] - end; + Compile; _ -> [] end. diff --git a/lib/tools/src/tags.erl b/lib/tools/src/tags.erl index 1c72ef8db5..e3cc51cdb2 100644 --- a/lib/tools/src/tags.erl +++ b/lib/tools/src/tags.erl @@ -292,7 +292,7 @@ word_char(C) when C >= $0, C =< $9 -> true; word_char($_) -> true; word_char(_) -> false. - + %%% Output routines %% Check the options `outfile' and `outdir'. @@ -323,7 +323,7 @@ genout(Os, Name, Entries) -> io:put_chars(Os, lists:reverse(Entries)). - + %%% help routines %% Flatten and reverse a nested list. diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl index c033be98a3..29b26c7a76 100644 --- a/lib/tools/test/cover_SUITE.erl +++ b/lib/tools/test/cover_SUITE.erl @@ -28,7 +28,7 @@ export_import/1, otp_5031/1, eif/1, otp_5305/1, otp_5418/1, otp_6115/1, otp_7095/1, otp_8188/1, otp_8270/1, otp_8273/1, otp_8340/1, - otp_10979_hanging_node/1]). + otp_10979_hanging_node/1, compile_beam_opts/1]). -include_lib("test_server/include/test_server.hrl"). @@ -53,7 +53,7 @@ all() -> dont_reconnect_after_stop, stop_node_after_disconnect, export_import, otp_5031, eif, otp_5305, otp_5418, otp_6115, otp_7095, otp_8188, otp_8270, otp_8273, - otp_8340, otp_10979_hanging_node]; + otp_8340, otp_10979_hanging_node, compile_beam_opts]; _pid -> {skip, "It looks like the test server is running " @@ -1401,6 +1401,39 @@ otp_10979_hanging_node(_Config) -> ok. +compile_beam_opts(doc) -> + ["Take compiler options from beam in cover:compile_beam"]; +compile_beam_opts(suite) -> []; +compile_beam_opts(Config) when is_list(Config) -> + {ok, Cwd} = file:get_cwd(), + ok = file:set_cwd(?config(priv_dir, Config)), + IncDir = filename:join(?config(data_dir, Config), + "included_functions"), + File = filename:join([?config(data_dir, Config), "otp_11439", "t.erl"]), + %% use all compiler options allowed by cover:filter_options + %% i and d don't make sense when compiling from beam though + {ok, t} = + compile:file(File, [{i, IncDir}, + {d, 'BOOL'}, + {d, 'MACRO', macro_defined}, + export_all, + debug_info, + return_errors]), + Exports = + [{func1,0}, + {macro, 0}, + {exported,0}, + {nonexported,0}, + {module_info,0}, + {module_info,1}], + Exports = t:module_info(exports), + {ok, t} = cover:compile_beam("t"), + Exports = t:module_info(exports), + cover:stop(), + ok = file:delete("t.beam"), + ok = file:set_cwd(Cwd), + ok. + %%--Auxiliary------------------------------------------------------------ analyse_expr(Expr, Config) -> diff --git a/lib/tools/test/cover_SUITE_data/otp_11439/t.erl b/lib/tools/test/cover_SUITE_data/otp_11439/t.erl new file mode 100644 index 0000000000..d1eb9f16ee --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/otp_11439/t.erl @@ -0,0 +1,11 @@ +-module(t). +-export([exported/0]). +-include("cover_inc.hrl"). +-ifdef(BOOL). +macro() -> + ?MACRO. +-endif. +exported() -> + ok. +nonexported() -> + ok. diff --git a/lib/tools/test/eprof_SUITE_data/eed.erl b/lib/tools/test/eprof_SUITE_data/eed.erl index 520c5f3dd1..5f2a21aa60 100644 --- a/lib/tools/test/eprof_SUITE_data/eed.erl +++ b/lib/tools/test/eprof_SUITE_data/eed.erl @@ -146,7 +146,7 @@ format_error({'EXIT', {Code, {Mod, Func, Args}}}) -> [{Code, {Mod, Func, length(Args)}}])); format_error(A) -> atom_to_list(A). - + %%% Parsing commands. @@ -327,7 +327,7 @@ when 0 =< Num1, Num1 =< Num2, Num2 =< State#state.lines -> check_lines(_, _, _, _) -> error(bad_linenum). - + %%% Executing commands. %% ($)= - print line number @@ -657,7 +657,7 @@ undo_command(_, _, _) -> write_command(_Cmd, [_First, _Last], _St) -> error(not_implemented). - + %%% Primitive buffer operations. print_current(St) -> @@ -717,7 +717,7 @@ wrap_next_line(State) when State#state.dot == State#state.lines -> wrap_next_line(State) -> next_line(State). - + %%% Utilities. get_pattern(End, Cmd, State) -> |