From 95dac8f19bcfde94d522a481dcfe39b8640cd498 Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Thu, 15 Jun 2023 17:00:59 +0200 Subject: [PATCH] service,terminal: when libraries don't have debug_info print reason (#3419) Print the reason why libraries don't have debug info in response to the 'libraries' command. --- pkg/terminal/command.go | 3 +++ service/api/conversions.go | 7 ++++++- service/api/types.go | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/terminal/command.go b/pkg/terminal/command.go index ef83ea46..2f8731fb 100644 --- a/pkg/terminal/command.go +++ b/pkg/terminal/command.go @@ -2547,6 +2547,9 @@ func libraries(t *Term, ctx callContext, args string) error { d := digits(len(libs)) for i := range libs { fmt.Fprintf(t.stdout, "%"+strconv.Itoa(d)+"d. %#x %s\n", i, libs[i].Address, libs[i].Path) + if libs[i].LoadError != "" { + fmt.Fprintf(t.stdout, " Load error: %s", libs[i].LoadError) + } } return nil } diff --git a/service/api/conversions.go b/service/api/conversions.go index 0d66749e..08eb3929 100644 --- a/service/api/conversions.go +++ b/service/api/conversions.go @@ -431,7 +431,12 @@ func ConvertRegisters(in *op.DwarfRegisters, dwarfRegisterToString func(int, *op // ConvertImage converts proc.Image to api.Image. func ConvertImage(image *proc.Image) Image { - return Image{Path: image.Path, Address: image.StaticBase} + err := image.LoadError() + lerr := "" + if err != nil { + lerr = err.Error() + } + return Image{Path: image.Path, Address: image.StaticBase, LoadError: lerr} } // ConvertDumpState converts proc.DumpState to api.DumpState. diff --git a/service/api/types.go b/service/api/types.go index c4a947c5..e658ad4a 100644 --- a/service/api/types.go +++ b/service/api/types.go @@ -571,8 +571,9 @@ type Checkpoint struct { // Image represents a loaded shared object (go plugin or shared library) type Image struct { - Path string - Address uint64 + Path string + Address uint64 + LoadError string } // Ancestor represents a goroutine ancestor