assemblygdbintellldbtui

gdb 12.1 on macosx and windows hanging sometimes, lldb missing equivalent features. Anything we can do?


We are running students on assembler on windows and some intel macs. gdb is failing under msys2 when using layout (TUI). I was able to get it working on the CMD window, but it still dies if:

gdb myexe
layout src
b main
r

program crashes. Sometimes the window is locked

It works if we first run in command line mode:

gdb myexe
b main
r

then

layout src

or

layout asm
layout reg

this is disconcerting and awful. We can't rerun anything, always have to terminate the debugger and start over.

On MacOSX Monteray 12.0.1 (Intel MacBook Pro 2019) we have similar problems. We installed gdb 12.1

gdb will not run by itself, must be run with sudo?

We realize that on the mac, the preferred platform is lldb, but we don't seem to have equivalent ability to step through assembler. We can see the assembler, but not the registers. and this is a class in low-level coding involving assembler. is there any way to either get gdb working on mac, or an alternative we can use to let students walk through their code.

gdb myexe

Solution

  • In the lldb command-line, register read is the command to view registers. You can also use register values in the expression evaluator much like you can in gdb (expr $rax etc.).

    If you are familiar with gdb, you might take a look at:

    https://lldb.llvm.org/use/map.html

    to see how to perform similar tasks in lldb.

    If you want to see the registers printed at every step, then just add a stop-hook with this command:

    (lldb) target stop-hook add -o "register read"

    I made a little Python command to switch between "source centric" and "assembly centric" stop context printing here:

    https://github.com/llvm/llvm-project/blob/main/lldb/examples/python/disassembly_mode.py

    you could extend that to also toggle on the register display stop hook if you wanted.

    If you are using the gui mode for lldb, then select "View", choose "Registers" from the menu, tab over to the Registers view, select the register group you want to see, and right-arrow will disclose the registers from that group.

    Xcode will also show registers, there's a popup menu in the Locals view, which allow you to switch between "auto", "locals" and "all variables and registers". Xcode will show source code if it has it, but you can get it to always show disassembly using Debug->Debug Workflow->Always show disassembly menu option.

    I haven't used VSCode much, but I'd be really surprised if it doesn't also have a registers view.