[Lldb-commits] [PATCH] Refactor POSIXThread::GetRegisterContext and use i386 register context
Todd Fiala
tfiala at google.com
Thu Feb 13 11:13:01 PST 2014
I've got a debug build now. We're hitting an assert in POSIXThread::WatchNotify() on a null wp_sp.get() call.
tfiala at ubuntu:~/play/hello$ ~/lldb/work/build-debug/bin/lldb ./hello
Current executable set to './hello' (i386).
(lldb) run
Process 23063 launching
lldb: /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:525: void POSIXThread::WatchNotify(const ProcessMessage&): Assertion `wp_sp.get() && "No watchpoint found"' failed.
Aborted (core dumped)
Core dump debug session follows. I believe the likely cause is that we're still getting an x86_64 register context on x86 below. The net result is it cannot lookup a watchpoint to point to:
tfiala at ubuntu:~/play/hello$ gdb ~/lldb/work/build-debug/bin/lldb core
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/tfiala/lldb/work/build-debug/bin/lldb-3.5...done.
warning: core file may not match specified executable file.
[New LWP 23056]
[New LWP 23062]
[New LWP 23061]
[New LWP 23065]
[New LWP 23064]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `/home/tfiala/lldb/work/build-debug/bin/lldb ./hello'.
Program terminated with signal 6, Aborted.
#0 0xb7764424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb7764424 in __kernel_vsyscall ()
#1 0xb1ce3aff in __GI_raise (sig=sig at entry=6)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2 0xb1ce7083 in __GI_abort () at abort.c:90
#3 0xb1cdc857 in __assert_fail_base (
fmt=0xb1e23214 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=assertion at entry=0xb56bee34 "wp_sp.get() && \"No watchpoint found\"",
file=file at entry=0xb56beba0 "/home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp", line=line at entry=525,
function=function at entry=0xb56bf2a0 <POSIXThread::WatchNotify(ProcessMessage const&)::__PRETTY_FUNCTION__> "void POSIXThread::WatchNotify(const ProcessMessage&)") at assert.c:92
#4 0xb1cdc907 in __GI___assert_fail (
assertion=0xb56bee34 "wp_sp.get() && \"No watchpoint found\"",
file=0xb56beba0 "/home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp", line=525,
function=0xb56bf2a0 <POSIXThread::WatchNotify(ProcessMessage const&)::__PRETTY_FUNCTION__> "void POSIXThread::WatchNotify(const ProcessMessage&)") at assert.c:101
#5 0xb3515b5d in POSIXThread::WatchNotify (this=0xb0000498, message=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:525
#6 0xb3513dcd in LinuxThread::TraceNotify (this=0xb0000498, message=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp:56
#7 0xb3515321 in POSIXThread::Notify (this=0xb0000498, message=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:367
#8 0xb35197c7 in ProcessPOSIX::RefreshStateAfterStop (this=0xa35f480)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp:550
#9 0xb3379428 in lldb_private::Process::ShouldBroadcastEvent (this=0xa35f480,
event_ptr=0xb0000860)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Target/Process.cpp:3864
#10 0xb3379d92 in lldb_private::Process::HandlePrivateEvent (this=0xa35f480, event_sp=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Target/Process.cpp:4115
#11 0xb3376f68 in lldb_private::Process::Launch (this=0xa35f480, launch_info=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Target/Process.cpp:3075
#12 0xb33ab7dd in lldb_private::Target::Launch (this=0xa33b9e0, listener=...,
launch_info=...)
---Type <return> to continue, or q <return> to quit---frame 10
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Target/Target.cpp:2388
#13 0xb3559b19 in CommandObjectProcessLaunch::DoExecute (this=0x99928c0, launch_args=...,
result=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Commands/CommandObjectProcess.cpp:241
#14 0xb329e1f1 in lldb_private::CommandObjectParsed::Execute (this=0x99928c0,
args_string=0xa35de5c "-c/bin/sh --", result=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Interpreter/CommandObject.cpp:1031
#15 0xb3290d74 in lldb_private::CommandInterpreter::HandleCommand (this=0x9a43288,
command_line=0xa35945c "run", lazy_add_to_history=lldb_private::eLazyBoolCalculate,
result=..., override_context=0x0, repeat_on_empty_command=true,
no_context_switching=false)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp:1858
#16 0xb32949b8 in lldb_private::CommandInterpreter::IOHandlerInputComplete (
this=0x9a43288, io_handler=..., line=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp:2995
#17 0xb317cfbb in lldb_private::IOHandlerEditline::Run (this=0x99cbc58)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Core/IOHandler.cpp:552
#18 0xb315f122 in lldb_private::Debugger::ExecuteIOHanders (this=0x9e6c128)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Core/Debugger.cpp:865
#19 0xb3295026 in lldb_private::CommandInterpreter::RunCommandInterpreter (this=0x9a43288,
auto_handle_events=true, spawn_thread=false)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp:3125
#20 0xb30674b6 in lldb::SBDebugger::RunCommandInterpreter (this=0xbfee04d8,
auto_handle_events=true, spawn_thread=false)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/API/SBDebugger.cpp:961
#21 0x0804f76d in Driver::MainLoop (this=0xbfee04c8)
at /home/tfiala/lldb/work/llvm/tools/lldb/tools/driver/Driver.cpp:967
#22 0x0804fb94 in main (argc=2, argv=0xbfee0604, envp=0xbfee0610)
at /home/tfiala/lldb/work/llvm/tools/lldb/tools/driver/Driver.cpp:1060
(gdb) f 10
#10 0xb3379d92 in lldb_private::Process::HandlePrivateEvent (this=0xa35f480, event_sp=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Target/Process.cpp:4115
4115 const bool should_broadcast = ShouldBroadcastEvent (event_sp.get());
(gdb) list
4110 break;
4111 }
4112 }
4113
4114 // See if we should broadcast this state to external clients?
4115 const bool should_broadcast = ShouldBroadcastEvent (event_sp.get());
4116
4117 if (should_broadcast)
4118 {
4119 if (log)
(gdb) p event_sp
$1 = (lldb::EventSP &) @0xbfedba94: {<std::__shared_ptr<lldb_private::Event, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0xb0000860, _M_refcount = {
_M_pi = 0xb0000870}}, <No data fields>}
(gdb) frame 9
#9 0xb3379428 in lldb_private::Process::ShouldBroadcastEvent (this=0xa35f480,
event_ptr=0xb0000860)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Target/Process.cpp:3864
3864 RefreshStateAfterStop ();
(gdb) list
3859 // We've stopped. First see if we're going to restart the target.
3860 // If we are going to stop, then we always broadcast the event.
3861 // If we aren't going to stop, let the thread plans decide if we're going to report this event.
3862 // If no thread has an opinion, we don't report it.
3863
3864 RefreshStateAfterStop ();
3865 if (ProcessEventData::GetInterruptedFromEvent (event_ptr))
3866 {
3867 if (log)
3868 log->Printf ("Process::ShouldBroadcastEvent (%p) stopped due to an interrupt, state: %s",
(gdb) frame 8
#8 0xb35197c7 in ProcessPOSIX::RefreshStateAfterStop (this=0xa35f480)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp:550
550 thread->Notify(message);
(gdb) list
545 m_thread_list.RefreshStateAfterStop();
546
547 POSIXThread *thread = static_cast<POSIXThread*>(
548 GetThreadList().FindThreadByID(tid, false).get());
549 if (thread)
550 thread->Notify(message);
551
552 if (message.GetKind() == ProcessMessage::eExitMessage)
553 {
554 // FIXME: We should tell the user about this, but the limbo message is probably better for that.
(gdb) p message
$2 = (ProcessMessage &) @0xa361b28: {m_tid = 23063,
m_kind = ProcessMessage::eTraceMessage,
m_crash_reason = ProcessMessage::eInvalidCrashReason, m_status = 0, m_addr = 0,
m_child_tid = 0}
(gdb) frame 7
#7 0xb3515321 in POSIXThread::Notify (this=0xb0000498, message=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:367
367 TraceNotify(message);
(gdb) list
362 case ProcessMessage::eSignalDeliveredMessage:
363 SignalDeliveredNotify(message);
364 break;
365
366 case ProcessMessage::eTraceMessage:
367 TraceNotify(message);
368 break;
369
370 case ProcessMessage::eBreakpointMessage:
371 BreakNotify(message);
(gdb) frame 6
#6 0xb3513dcd in LinuxThread::TraceNotify (this=0xb0000498, message=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp:56
56 WatchNotify(message);
(gdb) list
51 uint32_t wp_idx;
52 for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
53 {
54 if (reg_ctx->IsWatchpointHit(wp_idx))
55 {
56 WatchNotify(message);
57 return;
58 }
59 }
60 }
(gdb) p reg_ctx
$3 = (POSIXBreakpointProtocol *) 0xa34b1cc
(gdb) p *reg_ctx
$4 = {
_vptr.POSIXBreakpointProtocol = 0xb76a35e8 <vtable for **RegisterContextPOSIXProcessMonitor_x86_64**+200>, m_watchpoints_initialized = true}
(gdb) frame 5
#5 0xb3515b5d in POSIXThread::WatchNotify (this=0xb0000498, message=...)
at /home/tfiala/lldb/work/llvm/tools/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp:525
525 assert(wp_sp.get() && "No watchpoint found");
(gdb) list
520 Target &target = GetProcess()->GetTarget();
521 lldb::addr_t wp_monitor_addr = reg_ctx->GetWatchpointAddress(wp_idx);
522 const WatchpointList &wp_list = target.GetWatchpointList();
523 lldb::WatchpointSP wp_sp = wp_list.FindByAddress(wp_monitor_addr);
524
525 assert(wp_sp.get() && "No watchpoint found");
526 SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID(*this,
527 wp_sp->GetID()));
528 }
529 }
(gdb) p wp_sp
$5 = {<std::__shared_ptr<lldb_private::Watchpoint, (__gnu_cxx::_Lock_policy)2>> = {
_M_ptr = 0x0, _M_refcount = {_M_pi = 0x0}}, <No data fields>}
(gdb)
I think I see where we're setting this up. I can debug this a bit more.
Note the use of cmake/ninja is far easier to get working in my VM and avoided all the OOM issues I hit with configure/(g)make in debug mode.
http://llvm-reviews.chandlerc.com/D2765
More information about the lldb-commits
mailing list