Hi all,
I have been trying to diagnose a few problems with 32-bit linux. At
John Wolfe's suggestion I switched on ptrace logging. I found that initially
my logging was polluted with nonsensical data, e.g.
operation ptrace(PTRACE_PEEKUSER, 7972, (nil), 0x114, 0) called from file
(null) line -1220763056
in fact, the addr field is reported as nil, the data field contains the
addr, the size field contains the data and so on....
This bug occurs because the pid argument is 64 bits
typedef uint64_t pid_t;
but the corresponding field in the format list is %lu. Clearly, this does not
port between 32/64-bit environments, since in the 32-bit world 64-bits will be
put on the stack but the printf implementation takes only 32 of those bits
which results in misalignment as the remaining varargs are consumed.
One possible fix is to at least cast (and so in 32-bit land truncate) the
argument passed as the pid. (In the 64-bit OSes, the cast will have no
effect...).
Could someone either apply the attached patch, or fix this issue some other way?
Index: ProcessMonitor.cpp
===================================================================
--- ProcessMonitor.cpp (revision 201779)
+++ ProcessMonitor.cpp (working copy)
@@ -166,7 +166,7 @@
if (log)
log->Printf("ptrace(%s, %lu, %p, %p, %zu) called from file %s line %d",
- reqName, pid, addr, data, data_size, file, line);
+ reqName, static_cast<long>(pid), addr, data, data_size,
file, line);
PtraceDisplayBytes(req, data, data_size);
thanks
Matthew Gardiner
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.
Index: ProcessMonitor.cpp
===================================================================
--- ProcessMonitor.cpp (revision 201779)
+++ ProcessMonitor.cpp (working copy)
@@ -166,7 +166,7 @@
if (log)
log->Printf("ptrace(%s, %lu, %p, %p, %zu) called from file %s line %d",
- reqName, pid, addr, data, data_size, file, line);
+ reqName, static_cast<long>(pid), addr, data, data_size, file, line);
PtraceDisplayBytes(req, data, data_size);
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits