[Bug 48723] New: unfriendly error message when debugee does not start correctly

Bug ID 48723
Summary unfriendly error message when debugee does not start correctly
Product lldb
Version unspecified
Hardware PC
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter emaste@freebsd.org
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

On FreeBSD, and I assume other operating systems, there are cases where the
debugged application does not start correctly.

One recent case occurred on FreeBSD with W^X enabled (sysctl
kern.elf64.allow_wx=0) and an attempt to execute a binary that requested an
executable stack. Because W^X disallows mappings with simultaneous W & X
protections the initial stack cannot be created and the kernel image activator
reports SIGABRT from the target.

Similar cases occurred when attempting to execute a binary with a .text segment
larger than a kernel limit.

The failure reported by LLDB in this case is not particularly clear:

$ lldb ./exec-stack
(lldb) target create "./exec-stack"
Current executable set to
'/home/emaste/src/freebsd-git/main/exec-stack' (x86_64).
(lldb) run
error: 'A' packet returned an error: 8

The old in-process target plugin handled this even more poorly:

(lldb) run
Assertion failed: (WIFSTOPPED(status) && wpid == (::pid_t)pid &&
"Could not sync with inferior process."), function Launch, file
line 930.
PLEASE submit a bug report to [https://bugs.freebsd.org/submit/](https://bugs.freebsd.org/submit/) and
include the crash backtrace.
#0 0x0000000004444ade PrintStackTrace
#1 0x0000000004442e11 RunSignalHandlers
#2 0x0000000004445335 SignalHandler
#3 0x0000000805299b20 handle_signal
Abort trap (core dumped)

Although a relatively minor issue it would be nice to have an error message
along the lines of "Unable to start inferior process" or such. Taking this to
root cause would likely require finding a log message in the kernel log.

(For reference, the FreeBSD code review that prompted this investigation: