Home | History | Annotate | Download | only in debuggerd
      1 /* system/debuggerd/utility.h
      2 **
      3 ** Copyright 2008, The Android Open Source Project
      4 **
      5 ** Licensed under the Apache License, Version 2.0 (the "License");
      6 ** you may not use this file except in compliance with the License.
      7 ** You may obtain a copy of the License at
      8 **
      9 **     http://www.apache.org/licenses/LICENSE-2.0
     10 **
     11 ** Unless required by applicable law or agreed to in writing, software
     12 ** distributed under the License is distributed on an "AS IS" BASIS,
     13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 ** See the License for the specific language governing permissions and
     15 ** limitations under the License.
     16 */
     17 
     18 #ifndef _DEBUGGERD_UTILITY_H
     19 #define _DEBUGGERD_UTILITY_H
     20 
     21 #include <stddef.h>
     22 #include <stdbool.h>
     23 
     24 typedef struct {
     25     /* tombstone file descriptor */
     26     int tfd;
     27     /* Activity Manager socket file descriptor */
     28     int amfd;
     29     /* if true, does not log anything to the Android logcat or Activity Manager */
     30     bool quiet;
     31 } log_t;
     32 
     33 /* Log information onto the tombstone.  scopeFlags is a bitmask of the flags defined
     34  * here. */
     35 void _LOG(log_t* log, int scopeFlags, const char *fmt, ...)
     36         __attribute__ ((format(printf, 3, 4)));
     37 
     38 /* The message pertains specifically to the faulting thread / process */
     39 #define SCOPE_AT_FAULT (1 << 0)
     40 /* The message contains sensitive information such as RAM contents */
     41 #define SCOPE_SENSITIVE  (1 << 1)
     42 
     43 #define IS_AT_FAULT(x)    (((x) & SCOPE_AT_FAULT) != 0)
     44 #define IS_SENSITIVE(x)    (((x) & SCOPE_SENSITIVE) != 0)
     45 
     46 /* Further helpful macros */
     47 #define LOG(fmt...) _LOG(NULL, SCOPE_AT_FAULT, fmt)
     48 
     49 /* Set to 1 for normal debug traces */
     50 #if 0
     51 #define XLOG(fmt...) _LOG(NULL, SCOPE_AT_FAULT, fmt)
     52 #else
     53 #define XLOG(fmt...) do {} while(0)
     54 #endif
     55 
     56 /* Set to 1 for chatty debug traces. Includes all resolved dynamic symbols */
     57 #if 0
     58 #define XLOG2(fmt...) _LOG(NULL, SCOPE_AT_FAULT, fmt)
     59 #else
     60 #define XLOG2(fmt...) do {} while(0)
     61 #endif
     62 
     63 int wait_for_signal(pid_t tid, int* total_sleep_time_usec);
     64 void wait_for_stop(pid_t tid, int* total_sleep_time_usec);
     65 
     66 #endif // _DEBUGGERD_UTILITY_H
     67