[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for fixing this.




Comment at: lldb/source/Core/ValueObject.cpp:690
 
-  if (!valobj && synthetic_array_member)
-valobj = GetSyntheticValue()
- ->GetChildAtIndex(synthetic_index, synthetic_array_member)
- .get();
+  // In case of an incomplete type, LLDB will try to use the ValueObject's
+  // synthetic value to create the child ValueObject.

Sorry for the pedantry, but the wording "LLDB will try to ..." makes me think 
that there is some other part of lldb which "tries to use the synthetic value", 
and this code is somehow responding to that behavior.
But IIUC, this *is* the code which is using the synthetic value. In that case, 
it would be enough to say "In case of an incomplete type, **try to use** the 
synthetic value to ...".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib closed this revision.
mib added a comment.

Patch landed in 7177e63fb554 
 !


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 276157.
mib added a comment.

- Addressed Jim's comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/test/API/functionalities/target_var/Makefile
  lldb/test/API/functionalities/target_var/TestTargetVar.py
  lldb/test/API/functionalities/target_var/globals.c
  lldb/test/API/functionalities/target_var/globals.ll
  lldb/test/API/functionalities/target_var/main.c

Index: lldb/test/API/functionalities/target_var/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/target_var/main.c
@@ -0,0 +1,7 @@
+int i = 42;
+int *p = &i;
+
+struct incomplete;
+struct incomplete *var = (struct incomplete *)0xdead;
+
+int main() { return *p; }
Index: lldb/test/API/functionalities/target_var/globals.ll
===
--- lldb/test/API/functionalities/target_var/globals.ll
+++ /dev/null
@@ -1,42 +0,0 @@
-source_filename = "globals.c"
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.14.0"
-
-@i = global i32 42, align 4
-@p = global i32* @i, align 8, !dbg !0, !dbg !6
-
-; Function Attrs: noinline nounwind optnone ssp uwtable
-define i32 @main() #0 !dbg !15 {
-entry:
-  %retval = alloca i32, align 4
-  store i32 0, i32* %retval, align 4
-  %0 = load i32*, i32** @p, align 8, !dbg !18
-  %1 = load i32, i32* %0, align 4, !dbg !18
-  ret i32 %1, !dbg !18
-}
-
-attributes #0 = { noinline nounwind optnone ssp uwtable }
-
-!llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!10, !11, !12, !13}
-!llvm.ident = !{!14}
-
-!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_deref))
-!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true)
-!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug, globals: !5)
-!3 = !DIFile(filename: "globals.c", directory: "/")
-!4 = !{}
-!5 = !{!0, !6}
-!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
-!7 = distinct !DIGlobalVariable(name: "p", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
-!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = !{i32 2, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{i32 7, !"PIC Level", i32 2}
-!14 = !{!"clang version 8.0.0 (trunk 340838) (llvm/trunk 340843)"}
-!15 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: false, unit: !2, retainedNodes: !4)
-!16 = !DISubroutineType(types: !17)
-!17 = !{!9}
-!18 = !DILocation(line: 5, scope: !15)
Index: lldb/test/API/functionalities/target_var/globals.c
===
--- lldb/test/API/functionalities/target_var/globals.c
+++ /dev/null
@@ -1,6 +0,0 @@
-int i = 42;
-int *p = &i;
-
-int main() {
-  return *p;
-}
Index: lldb/test/API/functionalities/target_var/TestTargetVar.py
===
--- lldb/test/API/functionalities/target_var/TestTargetVar.py
+++ lldb/test/API/functionalities/target_var/TestTargetVar.py
@@ -20,3 +20,5 @@
 self.build()
 lldbutil.run_to_name_breakpoint(self, 'main')
 self.expect("target variable i", substrs=['i', '42'])
+self.expect("target variable var", patterns=['\(incomplete \*\) var = 0[xX](0)*dead'])
+self.expect("target variable var[0]", error=True, substrs=["can't find global variable 'var[0]'"])
Index: lldb/test/API/functionalities/target_var/Makefile
===
--- lldb/test/API/functionalities/target_var/Makefile
+++ lldb/test/API/functionalities/target_var/Makefile
@@ -1,5 +1,3 @@
-include Makefile.rules
+C_SOURCES := main.c
 
-a.out: globals.ll
-	$(CC) $(CFLAGS) -g -c $^ -o globals.o
-	$(LD) $(LDFLAGS) -g globals.o -o $@
+include Makefile.rules
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -687,10 +687,15 @@
 language_flags);
   }
 
