Skip to content

Commit 4e99d1f

Browse files
committed
Add bootstrap logs for appling launch v0
1 parent a9b1b27 commit 4e99d1f

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

src/entry.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ appling_launch_v0(const appling_launch_info_t *info) {
504504
path_behavior_system
505505
);
506506

507+
appling__bootstrap_log("launch-entrypoint", "v0");
508+
appling__bootstrap_log("launch-runtime", file);
509+
507510
const appling_app_t *app = info->app;
508511

509512
appling_path_t appling;
@@ -516,6 +519,8 @@ appling_launch_v0(const appling_launch_info_t *info) {
516519
strcpy(appling, app->path);
517520
#endif
518521

522+
appling__bootstrap_log("launch-appling", appling);
523+
519524
log_debug("appling_launch() launching application shell %s", appling);
520525

521526
char link[7 /* pear:// */ + APPLING_ID_MAX + 1 /* / */ + APPLING_LINK_DATA_MAX + 1 /* NULL */] = {'\0'};
@@ -528,6 +533,8 @@ appling_launch_v0(const appling_launch_info_t *info) {
528533
strcat(link, info->link->data);
529534
}
530535

536+
appling__bootstrap_log("launch-link", link);
537+
531538
log_debug("appling_launch() launching link %s", link);
532539

533540
char *argv[8];
@@ -548,6 +555,16 @@ appling_launch_v0(const appling_launch_info_t *info) {
548555
argv[i] = NULL;
549556

550557
#if defined(APPLING_OS_WIN32)
558+
{
559+
char cmd[1024];
560+
cmd[0] = '\0';
561+
for (size_t j = 0; argv[j] != NULL; j++) {
562+
if (j > 0) strncat(cmd, " ", sizeof(cmd) - strlen(cmd) - 1);
563+
strncat(cmd, argv[j], sizeof(cmd) - strlen(cmd) - 1);
564+
}
565+
appling__bootstrap_log("launch-cmd", cmd);
566+
}
567+
551568
STARTUPINFOW si;
552569
ZeroMemory(&si, sizeof(si));
553570

@@ -558,11 +575,19 @@ appling_launch_v0(const appling_launch_info_t *info) {
558575

559576
WCHAR *application_name;
560577
err = appling__utf8_to_utf16(file, &application_name);
561-
if (err < 0) return err;
578+
if (err < 0) {
579+
char buf[128];
580+
snprintf(buf, sizeof(buf), "utf16 err=%d", err);
581+
appling__bootstrap_log("launch-utf16", buf);
582+
return err;
583+
}
562584

563585
WCHAR *command_line;
564586
err = appling__argv_to_command_line((const char *const *) argv, &command_line);
565587
if (err < 0) {
588+
char buf[128];
589+
snprintf(buf, sizeof(buf), "cmdline err=%d", err);
590+
appling__bootstrap_log("launch-cmdline", buf);
566591
free(application_name);
567592

568593
return err;
@@ -584,7 +609,13 @@ appling_launch_v0(const appling_launch_info_t *info) {
584609
free(application_name);
585610
free(command_line);
586611

587-
if (!success) return -1;
612+
if (!success) {
613+
DWORD last = GetLastError();
614+
char buf[128];
615+
snprintf(buf, sizeof(buf), "CreateProcessW err=%lu", (unsigned long) last);
616+
appling__bootstrap_log("launch-createprocess", buf);
617+
return -1;
618+
}
588619

589620
WaitForSingleObject(pi.hProcess, INFINITE);
590621

0 commit comments

Comments
 (0)