Skip to content

Commit 5610592

Browse files
Ro6afFalehander92
authored andcommitted
fix(ux): reduce debug spam
1 parent c6026a3 commit 5610592

File tree

3 files changed

+1
-104
lines changed

3 files changed

+1
-104
lines changed

internal/engine/interpreter/interpreter.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -720,16 +720,12 @@ func (ce *callEngine) callNativeFunc(ctx context.Context, m *wasm.ModuleInstance
720720

721721
// TODO: Figure out a way to resolve how many local variables we need
722722
locals := make([]uint64, 10000)
723-
// 16d03 16d0d
724-
// fmt.Printf("FRAME HAS BASE: %d\n", len(ce.stack))
725723

726724
initialOffset := frame.f.parent.offsetsInWasmBinary[frame.pc]
727725

728726
// NOTE: Function PC intervals are disjoint, hence AnyIntersection() is sufficient
729727
functionRecord, _ := frame.f.parent.source.PCRecord.Function.AnyIntersection(initialOffset, initialOffset)
730728

731-
// fmt.Printf("Function record: %v\n", functionRecord)
732-
733729
tracking_call := m.Record != nil && (strings.HasSuffix(functionRecord.FileName, ".rs") &&
734730
!strings.HasPrefix(functionRecord.FileName, "/rustc") &&
735731
!strings.Contains(functionRecord.FileName, ".rustup") &&
@@ -817,7 +813,6 @@ func (ce *callEngine) callNativeFunc(ctx context.Context, m *wasm.ModuleInstance
817813
}
818814
}
819815

820-
fmt.Printf("STEP: %v\n", lineRecord)
821816
currLine = lineRecord
822817
m.Record.RegisterStep(currLine.FileName, trace_record.Line(currLine.Line))
823818

@@ -840,28 +835,8 @@ func (ce *callEngine) callNativeFunc(ctx context.Context, m *wasm.ModuleInstance
840835
}
841836
}
842837
}
843-
// positions := frame.f.parent.source.DWARFLines.DebugPositions(frame.f.parent.offsetsInWasmBinary[frame.pc])
844-
845-
// // TODO: handle inline stuff
846-
// if len(positions) == 1 {
847-
// for _, line := range positions {
848-
// if strings.HasSuffix(line.Line.FileName, ".rs") && !strings.HasPrefix(line.Line.FileName, "/rustc") && !strings.Contains(line.Line.FileName, ".rustup") && !strings.Contains(line.Line.FileName, ".cargo") && line.Line.Line != 0 {
849-
// if currPosition.Line.FileName != line.Line.FileName || currPosition.Line.Line != line.Line.Line {
850-
// fmt.Printf("Step: \"%v\"\n", line)
851-
// m.Record.RegisterStep(line.Line.FileName, trace_record.Line(line.Line.Line))
852-
// currPosition = line
853-
// }
854-
// }
855-
// }
856-
// }
857838
}
858839

859-
// bytes, flag := m.Memory().Read(65520+12, 4)
860-
861-
// if flag {
862-
// fmt.Printf("BYTES FOR LOCAL: %v\n", bytes)
863-
// }
864-
865840
op := &body[frame.pc]
866841

