This patch improves and simplifies the debugging hooks. Now you just have to break on nnd to find all "interesting" creations/modifications of node ids. No change in functionality; no test available.
Tested on x86_64-pc-linux-gnu, committed on trunk 2017-10-09 Bob Duff <d...@adacore.com> * atree.adb: Make nnd apply to everything "interesting", including Rewrite. Remove rrd.
Index: atree.adb =================================================================== --- atree.adb (revision 253546) +++ atree.adb (working copy) @@ -73,12 +73,13 @@ -- ww := 12345 -- and set a breakpoint on New_Node_Breakpoint (nickname "nn"). Continue. - -- Either way, gnat1 will stop when node 12345 is created + -- Either way, gnat1 will stop when node 12345 is created, or certain other + -- interesting operations are performed, such as Rewrite. To see exactly + -- which operations, search for "pragma Debug" below. - -- The second method is much faster + -- The second method is much faster if the amount of Ada code being + -- compiled is large. - -- Similarly, rr and rrd allow breaking on rewriting of a given node - ww : Node_Id'Base := Node_Id'First - 1; pragma Export (Ada, ww); -- trick the optimizer Watch_Node : Node_Id'Base renames ww; @@ -103,24 +104,8 @@ -- If Node = Watch_Node, this prints out the new node and calls -- New_Node_Breakpoint. Otherwise, does nothing. - procedure rr; - pragma Export (Ada, rr); - procedure Rewrite_Breakpoint renames rr; - -- This doesn't do anything interesting; it's just for setting breakpoint - -- on as explained above. - - procedure rrd (Old_Node, New_Node : Node_Id); - pragma Export (Ada, rrd); - procedure Rewrite_Debugging_Output - (Old_Node, New_Node : Node_Id) renames rrd; - -- For debugging. If debugging is turned on, Rewrite calls this. If debug - -- flag N is turned on, this prints out the new node. - -- - -- If Old_Node = Watch_Node, this prints out the old and new nodes and - -- calls Rewrite_Breakpoint. Otherwise, does nothing. - procedure Node_Debug_Output (Op : String; N : Node_Id); - -- Common code for nnd and rrd, writes Op followed by information about N + -- Called by nnd; writes Op followed by information about N procedure Print_Statistics; pragma Export (Ada, Print_Statistics); @@ -751,6 +736,8 @@ Save_Link : constant Union_Id := Nodes.Table (Destination).Link; begin + pragma Debug (New_Node_Debugging_Output (Source)); + pragma Debug (New_Node_Debugging_Output (Destination)); Nodes.Table (Destination) := Nodes.Table (Source); Nodes.Table (Destination).In_List := Save_In_List; Nodes.Table (Destination).Link := Save_Link; @@ -1348,6 +1335,8 @@ Temp_Flg : Flags_Byte; begin + pragma Debug (New_Node_Debugging_Output (E1)); + pragma Debug (New_Node_Debugging_Output (E2)); pragma Assert (True and then Has_Extension (E1) and then Has_Extension (E2) @@ -1746,7 +1735,6 @@ begin Write_Str ("Watched node "); Write_Int (Int (Watch_Node)); - Write_Str (" created"); Write_Eol; end nn; @@ -1759,7 +1747,7 @@ begin if Debug_Flag_N or else Node_Is_Watched then - Node_Debug_Output ("Allocate", N); + Node_Debug_Output ("Node", N); if Node_Is_Watched then New_Node_Breakpoint; @@ -2163,6 +2151,8 @@ (not Has_Extension (Old_Node) and not Has_Extension (New_Node) and not Nodes.Table (New_Node).In_List); + pragma Debug (New_Node_Debugging_Output (Old_Node)); + pragma Debug (New_Node_Debugging_Output (New_Node)); -- Do copy, preserving link and in list status and required flags @@ -2214,7 +2204,8 @@ (not Has_Extension (Old_Node) and not Has_Extension (New_Node) and not Nodes.Table (New_Node).In_List); - pragma Debug (Rewrite_Debugging_Output (Old_Node, New_Node)); + pragma Debug (New_Node_Debugging_Output (Old_Node)); + pragma Debug (New_Node_Debugging_Output (New_Node)); if Nkind (Old_Node) in N_Subexpr then Old_Paren_Count := Paren_Count (Old_Node); @@ -2264,36 +2255,6 @@ end if; end Rewrite; - ------------------------- - -- Rewrite_Breakpoint -- - ------------------------- - - procedure rr is - begin - Write_Str ("Watched node "); - Write_Int (Int (Watch_Node)); - Write_Str (" rewritten"); - Write_Eol; - end rr; - - ------------------------------ - -- Rewrite_Debugging_Output -- - ------------------------------ - - procedure rrd (Old_Node, New_Node : Node_Id) is - Node_Is_Watched : constant Boolean := Old_Node = Watch_Node; - - begin - if Debug_Flag_N or else Node_Is_Watched then - Node_Debug_Output ("Rewrite", Old_Node); - Node_Debug_Output ("into", New_Node); - - if Node_Is_Watched then - Rewrite_Breakpoint; - end if; - end if; - end rrd; - ------------------ -- Set_Analyzed -- ------------------