FreeBSD and Linux patch

[Resending from my subscribed email address]

Having taken a snapshot of lldb and pushed it into github, we have developed a patch set to refactor the Linux and FreeBSD support to reduce the differences and improve compatibility. The current repo has been built and run on 64bit FreeBSD and Linux systems.

The github repo is located here:

And a patch set against rXXXXX of lldb is here:

http://people.freebsd.org/~mp/lldb_r147532.patch

We'd like the current work to not diverge too far away from the main repo and we thought others might want to play with this or help out. Some of the todo's on our list are:

- Verify i386 operation on Linux, implement/verify on FreeBSD
- Verify attach support
- FreeBSD stop at exit
- thread support
- core file support
- Better process control for interrupting inferior
- Get buildbot passing reliably

Are there any volunteers with commit bits willing to review and commit this
patch to the lldb repo? Dawn is going to follow up with a formal patch to lldb-commits@.

Thanks,
Mark, Kip and Dawn

FYI - see patch titled "[PATCH] Merge of Linux and FreeBSD"
sent to lldb-commits and hopefully committed soon. :slight_smile:

-Dawn

A trip report. I tried both vanilla lldb and your git repository, and had similar

problems building them for Kubuntu 11.04 64-bit x86, with g++ 4.6.1. I attach the patches necessary
to make things compile (mostly just missing header includes); I also had some link
ordering problems which I sort of hacked support into the generated makefiles for. These
are the same patches I submitted a couple of months ago so I guess they didn’t end up
making it into the source tree, unfortunately.

I take it attaching to a process on Linux isn’t expected to work? It crashes for me
in this manner:

#0 0x00007ffff7bc9004 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ffff50973b4 in lldb_private::Mutex::Lock (mutex_ptr=0x18) at /home/jo/lldb/llvm/tools/lldb/source/Host/common/Mutex.cpp:190
#2 0x00007ffff509701c in lldb_private::Mutex::Locker::Locker (this=0x7fffffff8e00, m=…)
at /home/jo/lldb/llvm/tools/lldb/source/Host/common/Mutex.cpp:46
#3 0x00007ffff4fdad80 in lldb_private::Module::GetObjectFile (this=0x0) at /home/jo/lldb/llvm/tools/lldb/source/Core/Module.cpp:778
#4 0x00007ffff5c18b2e in ProcessPOSIX::ProcessPOSIX (this=0x7b17b0, target=…, listener=…)
at /home/jo/lldb/llvm/tools/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp:76
#5 0x00007ffff5c1e2c1 in ProcessLinux::ProcessLinux (this=0x7b17b0, target=…, listener=…)
at /home/jo/lldb/llvm/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp:67
#6 0x00007ffff5c1e205 in ProcessLinux::CreateInstance (target=…, listener=…)
at /home/jo/lldb/llvm/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp:37
#7 0x00007ffff52598d9 in lldb_private::Process::FindPlugin (target=…, plugin_name=0x0, listener=…)
at /home/jo/lldb/llvm/tools/lldb/source/Target/Process.cpp:729
#8 0x00007ffff527856b in lldb_private::Target::CreateProcess (this=0x7b1130, listener=…, plugin_name=0x0)
at /home/jo/lldb/llvm/tools/lldb/source/Target/Target.cpp:142
#9 0x00007ffff4f4849f in CommandObjectProcessAttach::Execute (this=0x6371a0, command=…, result=…)
at /home/jo/lldb/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp:504
#10 0x00007ffff50b2ae7 in lldb_private::CommandObject::ExecuteWithOptions (this=0x6371a0, args=…, result=…)
at /home/jo/lldb/llvm/tools/lldb/source/Interpreter/CommandObject.cpp:290
#11 0x00007ffff50a9dec in lldb_private::CommandInterpreter::HandleCommand (this=0x62aa60, command_line=0x629c68 “process attach -p 1568”,
add_to_history=true, result=…, override_context=0x0, repeat_on_empty_command=true, no_context_switching=false)
at /home/jo/lldb/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp:1510
#12 0x00007ffff4ed4c06 in lldb::SBCommandInterpreter::HandleCommand (this=0x7fffffffb490, command_line=0x629c68 “process attach -p 1568”,
result=…, add_to_history=true) at /home/jo/lldb/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp:97
#13 0x0000000000413d4a in Driver::HandleIOEvent (this=0x7fffffffdf50, event=…) at /home/jo/lldb/llvm/tools/lldb/tools/driver/Driver.cpp:933
#14 0x0000000000415017 in Driver::MainLoop (this=0x7fffffffdf50) at /home/jo/lldb/llvm/tools/lldb/tools/driver/Driver.cpp:1341
#15 0x00000000004155cd in main (argc=1, argv=0x7fffffffe158, envp=0x7fffffffe168) at /home/jo/lldb/llvm/tools/lldb/tools/driver/Driver.cpp:1460

  • GetTarget().GetExecutableModule()->GetObjectFile(); returns a null pointer, on both repositories.

I’d be happy to have a look into fixing this, if no-one else is and if someone wants to give me some hints on where to start. :slight_smile:

vanillapatch.diff (1.83 KB)

bsdpatch.diff (1.65 KB)

A trip report. I tried both vanilla lldb and your git repository, and had
similar
problems building them for Kubuntu 11.04 64-bit x86, with g++ 4.6.1. I
attach the patches necessary
to make things compile (mostly just missing header includes); I also had
some link
ordering problems which I sort of hacked support into the generated
makefiles for. These
are the same patches I submitted a couple of months ago so I guess they
didn't end up
making it into the source tree, unfortunately.

Please send them again to lldb-commits with [PATCH] in the subject.
The Apple lldb guys are usually pretty good about reviewing and/or commiting
them.

I take it attaching to a process on Linux isn't expected to work? It
crashes for me
in this manner:

[...]

I'd be happy to have a look into fixing this, if no-one else is and if
someone wants to give me some hints on where to start. :slight_smile:

Nope, attach doesn't work on Linux. :frowning: I started to work on a fix but ran out
of time before I could finish. Where I left off, there was a problem with
DynamicLoaderPOSIXDYLD.cpp not finding the module associated with the
PID and then getting an invalid architecture. Not sure if that's still the case.

Good luck! :slight_smile:
-Dawn