-  if (!valobj && synthetic_array_member)
-valobj = GetSyntheticValue()
- ->GetChildAtIndex(synthetic_index, synthetic_array_member)
- .get();
+  // In case of an incomplete type, LLDB will try to use the ValueObject's
+  // synthetic value to create the child ValueObject.
+  if (!valobj && synthetic_array_member) {
+if (ValueObjectSP synth_valobj_sp = GetSyntheticValue()) {
+  valobj = synth_valobj_sp
+   ->GetChildAtIndex(synthe

[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Other than a quibble about using _sp suffix, this is fine.




Comment at: lldb/source/Core/ValueObject.cpp:693
+  if (!valobj && synthetic_array_member) {
+if (ValueObjectSP synth_valobj = GetSyntheticValue()) {
+  valobj =

We usually use _sp suffix for shared pointers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D83327#2136863 , @davide wrote:

> In D83327#2136842 , @jingham wrote:
>
> > In D83327#2136814 , @davide wrote:
> >
> > > Aside from cosmetics, I'm not entirely sure this is the correct fix. Why 
> > > are we calling this code _at all_ if the type is incomplete?
> >
> >
> > Doing so allows one to write a synthetic child provider that provides the 
> > fields for an incomplete type.  This is useful if you don't have debug info 
> > for a given type but know its layouts by some other means.
>
>
> Interesting, thanks. Do we have an example of when this triggers?


This change was first introduced by D79554 , 
with the `CFDictionaryRef` formatter. They reused the same logic as 
NSCFDictionary but needed this to generate the ValueObject's children.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 276152.
mib added a comment.

- Addressed style comment.
- Added a comment to give more context.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/test/API/functionalities/target_var/Makefile
  lldb/test/API/functionalities/target_var/TestTargetVar.py
  lldb/test/API/functionalities/target_var/globals.c
  lldb/test/API/functionalities/target_var/globals.ll
  lldb/test/API/functionalities/target_var/main.c

Index: lldb/test/API/functionalities/target_var/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/target_var/main.c
@@ -0,0 +1,7 @@
+int i = 42;
+int *p = &i;
+
+struct incomplete;
+struct incomplete *var = (struct incomplete *)0xdead;
+
+int main() { return *p; }
Index: lldb/test/API/functionalities/target_var/globals.ll
===
--- lldb/test/API/functionalities/target_var/globals.ll
+++ /dev/null
@@ -1,42 +0,0 @@
-source_filename = "globals.c"
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.14.0"
-
-@i = global i32 42, align 4
-@p = global i32* @i, align 8, !dbg !0, !dbg !6
-
-; Function Attrs: noinline nounwind optnone ssp uwtable
-define i32 @main() #0 !dbg !15 {
-entry:
-  %retval = alloca i32, align 4
-  store i32 0, i32* %retval, align 4
-  %0 = load i32*, i32** @p, align 8, !dbg !18
-  %1 = load i32, i32* %0, align 4, !dbg !18
-  ret i32 %1, !dbg !18
-}
-
-attributes #0 = { noinline nounwind optnone ssp uwtable }
-
-!llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!10, !11, !12, !13}
-!llvm.ident = !{!14}
-
-!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_deref))
-!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true)
-!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug, globals: !5)
-!3 = !DIFile(filename: "globals.c", directory: "/")
-!4 = !{}
-!5 = !{!0, !6}
-!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
-!7 = distinct !DIGlobalVariable(name: "p", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
-!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = !{i32 2, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{i32 7, !"PIC Level", i32 2}
-!14 = !{!"clang version 8.0.0 (trunk 340838) (llvm/trunk 340843)"}
-!15 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: false, unit: !2, retainedNodes: !4)
-!16 = !DISubroutineType(types: !17)
-!17 = !{!9}
-!18 = !DILocation(line: 5, scope: !15)
Index: lldb/test/API/functionalities/target_var/globals.c
===
--- lldb/test/API/functionalities/target_var/globals.c
+++ /dev/null
@@ -1,6 +0,0 @@
-int i = 42;
-int *p = &i;
-
-int main() {
-  return *p;
-}
Index: lldb/test/API/functionalities/target_var/TestTargetVar.py
===
--- lldb/test/API/functionalities/target_var/TestTargetVar.py
+++ lldb/test/API/functionalities/target_var/TestTargetVar.py
@@ -20,3 +20,5 @@
 self.build()
 lldbutil.run_to_name_breakpoint(self, 'main')
 self.expect("target variable i", substrs=['i', '42'])
+self.expect("target variable var", patterns=['\(incomplete \*\) var = 0[xX](0)*dead'])
+self.expect("target variable var[0]", error=True, substrs=["can't find global variable 'var[0]'"])
Index: lldb/test/API/functionalities/target_var/Makefile
===
--- lldb/test/API/functionalities/target_var/Makefile
+++ lldb/test/API/functionalities/target_var/Makefile
@@ -1,5 +1,3 @@
-include Makefile.rules
+C_SOURCES := main.c
 
-a.out: globals.ll
-	$(CC) $(CFLAGS) -g -c $^ -o globals.o
-	$(LD) $(LDFLAGS) -g globals.o -o $@
+include Makefile.rules
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -687,10 +687,15 @@
 language_flags);
   }
 
