Skip to content

Commit dbb8a33

Browse files
committed
Merge pull request #217 from kennytm/debug-sym-fix
Fix some bugs regarding debugging symbols (ozc -g)
2 parents 40944fe + d329869 commit dbb8a33

File tree

5 files changed

+75
-29
lines changed

5 files changed

+75
-29
lines changed

lib/compiler/CodeGen.oz

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,7 @@ define
861861
StateReg = none
862862
end
863863
case @toCopy of unit then
864-
FormalRegs AllRegs AllRegs2 BodyVInter BodyVInstr GRegs Code VInter
865-
Cont1 Cont2
864+
FormalRegs AllRegs AllRegs2 BodyVInter GRegs Code Cont1 Cont2
866865
in
867866
{CS startDefinition()}
868867
FormalRegs = {Map @formalArgs
@@ -876,21 +875,16 @@ define
876875
elseof Vs then {GetRegs Vs}
877876
end
878877
case StateReg of none then
879-
BodyVInstr = BodyVInter
880-
VHd0 = VInter
881878
AllRegs2 = AllRegs
882879
else
883-
BodyVInstr = vSetSelf(_ StateReg BodyVInter)
884-
VHd0 = vGetSelf(_ StateReg VInter)
885880
AllRegs2 = StateReg|AllRegs
886881
end
887-
{CS endDefinition(BodyVInstr FormalRegs AllRegs2 ?GRegs ?Code
882+
{CS endDefinition(BodyVInter FormalRegs AllRegs2 ?GRegs ?Code
888883
?OuterNLiveRegs)}
889-
VInter = vDefinition(_ {V reg($)} PredId @procedureRef
890-
GRegs Code VTl0)
884+
VHd0 = vDefinition(_ {V reg($)} PredId @procedureRef
885+
GRegs Code VTl0)
891886
else
892-
VInter FormalRegs AllRegs
893-
InnerBodyVInter InnerBodyVInstr InnerGRegs InnerCode
887+
FormalRegs AllRegs InnerBodyVInter InnerGRegs InnerCode
894888
InnerDefinitionReg InnerPredId InnerNLiveRegs
895889
OuterBodyVInstr OuterBodyVInter2 OuterGRegs OuterCode
896890
in
@@ -905,14 +899,7 @@ define
905899
AllRegs = case @allVariables of nil then nil
906900
elseof Vs then {GetRegs Vs}
907901
end
908-
case StateReg of none then
909-
InnerBodyVInstr = InnerBodyVInter
910-
VHd0 = VInter
911-
else
912-
InnerBodyVInstr = vSetSelf(_ StateReg InnerBodyVInter)
913-
VHd0 = vGetSelf(_ StateReg VInter)
914-
end
915-
{CS endDefinition(InnerBodyVInstr nil AllRegs
902+
{CS endDefinition(InnerBodyVInter nil AllRegs
916903
?InnerGRegs ?InnerCode ?InnerNLiveRegs)}
917904
{CS newReg(?InnerDefinitionReg)}
918905
InnerPredId = {Adjoin PredId
@@ -964,8 +951,8 @@ define
964951
OuterBodyVInter2 = vCall(_ InnerDefinitionReg nil unit nil)
965952
{CS endDefinition(OuterBodyVInstr FormalRegs AllRegs
966953
?OuterGRegs ?OuterCode ?OuterNLiveRegs)}
967-
VInter = vDefinition(_ {V reg($)} PredId @procedureRef
968-
OuterGRegs OuterCode VTl0)
954+
VHd0 = vDefinition(_ {V reg($)} PredId @procedureRef
955+
OuterGRegs OuterCode VTl0)
969956
end
970957
{StepPoint @coord 'definition' VHd VTl VHd0 VTl0}
971958
statements <- unit % hand them to the garbage collector

platform-test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ endforeach()
3333

3434
# debug folder
3535
set(DEBUG_FUNCTORS
36-
"stacktrace_line_num.oz"
36+
"stacktrace_line_num.oz" "gc.oz"
3737
)
3838
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/debug")
3939
foreach(FUNCTOR ${DEBUG_FUNCTORS})

platform-test/debug/gc.oz

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
%%%
2+
%%% Authors:
3+
%%% kennytm
4+
%%%
5+
%%% Copyright:
6+
%%% Kenny Chan, 2014
7+
%%%
8+
%%% Last change:
9+
%%% $Date$ by $Author$
10+
%%% $Revision$
11+
%%%
12+
%%% This file is part of Mozart, an implementation
13+
%%% of Oz 3
14+
%%% http://www.mozart-oz.org
15+
%%%
16+
%%% See the file "LICENSE" or
17+
%%% http://www.mozart-oz.org/LICENSE.html
18+
%%% for information on usage and redistribution
19+
%%% of this file, and for a DISCLAIMER OF ALL
20+
%%% WARRANTIES.
21+
%%%
22+
23+
functor
24+
25+
import
26+
System(gcDo)
27+
28+
export
29+
Return
30+
31+
define
32+
Return = gcDebug([
33+
gcDebugTest(proc {$}
34+
{System.gcDo}
35+
{System.gcDo} % <-- should not crash at this point.
36+
end)
37+
])
38+
39+
end
40+

platform-test/debug/stacktrace_line_num.oz

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@ functor
2424
export
2525
Return
2626
define
27-
EnsureFailureLineNumber = 29
27+
FunctionFailureLineNumber = 31
28+
ClassFailureLineNumber = 39
29+
2830
proc {EnsureFailure}
2931
2 + 2 = 5
3032
end
3133

34+
class ClassFailure
35+
prop locking
36+
37+
meth something
38+
lock
39+
2 + 2 = 5
40+
end
41+
end
42+
end
43+
3244
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3345

3446
fun {CreateTestCase P LineNumber Key}
@@ -45,8 +57,15 @@ define
4557
keys: [Key stacktraceLineNum]
4658
)
4759
end
60+
4861
Return = stacktraceLineNum([
49-
{CreateTestCase EnsureFailure EnsureFailureLineNumber simpleFunctionCall}
62+
{CreateTestCase EnsureFailure
63+
FunctionFailureLineNumber
64+
simpleFunctionCall}
65+
66+
{CreateTestCase (proc {$} _ = {New ClassFailure something} end)
67+
ClassFailureLineNumber
68+
simpleMethodCall}
5069
])
5170
end
5271

vm/vm/main/emulate.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ DebugEntry::DebugEntry(GR gr, const DebugEntry& from):
7575
// StackEntry //
7676
////////////////
7777

78-
StackEntry::StackEntry(GR gr, StackEntry& from) {
78+
StackEntry::StackEntry(GR gr, StackEntry& from):
79+
debugEntry(gr, from.debugEntry)
80+
{
7981
if (from.abstraction == nullptr)
8082
abstraction = nullptr;
8183
else
@@ -92,8 +94,6 @@ StackEntry::StackEntry(GR gr, StackEntry& from) {
9294
gr->copyUnstableNode(yregs[i], from.yregs[i]);
9395
}
9496

95-
debugEntry = DebugEntry(gr, from.debugEntry);
96-
9797
// gregs and kregs are irrelevant
9898
}
9999

@@ -373,10 +373,10 @@ void Thread::run() {
373373
case OpDebugEntry:
374374
case OpDebugExit: {
375375
debugEntry.valid = true;
376-
debugEntry.file = new (vm) StableNode(vm, KPC(1));
376+
debugEntry.file = & KPC(1);
377377
debugEntry.lineNumber = IntPC(2);
378378
debugEntry.columnNumber = IntPC(3);
379-
debugEntry.kind = new (vm) StableNode(vm, KPC(4));
379+
debugEntry.kind = & KPC(4);
380380
advancePC(4);
381381
break;
382382
}

0 commit comments

Comments
 (0)