Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: runtime/vm/disassembler.cc

Issue 135843006: Improve Code object support in service and observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/disassembler.h" 5 #include "vm/disassembler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/json_stream.h" 10 #include "vm/json_stream.h"
(...skipping 25 matching lines...) Expand all
36 OS::VFPrint(stdout, format, args); 36 OS::VFPrint(stdout, format, args);
37 va_end(args); 37 va_end(args);
38 } 38 }
39 39
40 40
41 void DisassembleToJSONStream::ConsumeInstruction(char* hex_buffer, 41 void DisassembleToJSONStream::ConsumeInstruction(char* hex_buffer,
42 intptr_t hex_size, 42 intptr_t hex_size,
43 char* human_buffer, 43 char* human_buffer,
44 intptr_t human_size, 44 intptr_t human_size,
45 uword pc) { 45 uword pc) {
46 uint8_t* pc_ptr = reinterpret_cast<uint8_t*>(pc); 46 uint8_t* pc_ptr = reinterpret_cast<uint8_t*>(pc);
turnidge 2014/01/17 19:30:21 Could use a comment here. "Instructions are repre
Cutch 2014/01/17 21:15:42 Done.
47 JSONObject jsobj(&jsarr_); 47 jsarr_.AddValueF("%p", pc_ptr);
48 jsobj.AddProperty("type", "DisassembledInstruction"); 48 jsarr_.AddValue(hex_buffer);
49 jsobj.AddPropertyF("pc", "%p", pc_ptr); 49 jsarr_.AddValue(human_buffer);
50 jsobj.AddProperty("hex", hex_buffer);
51 jsobj.AddProperty("human", human_buffer);
52 } 50 }
53 51
54 52
55 void DisassembleToJSONStream::Print(const char* format, ...) { 53 void DisassembleToJSONStream::Print(const char* format, ...) {
56 va_list args; 54 va_list args;
57 va_start(args, format); 55 va_start(args, format);
58 intptr_t len = OS::VSNPrint(NULL, 0, format, args); 56 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
59 va_end(args); 57 va_end(args);
60 char* p = reinterpret_cast<char*>(malloc(len+1)); 58 char* p = reinterpret_cast<char*>(malloc(len+1));
61 va_start(args, format); 59 va_start(args, format);
62 intptr_t len2 = OS::VSNPrint(p, len, format, args); 60 intptr_t len2 = OS::VSNPrint(p, len, format, args);
63 va_end(args); 61 va_end(args);
64 ASSERT(len == len2); 62 ASSERT(len == len2);
65 for (intptr_t i = 0; i < len; i++) { 63 for (intptr_t i = 0; i < len; i++) {
66 if (p[i] == '\n' || p[i] == '\r') { 64 if (p[i] == '\n' || p[i] == '\r') {
67 p[i] = ' '; 65 p[i] = ' ';
68 } 66 }
69 } 67 }
turnidge 2014/01/17 19:30:21 Could use a comment here.
Cutch 2014/01/17 21:15:42 Done.
70 JSONObject jsobj(&jsarr_); 68 jsarr_.AddValue("");
71 jsobj.AddProperty("type", "DisassembledInstructionComment"); 69 jsarr_.AddValue("");
72 jsobj.AddProperty("comment", p); 70 jsarr_.AddValue(p);
73 free(p); 71 free(p);
74 } 72 }
75 73
76 74
77 class FindAddrVisitor : public FindObjectVisitor { 75 class FindAddrVisitor : public FindObjectVisitor {
78 public: 76 public:
79 explicit FindAddrVisitor(uword addr) 77 explicit FindAddrVisitor(uword addr)
80 : FindObjectVisitor(Isolate::Current()), addr_(addr) { } 78 : FindObjectVisitor(Isolate::Current()), addr_(addr) { }
81 virtual ~FindAddrVisitor() { } 79 virtual ~FindAddrVisitor() { }
82 80
(...skipping 10 matching lines...) Expand all
93 DISALLOW_COPY_AND_ASSIGN(FindAddrVisitor); 91 DISALLOW_COPY_AND_ASSIGN(FindAddrVisitor);
94 }; 92 };
95 93
96 94
97 bool Disassembler::CanFindOldObject(uword addr) { 95 bool Disassembler::CanFindOldObject(uword addr) {
98 FindAddrVisitor visitor(addr); 96 FindAddrVisitor visitor(addr);
99 return Isolate::Current()->heap()->FindOldObject(&visitor) != Object::null(); 97 return Isolate::Current()->heap()->FindOldObject(&visitor) != Object::null();
100 } 98 }
101 99
102 } // namespace dart 100 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698