|
@@ -368,35 +368,45 @@ func printAssembly(w io.Writer, rpt *Report, obj plugin.ObjTool) error {
|
368
|
368
|
|
369
|
369
|
function, file, line := "", "", 0
|
370
|
370
|
for _, n := range ns {
|
371
|
|
- flat := valueOrDot(n.flatValue(), rpt)
|
372
|
|
- cum := valueOrDot(n.cumValue(), rpt)
|
373
|
|
- if n.function == function && n.file == file && n.line == line {
|
|
371
|
+ locStr := ""
|
|
372
|
+ // Skip loc information if it hasn't changed from previous instruction.
|
|
373
|
+ if n.function != function || n.file != file || n.line != line {
|
|
374
|
+ function, file, line = n.function, n.file, n.line
|
|
375
|
+ if n.function != "" {
|
|
376
|
+ locStr = n.function + " "
|
|
377
|
+ }
|
|
378
|
+ if n.file != "" {
|
|
379
|
+ locStr += n.file
|
|
380
|
+ if n.line != 0 {
|
|
381
|
+ locStr += fmt.Sprintf(":%d", n.line)
|
|
382
|
+ }
|
|
383
|
+ }
|
|
384
|
+ }
|
|
385
|
+ switch {
|
|
386
|
+ case locStr == "":
|
|
387
|
+ // No location info, just print the instruction.
|
374
|
388
|
fmt.Fprintf(w, "%10s %10s %10x: %s\n",
|
375
|
|
- flat, cum,
|
|
389
|
+ valueOrDot(n.flatValue(), rpt),
|
|
390
|
+ valueOrDot(n.cumValue(), rpt),
|
376
|
391
|
n.address, n.instruction,
|
377
|
392
|
)
|
378
|
|
- continue
|
379
|
|
- }
|
380
|
|
- line := ""
|
381
|
|
- if n.line > 0 {
|
382
|
|
- line = fmt.Sprintf(":%d", n.line)
|
383
|
|
- }
|
384
|
|
- if len(n.instruction) <= 40 {
|
385
|
|
- fmt.Fprintf(w, "%10s %10s %10x: %-40s; %s %s%s\n",
|
386
|
|
- flat, cum,
|
|
393
|
+ case len(n.instruction) < 40:
|
|
394
|
+ // Short instruction, print loc on the same line.
|
|
395
|
+ fmt.Fprintf(w, "%10s %10s %10x: %-40s;%s\n",
|
|
396
|
+ valueOrDot(n.flatValue(), rpt),
|
|
397
|
+ valueOrDot(n.cumValue(), rpt),
|
|
398
|
+ n.address, n.instruction,
|
|
399
|
+ locStr,
|
|
400
|
+ )
|
|
401
|
+ default:
|
|
402
|
+ // Long instruction, print loc on a separate line.
|
|
403
|
+ fmt.Fprintf(w, "%74s;%s\n", "", locStr)
|
|
404
|
+ fmt.Fprintf(w, "%10s %10s %10x: %s\n",
|
|
405
|
+ valueOrDot(n.flatValue(), rpt),
|
|
406
|
+ valueOrDot(n.cumValue(), rpt),
|
387
|
407
|
n.address, n.instruction,
|
388
|
|
- n.function, n.file, line,
|
389
|
408
|
)
|
390
|
|
- continue
|
391
|
409
|
}
|
392
|
|
- fmt.Fprintf(w, "%75s; %s %s%s\n",
|
393
|
|
- "",
|
394
|
|
- n.function, n.file, line,
|
395
|
|
- )
|
396
|
|
- fmt.Fprintf(w, "%10s %10s %10x: %s\n",
|
397
|
|
- flat, cum,
|
398
|
|
- n.address, n.instruction,
|
399
|
|
- )
|
400
|
410
|
}
|
401
|
411
|
}
|
402
|
412
|
return nil
|