Reviewers: antonm,
Description:
Make the assumption on the minimum buffer size for GetLogLines explicit.
Please review this at http://codereview.chromium.org/799008
Affected files:
M include/v8.h
M src/api.cc
M src/log-utils.h
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
882eeddf153c1896e8c19a5c336c2f68b3e708b7..bed86cabd07b52aa29740f302f30c0b106bc8ba4
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2422,6 +2422,14 @@ class V8EXPORT V8 {
static int GetLogLines(int from_pos, char* dest_buf, int max_size);
/**
+ * The minimum allowed size for a log lines buffer. If the size of
+ * the buffer given will not be enough to hold a line of the maximum
+ * length, an attempt to find a log line end in GetLogLines will
+ * fail, and an empty result will be returned.
+ */
+ static const int kMinimumSizeForLogLinesBuffer = 2048;
+
+ /**
* Retrieve the V8 thread id of the calling thread.
*
* The thread id for a thread should only be retrieved after the V8
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
93fce79bdfacdf50293e1c30ee5572403187dfc5..af2e7ad243a6952faea1b434c8fc668e60eb836c
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3580,6 +3580,7 @@ int V8::GetActiveProfilerModules() {
int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) {
#ifdef ENABLE_LOGGING_AND_PROFILING
+ ASSERT(max_size >= kMinimumSizeForLogLinesBuffer);
return i::Logger::GetLogLines(from_pos, dest_buf, max_size);
#endif
return 0;
Index: src/log-utils.h
diff --git a/src/log-utils.h b/src/log-utils.h
index
b769e9046f21d12b0ec49a040fd63253350e8811..8889f1b77a30b17f9e7ae3802a2ffeeb350c71e9
100644
--- a/src/log-utils.h
+++ b/src/log-utils.h
@@ -115,7 +115,7 @@ class Log : public AllStatic {
}
// Size of buffer used for formatting log messages.
- static const int kMessageBufferSize = 2048;
+ static const int kMessageBufferSize =
v8::V8::kMinimumSizeForLogLinesBuffer;
private:
typedef int (*WritePtr)(const char* msg, int length);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev