summaryrefslogtreecommitdiff
path: root/cmds/incidentd/src/FdBuffer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Optimize memory usage in incidentdMike Ma2020-03-231-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Increase the size limit of incident reports.Yao Chen2019-05-231-1/+1
| | | | | | Bug: 133425862 Test: incidentd_test Change-Id: I323878958a93e0280b782de1745ed59e44f79b0b
* Raise the max section size of an incident report to 24 mbJoe Onorato2019-03-281-1/+1
| | | | | | Test: bit GtsIncidentManagerTestCases:* Bug: 123543706 Change-Id: If46fb3c3972b0367e57e6dcb49edd9e3fe834a98
* incidentd can now handle multiple callers asking it for incident reportsJoe Onorato2019-03-261-17/+39
| | | | | | Test: bit incident_test:* GtsIncidentManagerTestCases:* Bug: 123543706 Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
* Remove deprecated cutils/log.hMike Ma2018-12-061-1/+1
| | | | | Test: build Change-Id: I6f9b400173618bdf31ddbd8eacedea62669dfa27
* Refine incidentd error handling and loggingMike Ma2018-12-051-5/+16
| | | | | | | | | | | 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
* Retry when IO operations fail with EINTR, make incidentd more robust.Yi Jin2018-04-201-6/+8
| | | | | | Bug: 77333635 Test: atest incidentd_test Change-Id: I44929654b534aba9fcce7066a61c5c6e43644a50
* Remove some letters of verbose logYi Jin2018-04-021-2/+2
| | | | | | Bug: 77333635 Test: N/A Change-Id: I94b288d070dfb372edf345d369d75bb3255f631b
* Use modern c++ code style for incidentd.Yi Jin2018-03-301-1/+9
| | | | | | | | This cl does not contain code logic changes. Bug: 77333635 Test: manual and incidentd_test Change-Id: Iea0a402b1051defd45159ca267e6dd705f9ffa49
* Use unique_fd with the clear ownership.Yi Jin2018-03-281-31/+31
| | | | | | | | | 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
* Wrap fd with unique_fd so it won't leak.Yi Jin2018-03-141-32/+32
| | | | | | Bug: 74021345 Test: manual and atest incidentd_test Change-Id: Ib1000bfe6917c3d5cae7b9edce5b67d50897e10d
* Dumping stack traces to proto.Kweku Adams2018-03-071-0/+29
| | | | | | | Bug: 72177715 Test: flash device and check incident.proto output Change-Id: Id2a15e0fc62b66efe875949af97f0eb651c7e322 (cherry picked from commit 5c804e2b9893c7892900148229cf19fa6268e7dc)
* Implement a new section to attach LAST_KMSG to incident reportYi Jin2018-02-271-4/+7
| | | | | | | | | | | 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-0/+1
| | | | | | | | | | 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
* This cl formats incidentd and makes it easier for debugging.Yi Jin2018-02-151-54/+30
| | | | | | Bug: 72755317 Test: clang-format -type=file -i <files> Change-Id: Ide91227f26c6b1db6d2e5fe8117ca5cc4cf77fd3
* Fix permissions problems of incidentd.Yi Jin2018-01-171-0/+4
| | | | | Test: manual Change-Id: I4ee0d1f2349ee1a25a422cabf1b5b87c612710d2
* Implement Cpu Freq SectionYi Jin2017-11-141-1/+14
| | | | | | | | | When poll from sysfs, revents return POLLERR by default, handles this edge case in this cl. Bug: 68774444 Test: unit tested + on device tests Change-Id: I23540299c026d3e7676497f56690e9f8646a47bd
* Implement c++ native lib for streaming proto, part 1Yi Jin2017-09-271-135/+17
| | | | | | | | | | | | Extract protobuf class out and creates EncodedBuffer class which holds protobuf data. Next step is to create a ProtoOutputStream and let incident helper adapt the change as well. please see frameworks/base/core/java/android/util/proto Bug: 65641021 Test: unit tested Change-Id: I0dd343b2e62d60f091c8f857fae3452ec8da6b96
* Implement Pii Stripper Part 3Yi Jin2017-09-071-0/+59
| | | | | | | | | | The incident request args sets privacy spec. Strip action is optimized to run once for each type of spec and ready for flush multiple times. Incident command is updated to take -p option to specify privacy spec. Bug: 64687253 Test: unit tests written, manually run incident command to test as well Change-Id: I6753df117f76dc1a5f4d2152baa3fbbf56b490e4
* Implement PII Stripper, part 2Yi Jin2017-09-071-9/+11
| | | | | | | | | | | | | | | | | | Implement EncodedBuffer that strip pii based on given privacy request. The reason to implement another buffer is the length-delimited field's size could change when its submessage gets stripped. It also intends to keep the orignal data around for other requests to consume it. In addition, the section implementation has adapted EncodedBuffer so write out to each request's fd could be request-specific. The next step is allow requests to set its privacy spec. Notice the current design set the privacy spec of dropbox to AUTOMATIC, this behavior might change in the future. Bug: 64687253 Test: unit tests are writtern, see README.md for how to run unit tests. Change-Id: I7ac236b8265ba9289dc6e17a8a5bf7f67ffb6bf5
* Implement PII stripper in incidentd, part 1Yi Jin2017-08-231-1/+28
| | | | | | | | | 1. automatically parse privacy options and generate lookup table 2. create FdBuffer iterator API in order to remove dependency on Reporter.h Bug: 64687253 Test: Unit test for iterator API, and manually tested lookup table Change-Id: I1ea376a4481fc4afc7bdf447936f767b63690fd3
* This cl does the following things:Yi Jin2017-07-241-2/+131
| | | | | | | | | | | | | | | | 0) Implements a skeleton of incident_helper 1) Implements FileSection class which calls incident_helper to parse file content to protobuf 2) Adds Kernel Wake Sources to incident.proto and makes it parsed by FileSection 3) Adds basic gtests to test FdBuffer, io_utils, FileSection implementation Bug: 62923266 Bug: 62926061 Test: manual - push incidentd, incident_helper and incident to my device and verify kernel wakeup sources file is able to be parsed. Change-Id: I2aa6b6158d962ce70e6fa6c8a9c42213a45ff41c
* First checkin of incident reporting.Joe Onorato2016-12-151-0/+129
There are a few major pieces here: incidentd --------- This daemon (started by init) runs and accepts incoming requests to take incident reports. When prompted, it calls into various system services and fills in an IncidentProto data structure, and then writes the report into dropbox. The next steps for incidentd: - Security review of SELinux policies. These will be a subset of the dumpstate permissions. Until this is done, incidentd is not started at boot time. incident -------- This shell command calls into incidentd, and can initiate an incident report and either capture the output or leave for dropbox. incident_report --------------- This host side tool can call adb shell with the correct parameters and also format the incident report as text. This formatting code was left of the device on purpose. Right now it's pretty small, but as the number of fields increases, the metadata and code to do the formatting will start to grow. The incident_report command also contains a workaround to let it work before incidentd is turned on by default. Right now, it is implemented to call adb shell dumpsys <service> --proto directly, whereas in the future it will go through the full incidentd flow. incident_section_gen -------------------- A build-time tool that generates a stripped down set of information about the fields that are available. libincident ----------- This library contains the code to connect to incidentd, and the meta proto definitions that are used by the framework protos. The basics are here now, but they are not fully fleshed out yet. The privacy.proto file contains annotations that can go in the proto file that we will later use to filter which fields are uploaded, and which are used by local sources. For example, a device in a test lab is safe to upload much much more information than a real user. These will share the same mechanism, but the user's output will be filtered according to these annotations. frameworks/core/proto --------------------- These .proto files contain the definitions of the system's output. There is one master android.os.IncidentProto file that is the top level of an incident report, but some other services (notification, fingerprint, batterystats, etc) will have others that are used directly by the logging mechanism. Other files which are shared by several of the services also go here, such as ComponentName, Locale, Configuration, etc. There will be many more. There is also a first iplementation of a dump method handling --proto in the fingerprint service. IncidentManager --------------- The java API to trigger an incident report. Test: Not written yet Change-Id: I59568b115ac7fcf73af70c946c95752bf33ae67f