summaryrefslogtreecommitdiff
path: root/cmds/incidentd/src/Section.cpp
Commit message (Collapse)AuthorAgeFilesLines
* s/get_interesting_hal_pids/get_interesting_pids.Jayant Chowdhary2022-05-241-1/+1
| | | | | | | | | | | Since pids can belong to non hal processes as well, in theory. Bug: 233130219 Test: build Change-Id: I8ef6b2aaa871f6a8f992887a394d81c544e9cba4 Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
* Merge "Fix a lambda capture problem in TextDumpsysSection" into rvc-dev am: ↵TreeHugger Robot2020-06-051-3/+4
|\ | | | | | | | | | | | | | | 35a18b50c5 am: ddcab6fd21 Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11756603 Change-Id: I600de2a9a06834c454f29f6bfc0266a35b6600e4
| * Fix a lambda capture problem in TextDumpsysSectionMike Ma2020-06-051-3/+4
| | | | | | | | | | | | | | | | | | | | The [&] capture does not handle smart pointers (unique_ptr, unique_fd etc) well, which lead to leaked pointers. Fix by explicitly move the smart pointers. Bug: 158097879 Test: Build, flash and take an incident report. Verify no crash Change-Id: I5150aa3dddf9d59c1c9d6d32370370e8cde23946
* | Merge "mCallback defined in BringYourOwnSection should be an object instead ↵Wenjie Zhou2020-05-151-1/+3
|\| | | | | | | | | | | of a reference." into rvc-dev am: ad24e49e2f am: 9d83125d4d Change-Id: I129b61348e03980e0fa2372db3eb612fb3843f99
| * mCallback defined in BringYourOwnSection should be an object instead of a ↵Wenjie Zhou2020-05-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | reference. The referenced object could be destroyed and result in native crash when mCallback is used. Bug: 156536687 Test: manual test with registering a section from an app Change-Id: Ie36c0e6e64be1246539f12999f037c24377686dd
* | Include log/log_read.h for reading logsTom Cherry2020-04-221-1/+0
|/ | | | | | | | log/log.h is concerned with writing logs. Bug: 78370064 Test: build Change-Id: I3c7719bcbffc6809377e80292b00312b4598bfc2
* Fix a race condition on ReportHandler::mBatchMike Ma2020-03-301-1/+1
| | | | | | | | Hold mLock when accessing mBatch and mHandlerLooper in ReportHandler. Fixes: 147326028 Test: Take an incident report. Verify no race condition. Change-Id: I9d6da0067731f253532f60e5abb12dfb238b5411
* Optimize memory usage in incidentdMike Ma2020-03-231-38/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | EncodedBuffer is used a lot in incidentd. EncodedBuffer uses malloc internally to acquire memory. Frequently creating and destroying EncodedBuffer creates memory fragmentation, leading to high memory usage after taking an incident report. Also fixes a few other places with lots of malloc/free operations. This change: * Creates a pool of EncodedBuffer in incidentd. The saving is significant. It reduces EncodedBuffer creation from 3 per section to 3 per report. * Replaces malloc with mmap inside EncodedBuffer. mmap is guaranteed to be mem page aligned, so there will be no mem fragmentation after destroying EncodedBuffer. * Replaces new with mmap inside TombstoneSection * Forks a process to execute LogSection, because liblog malloc & free significant amount of memory Result: PSS before taking a report: 1295 KB PSS after taking a report: 1336 KB Bug: 150311553 Test: heapprofd Change-Id: I83bd9c969b751c80b2f42747020799bd85d8aae6
* TextDumpsysSection memory optimizationMike Ma2020-03-191-21/+31
| | | | | | | | | | TextDumpsysSection used to inherent WorkerThreadSection, which allocates 2x more memory than the dumped content. This change saves the extra allocation by writing dumpsys content directly to FdBuffer. Bug: 150311553 Test: Manually run "incident -p EXPLICIT 4000" Change-Id: I9c0c0db75c8595822ee0711040e8865dd69378b6
* Fix incidentd stack use-after-returnMike Ma2020-03-181-16/+17
| | | | | | | | | | | The detached thread may live longer than the caller, and then "data" goes out of scope. Fix it by managing data using a strong pointer. Fixes: 151335416 Test: turn on hwasan, tweak WorkerThreadSection timeout, verify no hwasan error Change-Id: I179204b17c381e4e920b9aee07900150d9497639
* Add text dumpsys section to incidentdMike Ma2020-02-231-61/+97
| | | | | | | | | | | | | | | Enable Incidentd to dump any existing dumpsys section in plain text (as dumpsys.proto), only in eng or userdebug build. This is for a few dumpsys services that are prohibitively expensive to migrate to protobuf dumpsys or will undergo a major rewrite (thus render the previously defined proto completely useless). Bug: 149816498 Bug: 146085372 Bug: 146086519 Test: $ incident -p EXPLICIT 4000 4001 Change-Id: I0693d9bace0055cfeb63d7c8d48995d57dc0b733 (cherry picked from commit 95ba73f9c9815da08cdb7015195939a3c1b250bd)
* Incident Report Extension APIMike Ma2020-01-141-7/+23
| | | | | | | | | | | Add an API for priv and system app to register a dump callback with Incident Service. Bug: 145924375 Test: Register a callback dumping a string. Capture an incident report and verify that the customized section exist. Change-Id: I6fff6c1ee97e25963068d284ba37adce1bb5ec31
* incidentd: Add missing va_end()Greg Kaiser2019-11-041-0/+1
| | | | | | | A recently added va_start() was missed its va_end(). We fix this. Test: TreeHugger Change-Id: I774da07096bee33bd91b78d734e8de946c87a87f
* Add last logcat data to incident reportzhouwenjie2019-11-011-7/+23
| | | | | | Bug: 142721354 Test: adb sehll incident -p EXPLICIT 1109 Change-Id: Iaee370310e36998e161955e0f12d98ac8cd8eb90
* Remove legacy logger_entry_v* structsTom Cherry2019-10-241-8/+8
| | | | | | | These are obsolete so we move all users to a single format. Test: build, logging unit tests Change-Id: I05ebb0b9135c61585ff103d24b785b9f21197257
* userdebug: support perfetto traces as a section in incident reportsRyan Savitski2019-06-071-0/+2
| | | | | | | | | | | | | | | | | | | | | This set of patches adds a way for the perfetto command line client to save a trace to a hardcoded location, /data/misc/perfetto-traces/incident-trace, and call into incidentd to start a report, which will include said trace in a new section. This is not a long-term solution, and is structured to minimize changes to perfetto and incidentd. The latter is currently architected in a way where it can only pull pre-defined information out of the system, so we're resorting to persisting the intermediate results in a hardcoded location. This will introduce at most two more linked files at the same time. Bug: 130543265 Tested: manually on crosshatch-userdebug Merged-In: Iaaa312d2d9da73ca329807211227a8c7a049102c Change-Id: Iaaa312d2d9da73ca329807211227a8c7a049102c (cherry picked from commit 09a847902fa428f97841c3689b9f11243cc60460)
* Don't include restricted images in incident reports unless they're ↵Joe Onorato2019-04-261-0/+9
| | | | | | | | | specifically mentioned in the IncidentReportArgs Test: adb shell incident -p EXPLICIT -s com.google.android.incident.gts/.ReportReadyReceiver 3025 Test: adb shell incident -p EXPLICIT -s com.google.android.incident.gts/.ReportReadyReceiver Bug: 123543706 Change-Id: I2c55831b73338f68196838ee529e595f566e657f
* incidentd sections for userdebug and eng are compiled outJoe Onorato2019-03-271-8/+9
| | | | | | | | | | | Previously, the decision to include or not include them was done at runtime. This changes them to be behind a compile time flag. It's just safer, because the code just isn't there instead of being dependent on a system property. Test: bit GtsIncidentManagerTestCases:* Bug: 123543706 Change-Id: If4e611914a7b0acd399ae27e55af8f718aee3ec8
* incidentd can now handle multiple callers asking it for incident reportsJoe Onorato2019-03-261-220/+31
| | | | | | Test: bit incident_test:* GtsIncidentManagerTestCases:* Bug: 123543706 Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
* Merge "Fix/suppress incident* google-explicit-constructor warnings" am: ↵Chih-hung Hsieh2018-12-211-1/+1
|\ | | | | | | | | | | | | | | 6af0e228f3 am: 78085ba0a3 am: ee844ad9a2 Change-Id: I53c2fd3886e565d824e2765671fb7965f07bd08d
| * Fix/suppress incident* google-explicit-constructor warningsChih-Hung Hsieh2018-12-201-1/+1
| | | | | | | | | | | | | | | | | | * Add explicit to conversion constructors/operators * Remove redundant explicit of copy constructors Bug: 28341362 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor Change-Id: I26a11bb798d25605577269ed340e97afc8566960
| * Handling potential SIGPIPE signals.Kweku Adams2018-09-181-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | There are cases where dumping Java traces times out and then later tries to write to a closed pipe, causing incidentd to crash. This introduces a handler for the SIGPIPE signal so it doesn't crash due to a closed pipe. Bug: 111729299 Test: lower section timeout to 5 seconds and make sure incident service doesn't crash Change-Id: I868aba1ae21a50ae76977e0e09e782cf94198473 (cherry picked from commit 5b763c13472effa7df25cc53a44d5bdae9392410)
| * Adding batterystats history to proto dump.Kweku Adams2018-05-071-7/+10
| | | | | | | | | | | | | | | | | | | | | | It will only print out a dump for userdebug or eng builds. Bug: 77727638 Test: flash device and check output of incident proto and 'dumpsys batterystats -c --history' Merged-In: Ib74d4c664f23a61e6fc33f700ba6a3c6fad32c74 Change-Id: Ia0c993d1281cc350d93f9c13f5540b349a4bfb84
| * Merge "Add a section flag to bypass failure if a specific path can't be ↵Yi Jin2018-05-021-4/+6
| |\ | | | | | | | | | found." into pi-dev
| | * Add a section flag to bypass failure if a specific path can't be found.Yi Jin2018-05-021-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a temporary solution to bypass failure of reading cpu info or battery type in P if the path doesn't exist on some devices. See bug for details. However in Q, incidentd should implement reading from the common Linux kernel interfaces. Bug: 78028767 Bug: 78239764 Test: atest incidentd_test Change-Id: I08ffcb21709efe5478d2ac46121deb5795af1024 Merged-In: I08ffcb21709efe5478d2ac46121deb5795af1024
* | | Refine incidentd error handling and loggingMike Ma2018-12-051-34/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added or changed some error messages and logging for easier debugging. Log a few section errors to incident metadata in addition to logcat. Also let incident reporting continue instead of failing when non-fatal error occurs. Bug: 119417232 Test: Take an incident report, and logcat. Change-Id: Id18b7b690100923a8074d99b2312ee80c0bcd760
* | | Handling potential SIGPIPE signals.Kweku Adams2018-09-131-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are cases where dumping Java traces times out and then later tries to write to a closed pipe, causing incidentd to crash. This introduces a handler for the SIGPIPE signal so it doesn't crash due to a closed pipe. Bug: 111729299 Test: lower section timeout to 5 seconds and make sure incident service doesn't crash Change-Id: I868aba1ae21a50ae76977e0e09e782cf94198473
* | | Treating all FileSection files as device specific.Kweku Adams2018-06-131-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Arc++ devices don't have the /d/wakeup_sources file. There's a chance other device won't have it either, and there may be other files that we thought were standard but are actually not, so it's safer to just assume that not every file will be available on every device and not treat a missing file as an error. Bug: 110109543 Test: atest incidentd_test Change-Id: Ief09427f08d18aee611d057ddafdb9a3466744db
* | | Adding batterystats history to proto dump.Kweku Adams2018-05-071-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It will only print out a dump for userdebug or eng builds. This is the same change as the pi-dev one (http://ag/3909863), but due to changes in master, that change has a merge conflict, so I have to create a separate CL for master. Bug: 77727638 Test: it builds Change-Id: Ib74d4c664f23a61e6fc33f700ba6a3c6fad32c74
* | | Merge "Preventing zombie process creation." into pi-dev am: ca6f36532dandroid-build-team Robot2018-05-021-0/+5
|\| | | | | | | | | | | | | | | | | am: 193c893b01 Change-Id: Id32203ab069343410a02c03956a7c6135f8a1b33
| * | Preventing zombie process creation.Kweku Adams2018-04-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Bug: 78363774 Test: flash device, run 'adb shell incident', then check 'adb shell ps | grep incidentd' Change-Id: I473894eb1c05ce8557da846d1ccdcbfa672356eb
* | | Add a section flag to bypass failure if a specific path can't be found.Yi Jin2018-05-011-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a temporary solution to bypass failure of reading cpu info or battery type in P if the path doesn't exist on some devices. See bug for details. However in Q, incidentd should implement reading from the common Linux kernel interfaces. Bug: 78028767 Bug: 78239764 Test: atest incidentd_test Change-Id: I08ffcb21709efe5478d2ac46121deb5795af1024
* | | Make the logging more concise.Yi Jin2018-04-201-74/+34
|/ / | | | | | | | | | | | | | | Each section's name will start with its type, e.g. file, gzip, cmd. Bug: 77333635 Test: atest incidentd_test Change-Id: I7c86f2682b1c2055c6063f6395fc7fe7fc7ffea5
* | Merge "Free allocated varargs" into pi-devTreeHugger Robot2018-04-171-1/+1
|\ \
| * | Free allocated varargsYi Jin2018-04-171-2/+2
| |/ | | | | | | | | | | Bug: 78173836 Test: atest incidentd_test Change-Id: I1e1b9f63d0e863c733c51efef432235eb94cdbab
* / Fix incidentd skip collecting timedout of a section.Yi Jin2018-04-161-11/+14
|/ | | | | | | | | By moving the section stats collection before any return statements, it won't missing stats collection. Bug: 77962855 Test: atest incidentd_test Change-Id: I0900556428c51636e24df48a407eb916ccff795c
* Use modern c++ code style for incidentd.Yi Jin2018-03-301-4/+11
| | | | | | | | This cl does not contain code logic changes. Bug: 77333635 Test: manual and incidentd_test Change-Id: Iea0a402b1051defd45159ca267e6dd705f9ffa49
* Merge "Use unique_fd with the clear ownership." into pi-devYi Jin2018-03-301-8/+9
|\
| * Use unique_fd with the clear ownership.Yi Jin2018-03-281-8/+9
| | | | | | | | | | | | | | | | | | FdBuffer won't take ownership of the `main` fd. It only enforces transfer ownership in readProcessedDataInStream. Bug: 74021345 Test: atest incidentd_test Change-Id: I6182730241c81c34b3be865b827a2d3e8c10c21c
* | Enable Last Kmsg, also fix the GZipSection test.Yi Jin2018-03-291-2/+4
|/ | | | | | Bug: 73354384, 76208934 Test: atest incidentd_test and manual as well Change-Id: I074027f4d972686ae3e9415b50e4d3967f6a2355
* Merge "Found out it is not possible to exec procrank as non-root/shell. But ↵TreeHugger Robot2018-03-281-59/+19
|\ | | | | | | it is ok to disable procrank since the information can be obtain via dumpsys meminfo" into pi-dev
| * Found out it is not possible to exec procrank as non-root/shell.Yi Jin2018-03-271-59/+19
| | | | | | | | | | | | | | | | | | | | | | But it is ok to disable procrank since the information can be obtain via dumpsys meminfo Optimize the code style a bit. Bug: 72510307 Test: atest incidentd_test Change-Id: If06201aa708461b569d9fb007f20d1e51342d5c2
* | Fix apct test.Yi Jin2018-03-231-3/+3
|/ | | | | | Bug: 76208934 Test: atest incidentd_test Change-Id: Ibc101aa3c523398b1e9dd6cff3d6735b4d704667
* Fix the test failure of LogSection, don't consider read log msg error asYi Jin2018-03-161-7/+7
| | | | | | | | | | a failure since it is used to signal EOF. Additionally tag this message as auto so user_id won't become explicit. Bug: 75017304 Test: atest incidentd_test Change-Id: I151bab5a72a532e7c9f54ae0686561001730bdeb
* Wrap fd with unique_fd so it won't leak.Yi Jin2018-03-141-51/+30
| | | | | | Bug: 74021345 Test: manual and atest incidentd_test Change-Id: Ib1000bfe6917c3d5cae7b9edce5b67d50897e10d
* Optimize incidentd memory usageYi Jin2018-03-071-10/+35
| | | | | | | | | 1. Remove dependency of libprotobuf-cpp-lite, saves .so mmap ~200KB 2. Don't use auto except iterator for readability. Bug: 74254200 Test: adb shell dumpsys meminfo `pid incidentd` Change-Id: If6198521c3b80929d6ea3f7ed466b5195991ccfd
* Dumping stack traces to proto.Kweku Adams2018-03-071-5/+145
| | | | | | | Bug: 72177715 Test: flash device and check incident.proto output Change-Id: Id2a15e0fc62b66efe875949af97f0eb651c7e322 (cherry picked from commit 5c804e2b9893c7892900148229cf19fa6268e7dc)
* Use uint64_t instead of long long as API type for consistent reason.Yi Jin2018-03-051-3/+3
| | | | | | Bug: 74118023 Test: manual Change-Id: Icd5f506c76d3a008a79cb6c9d2061962ca7fdd40
* Implement a new section to attach LAST_KMSG to incident reportYi Jin2018-02-271-58/+108
| | | | | | | | | | | This section simply gzip a large file and stores result in GZippedFileProto This greatly improves the size, before gzip, the last kmsg size ~500KB, after gzip the proto size is ~60KB. Bug: 73354384 Test: atest incidentd_test and manual on device test Change-Id: I9bfc2cf07384487671edbffb5f0bd8495608fea6
* Throttler for incidentd based on size putting into dropbox.Yi Jin2018-02-201-1/+3
| | | | | | | | | | The incidentd will accumulate the total size put into dropbox and once it exceeds a threshold (currently 20MB) daily, it will stop further requests. It allows collection again 24 hours later. Bug: 64219725 Test: atest incidentd_test and manually flashed incidentd and test. Change-Id: Iea21fbae40d5d01108797b190231d73e74eff213