cisco-open / llvm-crash-analyzer

llvm crash analysis
Apache License 2.0
40 stars 17 forks source link

Make lldb-(crash-)server able to work with GDB client #49

Closed niktesic closed 1 year ago

niktesic commented 1 year ago

Description

This patch makes LLDB-server able to establish communication with GDB (client).

  1. First commit updates'T' packet (Stop Reply Packet) to send information about stop context as GDB client expects. In first place, this is related to the General Purpose Register ID numbers (regnum), order and sizes. With this GDB and lldb-server can establish connection and perform simple debugging.

  2. Second commit updates'g' packet to match the size which GDB expects (560 Bytes). General Purpose Registers (output of "(gdb) info registers"), which are supported by llvm-crash-analyzer and have "regnum" up to 23, are sent with exact values. For other, unused registers, the 'g' packet is filled with zeros. With this change, GDB remote debugging won't break on "info all-register".

  3. When lldb-server is invoked via lldb-crash-server tool and if --core-file is specified, the lldb-server will assert when connected to GDB. This change makes lldb-server able to recognize "multiprocess+" client feature from GDB, and the connection can be established.

However, this PR doesn't make lldb-crash-server able to work with GDB (or LLDB) client, when --core-file is specified. Although the remote connection can be established, the debug session is not going to be initialized, because lldb-crash-server cannot setup inferior (debugged) thread. This needs to be fixed as the next step. LLDB client just returns control to the user without debug session and GDB goes into loop where it tries to find the inferior thread to be debugged.