platform_frameworks_native/cmds/dumpstate
Tom Cherry f4472f3aec dumpstate: calculate logcat timeout using readable buffer size
Calculate logcat timeout using readable buffer size instead of the
allotted buffer size for three reasons:

1) With log buffer compression, the readable buffer size may be much
larger than the consumed buffer size, so the timeout should be based
on the former.

2) __android_logger_get_buffer_size() reports the wrong value if
`logcat -G` is used to set the log buffer size, since that directly
informs logd of the new size, without writing to the properties.

3) Given 2), __android_logger_get_buffer_size() is an implementation
detail for logd and should not be generally used.  The
android_logger_get_log_*_size() functions should be used instead.
Future CLs will remove __android_logger_get_buffer_size() from liblog.

Test: bug reports capture logcat correctly
Test: bug reports succeed if `logd` is stopped, after timing out when
      reading from logcat
Change-Id: Iac5dcba4f729c022073a812b48cd028ca2d59e52
2020-08-05 12:17:15 -07:00
..
binder/android/os Remove old dumpstate aidl methods 2019-08-06 17:42:42 +00:00
tests Update contents of a telephony bug report. 2020-02-09 19:56:27 -08:00
.clang-format Refactored run_command functions. 2016-09-14 13:17:41 -07:00
Android.bp dumpstate: Fix required dependencies 2020-06-04 17:12:34 +08:00
AndroidTest.xml Add test config to bugreportz, dumpstate_test_fixture and surfaceFlinger_test 2017-03-27 22:59:50 -07:00
bugreport-format.md Flip bugreport version to 2.0 2018-02-05 13:04:09 -08:00
dumpstate.cpp dumpstate: calculate logcat timeout using readable buffer size 2020-08-05 12:17:15 -07:00
dumpstate.h Do not read the EMMC ext_csd register from dumpstate 2019-08-16 10:01:45 -07:00
dumpstate.rc Add a flag that makes dumpstate wait for options 2019-01-22 21:03:25 +00:00
dumpstate_test.xml Fix dumpstate_test test config 2019-06-27 09:59:25 -07:00
DumpstateInternal.cpp Hold a wake lock when taking bug report 2019-07-19 14:52:39 +01:00
DumpstateInternal.h Fix minor time bug in ConsentCallback::getElapsedTimeMs 2020-01-27 23:14:17 +00:00
DumpstateService.cpp unique_fd is passed by value in AIDL interfaces 2019-12-18 05:32:42 +00:00
DumpstateService.h unique_fd is passed by value in AIDL interfaces 2019-12-18 05:32:42 +00:00
DumpstateUtil.cpp Remove unused function GetPidByName() 2019-06-26 15:12:51 +01:00
DumpstateUtil.h Remove unused function GetPidByName() 2019-06-26 15:12:51 +01:00
main.cpp Add a flag that makes dumpstate wait for options 2019-01-22 21:03:25 +00:00
OWNERS Added OWNERS to bugreport-related projects 2018-09-26 10:17:57 -07:00
README.md dumpstate: format readme 2019-02-15 10:11:20 +00:00
TEST_MAPPING Add dumpstate_test to presubmit 2019-07-17 10:58:59 +01:00

dumpstate development tips

To build dumpstate

Do a full build first:

m -j dumpstate

Then incremental ones:

mmm -j frameworks/native/cmds/dumpstate

If you're working on device-specific code, you might need to build them as well. Example:

mmm -j frameworks/native/cmds/dumpstate device/acme/secret_device/dumpstate/ hardware/interfaces/dumpstate

To build, deploy, and take a bugreport

mmm -j frameworks/native/cmds/dumpstate && adb push ${OUT}/system/bin/dumpstate system/bin && adb push ${OUT}/system/lib64/*dumpstate*.so /system/lib64/ && adb shell am bug-report

Make sure that the device is remounted before running the above command. * If you're working with userdebug variant, you may need to run the following to remount your device:

  adb root && adb remount -R && adb wait-for-device && adb root && adb remount
  • If you're working with eng variant, you may need to run the following to remount your device:

    adb root && adb remount
    

To build, deploy, and run unit tests

First create /data/nativetest64:

adb shell mkdir /data/nativetest64

Then run:

mmm -j frameworks/native/cmds/dumpstate/ && adb push ${OUT}/data/nativetest64/dumpstate_* /data/nativetest64 && adb shell /data/nativetest64/dumpstate_test/dumpstate_test

And to run just one test (for example, DumpstateTest.RunCommandNoArgs):

mmm -j frameworks/native/cmds/dumpstate/ && adb push ${OUT}/data/nativetest64/dumpstate_test* /data/nativetest64 && adb shell /data/nativetest64/dumpstate_test/dumpstate_test --gtest_filter=DumpstateTest.RunCommandNoArgs

To take quick bugreports

adb shell setprop dumpstate.dry_run true

To emulate a device with user build

adb shell setprop dumpstate.unroot true

To change the dumpstate version

adb shell setprop dumpstate.version VERSION_NAME

Example:

adb shell setprop dumpstate.version split-dumpsys && adb shell dumpstate -v

Then to restore the default version:

adb shell setprop dumpstate.version default

Code style and formatting

Use the style defined at the Google C++ Style Guide and make sure to run the following command prior to repo upload:

git clang-format --style=file HEAD~

Useful Bash tricks

export BR_DIR=/bugreports

alias br='adb shell cmd activity bug-report'
alias ls_bugs='adb shell ls -l ${BR_DIR}/'

unzip_bug() {
  adb pull ${BR_DIR}/$1 && emacs $1 && mv $1 /tmp
}

less_bug() {
  adb pull ${BR_DIR}/$1 && less $1 && mv $1 /tmp
}

rm_bugs() {
 if [ -z "${BR_DIR}" ] ; then echo "Variable BR_DIR not set"; else adb shell rm -rf ${BR_DIR}/*; fi
}