utility.h revision c6c194ced095df5e777b8fa24527ebd29c8fef54
1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* system/debuggerd/utility.h 2dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** 3dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** Copyright 2008, The Android Open Source Project 4dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** 5dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License"); 6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** you may not use this file except in compliance with the License. 7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** You may obtain a copy of the License at 8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** 9dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** http://www.apache.org/licenses/LICENSE-2.0 10dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** 11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** Unless required by applicable law or agreed to in writing, software 12dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** distributed under the License is distributed on an "AS IS" BASIS, 13dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** See the License for the specific language governing permissions and 15dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project** limitations under the License. 16dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project*/ 17dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 1813e715b491e876865e752a3a69dd6f347049a488Jeff Brown#ifndef _DEBUGGERD_UTILITY_H 1913e715b491e876865e752a3a69dd6f347049a488Jeff Brown#define _DEBUGGERD_UTILITY_H 20dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 21dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <stdbool.h> 22c6c194ced095df5e777b8fa24527ebd29c8fef54Pavel Chupin#include <sys/types.h> 23053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown 24053b865412d1982ad1dc0e840898d82527deeb99Jeff Browntypedef struct { 25053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown /* tombstone file descriptor */ 26053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown int tfd; 27ded2e5acfcf0c705f08577d0ccb720bd5037f4baChristopher Tate /* Activity Manager socket file descriptor */ 28ded2e5acfcf0c705f08577d0ccb720bd5037f4baChristopher Tate int amfd; 29ded2e5acfcf0c705f08577d0ccb720bd5037f4baChristopher Tate /* if true, does not log anything to the Android logcat or Activity Manager */ 30053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown bool quiet; 31053b865412d1982ad1dc0e840898d82527deeb99Jeff Brown} log_t; 32dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 337716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate/* Log information onto the tombstone. scopeFlags is a bitmask of the flags defined 347716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate * here. */ 357716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tatevoid _LOG(log_t* log, int scopeFlags, const char *fmt, ...) 3613e715b491e876865e752a3a69dd6f347049a488Jeff Brown __attribute__ ((format(printf, 3, 4))); 37136dcc5ce628a1ba600a6818e5cb24d5f15eb016Andy McFadden 387716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate/* The message pertains specifically to the faulting thread / process */ 397716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define SCOPE_AT_FAULT (1 << 0) 407716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate/* The message contains sensitive information such as RAM contents */ 417716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define SCOPE_SENSITIVE (1 << 1) 427716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate 437716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define IS_AT_FAULT(x) (((x) & SCOPE_AT_FAULT) != 0) 447716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define IS_SENSITIVE(x) (((x) & SCOPE_SENSITIVE) != 0) 457716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate 467716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate/* Further helpful macros */ 477716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define LOG(fmt...) _LOG(NULL, SCOPE_AT_FAULT, fmt) 482c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner 492c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner/* Set to 1 for normal debug traces */ 50849249064cae9c1bb23b0204b5d35b832567801eBruce Beare#if 0 517716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define XLOG(fmt...) _LOG(NULL, SCOPE_AT_FAULT, fmt) 52849249064cae9c1bb23b0204b5d35b832567801eBruce Beare#else 53849249064cae9c1bb23b0204b5d35b832567801eBruce Beare#define XLOG(fmt...) do {} while(0) 54849249064cae9c1bb23b0204b5d35b832567801eBruce Beare#endif 55849249064cae9c1bb23b0204b5d35b832567801eBruce Beare 562c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner/* Set to 1 for chatty debug traces. Includes all resolved dynamic symbols */ 572c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner#if 0 587716aef138e8029357a7b3dc6a73b41f4de4b0adChristopher Tate#define XLOG2(fmt...) _LOG(NULL, SCOPE_AT_FAULT, fmt) 592c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner#else 602c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner#define XLOG2(fmt...) do {} while(0) 612c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner#endif 622c259914a0c5d49a3fcb525a75f4817a3a99a6c8David 'Digit' Turner 63053b865412d1982ad1dc0e840898d82527deeb99Jeff Brownint wait_for_signal(pid_t tid, int* total_sleep_time_usec); 64053b865412d1982ad1dc0e840898d82527deeb99Jeff Brownvoid wait_for_stop(pid_t tid, int* total_sleep_time_usec); 6513e715b491e876865e752a3a69dd6f347049a488Jeff Brown 664bb477205a2446c3ba9db8df0b0446173065d9ebKévin PETITvoid dump_memory(log_t* log, pid_t tid, uintptr_t addr, int scope_flags); 674bb477205a2446c3ba9db8df0b0446173065d9ebKévin PETIT 6813e715b491e876865e752a3a69dd6f347049a488Jeff Brown#endif // _DEBUGGERD_UTILITY_H 69