[Lldb-commits] [lldb] r173076 - in /lldb/trunk: include/lldb/Interpreter/OptionGroupFormat.h include/lldb/Target/Target.h source/Commands/CommandObjectMemory.cpp source/Interpreter/OptionGroupFormat.cpp source/Target/Target.cpp

Enrico Granata egranata at apple.com
Mon Jan 21 13:30:23 PST 2013


Hi Filipe,
no I meant item_count = 1
It is true that is gets erased, but it is previously saved in count.
Then I use item_count as the loop counter and count (which is now the same value of item_count) as the loop counter
The reason for this is that code below expects item_count to mean how many items are available, and I exploit this to break out of the loop earlier with the right count of items if I can't find a valid NULL-terminated chunk of data (you could say "read me 5 strings" but we only find 3 and then we have to stop reading before we find another 0).
Hope this clarifies the code path a little.

Thanks for keeping eyes open ;-)

Enrico Granata
✉ egranata@.com
✆ (408) 972-7683

On Jan 21, 2013, at 12:14 PM, Filipe Cabecinhas <filcab at gmail.com> wrote:

> Hi Enrico,
> 
> On Mon, Jan 21, 2013 at 11:20 AM, Enrico Granata <egranata at apple.com> wrote:
> ...
> @@ -674,6 +676,46 @@
>              if (bytes_read < total_byte_size)
>                  result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%" PRIx64 ".", bytes_read, total_byte_size, addr);
>          }
> +        else
> +        {
> +            // we treat c-strings as a special case because they do not have a fixed size
> +            if (m_format_options.GetByteSizeValue().OptionWasSet() && !m_format_options.HasGDBFormat())
> +                item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
> +            else
> +                item_byte_size = target->GetMaximumSizeOfStringSummary();
> +            if (!m_format_options.GetCountValue().OptionWasSet())
> +                item_count = 1;
> ^^ didn't you mean count = 1?
>  
> +            data_sp.reset (new DataBufferHeap ((item_byte_size+1) * item_count, '\0')); // account for NULLs as necessary
> +            uint8_t *data_ptr = data_sp->GetBytes();
> +            auto data_addr = addr;
> +            auto count = item_count;
> +            item_count = 0;
> ^^ Otherwise, it gets erased by this.
> 
> Thanks,
> 
>   Filipe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130121/6268a7c9/attachment.html>


More information about the lldb-commits mailing list