[csa] add utilities for printf-style debugging
Adds CSA::Print(const char* s), which generates a runtime call to Runtime::kGlobalPrint with a line-terminated ASCII string constant, and CSA::DebugPrint(const char* prefix, Node* tagged_value), which emits a runtime call to Runtime::kDebugPrint() with the tagged value, optionally prefixed by an ascii string constant. These simplify debugging TF builtins by providing a tool to easily observe the contents of values at arbitrary points in a program, without stepping endlessly through assembly in a debugger, and to easily observe the path taken through a TF builtin. These methods do not generate code in release builds. BUG=v8:5268 R=ishell@chromium.org, danno@chromium.org, bmeurer@chromium.org Review-Url: https://codereview.chromium.org/2651673003 Cr-Commit-Position: refs/heads/master@{#42660}
This commit is contained in:
parent
7c30fcf22d
commit
c18d4216a4
@ -8365,5 +8365,29 @@ Node* CodeStubAssembler::AllocatePromiseReactionJobInfo(
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeStubAssembler::Print(const char* s) {
|
||||
#ifdef DEBUG
|
||||
std::string formatted(s);
|
||||
formatted += "\n";
|
||||
Handle<String> string = isolate()->factory()->NewStringFromAsciiChecked(
|
||||
formatted.c_str(), TENURED);
|
||||
CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), HeapConstant(string));
|
||||
#endif
|
||||
}
|
||||
|
||||
void CodeStubAssembler::Print(const char* prefix, Node* tagged_value) {
|
||||
#ifdef DEBUG
|
||||
if (prefix != nullptr) {
|
||||
std::string formatted(prefix);
|
||||
formatted += ": ";
|
||||
Handle<String> string = isolate()->factory()->NewStringFromAsciiChecked(
|
||||
formatted.c_str(), TENURED);
|
||||
CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
|
||||
HeapConstant(string));
|
||||
}
|
||||
CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), tagged_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -1167,6 +1167,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
|
||||
Node* deferred_on_resolve,
|
||||
Node* deferred_on_reject, Node* context);
|
||||
|
||||
// Support for printf-style debugging
|
||||
void Print(const char* s);
|
||||
void Print(const char* prefix, Node* tagged_value);
|
||||
inline void Print(Node* tagged_value) { return Print(nullptr, tagged_value); }
|
||||
|
||||
protected:
|
||||
void DescriptorLookupLinear(Node* unique_name, Node* descriptors, Node* nof,
|
||||
Label* if_found, Variable* var_name_index,
|
||||
|
Loading…
Reference in New Issue
Block a user