<div dir="ltr">In Windows you can read any of a process's memory while the process is running.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 26, 2014 at 12:43 AM, Matthew Gardiner <span dir="ltr"><<a href="mailto:mg11@csr.com" target="_blank">mg11@csr.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As mentioned already on this list, some embedded devices permit reading<br>
of certain memory regions whilst the processor is running.<br>
<br>
For such situations it would be nice to engineer lldb to permit that<br>
functionality.<br>
<br>
Matt<br>
<div><div class="h5"><br>
On Thu, 2014-09-25 at 14:59 -0700, Greg Clayton wrote:<br>
> When the process resumes it takes a "run lock" to stop anything else that requires a process to stay stopped (like memory read, register read, or anything involving looking at the process). Only one thing can have the run lock at a time. When the process stops, one or more threads can take the "stop lock". It is like a read/write locker where the read lock can be taken by N threads and they will keep anyone from acquiring the write lock, and only one can take the write lock (process needs to run) after all readers have let go of the read lock (stay stopped). So somehow this isn't working on the system you are debugging on. That needs to be fixed.<br>
><br>
> Greg<br>
><br>
> > On Sep 25, 2014, at 2:42 PM, Mikhail Sosonkin <<a href="mailto:mike@nanotick.net">mike@nanotick.net</a>> wrote:<br>
> ><br>
> > I only have one thread in operation, so I don't expect there do be any<br>
> > race conditions unless LLDB has its own threads under the hood. So far<br>
> > as I can tell, this lock fails for some reason:<br>
> ><br>
> > Process::StopLocker stop_locker;<br>
> > if (stop_locker.TryLock(&process_sp->GetRunLock()))<br>
> > {<br>
> > Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());<br>
> > bytes_read = process_sp->ReadMemory (addr, dst, dst_len,<br>
> > sb_error.ref());<br>
> > }<br>
> > else<br>
> > {<br>
> > if (log)<br>
> > log->Printf ("SBProcess(%p)::ReadMemory() => error:<br>
> > process is running",<br>
> > static_cast<void*>(process_sp.get()));<br>
> > sb_error.SetErrorString("process is running");<br>
> > }<br>
> ><br>
> > At the moment, I don't know why but would be happy to hear your thoughts.<br>
> ><br>
> > Thanks,<br>
> > Mike.<br>
> ><br>
> > On Thu, Sep 25, 2014 at 1:47 PM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br>
> >> It should be easy for you to step through the SBProcess::ReadMemory() call and see what is going wrong. If the process is stopped, it should definitely be returning memory. You are sure you don't have thread race conditions where some other thread is resuming the process?<br>
> >><br>
> >><br>
> >>> On Sep 25, 2014, at 10:34 AM, Mikhail Sosonkin <<a href="mailto:mike@nanotick.net">mike@nanotick.net</a>> wrote:<br>
> >>><br>
> >>> Hello,<br>
> >>><br>
> >>> I'm trying to read some memory from a stopped process. However, the<br>
> >>> read function errors out with "process is running" message even though<br>
> >>> SBProcess::GetState tells me that the process is stopped. The process<br>
> >>> was stopped because it hit a breakpoint.<br>
> >>><br>
> >>> SBProcess(0x7fed13981600)::GetState () => stopped<br>
> >>> SBProcess(0x7fed13981600)::GetState () => stopped<br>
> >>> SBProcess(0x7fed13981600)::ReadMemory (addr=0x7fff5fc34000,<br>
> >>> dst=0x112eff900, dst_len=4096, SBError (0x0))...<br>
> >>> SBProcess(0x7fed13981600)::ReadMemory() => error: process is running<br>
> >>> SBProcess(0x7fed13981600)::ReadMemory (addr=0x7fff5fc34000,<br>
> >>> dst=0x112eff900, dst_len=4096, SBError (0x7fed12621ee0): error:<br>
> >>> process is running) => 0<br>
> >>><br>
> >>> I have two questions:<br>
> >>> - Is this a bug/known issue? I'm using lldb library that comes with<br>
> >>> Xcode 5 version lldb-310.2.37 (though I read somewhere that these<br>
> >>> version numbers don't help you much).<br>
> >>><br>
> >>> - Is there a mechanism to read memory of a running process?<br>
> >>><br>
> >>> Thanks,<br>
> >>> Mike.<br>
> >>> _______________________________________________<br>
> >>> lldb-dev mailing list<br>
> >>> <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> >>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
> >><br>
> ><br>
> > _______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
><br>
</div></div>> To report this email as spam click <a href="https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==" target="_blank">https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==</a> .<br>
<br>
<br>
<br>
<br>
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom<br>
More information can be found at <a href="http://www.csr.com" target="_blank">www.csr.com</a>. Keep up to date with CSR on our technical blog, <a href="http://www.csr.com/blog" target="_blank">www.csr.com/blog</a>, CSR people blog, <a href="http://www.csr.com/people" target="_blank">www.csr.com/people</a>, YouTube, <a href="http://www.youtube.com/user/CSRplc" target="_blank">www.youtube.com/user/CSRplc</a>, Facebook, <a href="http://www.facebook.com/pages/CSR/191038434253534" target="_blank">www.facebook.com/pages/CSR/191038434253534</a>, or follow us on Twitter at <a href="http://www.twitter.com/CSR_plc" target="_blank">www.twitter.com/CSR_plc</a>.<br>
New for 2014, you can now access the wide range of products powered by aptX at <a href="http://www.aptx.com" target="_blank">www.aptx.com</a>.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
</div></div></blockquote></div><br></div>