37 if (
full())
return false;
94 while (
offset < format.length()) {
102 int format_length = 0;
105 temp[format_length++] = format[
offset++];
107 temp[format_length++] = format[
offset++];
108 if (
offset >= format.length())
return;
109 char type = format[
offset];
110 temp[format_length++] =
type;
111 temp[format_length] =
'\0';
113 FmtElm current = elms[elm++];
117 const char* value = current.data_.u_c_str_;
125 Put(
static_cast<char>(value[
i]));
136 int value = current.data_.u_int_;
137 if (0x20 <= value && value <= 0x7F) {
139 }
else if (value <= 0xFF) {
140 Add(
"\\x%02x", value);
142 Add(
"\\u%04x", value);
152 int value = current.data_.u_int_;
163 double value = current.data_.u_double_;
164 int inf = std::isinf(value);
167 }
else if (inf == 1) {
169 }
else if (std::isnan(value)) {
179 void* value = current.data_.u_pointer_;
200 }
else if (
IsNumber(o) || IsOddball(o)) {
208 isolate->string_stream_debug_object_cache();
209 for (
size_t i = 0;
i < debug_object_cache->size();
i++) {
210 if (*(*debug_object_cache)[
i] == o) {
211 Add(
"#%d#",
static_cast<int>(
i));
216 Add(
"#%d#",
static_cast<int>(debug_object_cache->size()));
228 return std::unique_ptr<char[]>(str);
232 LOG(isolate, StringEvent(
"StackDump",
buffer_));
251 return isolate->factory()
257 isolate->set_string_stream_current_security_token(
Tagged<Object>());
258 if (isolate->string_stream_debug_object_cache() ==
nullptr) {
261 isolate->string_stream_debug_object_cache()->clear();
265bool StringStream::IsMentionedObjectCacheClear(
Isolate* isolate) {
267 isolate->string_stream_debug_object_cache()->size() == 0;
272 return Put(str, 0, str->length());
279 if (c >= 127 || c < 32) {
282 if (!
Put(
static_cast<char>(c))) {
290 if (IsString(name)) {
292 if (str->length() > 0) {
295 Add(
"/* anonymous */");
315 for (; len < 18; len++)
Put(
' ');
331 unsigned int limit) {
333 for (
unsigned int i = 0;
i < 10 &&
i < limit;
i++) {
335 if (IsTheHole(element, roots))
continue;
336 for (
int len = 1; len < 18; len++) {
347 unsigned int limit = byte_array->length();
348 for (
unsigned int i = 0;
i < 10 &&
i < limit;
i++) {
349 uint8_t b = byte_array->get(
i);
350 Add(
" %d: %3d 0x%02x",
i, b, b);
351 if (b >=
' ' && b <=
'~') {
353 }
else if (b ==
'\n') {
355 }
else if (b ==
'\r') {
357 }
else if (b >= 1 && b <= 26) {
358 Add(
" ^%c", b +
'A' - 1);
370 isolate->string_stream_debug_object_cache();
371 Add(
"-- ObjectCacheKey --\n\n");
372 for (
size_t i = 0;
i < debug_object_cache->size();
i++) {
374 Add(
" #%d# %p: ",
static_cast<int>(
i),
375 reinterpret_cast<void*
>(printee.
ptr()));
378 if (IsJSObject(printee)) {
379 if (IsJSPrimitiveWrapper(printee)) {
380 Add(
" value(): %o\n",
384 if (IsJSArray(printee)) {
386 if (array->HasObjectElements()) {
388 unsigned int length =
static_cast<uint32_t
>(
390 if (length < limit) limit =
length;
394 }
else if (IsByteArray(printee)) {
396 }
else if (IsFixedArray(printee)) {
407 if (token.
SafeEquals(isolate->string_stream_current_security_token())) {
408 Add(
"Security context: %o\n", token);
409 isolate->set_string_stream_current_security_token(token);
421 bool print_name =
false;
425 }
else if (!isolate->context().is_null()) {
433 !iter.
IsAtEnd(); iter.Advance()) {
434 if (!IsJSObject(iter.GetCurrent()))
break;
436 if (!IsUndefined(
key, isolate)) {
437 if (!IsString(name) || !IsString(
key) ||
460 unsigned new_bytes = *bytes * 2;
462 if (new_bytes <= *bytes) {
466 if (new_space ==
nullptr) {
constexpr T * begin() const
static FieldIndex ForDescriptor(Tagged< Map > map, InternalIndex descriptor_index)
char * allocate(unsigned bytes) override
char * grow(unsigned *bytes) override
char * allocate(unsigned bytes) override
char * grow(unsigned *bytes) override
static V8_INLINE Isolate * Current()
static Tagged< Map > GetPrototypeChainRootMap(Tagged< Object > obj, Isolate *isolate)
static double NumberValue(Tagged< Number > obj)
PropertyLocation location() const
PropertyKind kind() const
virtual char * grow(unsigned *bytes)=0
void PrintObject(Tagged< Object > obj)
void PrintFunction(Isolate *isolate, Tagged< JSFunction > function, Tagged< Object > receiver)
void PrintByteArray(Tagged< ByteArray > ba)
static V8_EXPORT_PRIVATE void ClearMentionedObjectCache(Isolate *isolate)
DirectHandle< String > ToString(Isolate *isolate)
void PrintPrototype(Isolate *isolate, Tagged< JSFunction > fun, Tagged< Object > receiver)
void PrintMentionedObjectCache(Isolate *isolate)
void PrintSecurityTokenIfChanged(Isolate *isolate, Tagged< JSFunction > function)
std::unique_ptr< char[]> ToCString() const
void OutputToFile(FILE *out)
void PrintFixedArray(Tagged< FixedArray > array, unsigned int limit)
void Add(const char *format)
void PrintName(Tagged< Object > o)
void PrintUsingMap(Isolate *isolate, Tagged< JSObject > js_object)
void Log(Isolate *isolate)
StringAllocator * allocator_
ObjectPrintMode object_print_mode_
static const uint32_t kMaxShortPrintLength
V8_INLINE constexpr StorageType ptr() const
constexpr bool SafeEquals(TaggedImpl< kOtherRefType, StorageType > other) const
#define LOG(isolate, Call)
void DeleteArray(T *array)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
static const int kMentionedObjectCacheMaxSize
bool IsNumber(Tagged< Object > obj)
ReadOnlyRoots GetReadOnlyRoots()
void PrintF(const char *format,...)
bool IsNullOrUndefined(Tagged< Object > obj, Isolate *isolate)
void ShortPrint(Tagged< Object > obj, FILE *out)
static bool IsControlChar(char c)
V8_INLINE constexpr bool IsHeapObject(TaggedImpl< kRefType, StorageType > obj)
V8_INLINE bool IsWasmObject(T obj, Isolate *=nullptr)
std::vector< Handle< HeapObject > > DebugObjectCache
void MemCopy(void *dest, const void *src, size_t size)
T * NewArray(size_t size)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define CHECK_LE(lhs, rhs)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)