diff options
author | Riley Andrews <riandrews@google.com> | 2014-06-26 13:56:01 -0700 |
---|---|---|
committer | Riley Andrews <riandrews@google.com> | 2014-06-26 15:05:15 -0700 |
commit | 24a3b783d5fcf55fdc9034ef395a5fbc77290c75 (patch) | |
tree | 8e125f970a110735809888d688c352cf55efb6f5 /init | |
parent | a42d5bf0064e8c8ce50b22abe13bb6eed4ea9dac (diff) | |
download | system_core-24a3b783d5fcf55fdc9034ef395a5fbc77290c75.zip system_core-24a3b783d5fcf55fdc9034ef395a5fbc77290c75.tar.gz system_core-24a3b783d5fcf55fdc9034ef395a5fbc77290c75.tar.bz2 |
Improve init's debug printing.
+ Make prints of rc commands significantly more verbose. All commands
will log all arguments, file/line number of the command, return value,
and parent action which triggered the command.
init: command 'mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000' action=init
status=0 (/init.rc:89)
init: command 'setprop net.tcp.default_init_rwnd 60' action=boot status=0
(/init.rc:403)
Change-Id: I5498c7258e4891706be4a12546df4231d14d86c4
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 15 | ||||
-rw-r--r-- | init/init.h | 8 | ||||
-rw-r--r-- | init/init_parser.c | 3 |
3 files changed, 22 insertions, 4 deletions
diff --git a/init/init.c b/init/init.c index f001071..e4ac1cf 100644 --- a/init/init.c +++ b/init/init.c @@ -528,7 +528,8 @@ static int is_last_command(struct action *act, struct command *cmd) void execute_one_command(void) { - int ret; + int ret, i; + char cmd_str[256] = ""; if (!cur_action || !cur_command || is_last_command(cur_action, cur_command)) { cur_action = action_remove_queue_head(); @@ -545,7 +546,17 @@ void execute_one_command(void) return; ret = cur_command->func(cur_command->nargs, cur_command->args); - INFO("command '%s' r=%d\n", cur_command->args[0], ret); + if (klog_get_level() >= KLOG_INFO_LEVEL) { + for (i = 0; i < cur_command->nargs; i++) { + strlcat(cmd_str, cur_command->args[i], sizeof(cmd_str)); + if (i < cur_command->nargs - 1) { + strlcat(cmd_str, " ", sizeof(cmd_str)); + } + } + INFO("command '%s' action=%s status=%d (%s:%d)\n", + cmd_str, cur_action ? cur_action->name : "", ret, cur_command->filename, + cur_command->line); + } } static int wait_for_coldboot_done_action(int nargs, char **args) diff --git a/init/init.h b/init/init.h index c241912..a7615a3 100644 --- a/init/init.h +++ b/init/init.h @@ -29,10 +29,14 @@ struct command struct listnode clist; int (*func)(int nargs, char **args); + + int line; + const char *filename; + int nargs; char *args[1]; }; - + struct action { /* node in list of all actions */ struct listnode alist; @@ -43,7 +47,7 @@ struct action { unsigned hash; const char *name; - + struct listnode commands; struct command *current; }; diff --git a/init/init_parser.c b/init/init_parser.c index 289e759..f412de7 100644 --- a/init/init_parser.c +++ b/init/init_parser.c @@ -584,6 +584,7 @@ void queue_builtin_action(int (*func)(int nargs, char **args), char *name) cmd = calloc(1, sizeof(*cmd)); cmd->func = func; cmd->args[0] = name; + cmd->nargs = 1; list_add_tail(&act->commands, &cmd->clist); list_add_tail(&action_list, &act->alist); @@ -870,6 +871,8 @@ static void parse_line_action(struct parse_state* state, int nargs, char **args) } cmd = malloc(sizeof(*cmd) + sizeof(char*) * nargs); cmd->func = kw_func(kw); + cmd->line = state->line; + cmd->filename = state->filename; cmd->nargs = nargs; memcpy(cmd->args, args, sizeof(char*) * nargs); list_add_tail(&act->commands, &cmd->clist); |