Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
'src/node_revert.h',
'src/node_i18n.h',
'src/pipe_wrap.h',
'src/print.h',
'src/tty_wrap.h',
'src/tcp_wrap.h',
'src/udp_wrap.h',
Expand Down
13 changes: 7 additions & 6 deletions src/backtrace_posix.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "node.h"
#include "print.h"

#if defined(__linux__)
#include <features.h>
Expand Down Expand Up @@ -30,21 +31,21 @@ void DumpBacktrace(FILE* fp) {
}
for (int i = 1; i < size; i += 1) {
void* frame = frames[i];
fprintf(fp, "%2d: ", i);
FPrintF(fp, "%2d: ", i);
Dl_info info;
const bool have_info = dladdr(frame, &info);
if (!have_info || info.dli_sname == nullptr) {
fprintf(fp, "%p", frame);
FPrintF(fp, "%p", frame);
} else if (char* demangled = abi::__cxa_demangle(info.dli_sname, 0, 0, 0)) {
fprintf(fp, "%s", demangled);
FPrintF(fp, "%s", demangled);
free(demangled);
} else {
fprintf(fp, "%s", info.dli_sname);
FPrintF(fp, "%s", info.dli_sname);
}
if (have_info && info.dli_fname != nullptr) {
fprintf(fp, " [%s]", info.dli_fname);
FPrintF(fp, " [%s]", info.dli_fname);
}
fprintf(fp, "\n");
FPrintF(fp, "\n");
}
#endif // HAVE_EXECINFO_H
}
Expand Down
13 changes: 7 additions & 6 deletions src/env.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "env.h"
#include "env-inl.h"
#include "async-wrap.h"
#include "print.h"
#include "v8.h"
#include "v8-profiler.h"

Expand Down Expand Up @@ -117,7 +118,7 @@ void Environment::PrintSyncTrace() const {
Local<v8::StackTrace> stack =
StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed);

fprintf(stderr, "(node:%d) WARNING: Detected use of sync API\n", getpid());
FPrintF(stderr, "(node:%d) WARNING: Detected use of sync API\n", getpid());

