summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-10-24 18:22:17 -0500
committerMark Salyzyn2016-10-25 16:48:33 -0500
commit60636fa872382a8cde0440b72cdfc9032b5fa7d0 (patch)
tree8284ae19bd944113d81e95709fecd09c74d1c2f9 /logd/LogBuffer.cpp
parentd97efe0383a8bdad7a335b268d4492c9ee5e39c6 (diff)
downloadplatform-system-core-60636fa872382a8cde0440b72cdfc9032b5fa7d0.tar.gz
platform-system-core-60636fa872382a8cde0440b72cdfc9032b5fa7d0.tar.xz
platform-system-core-60636fa872382a8cde0440b72cdfc9032b5fa7d0.zip
logd: getTag() functional for chatty entries
getTag() becomes invalid when entry is dropped because mMsg disappears to save space; but the per-tag spam filter depends on it still being valid. Conserve space in LogBufferElement by optimizing the size of the fields, then add a new mTag field that is set in the object constructor. Add an isBinary() method. SideEffects: save 12 bytes/log message overhead on 64-bit. Test: define DEBUG_CHECK_FOR_STALE_ENTRIES and look for stale entries Bug: 32247044 Change-Id: Iaa5f416718a92c9e0e6ffd56bd5260d8b908d5c0
Diffstat (limited to 'logd/LogBuffer.cpp')
-rw-r--r--logd/LogBuffer.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 5cab7a8c4..a00943309 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -13,6 +13,8 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16// for manual checking of stale entries during LogBuffer::erase()
17//#define DEBUG_CHECK_FOR_STALE_ENTRIES
16 18
17#include <ctype.h> 19#include <ctype.h>
18#include <errno.h> 20#include <errno.h>
@@ -256,6 +258,11 @@ LogBufferElementCollection::iterator LogBuffer::erase(
256 log_id_for_each(i) { 258 log_id_for_each(i) {
257 doSetLast |= setLast[i] = mLastSet[i] && (it == mLast[i]); 259 doSetLast |= setLast[i] = mLastSet[i] && (it == mLast[i]);
258 } 260 }
261#ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
262 LogBufferElementCollection::iterator bad = it;
263 int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ?
264 element->getTag() : element->getUid();
265#endif
259 it = mLogElements.erase(it); 266 it = mLogElements.erase(it);
260 if (doSetLast) { 267 if (doSetLast) {
261 log_id_for_each(i) { 268 log_id_for_each(i) {
@@ -269,6 +276,27 @@ LogBufferElementCollection::iterator LogBuffer::erase(
269 } 276 }
270 } 277 }
271 } 278 }
279#ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
280 log_id_for_each(i) {
281 for(auto b : mLastWorst[i]) {
282 if (bad == b.second) {
283 android::prdebug("stale mLastWorst[%d] key=%d mykey=%d\n",
284 i, b.first, key);
285 }
286 }
287 for(auto b : mLastWorstPidOfSystem[i]) {
288 if (bad == b.second) {
289 android::prdebug("stale mLastWorstPidOfSystem[%d] pid=%d\n",
290 i, b.first);
291 }
292 }
293 if (mLastSet[i] && (bad == mLast[i])) {
294 android::prdebug("stale mLast[%d]\n", i);
295 mLastSet[i] = false;
296 mLast[i] = mLogElements.begin();
297 }
298 }
299#endif
272 if (coalesce) { 300 if (coalesce) {
273 stats.erase(element); 301 stats.erase(element);
274 } else { 302 } else {