Skip to content

Commit ef69f29

Browse files
committed
Remove ro.debuggable and enable critical logs for all builds
Removed ro.debuggable property and enabled critical logs across all build types. Signed-off-by: Vinayak Katoch <[email protected]>
1 parent 59c8b54 commit ef69f29

File tree

3 files changed

+43
-47
lines changed

3 files changed

+43
-47
lines changed

inc/fastrpc_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@
126126
FASTRPC_ENABLE_SYSTRACE = 6, //to enable tracing using Systrace
127127
FASTRPC_DEBUG_PDDUMP = 7, // to enable pd dump debug data collection on rooted device for signed/unsigned pd
128128
FASTRPC_PROCESS_ATTRS_PERSISTENT = 8, // to set proc attr as persistent
129-
FASTRPC_BUILD_TYPE = 9 // Fetch build type of firmware image. It gives the details if its debug or prod build
130129
}fastrpc_properties;
131130

132131
/**

src/fastrpc_apps_user.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ const char *ENV_DEBUG_VAR_NAME[] = {"FASTRPC_PROCESS_ATTRS",
225225
"FASTRPC_PERF_FREQ",
226226
"FASTRPC_DEBUG_SYSTRACE",
227227
"FASTRPC_DEBUG_PDDUMP",
228-
"FASTRPC_PROCESS_ATTRS_PERSISTENT",
229-
"ro.debuggable"};
228+
"FASTRPC_PROCESS_ATTRS_PERSISTENT"};
230229

231230
const char *SUBSYSTEM_NAME[] = {"adsp", "mdsp", "sdsp", "cdsp", "cdsp1", "gdsp0", "gdsp1", "reserved"};
232231

@@ -3141,6 +3140,7 @@ static void domain_deinit(int domain) {
31413140
trace_marker_deinit(domain);
31423141
deinitFileWatcher(domain);
31433142
adspmsgd_stop(domain);
3143+
fastrpc_log_deinit();
31443144
fastrpc_mem_close(domain);
31453145
apps_mem_deinit(domain);
31463146
hlist[domain].state = 0;
@@ -3900,7 +3900,7 @@ static int domain_init(int domain, int *dev) {
39003900
}
39013901
VERIFY(AEE_SUCCESS == (nErr = fastrpc_mem_open(domain)));
39023902
VERIFY(AEE_SUCCESS == (nErr = apps_mem_init(domain)));
3903-
3903+
fastrpc_log_init();
39043904
if (dom == CDSP_DOMAIN_ID || dom == CDSP1_DOMAIN_ID || dom == GDSP0_DOMAIN_ID || dom == GDSP1_DOMAIN_ID) {
39053905
panic_handle = get_adsp_current_process1_handle(domain);
39063906
if (panic_handle != INVALID_HANDLE) {
@@ -4011,7 +4011,6 @@ static void fastrpc_apps_user_deinit(void) {
40114011
fastrpc_notif_deinit();
40124012
apps_mem_table_deinit();
40134013
fastrpc_wake_lock_deinit();
4014-
fastrpc_log_deinit();
40154014
fastrpc_mem_deinit();
40164015
PL_DEINIT(apps_std);
40174016
PL_DEINIT(rpcmem);
@@ -4073,7 +4072,6 @@ static int fastrpc_apps_user_init(void) {
40734072
VERIFY(AEE_SUCCESS == (nErr = PL_INIT(rpcmem)));
40744073
fastrpc_mem_init();
40754074
fastrpc_context_table_init();
4076-
fastrpc_log_init();
40774075
fastrpc_config_init();
40784076
pthread_mutex_init(&update_notif_list_mut, 0);
40794077
VERIFYC(NULL != (hlist = calloc(NUM_DOMAINS_EXTEND, sizeof(*hlist))),

src/fastrpc_log.c

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -162,44 +162,57 @@ void HAP_debug_runtime(int level, const char *file, int line,
162162
const char *format, ...) {
163163
int len = 0;
164164
va_list argp;
165-
char *buf = NULL, *log = NULL;
166-
167-
/*
168-
* Adding logs to persist buffer when level is set to
169-
* RUNTIME_RPC_CRITICAL and fastrpc_log mask is disabled.
170-
*/
171-
if (((1 << level) & (fastrpc_logmask)) ||
172-
((level == HAP_LEVEL_RPC_CRITICAL) && persist_buf.buf) ||
173-
log_userspace_file_fd != NULL) {
165+
char *buf = NULL;
166+
167+
if (!((1 << level) & (fastrpc_logmask))) {
168+
/*
169+
* Adding logs to persist buffer when level is set to
170+
* RUNTIME_RPC_CRITICAL and fastrpc_log mask is disabled.
171+
*/
172+
if ((level == HAP_LEVEL_RPC_CRITICAL) && persist_buf.buf) {
173+
buf = (char *)malloc(sizeof(char) * MAX_FARF_LEN);
174+
if (buf == NULL) {
175+
return;
176+
}
177+
va_start(argp, format);
178+
len = vsnprintf(buf, MAX_FARF_LEN, format, argp);
179+
va_end(argp);
180+
if (len > 0 && len < MAX_FARF_LEN) {
181+
print_dbgbuf_data(buf, len);
182+
}
183+
}
184+
} else {
174185
buf = (char *)malloc(sizeof(char) * MAX_FARF_LEN);
175186
if (buf == NULL) {
176187
return;
177188
}
178189
va_start(argp, format);
179190
len = vsnprintf(buf, MAX_FARF_LEN, format, argp);
180191
va_end(argp);
181-
log = (char *)malloc(sizeof(char) * MAX_FARF_LEN);
182-
if (log == NULL) {
183-
return;
192+
/*
193+
* If level is set to RUNTIME_RPC_CRITICAL append the farf message
194+
* to persist buffer.
195+
*/
196+
if (IS_PERSIST_BUF_DATA(len, level)) {
197+
print_dbgbuf_data(buf, len);
184198
}
185-
snprintf(log, MAX_FARF_LEN, "%d:%d:%s:%s:%d: %s", getpid(), gettid(),
186-
__progname, file, line, buf);
187-
}
188-
189-
print_dbgbuf_data(log, len);
190-
if (((1 << level) & (fastrpc_logmask))) {
191199
if (log_userspace_file_fd != NULL) {
192-
fputs(log, log_userspace_file_fd);
193-
fputs("\n", log_userspace_file_fd);
200+
char *filelog = NULL;
201+
filelog = (char *)malloc(sizeof(char) * MAX_FARF_LEN);
202+
if (filelog) {
203+
if (snprintf(filelog, MAX_FARF_LEN, "%d:%d:%s:%s:%d: %s", getpid(),
204+
gettid(), __progname, file, line, buf)) {
205+
fputs(filelog, log_userspace_file_fd);
206+
fputs("\n", log_userspace_file_fd);
207+
}
208+
free(filelog);
209+
}
194210
}
195211
HAP_debug(buf, level, file, line);
196212
}
197-
if (buf) {
213+
214+
if (buf)
198215
free(buf);
199-
}
200-
if (log) {
201-
free(log);
202-
}
203216
}
204217

205218
#ifdef __LE_TVM__
@@ -279,28 +292,14 @@ void HAP_debug(const char *msg, int level, const char *filename, int line) {
279292
}
280293

281294
void fastrpc_log_init() {
282-
bool debug_build_type = false;
283295
int nErr = AEE_SUCCESS, fd = -1;
284296
char build_type[PROPERTY_VALUE_MAX];
285297
char *logfilename;
286298

287299
pthread_mutex_init(&persist_buf.mut, 0);
288300
pthread_mutex_lock(&persist_buf.mut);
289-
/*
290-
* Get build type by reading the target properties,
291-
* if buuid type is eng or userdebug allocate 1 MB persist buf.
292-
*/
293-
if (fastrpc_get_property_string(FASTRPC_BUILD_TYPE, build_type, NULL)) {
294-
#if !defined(LE_ENABLE)
295-
if (!strncmp(build_type, "eng", PROPERTY_VALUE_MAX) ||
296-
!strncmp(build_type, "userdebug", PROPERTY_VALUE_MAX))
297-
debug_build_type = true;
298-
#else
299-
if (atoi(build_type))
300-
debug_build_type = true;
301-
#endif
302-
}
303-
if (persist_buf.buf == NULL && debug_build_type) {
301+
302+
if (persist_buf.buf == NULL) {
304303
/* Create a debug buffer to append DEBUG FARF level message. */
305304
persist_buf.buf = (char *)rpcmem_alloc_internal(
306305
RPCMEM_HEAP_ID_SYSTEM, RPCMEM_DEFAULT_FLAGS | RPCMEM_TRY_MAP_STATIC,

0 commit comments

Comments
 (0)