<div dir="ltr">It would be nice if we could get this into 3.8 to get rid of these asserts.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">-- Ryan Brown<br></div></div>
<br><div class="gmail_quote">On Fri, Jan 15, 2016 at 11:35 AM, Ryan Brown via lldb-commits <span dir="ltr"><<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ribrdb<br>
Date: Fri Jan 15 13:35:48 2016<br>
New Revision: 257926<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=257926&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=257926&view=rev</a><br>
Log:<br>
Implement missing GoASTContext methods<br>
<br>
Modified:<br>
lldb/trunk/source/Symbol/GoASTContext.cpp<br>
<br>
Modified: lldb/trunk/source/Symbol/GoASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/GoASTContext.cpp?rev=257926&r1=257925&r2=257926&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/GoASTContext.cpp?rev=257926&r1=257925&r2=257926&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Symbol/GoASTContext.cpp (original)<br>
+++ lldb/trunk/source/Symbol/GoASTContext.cpp Fri Jan 15 13:35:48 2016<br>
@@ -13,6 +13,7 @@<br>
<br>
#include "lldb/Core/Module.h"<br>
#include "lldb/Core/PluginManager.h"<br>
+#include "lldb/Core/StreamFile.h"<br>
#include "lldb/Core/UniqueCStringMap.h"<br>
#include "lldb/Core/ValueObject.h"<br>
#include "lldb/DataFormatters/StringPrinter.h"<br>
@@ -1268,13 +1269,115 @@ GoASTContext::ConvertStringToFloatValue(<br>
//----------------------------------------------------------------------<br>
// Dumping types<br>
//----------------------------------------------------------------------<br>
+#define DEPTH_INCREMENT 2<br>
+<br>
void<br>
GoASTContext::DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format,<br>
- const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size,<br>
+ const DataExtractor &data, lldb::offset_t data_byte_offset, size_t data_byte_size,<br>
uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary,<br>
bool verbose, uint32_t depth)<br>
{<br>
- assert(false);<br>
+ if (IsTypedefType(type))<br>
+ type = GetTypedefedType(type).GetOpaqueQualType();<br>
+ if (!type)<br>
+ return;<br>
+ GoType *t = static_cast<GoType *>(type);<br>
+<br>
+ if (GoStruct *st = t->GetStruct())<br>
+ {<br>
+ if (GetCompleteType(type))<br>
+ {<br>
+ uint32_t field_idx = 0;<br>
+ for (auto* field = st->GetField(field_idx); field != nullptr; field_idx++)<br>
+ {<br>
+ // Print the starting squiggly bracket (if this is the<br>
+ // first member) or comma (for member 2 and beyond) for<br>
+ // the struct/union/class member.<br>
+ if (field_idx == 0)<br>
+ s->PutChar('{');<br>
+ else<br>
+ s->PutChar(',');<br>
+<br>
+ // Indent<br>
+ s->Printf("\n%*s", depth + DEPTH_INCREMENT, "");<br>
+<br>
+ // Print the member type if requested<br>
+ if (show_types)<br>
+ {<br>
+ ConstString field_type_name = field->m_type.GetTypeName();<br>
+ s->Printf("(%s) ", field_type_name.AsCString());<br>
+ }<br>
+ // Print the member name and equal sign<br>
+ s->Printf("%s = ", field->m_name.AsCString());<br>
+<br>
+<br>
+ // Dump the value of the member<br>
+ CompilerType field_type = field->m_type;<br>
+ field_type.DumpValue (exe_ctx,<br>
+ s, // Stream to dump to<br>
+ field_type.GetFormat(), // The format with which to display the member<br>
+ data, // Data buffer containing all bytes for this type<br>
+ data_byte_offset + field->m_byte_offset,// Offset into "data" where to grab value from<br>
+ field->m_type.GetByteSize(exe_ctx->GetBestExecutionContextScope()), // Size of this type in bytes<br>
+ 0, // Bitfield bit size<br>
+ 0, // Bitfield bit offset<br>
+ show_types, // Boolean indicating if we should show the variable types<br>
+ show_summary, // Boolean indicating if we should show a summary for the current type<br>
+ verbose, // Verbose output?<br>
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children<br>
+ }<br>
+<br>
+ // Indent the trailing squiggly bracket<br>
+ if (field_idx > 0)<br>
+ s->Printf("\n%*s}", depth, "");<br>
+<br>
+ }<br>
+ }<br>
+<br>
+ if (GoArray *a = t->GetArray()) {<br>
+ CompilerType element_clang_type = a->GetElementType();<br>
+ lldb::Format element_format = element_clang_type.GetFormat();<br>
+ uint32_t element_byte_size = element_clang_type.GetByteSize(exe_ctx->GetBestExecutionContextScope());<br>
+<br>
+ uint64_t element_idx;<br>
+ for (element_idx = 0; element_idx < a->GetLength(); ++element_idx)<br>
+ {<br>
+ // Print the starting squiggly bracket (if this is the<br>
+ // first member) or comman (for member 2 and beyong) for<br>
+ // the struct/union/class member.<br>
+ if (element_idx == 0)<br>
+ s->PutChar('{');<br>
+ else<br>
+ s->PutChar(',');<br>
+<br>
+ // Indent and print the index<br>
+ s->Printf("\n%*s[%" PRIu64 "] ", depth + DEPTH_INCREMENT, "", element_idx);<br>
+<br>
+ // Figure out the field offset within the current struct/union/class type<br>
+ uint64_t element_offset = element_idx * element_byte_size;<br>
+<br>
+ // Dump the value of the member<br>
+ element_clang_type.DumpValue (exe_ctx,<br>
+ s, // Stream to dump to<br>
+ element_format, // The format with which to display the element<br>
+ data, // Data buffer containing all bytes for this type<br>
+ data_byte_offset + element_offset,// Offset into "data" where to grab value from<br>
+ element_byte_size, // Size of this type in bytes<br>
+ 0, // Bitfield bit size<br>
+ 0, // Bitfield bit offset<br>
+ show_types, // Boolean indicating if we should show the variable types<br>
+ show_summary, // Boolean indicating if we should show a summary for the current type<br>
+ verbose, // Verbose output?<br>
+ depth + DEPTH_INCREMENT); // Scope depth for any types that have children<br>
+ }<br>
+<br>
+ // Indent the trailing squiggly bracket<br>
+ if (element_idx > 0)<br>
+ s->Printf("\n%*s}", depth, "");<br>
+ }<br>
+<br>
+ if (show_summary)<br>
+ DumpSummary (type, exe_ctx, s, data, data_byte_offset, data_byte_size);<br>
}<br>
<br>
bool<br>
@@ -1371,19 +1474,55 @@ void<br>
GoASTContext::DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data,<br>
lldb::offset_t data_offset, size_t data_byte_size)<br>
{<br>
- assert(false);<br>
+ if (type && GoType::KIND_STRING == static_cast<GoType *>(type)->GetGoKind())<br>
+ {<br>
+ // TODO(ribrdb): read length and data<br>
+ }<br>
}<br>
<br>
void<br>
GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type)<br>
{<br>
- assert(false);<br>
-} // Dump to stdout<br>
+ // Dump to stdout<br>
+ StreamFile s (stdout, false);<br>
+ DumpTypeDescription (type, &s);<br>
+}<br>
<br>
void<br>
GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s)<br>
{<br>
- assert(false);<br>
+ if (!type)<br>
+ return;<br>
+ ConstString name = GetTypeName(type);<br>
+ GoType *t = static_cast<GoType *>(type);<br>
+<br>
+ if (GoStruct *st = t->GetStruct())<br>
+ {<br>
+ if (GetCompleteType(type))<br>
+ {<br>
+ if (NULL == strchr(name.AsCString(), '{'))<br>
+ s->Printf("type %s ", name.AsCString());<br>
+ s->PutCString("struct {");<br>
+ if (st->GetNumFields() == 0) {<br>
+ s->PutChar('}');<br>
+ return;<br>
+ }<br>
+ s->IndentMore();<br>
+ uint32_t field_idx = 0;<br>
+ for (auto* field = st->GetField(field_idx); field != nullptr; field_idx++)<br>
+ {<br>
+ s->PutChar('\n');<br>
+ s->Indent();<br>
+ s->Printf("%s %s", field->m_name.AsCString(), field->m_type.GetTypeName().AsCString());<br>
+ }<br>
+ s->IndentLess();<br>
+ s->PutChar('\n');<br>
+ s->Indent("}");<br>
+ return;<br>
+ }<br>
+ }<br>
+<br>
+ s->PutCString(name.AsCString());<br>
}<br>
<br>
CompilerType<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>