diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:32:55 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:32:55 -0800 |
| commit | dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0 (patch) | |
| tree | 2ba8d1a0846d69b18f623515e8d9b5d9fe38b590 /logcat | |
| parent | e54eebbf1a908d65ee8cf80bab62821c05666d70 (diff) | |
| download | system_core-dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0.tar.gz system_core-dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0.tar.bz2 system_core-dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0.zip | |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'logcat')
| -rw-r--r-- | logcat/Android.mk | 27 | ||||
| -rw-r--r-- | logcat/MODULE_LICENSE_APACHE2 | 0 | ||||
| -rw-r--r-- | logcat/NOTICE | 190 | ||||
| -rw-r--r-- | logcat/event-log-tags | 346 | ||||
| -rw-r--r-- | logcat/logcat.cpp | 568 |
5 files changed, 1131 insertions, 0 deletions
diff --git a/logcat/Android.mk b/logcat/Android.mk new file mode 100644 index 000000000..3ee051d71 --- /dev/null +++ b/logcat/Android.mk @@ -0,0 +1,27 @@ +# Copyright 2006 The Android Open Source Project + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= logcat.cpp + +LOCAL_SHARED_LIBRARIES := liblog + +LOCAL_MODULE:= logcat + +include $(BUILD_EXECUTABLE) + +######################## +include $(CLEAR_VARS) + +LOCAL_MODULE := event-log-tags + +#LOCAL_MODULE_TAGS := user development + +# This will install the file in /system/etc +# +LOCAL_MODULE_CLASS := ETC + +LOCAL_SRC_FILES := $(LOCAL_MODULE) + +include $(BUILD_PREBUILT) diff --git a/logcat/MODULE_LICENSE_APACHE2 b/logcat/MODULE_LICENSE_APACHE2 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/logcat/MODULE_LICENSE_APACHE2 diff --git a/logcat/NOTICE b/logcat/NOTICE new file mode 100644 index 000000000..c5b1efa7a --- /dev/null +++ b/logcat/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/logcat/event-log-tags b/logcat/event-log-tags new file mode 100644 index 000000000..28cad0a31 --- /dev/null +++ b/logcat/event-log-tags @@ -0,0 +1,346 @@ +# The entries in this file map a sparse set of log tag numbers to tag names. +# This is installed on the device, in /system/etc, and parsed by logcat. +# +# Tag numbers are decimal integers, from 0 to 2^31. (Let's leave the +# negative values alone for now.) +# +# Tag names are one or more ASCII letters and numbers or underscores, i.e. +# "[A-Z][a-z][0-9]_". Do not include spaces or punctuation (the former +# impacts log readability, the latter makes regex searches more annoying). +# +# Tag numbers and names are separated by whitespace. Blank lines and lines +# starting with '#' are ignored. +# +# Optionally, after the tag names can be put a description for the value(s) +# of the tag. Description are in the format +# (<name>|data type[|data unit]) +# Multiple values are separated by commas. +# +# The data type is a number from the following values: +# 1: int +# 2: long +# 3: string +# 4: list +# +# The data unit is a number taken from the following list: +# 1: Number of objects +# 2: Number of bytes +# 3: Number of milliseconds +# 4: Number of allocations +# 5: Id +# 6: Percent +# Default value for data of type int/long is 2 (bytes). +# +# TODO: generate ".java" and ".h" files with integer constants from this file. + +# These are used for testing, do not modify without updating +# tests/framework-tests/src/android/util/EventLogFunctionalTest.java. +42 answer (to life the universe etc|3) +314 pi +2718 e + +2719 configuration_changed (config mask|1|5) +2720 sync (id|3),(event|1|5),(source|1|5) +2721 cpu (total|1|6),(user|1|6),(system|1|6),(iowait|1|6),(irq|1|6),(softirq|1|6) +2722 battery_level (level|1|6),(voltage|1|1),(temperature|1|1) +2723 battery_status (status|1|5),(health|1|5),(present|1|5),(plugged|1|5),(technology|3) +# This is logged when the device is being forced to sleep (typically by +# the user pressing the power button). +2724 power_sleep_requested (wakeLocksCleared|1|1) +# This is logged when the screen on broadcast has completed +2725 power_screen_broadcast_send (wakelockCount|1|1) +# This is logged when the screen broadcast has completed +2726 power_screen_broadcast_done (on|1|5),(broadcastDuration|2|3),(wakelockCount|1|1) +# This is logged when the screen on broadcast has completed +2727 power_screen_broadcast_stop (which|1|5),(wakelockCount|1|1) +# This is logged when the screen is turned on or off. +2728 power_screen_state (offOrOn|1|5),(becauseOfUser|1|5),(totalTouchDownTime|2|3),(touchCycles|1|1) +# This is logged when the partial wake lock (keeping the device awake +# regardless of whether the screen is off) is acquired or released. +2729 power_partial_wake_state (releasedorAcquired|1|5),(tag|3) +# This is logged when battery goes from discharging to charging. +# It lets us count the total amount of time between charges and the discharge level +2730 battery_discharge (duration|2|3),(minLevel|1|6),(maxLevel|1|6) +# +# Leave IDs through 2739 for more power logs +# + +# This event is logged when the location service uploads location data. +2740 location_controller +# This event is logged when someone is deciding to force a garbage collection +2741 force_gc (reason|3) +# This event is logged on each tickle +2742 tickle (authority|3) +# What happens in a sync operation (bytes sent and received, and +# operation details) +2743 sync_details (authority|3),(send|1|2),(recv|1|2),(details|3) + +# The disk space free on the /data partition, in bytes +2744 free_storage_changed (data|2|2) +# Device low memory notification and disk space free on the /data partition, in bytes at that time +2745 low_storage (data|2|2) +# disk space free on the /data partition in bytes +2746 free_storage_left (data|2|2) + +# when a NotificationManager.notify is called +2750 notification_enqueue (pkg|3),(id|1|5),(notification|3) +# when someone tries to cancel a notification, the notification manager sometimes +# calls this with flags too +2751 notification_cancel (pkg|3),(id|1|5),(required_flags|1) +# when someone tries to cancel all of the notifications for a particular package +2752 notification_cancel_all (pkg|3),(required_flags|1) + +# This event is logged when GTalkService encounters important events +2800 gtalkservice (eventType|1) +# This event is logged for GTalk connection state changes. The status field is an int, but +# it really contains 4 separate values, each taking up a byte +# (eventType, connection state, connection error, network state) +2801 gtalk_connection (status|1) + +2802 watchdog (Service|3) +2803 watchdog_proc_pss (Process|3),(Pid|1|5),(Pss|1|2) +2804 watchdog_soft_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2),(Skip|3) +2805 watchdog_hard_reset (Process|3),(Pid|1|5),(MaxPss|1|2),(Pss|1|2) +2806 watchdog_pss_stats (EmptyPss|1|2),(EmptyCount|1|1),(BackgroundPss|1|2),(BackgroundCount|1|1),(ServicePss|1|2),(ServiceCount|1|1),(VisiblePss|1|2),(VisibleCount|1|1),(ForegroundPss|1|2),(ForegroundCount|1|1),(NoPssCount|1|1) +2807 watchdog_proc_stats (DeathsInOne|1|1),(DeathsInTwo|1|1),(DeathsInThree|1|1),(DeathsInFour|1|1),(DeathsInFive|1|1) +2808 watchdog_scheduled_reboot (Now|2|1),(Interval|1|3),(StartTime|1|3),(Window|1|3),(Skip|3) +2809 watchdog_meminfo (MemFree|1|2),(Buffers|1|2),(Cached|1|2),(Active|1|2),(Inactive|1|2),(AnonPages|1|2),(Mapped|1|2),(Slab|1|2),(SReclaimable|1|2),(SUnreclaim|1|2),(PageTables|1|2) +2810 watchdog_vmstat (runtime|2|3),(pgfree|1|1),(pgactivate|1|1),(pgdeactivate|1|1),(pgfault|1|1),(pgmajfault|1|1) +2811 watchdog_requested_reboot (NoWait|1|1),(ScheduleInterval|1|3),(RecheckInterval|1|3),(StartTime|1|3),(Window|1|3),(MinScreenOff|1|3),(MinNextAlarm|1|3) + +# Device boot timings. We include monotonic clock values because the +# intrinsic event log times are wall-clock. +# +# Runtime starts: +3000 boot_progress_start (time|2|3) +# SystemServer.run() starts: +3010 boot_progress_system_run (time|2|3) +# ZygoteInit class preloading starts: +3020 boot_progress_preload_start (time|2|3) +# ZygoteInit class preloading ends: +3030 boot_progress_preload_end (time|2|3) +# ActivityManagerService.systemReady() starts: +3040 boot_progress_ams_ready (time|2|3) +# ActivityManagerService calls enableScreenAfterBoot(): +3050 boot_progress_enable_screen (time|2|3) +# Package Manager starts: +3060 boot_progress_pms_start (time|2|3) +# Package Manager .apk scan starts: +3070 boot_progress_pms_system_scan_start (time|2|3) +# Package Manager .apk scan starts: +3080 boot_progress_pms_data_scan_start (time|2|3) +# Package Manager .apk scan ends: +3090 boot_progress_pms_scan_end (time|2|3) +# Package Manager ready: +3100 boot_progress_pms_ready (time|2|3) +# + check activity_launch_time for Home app + +# Do not change these names without updating the checkin_events setting in +# google3/googledata/wireless/android/provisioning/gservices.config !! +# +# An activity is being finished: +30001 am_finish_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) +# A task is being brought to the front of the screen: +30002 am_task_to_front (Task|1|5) +# An existing activity is being given a new intent: +30003 am_new_intent (Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) +# A new task is being created: +30004 am_create_task (Task ID|1|5) +# A new activity is being created in an existing task: +30005 am_create_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) +# An activity has been resumed into the foreground but was not already running: +30006 am_restart_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +# An activity has been resumed and is now in the foreground: +30007 am_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +# Application Not Responding +30008 anr (pid|1|5),(Package Name|3),(reason|3) +# Activity launch time +30009 activity_launch_time (Token|1|5),(Component Name|3),(time|2|3) +# Application process bound to work +30010 am_proc_bound (PID|1|5),(Process Name|3) +# Application process died +30011 am_proc_died (PID|1|5),(Process Name|3) +# The Activity Manager failed to pause the given activity. +30012 am_failed_to_pause (Token|1|5),(Wanting to pause|3),(Currently pausing|3) +# Attempting to pause the current activity +30013 am_pause_activity (Token|1|5),(Component Name|3) +# Application process has been started +30014 am_proc_start (PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) +# An application process has been marked as bad +30015 am_proc_bad (UID|1|5),(Process Name|3) +# An application process that was bad is now marked as good +30016 am_proc_good (UID|1|5),(Process Name|3) +# Reporting to applications that memory is low +30017 am_low_memory (Num Processes|1|1) +# An activity is being destroyed: +30018 am_destroy_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +# An activity has been relaunched, resumed, and is now in the foreground: +30019 am_relaunch_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +# An activity has been relaunched: +30020 am_relaunch_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +# The activity's onPause has been called. +30021 am_on_paused_called (Component Name|3) +# The activity's onResume has been called. +30022 am_on_resume_called (Component Name|3) +# Kill a process to reclaim memory. +30023 am_kill_for_memory (PID|1|5),(Process Name|3),(OomAdj|1|5) +# Discard an undelivered serialized broadcast (timeout/ANR/crash) +30024 am_broadcast_discard_filter (Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5) +30025 am_broadcast_discard_app (Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3) +# A service is being created +30030 am_create_service (Service Record|1|5),(Name|3),(Intent|3),(PID|1|5) +# A service is being destroyed +30031 am_destroy_service (Service Record|1|5),(Name|3),(PID|1|5) +# A process has crashed too many times, it is being cleared +30032 am_process_crashed_too_much (Name|3),(PID|1|5) +# An unknown process is trying to attach to the activity manager +30033 am_drop_process (PID|1|5) +# A service has crashed too many times, it is being stopped +30034 am_service_crashed_too_much (Crash Count|1|1),(Component Name|3),(PID|1|5) +# A service is going to be restarted after its process went away +30035 am_schedule_service_restart (Component Name|3),(Time|2|3) +# A client was waiting for a content provider, but its process was lost +30036 am_provider_lost_process (Package Name|3),(UID|1|5),(Name|3) + +# Out of memory for surfaces. +31000 wm_no_surface_memory (Window|3),(PID|1|5),(Operation|3) + +# Re-connecting to input method service because we haven't received its interface +32000 imf_force_reconnect_ime (IME|4),(Time Since Connect|2|3),(Showing|1|1) + +# dvm_gc_info: LIST (LONG, LONG, LONG) +# +# First LONG: +# +# [63] 1 +# [62-24] ASCII process identifier +# [23-12] GC time in ms +# [11- 0] Bytes freed +# +# Second LONG (aggregated heap info): +# +# [63-62] 10 +# [61-60] Reserved; must be zero +# [59-48] Objects freed +# [47-36] Actual size (current footprint) +# [35-24] Allowed size (current hard max) +# [23-12] Objects allocated +# [11- 0] Bytes allocated +# +# Third LONG (zygote heap info): +# +# [63-62] 11 +# [61-60] Reserved; must be zero +# [59-48] Soft limit +# [47-36] Actual size (current footprint) +# [35-24] Allowed size (current hard max) +# [23-12] Objects allocated +# [11- 0] Bytes allocated +# +# Fourth LONG: +# +# [63-48] Reserved; must be zero +# [47-36] dlmallocFootprint +# [35-24] mallinfo: total allocated space +# [23-12] External byte limit +# [11- 0] External bytes allocated +# +# See HeapDebug.c +# +20001 dvm_gc_info (custom|2),(custom|2),(custom|2),(custom|2) +20002 dvm_gc_madvise_info (total|1|2),(zygote|1|2) + +75000 sqlite_mem_alarm_current (current|1|2) +75001 sqlite_mem_alarm_max (max|1|2) +75002 sqlite_mem_alarm_alloc_attempt (attempts|1|4) +75003 sqlite_mem_released (Memory released|1|2) + +40000 checkin (Check in time|2|3) + +50000 menu_item_selected (Menu type where 0 is options and 1 is context|1|5),(Menu item title|3) +50001 menu_opened (Menu type where 0 is options and 1 is context|1|5) +# Connectivity state changed: +# [31-13] Reserved for future use +# [12- 9] Network subtype (for mobile network, as defined by TelephonyManager) +# [ 8- 3] Detailed state ordinal (as defined by NetworkInfo.DetailedState) +# [ 2- 0] Network type (as defined by ConnectivityManager) +50020 connectivity_state_changed (custom|1|5) + +# Wi-Fi network state changed: +# [31- 6] Reserved for future use +# [ 5- 0] Detailed state ordinal (as defined by NetworkInfo.DetailedState) +50021 wifi_network_state_changed (network_state|1|5) + +# Wi-Fi supplicant state changed: +# [31- 6] Reserved for future use +# [ 5- 0] Supplicant state ordinal (as defined by SupplicantState) +50022 wifi_supplicant_state_changed (supplicant_state|1|5) + +# Wi-Fi driver state changed: +# [31- 1] Reserved for future use +# [ 0- 0] Driver start (1) or stopped (0) +50023 wifi_driver_state_changed (driver_state|1|5) + +# Wi-Fi interface configuration state changed: +# [31- 1] Reserved for future use +# [ 0- 0] Interface configuration succeeded (1) or failed (0) +50024 wifi_interface_configuration_state_changed (IP_configuration|1|5) + +# Wi-Fi supplicant connection state changed: +# [31- 2] Reserved for future use +# [ 1- 0] Connected to supplicant (1) or disconnected from supplicant (0), +# or supplicant died (2) +50025 wifi_supplicant_connection_state_changed (connected|1|5) + +# PDP Context has a bad DNS address +50100 pdp_bad_dns_address (dns_address|3) + +# For data connection on PDP context, reached the data-out-without-data-in +# packet count that triggers a countdown to radio restart +50101 pdp_radio_reset_countdown_triggered (out_packet_count|1|1) + +# Radio restart - timed out with no incoming packets. +50102 pdp_radio_reset (out_packet_count|1|1) + +# PDP context reset - timed out with no incoming packets. +50103 pdp_context_reset (out_packet_count|1|1) + +# Reregister to data network - timed out with no incoming packets. +50104 pdp_reregister_network (out_packet_count|1|1) + +# PDP Setup failures +50105 pdp_setup_fail (cause|1|5), (cid|1|5), (network_type|1|5) + +# Call drops +50106 call_drop (cause|1|5), (cid|1|5), (network_type|1|5) + +# Data network registration failed after successful voice registration +50107 data_network_registration_fail (op_numeric|1|5), (cid|1|5) + +# Suspicious status of data connection while radio poweroff +50108 data_network_status_on_radio_off (dc_state|3), (enable|1|5) + +# PDP drop caused by network +50109 pdp_network_drop (cid|1|5), (network_type|1|5) + +# Do not change these names without updating tag in: +#//device/dalvik/libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.c +51000 socket_stats (send|1|2),(recv|1|2),(ip|1|5),(port|1|5),(close|1|5) + +# db stats. 0 is query, 1 is write (may become more fine grained in the +# future) +52000 db_operation (name|3),(op_type|1|5),(time|2|3) + +# http request/response stats +52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2) +60000 viewroot_draw (Draw time|1|3) +60001 viewroot_layout (Layout time|1|3) +60002 view_build_drawing_cache (View created drawing cache|1|5) +60003 view_use_drawing_cache (View drawn using bitmap cache|1|5) + +# 0 for screen off, 1 for screen on, 2 for key-guard done +70000 screen_toggled (screen_state|1|5) + +# browser stats for diary study +70101 browser_zoom_level_change (start level|1|5),(end level|1|5),(time|2|3) +70102 browser_double_tap_duration (duration|1|3),(time|2|3) diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp new file mode 100644 index 000000000..3130a1cce --- /dev/null +++ b/logcat/logcat.cpp @@ -0,0 +1,568 @@ +// Copyright 2006 The Android Open Source Project + +#include <cutils/logger.h> +#include <cutils/logd.h> +#include <cutils/sockets.h> +#include <cutils/logprint.h> +#include <cutils/event_tag_map.h> + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <time.h> +#include <errno.h> +#include <assert.h> +#include <ctype.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <arpa/inet.h> + +#define DEFAULT_LOG_ROTATE_SIZE_KBYTES 16 +#define DEFAULT_MAX_ROTATED_LOGS 4 + +static AndroidLogFormat * g_logformat; + +/* logd prefixes records with a length field */ +#define RECORD_LENGTH_FIELD_SIZE_BYTES sizeof(uint32_t) + +#define LOG_FILE_DIR "/dev/log/" + + +namespace android { + +/* Global Variables */ + +static const char * g_outputFileName = NULL; +static int g_logRotateSizeKBytes = 0; // 0 means "no log rotation" +static int g_maxRotatedLogs = DEFAULT_MAX_ROTATED_LOGS; // 0 means "unbounded" +static int g_outFD = -1; +static off_t g_outByteCount = 0; +static int g_isBinary = 0; +static int g_printBinary = 0; + +static EventTagMap* g_eventTagMap = NULL; + +static int openLogFile (const char *pathname) +{ + return open(g_outputFileName, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR); +} + +static void rotateLogs() +{ + int err; + + // Can't rotate logs if we're not outputting to a file + if (g_outputFileName == NULL) { + return; + } + + close(g_outFD); + + for (int i = g_maxRotatedLogs ; i > 0 ; i--) { + char *file0, *file1; + + asprintf(&file1, "%s.%d", g_outputFileName, i); + + if (i - 1 == 0) { + asprintf(&file0, "%s", g_outputFileName); + } else { + asprintf(&file0, "%s.%d", g_outputFileName, i - 1); + } + + err = rename (file0, file1); + + if (err < 0 && errno != ENOENT) { + perror("while rotating log files"); + } + + free(file1); + free(file0); + } + + g_outFD = openLogFile (g_outputFileName); + + if (g_outFD < 0) { + perror ("couldn't open output file"); + exit(-1); + } + + g_outByteCount = 0; + +} + +void printBinary(struct logger_entry *buf) +{ + size_t size = sizeof(logger_entry) + buf->len; + int ret; + + do { + ret = write(g_outFD, buf, size); + } while (ret < 0 && errno == EINTR); +} + +static void processBuffer(struct logger_entry *buf) +{ + int bytesWritten; + int err; + AndroidLogEntry entry; + char binaryMsgBuf[1024]; + + if (g_isBinary) { + err = android_log_processBinaryLogBuffer(buf, &entry, g_eventTagMap, + binaryMsgBuf, sizeof(binaryMsgBuf)); + //printf(">>> pri=%d len=%d msg='%s'\n", + // entry.priority, entry.messageLen, entry.message); + } else { + err = android_log_processLogBuffer(buf, &entry); + } + if (err < 0) + goto error; + + bytesWritten = android_log_filterAndPrintLogLine( + g_logformat, g_outFD, &entry); + + if (bytesWritten < 0) { + perror("output error"); + exit(-1); + } + + g_outByteCount += bytesWritten; + + if (g_logRotateSizeKBytes > 0 + && (g_outByteCount / 1024) >= g_logRotateSizeKBytes + ) { + rotateLogs(); + } + +error: + //fprintf (stderr, "Error processing record\n"); + return; +} + +static void readLogLines(int logfd) +{ + while (1) { + unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1] __attribute__((aligned(4))); + struct logger_entry *entry = (struct logger_entry *) buf; + int ret; + + ret = read(logfd, entry, LOGGER_ENTRY_MAX_LEN); + if (ret < 0) { + if (errno == EINTR) + continue; + if (errno == EAGAIN) + break; + perror("logcat read"); + exit(EXIT_FAILURE); + } + else if (!ret) { + fprintf(stderr, "read: Unexpected EOF!\n"); + exit(EXIT_FAILURE); + } + + /* NOTE: driver guarantees we read exactly one full entry */ + + entry->msg[entry->len] = '\0'; + + if (g_printBinary) { + printBinary(entry); + } else { + (void) processBuffer(entry); + } + } +} + +static int clearLog(int logfd) +{ + return ioctl(logfd, LOGGER_FLUSH_LOG); +} + +/* returns the total size of the log's ring buffer */ +static int getLogSize(int logfd) +{ + return ioctl(logfd, LOGGER_GET_LOG_BUF_SIZE); +} + +/* returns the readable size of the log's ring buffer (that is, amount of the log consumed) */ +static int getLogReadableSize(int logfd) +{ + return ioctl(logfd, LOGGER_GET_LOG_LEN); +} + +static void setupOutput() +{ + + if (g_outputFileName == NULL) { + g_outFD = STDOUT_FILENO; + + } else { + struct stat statbuf; + + g_outFD = openLogFile (g_outputFileName); + + if (g_outFD < 0) { + perror ("couldn't open output file"); + exit(-1); + } + + fstat(g_outFD, &statbuf); + + g_outByteCount = statbuf.st_size; + } +} + +static void show_help(const char *cmd) +{ + fprintf(stderr,"Usage: %s [options] [filterspecs]\n", cmd); + + fprintf(stderr, "options include:\n" + " -s Set default filter to silent.\n" + " Like specifying filterspec '*:s'\n" + " -f <filename> Log to file. Default to stdout\n" + " -r [<kbytes>] Rotate log every kbytes. (16 if unspecified). Requires -f\n" + " -n <count> Sets max number of rotated logs to <count>, default 4\n" + " -v <format> Sets the log print format, where <format> is one of:\n\n" + " brief process tag thread raw time threadtime long\n\n" + " -c clear (flush) the entire log and exit\n" + " -d dump the log and then exit (don't block)\n" + " -g get the size of the log's ring buffer and exit\n" + " -b <buffer> request alternate ring buffer\n" + " ('main' (default), 'radio', 'events')\n" + " -B output the log in binary"); + + + fprintf(stderr,"\nfilterspecs are a series of \n" + " <tag>[:priority]\n\n" + "where <tag> is a log component tag (or * for all) and priority is:\n" + " V Verbose\n" + " D Debug\n" + " I Info\n" + " W Warn\n" + " E Error\n" + " F Fatal\n" + " S Silent (supress all output)\n" + "\n'*' means '*:d' and <tag> by itself means <tag>:v\n" + "\nIf not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.\n" + "If no filterspec is found, filter defaults to '*:I'\n" + "\nIf not specified with -v, format is set from ANDROID_PRINTF_LOG\n" + "or defaults to \"brief\"\n\n"); + + + +} + + +} /* namespace android */ + +static int setLogFormat(const char * formatString) +{ + static AndroidLogPrintFormat format; + + format = android_log_formatFromString(formatString); + + if (format == FORMAT_OFF) { + // FORMAT_OFF means invalid string + return -1; + } + + android_log_setPrintFormat(g_logformat, format); + + return 0; +} + +extern "C" void logprint_run_tests(void); + +int main (int argc, char **argv) +{ + int logfd; + int err; + int hasSetLogFormat = 0; + int clearLog = 0; + int getLogSize = 0; + int mode = O_RDONLY; + char *log_device = strdup("/dev/"LOGGER_LOG_MAIN); + const char *forceFilters = NULL; + + g_logformat = android_log_format_new(); + + if (argc == 2 && 0 == strcmp(argv[1], "--test")) { + logprint_run_tests(); + exit(0); + } + + if (argc == 2 && 0 == strcmp(argv[1], "--help")) { + android::show_help(argv[0]); + exit(0); + } + + for (;;) { + int ret; + + ret = getopt(argc, argv, "cdgsQf:r::n:v:b:B"); + + if (ret < 0) { + break; + } + + switch(ret) { + case 's': + // default to all silent + android_log_addFilterRule(g_logformat, "*:s"); + break; + + case 'c': + clearLog = 1; + mode = O_WRONLY; + break; + + case 'd': + mode |= O_NONBLOCK; + break; + + case 'g': + getLogSize = 1; + break; + + case 'b': + free(log_device); + log_device = + (char*) malloc(strlen(LOG_FILE_DIR) + strlen(optarg) + 1); + strcpy(log_device, LOG_FILE_DIR); + strcat(log_device, optarg); + + android::g_isBinary = (strcmp(optarg, "events") == 0); + break; + + case 'B': + android::g_printBinary = 1; + break; + + case 'f': + // redirect output to a file + + android::g_outputFileName = optarg; + + break; + + case 'r': + if (optarg == NULL) { + android::g_logRotateSizeKBytes + = DEFAULT_LOG_ROTATE_SIZE_KBYTES; + } else { + long logRotateSize; + char *lastDigit; + + if (!isdigit(optarg[0])) { + fprintf(stderr,"Invalid parameter to -r\n"); + android::show_help(argv[0]); + exit(-1); + } + android::g_logRotateSizeKBytes = atoi(optarg); + } + break; + + case 'n': + if (!isdigit(optarg[0])) { + fprintf(stderr,"Invalid parameter to -r\n"); + android::show_help(argv[0]); + exit(-1); + } + + android::g_maxRotatedLogs = atoi(optarg); + break; + + case 'v': + err = setLogFormat (optarg); + if (err < 0) { + fprintf(stderr,"Invalid parameter to -v\n"); + android::show_help(argv[0]); + exit(-1); + } + + hasSetLogFormat = 1; + break; + + case 'Q': + /* this is a *hidden* option used to start a version of logcat */ + /* in an emulated device only. it basically looks for androidboot.logcat= */ + /* on the kernel command line. If something is found, it extracts a log filter */ + /* and uses it to run the program. If nothing is found, the program should */ + /* quit immediately */ +#define KERNEL_OPTION "androidboot.logcat=" +#define CONSOLE_OPTION "androidboot.console=" + { + int fd; + char* logcat; + char* console; + int force_exit = 1; + static char cmdline[1024]; + + fd = open("/proc/cmdline", O_RDONLY); + if (fd >= 0) { + int n = read(fd, cmdline, sizeof(cmdline)-1 ); + if (n < 0) n = 0; + cmdline[n] = 0; + close(fd); + } else { + cmdline[0] = 0; + } + + logcat = strstr( cmdline, KERNEL_OPTION ); + console = strstr( cmdline, CONSOLE_OPTION ); + if (logcat != NULL) { + char* p = logcat + sizeof(KERNEL_OPTION)-1;; + char* q = strpbrk( p, " \t\n\r" );; + + if (q != NULL) + *q = 0; + + forceFilters = p; + force_exit = 0; + } + /* if nothing found or invalid filters, exit quietly */ + if (force_exit) + exit(0); + + /* redirect our output to the emulator console */ + if (console) { + char* p = console + sizeof(CONSOLE_OPTION)-1; + char* q = strpbrk( p, " \t\n\r" ); + char devname[64]; + int len; + + if (q != NULL) { + len = q - p; + } else + len = strlen(p); + + len = snprintf( devname, sizeof(devname), "/dev/%.*s", len, p ); + fprintf(stderr, "logcat using %s (%d)\n", devname, len); + if (len < (int)sizeof(devname)) { + fd = open( devname, O_WRONLY ); + if (fd >= 0) { + dup2(fd, 1); + dup2(fd, 2); + close(fd); + } + } + } + } + break; + + default: + fprintf(stderr,"Unrecognized Option\n"); + android::show_help(argv[0]); + exit(-1); + break; + } + } + + if (android::g_logRotateSizeKBytes != 0 + && android::g_outputFileName == NULL + ) { + fprintf(stderr,"-r requires -f as well\n"); + android::show_help(argv[0]); + exit(-1); + } + + android::setupOutput(); + + if (hasSetLogFormat == 0) { + const char* logFormat = getenv("ANDROID_PRINTF_LOG"); + + if (logFormat != NULL) { + err = setLogFormat(logFormat); + + if (err < 0) { + fprintf(stderr, "invalid format in ANDROID_PRINTF_LOG '%s'\n", + logFormat); + } + } + } + + if (forceFilters) { + err = android_log_addFilterString(g_logformat, forceFilters); + if (err < 0) { + fprintf (stderr, "Invalid filter expression in -logcat option\n"); + exit(0); + } + } else if (argc == optind) { + // Add from environment variable + char *env_tags_orig = getenv("ANDROID_LOG_TAGS"); + + if (env_tags_orig != NULL) { + err = android_log_addFilterString(g_logformat, env_tags_orig); + + if (err < 0) { + fprintf(stderr, "Invalid filter expression in" + " ANDROID_LOG_TAGS\n"); + android::show_help(argv[0]); + exit(-1); + } + } + } else { + // Add from commandline + for (int i = optind ; i < argc ; i++) { + err = android_log_addFilterString(g_logformat, argv[i]); + + if (err < 0) { + fprintf (stderr, "Invalid filter expression '%s'\n", argv[i]); + android::show_help(argv[0]); + exit(-1); + } + } + } + + logfd = open(log_device, mode); + if (logfd < 0) { + fprintf(stderr, "Unable to open log device '%s': %s\n", + log_device, strerror(errno)); + exit(EXIT_FAILURE); + } + + if (clearLog) { + int ret; + ret = android::clearLog(logfd); + if (ret) { + perror("ioctl"); + exit(EXIT_FAILURE); + } + return 0; + } + + if (getLogSize) { + int size, readable; + + size = android::getLogSize(logfd); + if (size < 0) { + perror("ioctl"); + exit(EXIT_FAILURE); + } + + readable = android::getLogReadableSize(logfd); + if (readable < 0) { + perror("ioctl"); + exit(EXIT_FAILURE); + } + + printf("ring buffer is %dKb (%dKb consumed), " + "max entry is %db, max payload is %db\n", + size / 1024, readable / 1024, + (int) LOGGER_ENTRY_MAX_LEN, (int) LOGGER_ENTRY_MAX_PAYLOAD); + return 0; + } + + //LOG_EVENT_INT(10, 12345); + //LOG_EVENT_LONG(11, 0x1122334455667788LL); + //LOG_EVENT_STRING(0, "whassup, doc?"); + + if (android::g_isBinary) + android::g_eventTagMap = android_openEventTagMap(EVENT_TAG_MAP_FILE); + + android::readLogLines(logfd); + + return 0; +} |