867842
// TODO: add description of each operation/case
@@ -4515,7 +4490,6 @@ func traceReturnType(functionRecord wasmdebug.FunctionRecord,
45154490

45164491
if functionRecord.ReturnType == nil {
45174492
typeName := "void"
4518-
fmt.Printf("Return: %v\n", functionRecord.Name)
45194493
_, seen := m.TypesIndex[typeName]
45204494

45214495
if !seen {
@@ -4529,10 +4503,6 @@ func traceReturnType(functionRecord wasmdebug.FunctionRecord,
45294503
rawValue := ce.stack[len(ce.stack)-1]
45304504
rvSize := (*functionRecord.ReturnType).Size()
45314505

4532-
fmt.Printf("RAW VAL: %d\n", rawValue)
4533-
4534-
fmt.Printf("FUNCTION: %s has return value size: %d and byte size: %d and other size: %d and type: %#v\n", functionRecord.Name, (*functionRecord.ReturnType).Size(), (*functionRecord.ReturnType).Common().ByteSize, (*functionRecord.ReturnType).Common().Size(), (*functionRecord.ReturnType))
4535-
45364506
var value trace_record.ValueRecord
45374507
if rvSize <= 8 {
45384508

@@ -4577,7 +4547,6 @@ func traceReturnType(functionRecord wasmdebug.FunctionRecord,
45774547
}
45784548

45794549
m.Record.RegisterReturn(value)
4580-
fmt.Printf("Return: %v. Value: %v\n", functionRecord.Name, value)
45814550
}
45824551
}
45834552

@@ -4588,17 +4557,13 @@ func traceFunctionEntry(m *wasm.ModuleInstance, loggedCall *bool, functionRecord
45884557

45894558
*loggedCall = true
45904559

4591-
fmt.Printf("Call: %v. Args:\n", functionRecord.Name)
4592-
45934560
args := make([]trace_record.FullValueRecord, 0)
45944561

45954562
for _, argRec := range functionRecord.Params {
4596-
fmt.Printf("\t")
45974563
val, err := readVariable(m, argRec, functionRecord, locals)
45984564
if err != nil {
45994565
fmt.Fprintf(os.Stderr, "Can't read function argument %s: %v\n", argRec.Name, err)
46004566
} else {
4601-
fmt.Printf("\t%v: %v\n", argRec.Name, val)
46024567
args = append(args, m.Record.Arg(argRec.Name, val))
46034568
}
46044569
}
@@ -4625,7 +4590,6 @@ func traceCurrentLocals(localRecords *[]wasmdebug.VariableRecord, offset uint64,
46254590
if err != nil {
46264591
fmt.Fprintf(os.Stderr, "Can't read variable %s: %v\n", v.Name, err)
46274592
} else {
4628-
// fmt.Printf("local %v: %v\n", v.Name, val)
46294593
m.Record.RegisterVariable(v.Name, val)
46304594
}
46314595
}
@@ -4634,11 +4598,8 @@ func traceCurrentLocals(localRecords *[]wasmdebug.VariableRecord, offset uint64,
46344598
}
46354599

46364600
func traceInlineEntry(m *wasm.ModuleInstance, rec wasmdebug.InlineRecord, functionRecord wasmdebug.FunctionRecord, locals []uint64, offset uint64, currLocals *[]wasmdebug.VariableRecord) {
4637-
4638-
fmt.Printf("INLINE CALL: %s\n", rec.Name)
46394601
args := make([]trace_record.FullValueRecord, 0)
46404602
for _, argRec := range rec.Params {
4641-
fmt.Printf("%s has var: %s", rec.Name, argRec.Name)
46424603
val, err := readVariable(m, argRec, functionRecord, locals)
46434604
if err != nil {
46444605
fmt.Fprintf(os.Stderr, "Can't read inline argument %s: %v\n", argRec.Name, err)
@@ -4647,7 +4608,6 @@ func traceInlineEntry(m *wasm.ModuleInstance, rec wasmdebug.InlineRecord, functi
46474608
}
46484609
}
46494610

4650-
fmt.Printf("INLINED STEP: %v\n", rec.CallLine)
46514611
m.Record.RegisterStep(rec.FileName, trace_record.Line(rec.CallLine))
46524612
traceCurrentLocals(currLocals, offset, m, &functionRecord, locals)
46534613

internal/engine/interpreter/variable_readers.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ func readVariable(m *wasm.ModuleInstance, v wasmdebug.VariableRecord, functionRe
4646
}
4747

4848
func bytesToValueRecord(rawBytes []byte, typ dwarf.Type, m *wasm.ModuleInstance) (val trace_record.ValueRecord, typeId trace_record.TypeId, err error) {
49-
fmt.Printf("PARSING BYTES FOR TYPE %v. SIZE IS %v AND RAW BYTES ARE %v\n", typ.String(), typ.Size(), len(rawBytes))
50-
5149
switch t := typ.(type) {
5250
case *dwarf.IntType:
5351
val, typeId, err = bytesToInt(rawBytes, t, m)
@@ -70,7 +68,6 @@ func bytesToValueRecord(rawBytes []byte, typ dwarf.Type, m *wasm.ModuleInstance)
7068
case *dwarf.StructType:
7169
// TODO: make these language specific
7270
typeStr := typ.String()
73-
fmt.Printf("Type str: %s\n", typeStr)
7471
if typeStr == "struct &str" {
7572
val, typeId, err = bytesToStringRust(rawBytes, t, m)
7673
} else if strings.HasPrefix(typeStr, "struct (") && strings.HasSuffix(typeStr, ")") {
@@ -343,8 +340,6 @@ func bytesToArray(rawBytes []byte, typ *dwarf.ArrayType, m *wasm.ModuleInstance)
343340

344341
elems := make([]trace_record.ValueRecord, 0)
345342

346-
fmt.Printf("ARR HAS LEN: %d AND ELEM SIZE: %d\n", int(arrayLen), elemSize)
347-
348343
for i := 0; i < int(arrayLen); i++ {
349344

350345
// TODO: Construct array Type info, DO NOT ignore it

internal/wasmdebug/dwarf_indexing.go

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ func IndexDwarfData(d *dwarf.Data) (ret PCRecord, err error) {
122122
fmt.Fprintf(os.Stderr, "error indexing compile unit: %v\n", err)
123123
}
124124

125-
// case dwarf.TagInlinedSubroutine:
126-
// fmt.Println("INDEXING INLINED ENTRY INFORMATION!")
127-
// if err := indexInlineEntry(r, ent, d, files, &ret); err != nil {
128-
// fmt.Fprintf(os.Stderr, "error indexing inlined subroutine:\n\t%#v\n\t%v\n", ent, err)
129-
// }
130-
131125
case dwarf.TagSubprogram:
132126
if err := indexFunctionEntry(r, ent, d, files, &ret, offset2function); err != nil {
133127
fmt.Fprintf(os.Stderr, "error indexing function:\n\t%#v\n\t%v\n", ent, err)
@@ -140,17 +134,13 @@ func IndexDwarfData(d *dwarf.Data) (ret PCRecord, err error) {
140134
}
141135
}
142136

143-
fmt.Printf("Type param map: %#v\n", ret.TypeParamMap)
144-
145137
for _, record := range offset2function {
146138
// TODO: are these all the cases when an entry is invalid?
147139
if record == nil || isTombstoneAddr(record.LowPC) || isTombstoneAddr(record.HighPC) || record.Name == "" {
148-
fmt.Fprintf(os.Stderr, "Malformed function entry %#v\n", record)
140+
fmt.Fprintf(os.Stderr, "Malformed function entry %s %s:%d\n", record.Name, record.FileName, record.Line)
149141
continue
150142
}
151143

152-
fmt.Printf("INDEXED %#v\n", record)
153-
154144
ret.Function.Insert(record.LowPC, record.HighPC-1, *record)
155145
}
156146

@@ -161,8 +151,6 @@ func indexStructType(d *dwarf.Data, ent *dwarf.Entry, ret *PCRecord) error {
161151
sr := d.Reader()
162152
sr.Seek(ent.Offset)
163153

164-
fmt.Printf("INDEXING TYPE PARAMS FOR STRUCT: %s\n", ent.AttrField(dwarf.AttrName).Val.(string))
165-
166154
for ent.Children {
167155
child, err := sr.Next()
168156

@@ -193,8 +181,6 @@ func indexStructType(d *dwarf.Data, ent *dwarf.Entry, ret *PCRecord) error {
193181
}
194182

195183
ret.TypeParamMap[typeName][templateName] = paramType
196-
197-
fmt.Printf("FOUND TYPE PARAM: %s %s %#v\n", typeName, templateName, paramType)
198184
}
199185

200186
}
@@ -257,7 +243,6 @@ func indexVariable(arr *[]VariableRecord, varEntry *dwarf.Entry, d *dwarf.Data,
257243
Index: uint32(res),
258244
}
259245
} else {
260-
fmt.Println("INTERESTING CYKA")
261246
res := parseLEB128(v[2:])
262247
varLocation = MemoryLocation{
263248
Typ: LocationTypeDirectLocal,
@@ -270,11 +255,9 @@ func indexVariable(arr *[]VariableRecord, varEntry *dwarf.Entry, d *dwarf.Data,
270255
// This is probably some location field
271256

272257
default:
273-
fmt.Printf("CYKA: %s - %#v\n", varName, varLocationField)
274258
return fmt.Errorf("keep going :)")
275259
}
276260

277-
fmt.Printf("ADDING VAR %s with range %d - %d and location: %#v\n", varName, lowPC, highPC, varLocationField)
278261
*arr = append(*arr, VariableRecord{
279262
Name: varName,
280263
// Offset: varLocation,
@@ -288,45 +271,8 @@ func indexVariable(arr *[]VariableRecord, varEntry *dwarf.Entry, d *dwarf.Data,
288271
}
289272

290273
func indexLexBlock(r dwarf.Reader, lexEntry *dwarf.Entry, files []*dwarf.LineFile, d *dwarf.Data, locals *[]VariableRecord, params *[]VariableRecord, ret *PCRecord) (DwarfPC, error) {
291-
292-
// var lowPC uint64
293-
// var highPC uint64
294-
295274
entryOffset := DwarfPC(lexEntry.Offset)
296275

297-
// if lowPcWrapped := lexEntry.AttrField(dwarf.AttrLowpc); lowPcWrapped != nil {
298-
// switch v := lowPcWrapped.Val.(type) {
299-
// case uint64:
300-
// lowPC = v
301-
// // case int64:
302-
// // record.LowPC = uint64(v)
303-
// default:
304-
// // return entryOffset, fmt.Errorf("unrecognized lowPc format")
305-
// lowPC = 0
306-
// }
307-
// } else {
308-
//
309-
// lowPC = 0
310-
// }
311-
312-
// if highPcWrapped := lexEntry.AttrField(dwarf.AttrHighpc); highPcWrapped != nil {
313-
// switch highPcWrapped.Class {
314-
// case dwarf.ClassAddress: // we assume it's an absolute offset
315-
// highPC = highPcWrapped.Val.(uint64)
316-
// case dwarf.ClassConstant:
317-
// highPC = lowPC + uint64(highPcWrapped.Val.(int64))
318-
// default:
319-
// //return entryOffset, fmt.Errorf("unrecognized highPc format")
320-
// highPC = math.MaxUint64
321-
// }
322-
// } else {
323-
// highPC = math.MaxUint64
324-
// }
325-
326-
// if isTombstoneAddr(lowPC) || isTombstoneAddr(highPC) {
327-
// return entryOffset, fmt.Errorf("tombstone address")
328-
// }
329-
330276
ranges, err := d.Ranges(lexEntry)
331277
if err != nil {
332278
return entryOffset, err
@@ -656,8 +602,6 @@ func indexInlinedEntry(r dwarf.Reader, inlinedEnt *dwarf.Entry, d *dwarf.Data, f
656602
entry = append(entry, rec)
657603
ret.InlinedRoutines.Insert(lowPC, highPC-1, entry)
658604
}
659-
660-
fmt.Printf("INSERTING INLINE INTERVAL [%d %d] : %#v\n", lowPC, highPC-1, rec)
661605
}
662606

663607
return exitOffset, nil
@@ -684,7 +628,6 @@ func parseLEB128(v []uint8) uint64 {
684628
}
685629

686630
func indexCompileUnit(cu *dwarf.Entry, d *dwarf.Data, tree *PCRecord) ([]*dwarf.LineFile, error) {
687-
fmt.Println("---------------------------------------------------------")
688631
lineReader, err := d.LineReader(cu)
689632
if err != nil || lineReader == nil {
690633
return nil, fmt.Errorf("can't initialize line reader: %v", err)
@@ -703,7 +646,6 @@ func indexCompileUnit(cu *dwarf.Entry, d *dwarf.Data, tree *PCRecord) ([]*dwarf.
703646

704647
if prevLe != nil {
705648
if prevLe.IsStmt {
706-
fmt.Printf("LINE: %s:%d:%d RANGE: [%x; %x]\n", prevLe.File.Name, prevLe.Line, prevLe.Column, prevLe.Address, le.Address-1)
707649
tree.Line.Insert(prevLe.Address, le.Address-1, LineRecord{
708650
FileName: prevLe.File.Name,
709651
Line: int64(prevLe.Line),

0 commit comments

Comments
 (0)