Subject: bug#66604: [PATCH] Gud LLDB completions

From: Mattias Engdegård <[email-masked]>
Date: Tue, 24 Oct 2023 10:47:57 +0200

24 okt. 2023 kl. 06.35 skrev Gerd Möllmann <[email-masked]>:

> The idea would have been to append the Gud format to frame-format, so
> that the possibly user-defined frame-format stays visible. I found the
> output of "settings show frame-format" too difficult to parse in the
> general case, and LLDB's Python API didn't give me a clue how to get at
> the value of frame-format so that I could perhaps produce something
> that's easier to handle.

I'm sure there's a better way, but this seems to work:

deb = lldb.debugger
inst = deb.GetInstanceName()
ff0 = deb.GetInternalVariableValue("frame-format", inst).GetStringAtIndex(0)
ff1 = ff0[:-1] + '!gud file ${line.file.fullpath}\\n"'
deb.SetInternalVariable("frame-format", ff1, inst)

The GetInternalVariableValue method returns an lldb.SBStringList with the actual string as its first element. For some reason this string is in quoted form and the newline is escaped as well, so we peel off the last quote before gluing on the rest.