diff options
Diffstat (limited to 'lib/reltool/examples')
-rw-r--r-- | lib/reltool/examples/Makefile | 79 | ||||
-rw-r--r-- | lib/reltool/examples/display_args | 8 | ||||
-rwxr-xr-x | lib/reltool/examples/mnesia_core_dump_viewer | 54 |
3 files changed, 141 insertions, 0 deletions
diff --git a/lib/reltool/examples/Makefile b/lib/reltool/examples/Makefile new file mode 100644 index 0000000000..dacfd4e7d4 --- /dev/null +++ b/lib/reltool/examples/Makefile @@ -0,0 +1,79 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2009. 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 +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# + +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(RELTOOL_VSN) + +# ---------------------------------------------------- +# Release Macros +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/lib/reltool-$(VSN) + +# ---------------------------------------------------- +# Common Macros +# ---------------------------------------------------- + + +MODULES = + +ERL_FILES= $(MODULES:=.erl) + +HRL_FILES = + +DATA_FILES = \ + display_args \ + mnesia_core_dump_viewer + +# TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) +TARGET_FILES = + +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_COMPILE_FLAGS += -pa ../ebin +EBIN = . + +# ---------------------------------------------------- +# Make Rules +# ---------------------------------------------------- +debug opt: $(TARGET_FILES) + +clean: + rm -f $(TARGET_FILES) *~ + +docs: + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: opt + $(INSTALL_DIR) $(RELSYSDIR)/examples + $(INSTALL_DATA) $(ERL_FILES) $(DATA_FILES) $(HRL_FILES) $(RELSYSDIR)/examples + +release_docs_spec: + diff --git a/lib/reltool/examples/display_args b/lib/reltool/examples/display_args new file mode 100644 index 0000000000..bf0994ab7c --- /dev/null +++ b/lib/reltool/examples/display_args @@ -0,0 +1,8 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%%! -smp disable + +main(Args) -> + io:format("Root dir: ~s\n", [code:root_dir()]), + io:format("Script args: ~p\n", [Args]), + io:format("Smp: ~p\n", [erlang:system_info(smp_support)]). diff --git a/lib/reltool/examples/mnesia_core_dump_viewer b/lib/reltool/examples/mnesia_core_dump_viewer new file mode 100755 index 0000000000..725637f95b --- /dev/null +++ b/lib/reltool/examples/mnesia_core_dump_viewer @@ -0,0 +1,54 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%% +%% Pretty print a Mnesia Core Dump +%% +%% core_dump_viewer CoreFile [OutputFile] +%% +%% Status codes: +%% +%% 0 -> Ok +%% 1 -> Bad usage +%% 2 -> Cannot read Mnesia Core file +%% 3 -> Cannot write to file + +-mode(compile). + +main([CoreFile | OptOutputFile]) when CoreFile =/= "--help" -> + %% io:format("Args: ~p\n", [init:get_arguments()]), + case file:read_file(CoreFile) of + {ok, Bin} -> + Core = binary_to_term(Bin), + PrettyCore = io_lib:format("~p\n", [Core]), + PrettyBin = list_to_binary(PrettyCore), + case OptOutputFile of + [OutputFile] -> + case file:write_file(OutputFile, PrettyBin) of + ok -> + ok; + {error, Reason} -> + io:format("<ERROR> Cannot write to file ~p ~p\n", + [OutputFile, Reason]), + halt(3) + end; + [] -> + io:format("~p\n", [Core]), + io:format("ok\n", []), + timer:sleep(timer:seconds(2)), % Poor mans flush of io buffers + init:stop(); + _ -> + usage() + end; + {error, Reason} -> + io:format("<ERROR> Cannot read Mnesia Core file ~p ~p\n", + [CoreFile, Reason]), + halt(2) + end; +main(_BadArgs) -> + usage(). + +usage() -> + FullName = escript:script_name(), + BaseName = filename:basename(FullName), + io:format("usage: ~s CoreFile [OutputFile]\n", [BaseName]), + halt(1). |