<div dir="ltr">Hi,<div><br></div><div>In any case ptrace(PTRACE_PEEKDATA, ) should be left as fallback, at least for attaching.</div><div>Your debugger might CAP_SYS_PTRACE, that would allow it read memory of an process running with different UID, and it won't be possible with /proc/<pid>/mem.</div>
<div>It is also very popular for LSM's or hardening patches floating around to disable access to process memory via proc at all.</div><div>So I see that more as optimization rather than replacement.</div><div><br></div>
<div>Cheers,</div><div>/Piotr</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-25 10:31 GMT+01:00 Matthew Gardiner <span dir="ltr"><<a href="mailto:mg11@csr.com" target="_blank">mg11@csr.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Folks,<br>
<br>
Is there a good reason why the DoReadMemory function of<br>
Linux/ProcessMonitor.cpp is implemented using multiple calls of<br>
<br>
ptrace(PTRACE_PEEKDATA, ...) ?<br>
<br>
An easier, and less CPU-intensive way is to read the memory using the proc<br>
filesystem. The inferior's memory will be available in the file<br>
<br>
/proc/<pid>/mem<br>
<br>
int fd = open("/proc/<pid>/mem", O_RDONLY);<br>
ssize_t bytes = read(fd, buf, count);<br>
<br>
The read-of-procfs just seems more succinct to me, so I wondered what the<br>
rationale was for not using this.<br>
<br>
Discussion welcomed,<br>
Matt<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/<u></u>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>
______________________________<u></u>_________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">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/<u></u>mailman/listinfo/lldb-dev</a><br>
</blockquote></div><br></div>