Permalink
Browse files

Distributed debugging options

  • Loading branch information...
1 parent 4c7e715 commit d3abdd712c999c4e78f688e6de8a1a0b3828ffad @jakobc jakobc committed with vladdu Jun 12, 2012
@@ -763,7 +763,8 @@ private OtpErlangBinary getDebuggerBeam(final String module) {
final String ver = getErlangVersion();
for (final IConfigurationElement el : els) {
final IContributor c = el.getContributor();
- if (c.getName().equals(bundle.getSymbolicName())) {
+ final String name = c.getName();
+ if (name.equals(bundle.getSymbolicName())) {
final String dir_path = el.getAttribute("path");
Enumeration<?> e = bundle.getEntryPaths(dir_path + "/" + ver);
if (e == null || !e.hasMoreElements()) {
@@ -777,7 +778,9 @@ private OtpErlangBinary getDebuggerBeam(final String module) {
while (e.hasMoreElements()) {
final String s = (String) e.nextElement();
final Path path = new Path(s);
- return getBeamFromBundlePath(bundle, beamname, s, path);
+ if (path.lastSegment().equals(beamname)) {
+ return getBeamFromBundlePath(bundle, beamname, s, path);
+ }
}
}
}
@@ -786,18 +789,16 @@ private OtpErlangBinary getDebuggerBeam(final String module) {
private OtpErlangBinary getBeamFromBundlePath(final Bundle bundle,
final String beamname, final String s, final Path path) {
- if (path.lastSegment().equals(beamname)) {
- if (path.getFileExtension() != null
- && "beam".compareTo(path.getFileExtension()) == 0) {
- final String m = path.removeFileExtension().lastSegment();
- try {
- return BeamUtil.getBeamBinary(m, bundle.getEntry(s));
- } catch (final Exception ex) {
- ErlLogger.warn(ex);
- }
- }
+ if (!path.lastSegment().equals(beamname)) {
+ return null; // Shouln't happen
+ }
+ final String m = path.removeFileExtension().lastSegment();
+ try {
+ return BeamUtil.getBeamBinary(m, bundle.getEntry(s));
+ } catch (final Exception ex) {
+ ErlLogger.warn(ex);
+ return null;
}
- return null;
}
@Override
@@ -491,6 +491,7 @@ parse_cmd(Cmd, LineNo) ->
%%====================================================================
tell_attached(Msg) ->
+ erlang:display({tell, get(attached), Msg}),
case get(attached) of
undefined -> ignore;
AttPid ->
@@ -42,12 +42,11 @@
nodes/0,
process_info/2,
processes/2,
- drop_to_frame/2]).
+ drop_to_frame/2,
+ is_erlide_process/1]).
-export([log/1]).
-%% -compile(export_all).
-
%%
%% API Functions
%%
@@ -64,10 +63,15 @@ fix_flags(N) ->
fix_flag(N, F, A) when N band F =/= 0 -> [A];
fix_flag(_, _, _) -> [].
+local_global(N) when N band 1 =/= 0 ->
+ global;
+local_global(_) ->
+ local.
+
start_debug(Flags) ->
- group_leader(whereis(init), self()),
- {ok, Pid} = erlide_dbg_mon:start(local, fix_flags(Flags)),
- Pid.
+ group_leader(whereis(init), self()),
+ {ok, Pid} = erlide_dbg_mon:start(local_global(Flags), fix_flags(Flags)),
+ Pid.
send_started(JPid) ->
JPid ! {started, whereis(erlide_dbg_mon)}.
@@ -92,20 +96,18 @@ processes(ShowSys, ShowErlide) ->
L
end.
-is_erlide_process(Pid) when is_pid(Pid)->
- Started = case erlang:process_info(Pid, initial_call) of
- undefined ->
- false;
+is_erlide_process(Pid) -> % when is_pid(Pid)->
+ Started = case (catch erlang:process_info(Pid, initial_call)) of
{initial_call, {M1, _, _}} ->
- lists:prefix("erlide_", atom_to_list(M1))
- %% string:equal(string:sub_string(atom_to_list(M1), 1, 7), "erlide_")
+ lists:prefix("erlide_", atom_to_list(M1));
+ _ ->
+ false
end,
- Current = case erlang:process_info(Pid, current_function) of
- undefined ->
- false;
+ Current = case (catch erlang:process_info(Pid, current_function)) of
{current_function, {M2, _, _}} ->
- lists:prefix("erlide_", atom_to_list(M2))
- %% string:equal(string:sub_string(atom_to_list(M2), 1, 7), "erlide_")
+ lists:prefix("erlide_", atom_to_list(M2));
+ _ ->
+ false
end,
Started or Current.
@@ -159,8 +161,8 @@ set_variable_value(Variable, Value, SP, MetaPid) ->
erlide_dbg_mon:set_variable_value(Variable, Value, SP, MetaPid).
distribute_debugger_code(Modules) ->
- [rpc:multicall(code, load_binary, [Module, Filename, Binary]) ||
- {Module, Filename, Binary} <- Modules].
+ [rpc:multicall(code, load_binary, [Module, Filename, Binary])
+ || {Module, Filename, Binary} <- Modules].
nodes() ->
[node() | erlang:nodes()].
@@ -505,6 +505,7 @@ load({Mod, Src, Beam, Exp, Abst}, Dist) ->
fun() ->
code:purge(Mod),
erts_debug:breakpoint({Mod,'_','_'}, false),
+ erlang:display({load, Mod, node()}),
{module,Mod} = code:load_abs(filename:rootname(Beam),
Mod)
end),
@@ -519,12 +520,15 @@ load({Mod, Src, Beam, Exp, Abst}, Dist) ->
end),
{module, Mod};
load({Mod, Beam, Exp, Abst}, Dist) ->
+ X = everywhere(Dist, fun() -> erlang:display({lo2, node(), is_alive()}) end),
+ erlang:display({x, X}),
everywhere(Dist,
fun() ->
code:purge(Mod),
erts_debug:breakpoint({Mod,'_','_'}, false),
{module,Mod} = code:load_abs(filename:rootname(Beam),
Mod),
+ erlang:display({load2, Mod, node()}),
{module,Mod}
end),
{ok, BeamBin} = file:read_file(Beam),
@@ -204,11 +204,11 @@ private void updateMenuCategoryCheckedState(
public void setChecked(final CheckboxTreeViewer checkboxTreeViewer,
final Collection<IErlModule> list) {
setGrayChecked(checkboxTreeViewer, false, list.contains(item));
- // for (final DebugTreeItem c : children) {
- // c.setChecked(checkboxTreeViewer, list);
- // // c.getParent()
- // // .updateMenuCategoryCheckedState(checkboxTreeViewer);
- // }
+ for (final DebugTreeItem c : children) {
+ c.setChecked(checkboxTreeViewer, list);
+ c.getParent()
+ .updateMenuCategoryCheckedState(checkboxTreeViewer);
+ }
}
}

0 comments on commit d3abdd7

Please sign in to comment.