[lldb-dev] Reading process memory

Zachary Turner zturner at google.com
Fri Sep 26 09:30:40 PDT 2014


In Windows you can read any of a process's memory while the process is
running.

On Fri, Sep 26, 2014 at 12:43 AM, Matthew Gardiner <mg11 at csr.com> wrote:

> As mentioned already on this list, some embedded devices permit reading
> of certain memory regions whilst the processor is running.
>
> For such situations it would be nice to engineer lldb to permit that
> functionality.
>
> Matt
>
> On Thu, 2014-09-25 at 14:59 -0700, Greg Clayton wrote:
> > 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.
> >
> > Greg
> >
> > > On Sep 25, 2014, at 2:42 PM, Mikhail Sosonkin <mike at nanotick.net>
> wrote:
> > >
> > > I only have one thread in operation, so I don't expect there do be any
> > > race conditions unless LLDB has its own threads under the hood. So far
> > > as I can tell, this lock fails for some reason:
> > >
> > >        Process::StopLocker stop_locker;
> > >        if (stop_locker.TryLock(&process_sp->GetRunLock()))
> > >        {
> > >            Mutex::Locker api_locker
> (process_sp->GetTarget().GetAPIMutex());
> > >            bytes_read = process_sp->ReadMemory (addr, dst, dst_len,
> > > sb_error.ref());
> > >        }
> > >        else
> > >        {
> > >            if (log)
> > >                log->Printf ("SBProcess(%p)::ReadMemory() => error:
> > > process is running",
> > >                             static_cast<void*>(process_sp.get()));
> > >            sb_error.SetErrorString("process is running");
> > >        }
> > >
> > > At the moment, I don't know why but would be happy to hear your
> thoughts.
> > >
> > > Thanks,
> > > Mike.
> > >
> > > On Thu, Sep 25, 2014 at 1:47 PM, Greg Clayton <gclayton at apple.com>
> wrote:
> > >> 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?
> > >>
> > >>
> > >>> On Sep 25, 2014, at 10:34 AM, Mikhail Sosonkin <mike at nanotick.net>
> wrote:
> > >>>
> > >>> Hello,
> > >>>
> > >>> I'm trying to read some memory from a stopped process. However, the
> > >>> read function errors out with "process is running" message even
> though
> > >>> SBProcess::GetState tells me that the process is stopped. The process
> > >>> was stopped because it hit a breakpoint.
> > >>>
> > >>> SBProcess(0x7fed13981600)::GetState () => stopped
> > >>> SBProcess(0x7fed13981600)::GetState () => stopped
> > >>> SBProcess(0x7fed13981600)::ReadMemory (addr=0x7fff5fc34000,
> > >>> dst=0x112eff900, dst_len=4096, SBError (0x0))...
> > >>> SBProcess(0x7fed13981600)::ReadMemory() => error: process is running
> > >>> SBProcess(0x7fed13981600)::ReadMemory (addr=0x7fff5fc34000,
> > >>> dst=0x112eff900, dst_len=4096, SBError (0x7fed12621ee0): error:
> > >>> process is running) => 0
> > >>>
> > >>> I have two questions:
> > >>> - Is this a bug/known issue? I'm using lldb library that comes with
> > >>> Xcode 5 version lldb-310.2.37 (though I read somewhere that these
> > >>> version numbers don't help you much).
> > >>>
> > >>> - Is there a mechanism to read memory of a running process?
> > >>>
> > >>> Thanks,
> > >>> Mike.
> > >>> _______________________________________________
> > >>> lldb-dev mailing list
> > >>> lldb-dev at cs.uiuc.edu
> > >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> > >>
> > >
> > > _______________________________________________
> > > lldb-dev mailing list
> > > lldb-dev at cs.uiuc.edu
> > > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> >
> > _______________________________________________
> > lldb-dev mailing list
> > lldb-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> >
> >
> >  To report this email as spam click
> https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ== .
>
>
>
>
> 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
> More information can be found at www.csr.com. Keep up to date with CSR on
> our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people,
> YouTube, www.youtube.com/user/CSRplc, Facebook,
> www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at
> www.twitter.com/CSR_plc.
> New for 2014, you can now access the wide range of products powered by
> aptX at www.aptx.com.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140926/ffc595d9/attachment.html>


More information about the lldb-dev mailing list