-  if (!valobj && synthetic_array_member)
-valobj = GetSyntheticValue()
- ->GetChildAtIndex(synthetic_index, synthetic_array_member)
- .get();
+  // In case of an incomplete type, LLDB will try to use the ValueObject's
+  // synthetic value to create the child ValueObject.
+  if (!valobj && synthetic_array_member) {
+if (ValueObjectSP synth_valobj = GetSyntheticValue()) {
+  valobj =
+  synth_valobj

[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In D83327#2136842 , @jingham wrote:

> In D83327#2136814 , @davide wrote:
>
> > Aside from cosmetics, I'm not entirely sure this is the correct fix. Why 
> > are we calling this code _at all_ if the type is incomplete?
>
>
> Doing so allows one to write a synthetic child provider that provides the 
> fields for an incomplete type.  This is useful if you don't have debug info 
> for a given type but know its layouts by some other means.


Interesting, thanks. Do we have an example of when this triggers?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

It sounds like that would be worth adding as a comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D83327#2136814 , @davide wrote:

> Aside from cosmetics, I'm not entirely sure this is the correct fix. Why are 
> we calling this code _at all_ if the type is incomplete?


The code is called because some incomplete types can actually be typedefs. In 
this case, we use the pointee type to create the ValueObject child (in 
ValueObject::CreateChildAtIndex)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D83327#2136814 , @davide wrote:

> Aside from cosmetics, I'm not entirely sure this is the correct fix. Why are 
> we calling this code _at all_ if the type is incomplete?


Doing so allows one to write a synthetic child provider that provides the 
fields for an incomplete type.  This is useful if you don't have debug info for 
a given type but know its layouts by some other means.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

Aside from cosmetics, I'm not entirely sure this is the correct fix. Why are we 
calling this code _at all_ if the type is incomplete?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Core/ValueObject.cpp:691
+  if (!valobj && synthetic_array_member) {
+auto synth_valobj = GetSyntheticValue();
+if (!synth_valobj)

Style-nit: I think few people love early returns a much as I do, but here I 
think the llvm-way of checking a pointer is would be preferable over a 
very-late-early-exit: 
```
if (auto* synth_valobj = GetSyntheticValue()) {
  valobj =
synth_valobj->GetChildAtIndex(synthetic_index, synthetic_array_member)
.get();
}
```
Additionally, I'm not sure if this should be `auto` according to the LLVM 
coding rules. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83327/new/

https://reviews.llvm.org/D83327



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83327: [lldb/Core] Fix incomplete type variable dereferencing crash.

2020-07-07 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: jingham, labath.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.

The patch fixes a crash in ValueObject::CreateChildAtIndex caused by a
null pointer dereferencing. This is a corner case that is happening when
trying to dereference a variable with an incomplete type, and this same
variable doesn't have a synthetic value to get the child ValueObject.

If this happens, lldb will now return a null pointer that will results
in an error message.

rdar://65181171

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83327

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/test/API/functionalities/target_var/Makefile
  lldb/test/API/functionalities/target_var/TestTargetVar.py
  lldb/test/API/functionalities/target_var/globals.c
  lldb/test/API/functionalities/target_var/globals.ll
  lldb/test/API/functionalities/target_var/main.c

Index: lldb/test/API/functionalities/target_var/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/target_var/main.c
@@ -0,0 +1,7 @@
+int i = 42;
+int *p = &i;
+
+struct incomplete;
+struct incomplete *var = (struct incomplete *)0xdead;
+
+int main() { return *p; }
Index: lldb/test/API/functionalities/target_var/globals.ll
===
--- lldb/test/API/functionalities/target_var/globals.ll
+++ /dev/null
@@ -1,42 +0,0 @@
-source_filename = "globals.c"
-target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.14.0"
-
-@i = global i32 42, align 4
-@p = global i32* @i, align 8, !dbg !0, !dbg !6
-
-; Function Attrs: noinline nounwind optnone ssp uwtable
-define i32 @main() #0 !dbg !15 {
-entry:
-  %retval = alloca i32, align 4
-  store i32 0, i32* %retval, align 4
-  %0 = load i32*, i32** @p, align 8, !dbg !18
-  %1 = load i32, i32* %0, align 4, !dbg !18
-  ret i32 %1, !dbg !18
-}
-
-attributes #0 = { noinline nounwind optnone ssp uwtable }
-
-!llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!10, !11, !12, !13}
-!llvm.ident = !{!14}
-
-!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_deref))
-!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true)
-!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug, globals: !5)
-!3 = !DIFile(filename: "globals.c", directory: "/")
-!4 = !{}
-!5 = !{!0, !6}
-!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
-!7 = distinct !DIGlobalVariable(name: "p", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
-!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = !{i32 2, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{i32 7, !"PIC Level", i32 2}
-!14 = !{!"clang version 8.0.0 (trunk 340838) (llvm/trunk 340843)"}
-!15 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: false, unit: !2, retainedNodes: !4)
-!16 = !DISubroutineType(types: !17)
-!17 = !{!9}
-!18 = !DILocation(line: 5, scope: !15)
Index: lldb/test/API/functionalities/target_var/globals.c
===
--- lldb/test/API/functionalities/target_var/globals.c
+++ /dev/null
@@ -1,6 +0,0 @@
-int i = 42;
-int *p = &i;
-
-int main() {
-  return *p;
-}
Index: lldb/test/API/functionalities/target_var/TestTargetVar.py
===
--- lldb/test/API/functionalities/target_var/TestTargetVar.py
+++ lldb/test/API/functionalities/target_var/TestTargetVar.py
@@ -20,3 +20,5 @@
 self.build()
 lldbutil.run_to_name_breakpoint(self, 'main')
 self.expect("target variable i", substrs=['i', '42'])
+self.expect("target variable var", patterns=['\(incomplete \*\) var = 0[xX](0)*dead'])
+self.expect("target variable var[0]", error=True, substrs=["can't find global variable 'var[0]'"])
Index: lldb/test/API/functionalities/target_var/Makefile
===
--- lldb/test/API/functionalities/target_var/Makefile
+++ lldb/test/API/functionalities/target_var/Makefile
@@ -1,5 +1,3 @@
-include Makefile.rules
+C_SOURCES := main.c
 
-a.out: globals.ll
-	$(CC) $(CFLAGS) -g -c $^ -o globals.o
-	$(LD) $(LDFLAGS) -g globals.o -o $@
+include Makefile.rules
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -687,10 +687,15 @@
 language_flags);
   }
 
-  if (!valobj && synthetic_array_member)
-valobj = GetSyntheticValue()
-