[Lldb-commits] PtraceWrapper's printf assumes incorrect size for pid for 32-bit linux

Greg Clayton gclayton at apple.com
Mon Feb 24 12:56:48 PST 2014


Yes, the PRIxxx macros are the way to go. This fix looks good. For any types that might be a larger size on other systems, we need to cast the argument. In this case, the pid will always be 64 bit. In other cases we will need to cast (please cast to constant sized types like uint8_t, uint16_t, uint32_t, uint64_t) and you would need to use the PRI macros.

Greg

On Feb 24, 2014, at 6:07 AM, Matthew Gardiner <mg11 at csr.com> wrote:

> Upon Ed's advice I'm presenting a new version of this patch
> using a PRIu64 macro. I've built this under 32-bit linux
> and briefly tested it.
> 
> Could you apply it for me Ed, please?
> 
> Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
> ===================================================================
> --- source/Plugins/Process/Linux/ProcessMonitor.cpp    (revision 201779)
> +++ source/Plugins/Process/Linux/ProcessMonitor.cpp    (working copy)
> @@ -164,10 +164,6 @@
> 
>     Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PTRACE));
> 
> -    if (log)
> -        log->Printf("ptrace(%s, %lu, %p, %p, %zu) called from file %s line %d",
> -                    reqName, pid, addr, data, data_size, file, line);
> -
>     PtraceDisplayBytes(req, data, data_size);
> 
>     errno = 0;
> @@ -176,6 +172,10 @@
>     else
>         result = ptrace(static_cast<__ptrace_request>(req), pid, addr, data);
> 
> +    if (log)
> +        log->Printf("ptrace(%s, %" PRIu64 ", %p, %p, %zu)=%lX called from file %s line %d",
> +                    reqName, pid, addr, data, data_size, result, file, line);
> +
>     PtraceDisplayBytes(req, data, data_size);
> 
>     if (log && errno != 0)
> 
> 
> Diff attached.
> 
> thanks
> Matt
> 
> 
> 
> 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.
> <ProcessMonitor.cpp.diff>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list