Return values for locals, so "locals" can show them.
Also implement a couple of other JDWP commands so jdb can show the length
of arrays and the value of strings.
Change-Id: Ib2a4dc2ee784ee10bdb924e91b0150aa8a96845d
diff --git a/src/context.h b/src/context.h
index b4a8b65..75eb8ca 100644
--- a/src/context.h
+++ b/src/context.h
@@ -3,6 +3,7 @@
#ifndef ART_SRC_CONTEXT_H_
#define ART_SRC_CONTEXT_H_
+#include <stddef.h>
#include <stdint.h>
namespace art {
@@ -34,6 +35,42 @@
virtual void DoLongJump() = 0;
};
+class VmapTable {
+ public:
+ VmapTable(const uint16_t* table) : table_(table) {
+ }
+
+ uint16_t operator[](size_t i) const {
+ return table_[i + 1];
+ }
+
+ size_t size() const {
+ return table_[0];
+ }
+
+ // Is register 'reg' in the context or on the stack?
+ bool IsInContext(size_t reg, uint32_t& vmap_offset) const {
+ vmap_offset = 0xEBAD0FF5;
+ // TODO: take advantage of the registers being ordered
+ for (size_t i = 0; i < size(); ++i) {
+ // Stop if we find what we are are looking for...
+ if (table_[i + 1] == reg) {
+ vmap_offset = i;
+ return true;
+ }
+ // ...or the INVALID_VREG that marks lr.
+ // TODO: x86?
+ if (table_[i + 1] == 0xffff) {
+ break;
+ }
+ }
+ return false;
+ }
+
+ private:
+ const uint16_t* table_;
+};
+
} // namespace art
#endif // ART_SRC_CONTEXT_H_