Subject: bug#30320: 26.0.91; Crash when using lsp-ui-doc-mode

From: Jake Goulding <[email-masked]>
Date: Sun, 4 Feb 2018 16:08:37 -0500

> the first
> element of the args[] array passed to Ffuncall is the symbol of the
> function that is being called.  To display the name of that symbol,
> you will have to emulate by hand what the xsymbol command, defined on
> .gdbinit, does.

I cannot find a way to just use the GDB `define`d helpers in LLDB, so
it looks like I need to re-create
them. Unfortunately, I'm getting values that don't make sense; I'm
sure I'm not translating something
correctly but it's not obvious what:

(lldb) frame info
frame #36: 0x00000001002e4105 Emacs`Ffuncall(nargs=3,
args=0x00007ffeefbfb610) at eval.c:2768
(lldb) p args
(Lisp_Object *) $76 = 0x00007ffeefbfb610
(lldb) p args[0]
(Lisp_Object) $77 = 48784336

# Attempting equivalent to `xgetptr`
(lldb) p args[0] & VALMASK
(long) $78 = 48784336

# Attempting equivalent to `xgetsym`
(lldb) p ((struct Lisp_Symbol *) ((char *)lispsym + (args[0] & VALMASK)))
(struct Lisp_Symbol *) $79 = 0x0000000110340d80
(lldb) p *((struct Lisp_Symbol *) ((char *)lispsym + (args[0] & VALMASK)))
error: Couldn't apply expression side effects : Couldn't dematerialize
a result variable: couldn't read its memory

For reference, here are the GDB definitions I see in src/.gdbinit

define xgetptr
  if (CHECK_LISP_OBJECT_TYPE)
    set $bugfix = $arg0.i
  else
    set $bugfix = $arg0
  end
  set $ptr = $bugfix & VALMASK
end

define xgetsym
  xgetptr $arg0
  set $ptr = ((struct Lisp_Symbol *) ((char *)lispsym + $ptr))
end

define xsymbol
  set $sym = $
  xgetsym $sym
  print (struct Lisp_Symbol *) $ptr
  xprintsym $sym
  echo \n
end

And the value of VALMASK:

(lldb) p VALMASK
(EMACS_INT) $83 = -8