Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::DisassembleToJSONStream Class Reference

#include <disassembler.h>

Inheritance diagram for dart::DisassembleToJSONStream:
dart::DisassemblyFormatter

Public Member Functions

 DisassembleToJSONStream (const JSONArray &jsarr)
 
 ~DisassembleToJSONStream ()
 
virtual void ConsumeInstruction (char *hex_buffer, intptr_t hex_size, char *human_buffer, intptr_t human_size, Object *object, uword pc)
 
virtual void Print (const char *format,...) PRINTF_ATTRIBUTE(2
 
- Public Member Functions inherited from dart::DisassemblyFormatter
 DisassemblyFormatter ()
 
virtual ~DisassemblyFormatter ()
 
virtual void ConsumeInstruction (char *hex_buffer, intptr_t hex_size, char *human_buffer, intptr_t human_size, Object *object, uword pc)=0
 
virtual void Print (const char *format,...) PRINTF_ATTRIBUTE(2
 

Detailed Description

Definition at line 66 of file disassembler.h.

Constructor & Destructor Documentation

◆ DisassembleToJSONStream()

dart::DisassembleToJSONStream::DisassembleToJSONStream ( const JSONArray jsarr)
inlineexplicit

Definition at line 68 of file disassembler.h.

69 : DisassemblyFormatter(), jsarr_(jsarr) {}

◆ ~DisassembleToJSONStream()

dart::DisassembleToJSONStream::~DisassembleToJSONStream ( )
inline

Definition at line 70 of file disassembler.h.

70{}

Member Function Documentation

◆ ConsumeInstruction()

void dart::DisassembleToJSONStream::ConsumeInstruction ( char *  hex_buffer,
intptr_t  hex_size,
char *  human_buffer,
intptr_t  human_size,
Object object,
uword  pc 
)
virtual

Implements dart::DisassemblyFormatter.

Definition at line 502 of file disassembler.cc.

507 {
508 // Instructions are represented as four consecutive values in a JSON array.
509 // The first is the address of the instruction, the second is the hex string,
510 // of the code, and the third is a human readable string, and the fourth is
511 // the object loaded by the instruction.
512 jsarr_.AddValueF("%" Pp "", pc);
513 jsarr_.AddValue(hex_buffer);
514 jsarr_.AddValue(human_buffer);
515
516 if (object != nullptr) {
517 jsarr_.AddValue(*object);
518 } else {
519 jsarr_.AddValueNull(); // Not a reference to null.
520 }
521}
void AddValueNull() const
Definition: json_stream.h:493
void AddValue(bool b) const
Definition: json_stream.h:494
void AddValueF(const char *format,...) const PRINTF_ATTRIBUTE(2
Definition: json_stream.cc:596
#define Pp
Definition: globals.h:425

◆ Print()

void dart::DisassembleToJSONStream::Print ( const char *  format,
  ... 
)
virtual

Reimplemented from dart::DisassemblyFormatter.

Definition at line 523 of file disassembler.cc.

523 {
524 va_list measure_args;
525 va_start(measure_args, format);
526 intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args);
527 va_end(measure_args);
528
529 char* p = reinterpret_cast<char*>(malloc(len + 1));
530 va_list print_args;
531 va_start(print_args, format);
532 intptr_t len2 = Utils::VSNPrint(p, len, format, print_args);
533 va_end(print_args);
534 ASSERT(len == len2);
535 for (intptr_t i = 0; i < len; i++) {
536 if (p[i] == '\n' || p[i] == '\r') {
537 p[i] = ' ';
538 }
539 }
540 // Instructions are represented as four consecutive values in a JSON array.
541 // Comments only use the third slot. See above comment for more information.
542 jsarr_.AddValueNull();
543 jsarr_.AddValueNull();
544 jsarr_.AddValue(p);
545 jsarr_.AddValueNull();
546 free(p);
547}
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
#define ASSERT(E)
uint32_t uint32_t * format
va_start(args, format)
va_end(args)
void * malloc(size_t size)
Definition: allocation.cc:19

The documentation for this class was generated from the following files: