DWARFExpression: Fix implementation of DW_OP_pick

Summary:
The DWARF spec states that the DWARF stack arguments are numbered from
the top. Our implementation of DW_OP_pick was counting them from the
bottom.

This bug probably wasn't noticed because nobody (except my upcoming
postfix-to-DWARF converter) uses DW_OP_pick, but I've cross-checked with
gdb to confirm that counting from the top is the expected behavior.

This patch fixes the implementation to match the spec and gdb behavior
and adds a test.

Reviewers: jasonmolenda, clayborg

Subscribers: mgorny, aprantl, lldb-commits

Differential Revision: https://reviews.llvm.org/D61182

llvm-svn: 359436
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 2b5753e..7658ac8 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-types.h"
 
 #include "llvm/ADT/SmallString.h"
@@ -2844,3 +2845,9 @@
   }
   return false;
 }
+
+llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &os, const Scalar &scalar) {
+  StreamString s;
+  scalar.GetValue(&s, /*show_type*/ true);
+  return os << s.GetString();
+}