[llvm] r269374 - [codeview] Fix dumping VFTables, stop when we see LF_PAD*
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu May 12 15:46:42 PDT 2016
Author: rnk
Date: Thu May 12 17:46:41 2016
New Revision: 269374
URL: http://llvm.org/viewvc/llvm-project?rev=269374&view=rev
Log:
[codeview] Fix dumping VFTables, stop when we see LF_PAD*
Also stop visiting type records when we encounter an error.
Added:
llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-vftable.obj.coff
llvm/trunk/test/tools/llvm-readobj/codeview-vftable.test
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h?rev=269374&r1=269373&r2=269374&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h Thu May 12 17:46:41 2016
@@ -78,8 +78,11 @@ public:
/// Visits the type records in Data. Sets the error flag on parse failures.
void visitTypeStream(ArrayRef<uint8_t> Data) {
- for (const auto &I : makeTypeRange(Data))
+ for (const auto &I : makeTypeRange(Data)) {
visitTypeRecord(I);
+ if (hadError())
+ break;
+ }
}
/// Action to take on unknown types. By default, they are ignored.
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h?rev=269374&r1=269373&r2=269374&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/RecordSerialization.h Thu May 12 17:46:41 2016
@@ -14,6 +14,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Endian.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
#include <cinttypes>
#include <tuple>
@@ -113,7 +114,8 @@ template <typename T> struct serialize_a
std::error_code deserialize(ArrayRef<uint8_t> &Data) const {
T Field;
- while (!Data.empty()) {
+ // Stop when we run out of bytes or we hit record padding bytes.
+ while (!Data.empty() && Data.front() < LF_PAD0) {
if (auto EC = consume(Data, Field))
return EC;
Item.push_back(Field);
Added: llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-vftable.obj.coff
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-vftable.obj.coff?rev=269374&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-vftable.obj.coff (added) and llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-vftable.obj.coff Thu May 12 17:46:41 2016 differ
Added: llvm/trunk/test/tools/llvm-readobj/codeview-vftable.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/codeview-vftable.test?rev=269374&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/codeview-vftable.test (added)
+++ llvm/trunk/test/tools/llvm-readobj/codeview-vftable.test Thu May 12 17:46:41 2016
@@ -0,0 +1,51 @@
+; The following two object files were generated using the following command:
+; $ cl /Z7 /c t.cpp
+; The contents of t.cpp follow:
+; struct A {
+; virtual void f();
+; };
+; struct B {
+; virtual void f();
+; virtual void g();
+; };
+; struct C {
+; virtual void f();
+; virtual void g();
+; virtual void h();
+; };
+; A a;
+; B b;
+; C c;
+
+RUN: llvm-readobj -codeview %p/Inputs/codeview-vftable.obj.coff | FileCheck %s
+
+CHECK: VFTableType {
+CHECK-NEXT: TypeLeafKind: LF_VFTABLE (0x151D)
+CHECK-NEXT: TypeIndex: 0x10F0
+CHECK-NEXT: CompleteClass: A
+CHECK-NEXT: OverriddenVFTable: 0x0
+CHECK-NEXT: VFPtrOffset: 0x0
+CHECK-NEXT: VFTableName: ??_7A@@6B@
+CHECK-NEXT: MethodName: ?f at A@@UEAAXXZ
+CHECK-NEXT: }
+CHECK-NEXT: VFTableType {
+CHECK-NEXT: TypeLeafKind: LF_VFTABLE (0x151D)
+CHECK-NEXT: TypeIndex: 0x10F1
+CHECK-NEXT: CompleteClass: B
+CHECK-NEXT: OverriddenVFTable: ??_7A@@6B@ (0x10F0)
+CHECK-NEXT: VFPtrOffset: 0x0
+CHECK-NEXT: VFTableName: ??_7B@@6B@
+CHECK-NEXT: MethodName: ?f at B@@UEAAXXZ
+CHECK-NEXT: MethodName: ?g at B@@UEAAXXZ
+CHECK-NEXT: }
+CHECK-NEXT: VFTableType {
+CHECK-NEXT: TypeLeafKind: LF_VFTABLE (0x151D)
+CHECK-NEXT: TypeIndex: 0x10F2
+CHECK-NEXT: CompleteClass: C
+CHECK-NEXT: OverriddenVFTable: ??_7B@@6B@ (0x10F1)
+CHECK-NEXT: VFPtrOffset: 0x0
+CHECK-NEXT: VFTableName: ??_7C@@6B@
+CHECK-NEXT: MethodName: ?f at C@@UEAAXXZ
+CHECK-NEXT: MethodName: ?g at C@@UEAAXXZ
+CHECK-NEXT: MethodName: ?h at C@@UEAAXXZ
+CHECK-NEXT: }
More information about the llvm-commits
mailing list