for (int i = 0; i < stack->GetFrameCount() - 1; i++) {
Local<StackFrame> stack_frame = stack->GetFrame(i);
Expand All @@ -128,9 +129,9 @@ void Environment::PrintSyncTrace() const {

if (stack_frame->IsEval()) {
if (stack_frame->GetScriptId() == Message::kNoScriptIdInfo) {
fprintf(stderr, " at [eval]:%i:%i\n", line_number, column);
FPrintF(stderr, " at [eval]:%i:%i\n", line_number, column);
} else {
fprintf(stderr,
FPrintF(stderr,
" at [eval] (%s:%i:%i)\n",
*script_name,
line_number,
Expand All @@ -140,17 +141,17 @@ void Environment::PrintSyncTrace() const {
}

if (fn_name_s.length() == 0) {
fprintf(stderr, " at %s:%i:%i\n", *script_name, line_number, column);
FPrintF(stderr, " at %s:%i:%i\n", *script_name, line_number, column);
} else {
fprintf(stderr,
FPrintF(stderr,
" at %s (%s:%i:%i)\n",
*fn_name_s,
*script_name,
line_number,
column);
}
}
fflush(stderr);
FFlush(stderr);
}

} // namespace node
7 changes: 4 additions & 3 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "node_crypto.h"
#include "node_mutex.h"
#include "node_version.h"
#include "print.h"
#include "v8-inspector.h"
#include "v8-platform.h"
#include "util.h"
Expand Down Expand Up @@ -468,8 +469,8 @@ void AgentImpl::WaitForDisconnect() {
if (state_ == State::kConnected) {
shutting_down_ = true;
Write(TransportAction::kStop, 0, StringView());
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
fflush(stderr);
FPrintF(stderr, "Waiting for the debugger to disconnect...\n");
FFlush(stderr);
inspector_->runMessageLoopOnPause(0);
}
}
Expand Down Expand Up @@ -679,7 +680,7 @@ void AgentImpl::DispatchMessages() {
CHECK_EQ(State::kAccepting, state_);
session_id_ = std::get<1>(task);
state_ = State::kConnected;
fprintf(stderr, "Debugger attached.\n");
FPrintF(stderr, "Debugger attached.\n");
inspector_->connectFrontend();
break;
case InspectorAction::kEndSession:
Expand Down
19 changes: 10 additions & 9 deletions src/inspector_socket.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "inspector_socket.h"
#include "print.h"
#include "util.h"
#include "util-inl.h"

Expand Down Expand Up @@ -36,18 +37,18 @@ static void dump_hex(const char* buf, size_t len) {
while (ptr < end) {
cptr = ptr;
for (i = 0; i < 16 && ptr < end; i++) {
printf("%2.2X ", static_cast<unsigned char>(*(ptr++)));
PrintF("%2.2X ", static_cast<unsigned char>(*(ptr++)));
}
for (i = 72 - (i * 4); i > 0; i--) {
printf(" ");
PrintF(" ");
}
for (i = 0; i < 16 && cptr < end; i++) {
c = *(cptr++);
printf("%c", (c > 0x19) ? c : '.');
PrintF("%c", (c > 0x19) ? c : '.');
}
printf("\n");
PrintF("\n");
}
printf("\n\n");
PrintF("\n\n");
}
#endif

Expand Down Expand Up @@ -101,7 +102,7 @@ static int write_to_client(InspectorSocket* inspector,
size_t len,
uv_write_cb write_cb = write_request_cleanup) {
#if DUMP_WRITES
printf("%s (%ld bytes):\n", __FUNCTION__, len);
PrintF("%s (%ld bytes):\n", __FUNCTION__, len);
dump_hex(msg, len);
#endif

Expand Down Expand Up @@ -337,7 +338,7 @@ static void websockets_data_cb(uv_stream_t* stream, ssize_t nread,
}
} else {
#if DUMP_READS
printf("%s read %ld bytes\n", __FUNCTION__, nread);
PrintF("%s read %ld bytes\n", __FUNCTION__, nread);
if (nread > 0) {
dump_hex(inspector->buffer.data() + inspector->buffer.size() - nread,
nread);
Expand Down Expand Up @@ -513,10 +514,10 @@ static void data_received_cb(uv_stream_s* client, ssize_t nread,
const uv_buf_t* buf) {
#if DUMP_READS
if (nread >= 0) {
printf("%s (%ld bytes)\n", __FUNCTION__, nread);
PrintF("%s (%ld bytes)\n", __FUNCTION__, nread);
dump_hex(buf->base, nread);
} else {
printf("[%s:%d] %s\n", __FUNCTION__, __LINE__, uv_err_name(nread));
PrintF("[%s:%d] %s\n", __FUNCTION__, __LINE__, uv_err_name(nread));
}
#endif
InspectorSocket* inspector = inspector_from_stream(client);
Expand Down
15 changes: 8 additions & 7 deletions src/inspector_socket_server.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "inspector_socket_server.h"

#include "node.h"
#include "print.h"
#include "uv.h"
#include "zlib.h"

Expand Down Expand Up @@ -81,22 +82,22 @@ void PrintDebuggerReadyMessage(const std::string& host,
if (out == NULL) {
return;
}
fprintf(out,
FPrintF(out,
"Debugger listening on port %d.\n"
"Warning: This is an experimental feature "
"and could change at any time.\n",
port);
if (ids.size() == 1)
fprintf(out, "To start debugging, open the following URL in Chrome:\n");
FPrintF(out, "To start debugging, open the following URL in Chrome:\n");
if (ids.size() > 1)
fprintf(out, "To start debugging, open the following URLs in Chrome:\n");
FPrintF(out, "To start debugging, open the following URLs in Chrome:\n");
for (const std::string& id : ids) {
fprintf(out,
FPrintF(out,
" chrome-devtools://devtools/bundled/inspector.html?"
"experiments=true&v8only=true&ws=%s\n",
GetWsUrl(host, port, id).c_str());
}
fflush(out);
FFlush(out);
}

void SendHttpResponse(InspectorSocket* socket, const std::string& response) {
Expand Down Expand Up @@ -395,9 +396,9 @@ bool InspectorSocketServer::Start(uv_loop_t* loop) {
}
if (err != 0 && connected_sessions_.empty()) {
if (out_ != NULL) {
fprintf(out_, "Starting inspector on %s:%d failed: %s\n",
FPrintF(out_, "Starting inspector on %s:%d failed: %s\n",
host_.c_str(), port_, uv_strerror(err));
fflush(out_);
FFlush(out_);
}
uv_close(reinterpret_cast<uv_handle_t*>(&server_), nullptr);
return false;
Expand Down
Loading