@@ -641,8 +641,7 @@ defmodule ElixirLS.Debugger.Server do
641
641
case current [ { m , f , a } ] do
642
642
nil ->
643
643
case interpret ( m , false ) do
644
- { :module , _ } ->
645
- ModuleInfoCache . store ( m )
644
+ :ok ->
646
645
breaks_before = :int . all_breaks ( m )
647
646
648
647
Output . debugger_console (
@@ -663,8 +662,15 @@ defmodule ElixirLS.Debugger.Server do
663
662
{ :error , "Function #{ inspect ( m ) } .#{ f } /#{ a } not found" }
664
663
end
665
664
666
- :error ->
665
+ { :error , :cannot_interpret } ->
667
666
{ :error , "Cannot interpret module #{ inspect ( m ) } " }
667
+
668
+ { :error , :cannot_load } ->
669
+ { :error , "Module #{ inspect ( m ) } cannot be loaded" }
670
+
671
+ { :error , :excluded } ->
672
+ { :error ,
673
+ "Module #{ inspect ( m ) } is used internally by the debugger and cannot be interpreted" }
668
674
end
669
675
670
676
lines ->
@@ -1585,8 +1591,7 @@ defmodule ElixirLS.Debugger.Server do
1585
1591
defp save_and_reload ( module , beam_bin ) do
1586
1592
:ok = File . write ( Path . join ( @ temp_beam_dir , to_string ( module ) <> ".beam" ) , beam_bin )
1587
1593
true = :code . delete ( module )
1588
- { :module , _ } = interpret ( module )
1589
- ModuleInfoCache . store ( module )
1594
+ :ok = interpret ( module )
1590
1595
end
1591
1596
1592
1597
defp set_breakpoints ( path , lines ) do
@@ -1637,18 +1642,28 @@ defmodule ElixirLS.Debugger.Server do
1637
1642
modules_with_breakpoints =
1638
1643
Enum . reduce ( modules , [ ] , fn module , added ->
1639
1644
case interpret ( module , false ) do
1640
- { :module , _ } ->
1641
- ModuleInfoCache . store ( module )
1645
+ :ok ->
1642
1646
Output . debugger_console ( "Setting breakpoint in #{ inspect ( module ) } #{ path } :#{ line } " )
1643
1647
# no need to handle errors here, it can fail only with {:error, :break_exists}
1644
1648
:int . break ( module , line )
1645
1649
update_break_condition ( module , line , condition , log_message , hit_count )
1646
1650
1647
1651
[ module | added ]
1648
1652
1649
- :error ->
1653
+ { :error , :cannot_interpret } ->
1650
1654
Output . debugger_console ( "Could not interpret module #{ inspect ( module ) } in #{ path } " )
1651
1655
added
1656
+
1657
+ { :error , :cannot_load } ->
1658
+ Output . debugger_console ( "Module #{ inspect ( module ) } in #{ path } cannot be loaded" )
1659
+ added
1660
+
1661
+ { :error , :excluded } ->
1662
+ Output . debugger_console (
1663
+ "Module #{ inspect ( module ) } in #{ path } is used internally by the debugger and cannot be interpreted"
1664
+ )
1665
+
1666
+ added
1652
1667
end
1653
1668
end )
1654
1669
@@ -1671,18 +1686,26 @@ defmodule ElixirLS.Debugger.Server do
1671
1686
end
1672
1687
1673
1688
defp interpret_module ( mod ) do
1674
- try do
1675
- case interpret ( mod ) do
1676
- { :module , _ } -> :ok
1677
- { :error , :excluded } -> :ok
1678
- end
1679
- catch
1680
- _kind , _error ->
1689
+ case interpret ( mod ) do
1690
+ :ok ->
1691
+ :ok
1692
+
1693
+ { :error , :cannot_interpret } ->
1681
1694
Output . debugger_important (
1682
1695
"Module #{ inspect ( mod ) } cannot be interpreted. Consider adding it to `excludeModules`."
1683
1696
)
1684
- after
1685
- ModuleInfoCache . store ( mod )
1697
+
1698
+ :ok
1699
+
1700
+ { :error , :excluded } ->
1701
+ :ok
1702
+
1703
+ { :error , :cannot_load } ->
1704
+ Output . debugger_important (
1705
+ "Module #{ inspect ( mod ) } cannot be loaded. Consider adding it to `excludeModules`."
1706
+ )
1707
+
1708
+ :ok
1686
1709
end
1687
1710
end
1688
1711
@@ -1878,7 +1901,16 @@ defmodule ElixirLS.Debugger.Server do
1878
1901
Output . debugger_console ( "Interpreting module #{ inspect ( module ) } " )
1879
1902
end
1880
1903
1881
- :int . ni ( module )
1904
+ case :int . ni ( module ) do
1905
+ :error ->
1906
+ { :error , :cannot_interpret }
1907
+
1908
+ { :module , _ } ->
1909
+ # calling module_info when paused on a breakpoint can deadlock the debugger
1910
+ # cache it for each interpreted module
1911
+ ModuleInfoCache . store ( module )
1912
+ :ok
1913
+ end
1882
1914
end
1883
1915
else
1884
1916
{ :error , :cannot_load }
0 commit comments