diff options
| author | Mark Salyzyn <salyzyn@google.com> | 2014-04-01 17:19:47 -0700 |
|---|---|---|
| committer | Mark Salyzyn <salyzyn@google.com> | 2014-04-02 13:12:04 -0700 |
| commit | 1c950479393d42d18829d4009dbdb3a7f03acbb7 (patch) | |
| tree | 1ba86b1f06f7df22e46ed2c022685fd71589d1bc /logd | |
| parent | 223fc42b5e289e882f67c893374ffbef595a6901 (diff) | |
| download | system_core-1c950479393d42d18829d4009dbdb3a7f03acbb7.tar.gz system_core-1c950479393d42d18829d4009dbdb3a7f03acbb7.tar.bz2 system_core-1c950479393d42d18829d4009dbdb3a7f03acbb7.zip | |
logd: liblog: logcat: enable prune features for user
- Enable whitelist, blacklist and logsize tuneables for user
Change-Id: Id0c283844c71c5263a8cfbebf2e550f7ac415858
Diffstat (limited to 'logd')
| -rw-r--r-- | logd/Android.mk | 4 | ||||
| -rw-r--r-- | logd/CommandListener.cpp | 12 | ||||
| -rw-r--r-- | logd/CommandListener.h | 4 | ||||
| -rw-r--r-- | logd/LogBuffer.cpp | 49 | ||||
| -rw-r--r-- | logd/LogBuffer.h | 6 | ||||
| -rw-r--r-- | logd/LogWhiteBlackList.cpp | 4 |
6 files changed, 7 insertions, 72 deletions
diff --git a/logd/Android.mk b/logd/Android.mk index b0bc746c9..ad747dd5d 100644 --- a/logd/Android.mk +++ b/logd/Android.mk @@ -4,10 +4,6 @@ include $(CLEAR_VARS) LOCAL_MODULE:= logd -ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),) -LOCAL_CFLAGS += -DUSERDEBUG_BUILD=1 -endif - LOCAL_SRC_FILES := \ main.cpp \ LogCommand.cpp \ diff --git a/logd/CommandListener.cpp b/logd/CommandListener.cpp index 12b10ca50..0bb233ac7 100644 --- a/logd/CommandListener.cpp +++ b/logd/CommandListener.cpp @@ -37,15 +37,11 @@ CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/, // registerCmd(new ShutdownCmd(buf, writer, swl)); registerCmd(new ClearCmd(buf)); registerCmd(new GetBufSizeCmd(buf)); -#ifdef USERDEBUG_BUILD registerCmd(new SetBufSizeCmd(buf)); -#endif registerCmd(new GetBufSizeUsedCmd(buf)); registerCmd(new GetStatisticsCmd(buf)); -#ifdef USERDEBUG_BUILD registerCmd(new SetPruneListCmd(buf)); registerCmd(new GetPruneListCmd(buf)); -#endif } CommandListener::ShutdownCmd::ShutdownCmd(LogBuffer *buf, LogReader *reader, @@ -117,8 +113,6 @@ int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli, return 0; } -#ifdef USERDEBUG_BUILD - CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) : LogCommand("setLogSize") , mBuf(*buf) @@ -152,8 +146,6 @@ int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli, return 0; } -#endif // USERDEBUG_BUILD - CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) : LogCommand("getLogSizeUsed") , mBuf(*buf) @@ -236,8 +228,6 @@ int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli, return 0; } -#ifdef USERDEBUG_BUILD - CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) : LogCommand("getPruneList") , mBuf(*buf) @@ -293,5 +283,3 @@ int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli, return 0; } - -#endif // USERDEBUG_BUILD diff --git a/logd/CommandListener.h b/logd/CommandListener.h index de1dcb90f..12905199f 100644 --- a/logd/CommandListener.h +++ b/logd/CommandListener.h @@ -53,15 +53,11 @@ private: LogBufferCmd(Clear) LogBufferCmd(GetBufSize) -#ifdef USERDEBUG_BUILD LogBufferCmd(SetBufSize) -#endif LogBufferCmd(GetBufSizeUsed) LogBufferCmd(GetStatistics) -#ifdef USERDEBUG_BUILD LogBufferCmd(GetPruneList) LogBufferCmd(SetPruneList) -#endif }; #endif diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index 81eb091a7..70f3e9194 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -28,22 +28,16 @@ // Default #define LOG_BUFFER_SIZE (256 * 1024) // Tuned on a per-platform basis here? -#ifdef USERDEBUG_BUILD #define log_buffer_size(id) mMaxSize[id] -#else -#define log_buffer_size(id) LOG_BUFFER_SIZE -#endif LogBuffer::LogBuffer(LastLogTimes *times) : mTimes(*times) { pthread_mutex_init(&mLogElementsLock, NULL); dgram_qlen_statistics = false; -#ifdef USERDEBUG_BUILD log_id_for_each(i) { mMaxSize[i] = LOG_BUFFER_SIZE; } -#endif } void LogBuffer::log(log_id_t log_id, log_time realtime, @@ -171,10 +165,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { size_t worst_sizes = 0; size_t second_worst_sizes = 0; -#ifdef USERDEBUG_BUILD - if (mPrune.worstUidEnabled()) -#endif - { + if (mPrune.worstUidEnabled()) { LidStatistics &l = stats.id(id); UidStatisticsCollection::iterator iu; for (iu = l.begin(); iu != l.end(); ++iu) { @@ -217,9 +208,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { break; } worst_sizes -= len; - } -#ifdef USERDEBUG_BUILD - else if (mPrune.naughty(e)) { // BlackListed + } else if (mPrune.naughty(e)) { // BlackListed it = mLogElements.erase(it); stats.subtract(e->getMsgLen(), id, uid, e->getPid()); delete e; @@ -227,34 +216,23 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { if (pruneRows == 0) { break; } - } -#endif - else { + } else { ++it; } } - if (!kick -#ifdef USERDEBUG_BUILD - || !mPrune.worstUidEnabled() -#endif - ) { + if (!kick || !mPrune.worstUidEnabled()) { break; // the following loop will ask bad clients to skip/drop } } -#ifdef USERDEBUG_BUILD bool whitelist = false; -#endif it = mLogElements.begin(); while((pruneRows > 0) && (it != mLogElements.end())) { LogBufferElement *e = *it; if (e->getLogId() == id) { if (oldest && (oldest->mStart <= e->getMonotonicTime())) { -#ifdef USERDEBUG_BUILD - if (!whitelist) -#endif - { + if (!whitelist) { if (stats.sizes(id) > (2 * log_buffer_size(id))) { // kick a misbehaving log reader client off the island oldest->release_Locked(); @@ -264,13 +242,13 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { } break; } -#ifdef USERDEBUG_BUILD + if (mPrune.nice(e)) { // WhiteListed whitelist = true; it++; continue; } -#endif + it = mLogElements.erase(it); stats.subtract(e->getMsgLen(), id, e->getUid(), e->getPid()); delete e; @@ -280,7 +258,6 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { } } -#ifdef USERDEBUG_BUILD if (whitelist && (pruneRows > 0)) { it = mLogElements.begin(); while((it != mLogElements.end()) && (pruneRows > 0)) { @@ -304,7 +281,6 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { } } } -#endif LogTimeEntry::unlock(); } @@ -324,8 +300,6 @@ unsigned long LogBuffer::getSizeUsed(log_id_t id) { return retval; } -#ifdef USERDEBUG_BUILD - // set the total space allocated to "id" int LogBuffer::setSize(log_id_t id, unsigned long size) { // Reasonable limits ... @@ -346,15 +320,6 @@ unsigned long LogBuffer::getSize(log_id_t id) { return retval; } -#else // ! USERDEBUG_BUILD - -// get the total space allocated to "id" -unsigned long LogBuffer::getSize(log_id_t /*id*/) { - return log_buffer_size(id); -} - -#endif - log_time LogBuffer::flushTo( SocketClient *reader, const log_time start, bool privileged, bool (*filter)(const LogBufferElement *element, void *arg), void *arg) { diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h index c3460cadf..dd02009e1 100644 --- a/logd/LogBuffer.h +++ b/logd/LogBuffer.h @@ -38,11 +38,9 @@ class LogBuffer { bool dgram_qlen_statistics; -#ifdef USERDEBUG_BUILD PruneList mPrune; unsigned long mMaxSize[LOG_ID_MAX]; -#endif public: LastLogTimes &mTimes; @@ -59,9 +57,7 @@ public: void clear(log_id_t id); unsigned long getSize(log_id_t id); -#ifdef USERDEBUG_BUILD int setSize(log_id_t id, unsigned long size); -#endif unsigned long getSizeUsed(log_id_t id); // *strp uses malloc, use free to release. void formatStatistics(char **strp, uid_t uid, unsigned int logMask); @@ -71,11 +67,9 @@ public: dgram_qlen_statistics = true; } -#ifdef USERDEBUG_BUILD int initPrune(char *cp) { return mPrune.init(cp); } // *strp uses malloc, use free to release. void formatPrune(char **strp) { mPrune.format(strp); } -#endif private: void maybePrune(log_id_t id); diff --git a/logd/LogWhiteBlackList.cpp b/logd/LogWhiteBlackList.cpp index 5f8173f6a..c6c7b232a 100644 --- a/logd/LogWhiteBlackList.cpp +++ b/logd/LogWhiteBlackList.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#ifdef USERDEBUG_BUILD - #include <ctype.h> #include <utils/String8.h> @@ -239,5 +237,3 @@ bool PruneList::nice(LogBufferElement *element) { } return false; } - -#endif // USERDEBUG_BUILD |
