<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19190"></HEAD>
<BODY>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>Hi
everyone,</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>here is a patch,
which should fix two problems in lldb. </SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>The first problem is
a segmentation fault on the 'process connect' command. The segfault occurs in
lldb_private::Module::GetObjectFile in case no executable module was
specified and/or loaded. There is a log to reproduce:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012> freebsd1#
./lldb<BR> (lldb) platform select remote-freebsd<BR> Host: FreeBSD
9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC
2012 <A
href="mailto:root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC">root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC</A><BR></SPAN></FONT><FONT
size=2 face=Arial><SPAN class=972065019-30032012> Hostname:
localhost<BR> (lldb) process connect localhost<BR> Segmentation
fault (core dumped)</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>This is a stack
trace for this case:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>Program received
signal SIGSEGV, Segmentation fault.<BR>0x00000008042c5344 in pthread_mutex_lock
() from /lib/libthr.so.3<BR>(gdb) bt<BR>#0 0x00000008042c5344 in
pthread_mutex_lock () from /lib/libthr.so.3<BR>#1 0x000000080149c7c5 in
lldb_private::Mutex::Lock (mutex_ptr=0x18) at
/usr/home/projects/llvm-lldb/tools/lldb/source/Host/common/Mutex.cpp:212<BR>#2
0x000000080149c791 in lldb_private::Mutex::Locker::Locker () at
SmallPtrSet.h:159<BR>#3 0x00000008013b0c40 in
lldb_private::Module::GetObjectFile (this=0x0) at
/usr/home/projects/llvm-lldb/tools/lldb/source/Core/Module.cpp:945<BR>#4
0x00000008023b5b1c in ProcessPOSIX::ProcessPOSIX (this=0x805f4b800, <A
href="mailto:target=@0x808b8d100">target=@0x808b8d100</A>, <A
href="mailto:listener=@0x805c94d90">listener=@0x805c94d90</A>)<BR>
at
/usr/home/projects/llvm-lldb/tools/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp:76<BR>#5
0x00000008023bd00a in ProcessFreeBSD::ProcessFreeBSD (this=0x805f4b800, <A
href="mailto:target=@0x808b8d100">target=@0x808b8d100</A>, <A
href="mailto:listener=@0x805c94d90">listener=@0x805c94d90</A>)<BR>
at
/usr/home/projects/llvm-lldb/tools/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:122<BR>#6
0x00000008023bcdb1 in ProcessFreeBSD::CreateInstance (<A
href="mailto:target=@0x808b8d100">target=@0x808b8d100</A>, <A
href="mailto:listener=@0x805c94d90">listener=@0x805c94d90</A>,
crash_file_path=0x0)<BR> at
/usr/home/projects/llvm-lldb/tools/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:41<BR>#7
0x0000000801702cb3 in lldb_private::Process::FindPlugin (<A
href="mailto:target=@0x808b8d100">target=@0x808b8d100</A>, plugin_name=0x0, <A
href="mailto:listener=@0x805c94d90">listener=@0x805c94d90</A>,
crash_file_path=0x0)<BR> at
/usr/home/projects/llvm-lldb/tools/lldb/source/Target/Process.cpp:735<BR>#8
0x000000080172a27e in lldb_private::Target::CreateProcess (this=0x808b8d100, <A
href="mailto:listener=@0x805c94d90">listener=@0x805c94d90</A>, plugin_name=0x0,
crash_file=0x0)<BR> at
/usr/home/projects/llvm-lldb/tools/lldb/source/Target/Target.cpp:154<BR>#9
0x00000008012fde09 in CommandObjectProcessConnect::Execute (this=0x805c2fc00, <A
href="mailto:command=@0x7fffffffbf10">command=@0x7fffffffbf10</A>, <A
href="mailto:result=@0x805d48140">result=@0x805d48140</A>)<BR>
at
/usr/home/projects/llvm-lldb/tools/lldb/source/Commands/CommandObjectProcess.cpp:873<BR>#10
0x00000008014bdf20 in lldb_private::CommandObject::ExecuteWithOptions
(this=0x805c2fc00, <A
href="mailto:args=@0x7fffffffbf10">args=@0x7fffffffbf10</A>, <A
href="mailto:result=@0x805d48140">result=@0x805d48140</A>)<BR>
at
/usr/home/projects/llvm-lldb/tools/lldb/source/Interpreter/CommandObject.cpp:281<BR>#11
0x00000008014b2263 in lldb_private::CommandInterpreter::HandleCommand
(this=0x805ca4200, command_line=0x80a41f198 "process connect localhost",
add_to_history=true, <A
href="mailto:result=@0x805d48140">result=@0x805d48140</A>,
<BR> override_context=0x0, repeat_on_empty_command=true,
no_context_switching=false) at
/usr/home/projects/llvm-lldb/tools/lldb/source/Interpreter/CommandInterpreter.cpp:1540<BR>#12
0x000000080124a7b5 in lldb::SBCommandInterpreter::HandleCommand
(this=0x7fffffffc2f0, command_line=0x80a41f198 "process connect localhost", <A
href="mailto:result=@0x7fffffffc2f8">result=@0x7fffffffc2f8</A>,
add_to_history=true)<BR> at
/usr/home/projects/llvm-lldb/tools/lldb/source/API/SBCommandInterpreter.cpp:97<BR>#13
0x000000000040b666 in Driver::HandleIOEvent (this=0x7fffffffd718, <A
href="mailto:event=@0x7fffffffc560">event=@0x7fffffffc560</A>) at
/usr/home/projects/llvm-lldb/tools/lldb/tools/driver/Driver.cpp:980<BR>#14
0x000000000040cc3e in Driver::MainLoop (this=0x7fffffffd718) at
/usr/home/projects/llvm-lldb/tools/lldb/tools/driver/Driver.cpp:1406<BR>#15
0x000000000040d28b in main (argc=1, argv=0x7fffffffd888, envp=0x7fffffffd898) at
/usr/home/projects/llvm-lldb/tools/lldb/tools/driver/Driver.cpp:1540<BR></SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>The second problem
is a misbehavior after an unseccessful process connect commend
has been involved. The process connect leaves an 'undefined' process object if
the command has been finished with an error. There is a log to
reproduce:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012> freebsd1#
./lldb /bin/ls<BR> Current executable set to '/bin/ls' (x86_64).<BR>
(lldb) platform select remote-freebsd<BR> Host: FreeBSD 9.0-RELEASE
FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC
2012 <A
href="mailto:root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC">root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC</A><BR></SPAN></FONT><FONT
size=2 face=Arial><SPAN class=972065019-30032012> (lldb) process connect
localhost<BR> error: remote connections are not supported<BR> (lldb)
process connect connect://localhost<BR> error: Process 0 is currently
being debugged, kill the process before connecting.<BR> (lldb)
exit<BR></SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>The second error
should not appear as far as I understood. This patch fixes it by deleting a
process object.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=972065019-30032012></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=972065019-30032012>
<DIV><FONT size=2 face=Arial><SPAN
class=463402519-30032012> </DIV></SPAN></FONT>
<DIV><FONT size=2 face=Arial><SPAN class=463402519-30032012>Would somebody
review and apply this patch if it looks ok?</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=463402519-30032012>Thanks.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=463402519-30032012>Viktor.</SPAN></FONT></SPAN></FONT><FONT size=2
face=Arial><SPAN
class=972065019-30032012></DIV></DIV></SPAN></FONT></BODY></HTML>