Changeset 84876aa4 in mainline for uspace/app
- Timestamp:
- 2019-11-15T13:46:34Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ecb7828
- Parents:
- b093a62 (diff), d548fc0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/app
- Files:
-
- 6 edited
-
bdsh/cmds/modules/ls/ls.c (modified) (2 diffs)
-
df/df.c (modified) (2 diffs)
-
fdisk/fdisk.c (modified) (37 diffs)
-
sysinst/sysinst.c (modified) (4 diffs)
-
trace/syscalls.c (modified) (3 diffs)
-
trace/trace.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/ls/ls.c
rb093a62 r84876aa4 42 42 #include <vfs/vfs.h> 43 43 #include <str.h> 44 #include <cap .h>44 #include <capa.h> 45 45 46 46 #include "ls.h" … … 106 106 } 107 107 108 cap _spec_t cap;109 cap _from_blocks(de->s.size, 1, &cap);110 cap _simplify(&cap);108 capa_spec_t capa; 109 capa_from_blocks(de->s.size, 1, &capa); 110 capa_simplify(&capa); 111 111 112 112 char *rptr; 113 errno_t rc = cap _format(&cap, &rptr);113 errno_t rc = capa_format(&capa, &rptr); 114 114 if (rc != EOK) { 115 115 return rc; -
uspace/app/df/df.c
rb093a62 r84876aa4 35 35 */ 36 36 37 #include <cap .h>37 #include <capa.h> 38 38 #include <stdbool.h> 39 39 #include <stdio.h> … … 124 124 static errno_t size_to_human_readable(uint64_t nblocks, size_t block_size, char **rptr) 125 125 { 126 cap _spec_t cap;127 128 cap _from_blocks(nblocks, block_size, &cap);129 cap _simplify(&cap);130 return cap _format(&cap, rptr);126 capa_spec_t capa; 127 128 capa_from_blocks(nblocks, block_size, &capa); 129 capa_simplify(&capa); 130 return capa_format(&capa, rptr); 131 131 } 132 132 -
uspace/app/fdisk/fdisk.c
rb093a62 r84876aa4 34 34 */ 35 35 36 #include <cap .h>36 #include <capa.h> 37 37 #include <errno.h> 38 38 #include <fdisk.h> … … 136 136 nchoice_t *choice = NULL; 137 137 char *svcname = NULL; 138 cap _spec_t cap;138 capa_spec_t capa; 139 139 fdisk_dev_info_t *sdev; 140 char *scap = NULL;140 char *scapa = NULL; 141 141 char *dtext = NULL; 142 142 service_id_t svcid; … … 177 177 } 178 178 179 rc = fdisk_dev_info_capacity(info, &cap );179 rc = fdisk_dev_info_capacity(info, &capa); 180 180 if (rc != EOK) { 181 181 printf("Error getting device capacity " … … 185 185 } 186 186 187 cap _simplify(&cap);188 189 rc = cap _format(&cap, &scap);187 capa_simplify(&capa); 188 189 rc = capa_format(&capa, &scapa); 190 190 if (rc != EOK) { 191 191 assert(rc == ENOMEM); … … 194 194 } 195 195 196 int ret = asprintf(&dtext, "%s (%s)", svcname, scap );196 int ret = asprintf(&dtext, "%s (%s)", svcname, scapa); 197 197 if (ret < 0) { 198 198 rc = ENOMEM; … … 203 203 free(svcname); 204 204 svcname = NULL; 205 free(scap );206 scap = NULL;205 free(scapa); 206 scapa = NULL; 207 207 208 208 rc = nchoice_add(choice, dtext, info, 0); … … 261 261 free(dtext); 262 262 free(svcname); 263 free(scap );263 free(scapa); 264 264 return rc; 265 265 } … … 432 432 errno_t rc; 433 433 fdisk_part_spec_t pspec; 434 cap _spec_t cap;435 cap _spec_t mcap;434 capa_spec_t capa; 435 capa_spec_t mcapa; 436 436 vol_label_supp_t vlsupp; 437 437 vol_fstype_t fstype = 0; 438 438 tinput_t *tinput = NULL; 439 439 fdisk_spc_t spc; 440 char *scap ;441 char *smcap = NULL;440 char *scapa; 441 char *smcapa = NULL; 442 442 char *label = NULL; 443 443 char *mountp = NULL; … … 448 448 spc = spc_pri; 449 449 450 rc = fdisk_part_get_max_avail(dev, spc, &mcap );450 rc = fdisk_part_get_max_avail(dev, spc, &mcapa); 451 451 if (rc != EOK) { 452 452 rc = EIO; … … 454 454 } 455 455 456 cap _simplify(&mcap);457 458 rc = cap _format(&mcap, &smcap);456 capa_simplify(&mcapa); 457 458 rc = capa_format(&mcapa, &smcapa); 459 459 if (rc != EOK) { 460 460 rc = ENOMEM; … … 474 474 while (true) { 475 475 printf("Enter capacity of new partition.\n"); 476 rc = tinput_read_i(tinput, smcap , &scap);476 rc = tinput_read_i(tinput, smcapa, &scapa); 477 477 if (rc != EOK) 478 478 goto error; 479 479 480 rc = cap _parse(scap, &cap);480 rc = capa_parse(scapa, &capa); 481 481 if (rc == EOK) 482 482 break; … … 485 485 tinput_destroy(tinput); 486 486 tinput = NULL; 487 free(smcap );488 smcap = NULL;487 free(smcapa); 488 smcapa = NULL; 489 489 490 490 if (pkind != lpk_extended) { … … 545 545 546 546 fdisk_pspec_init(&pspec); 547 pspec.capacity = cap ;547 pspec.capacity = capa; 548 548 pspec.pkind = pkind; 549 549 pspec.fstype = fstype; … … 561 561 return EOK; 562 562 error: 563 free(smcap );563 free(smcapa); 564 564 free(label); 565 565 free(mountp); … … 581 581 fdisk_part_t *part; 582 582 fdisk_part_info_t pinfo; 583 char *scap = NULL;583 char *scapa = NULL; 584 584 char *spkind = NULL; 585 585 char *sfstype = NULL; … … 596 596 } 597 597 598 cap _simplify(&pinfo.capacity);599 600 rc = cap _format(&pinfo.capacity, &scap);598 capa_simplify(&pinfo.capacity); 599 600 rc = capa_format(&pinfo.capacity, &scapa); 601 601 if (rc != EOK) { 602 602 printf("Out of memory.\n"); … … 623 623 624 624 int ret = asprintf(&sdesc, "%s %s, %s, %s", label, 625 scap , spkind, sfstype);625 scapa, spkind, sfstype); 626 626 if (ret < 0) { 627 627 rc = ENOMEM; … … 630 630 631 631 } else { 632 int ret = asprintf(&sdesc, "%s, %s", scap , spkind);632 int ret = asprintf(&sdesc, "%s, %s", scapa, spkind); 633 633 if (ret < 0) { 634 634 rc = ENOMEM; … … 644 644 } 645 645 646 free(scap );647 scap = NULL;646 free(scapa); 647 scapa = NULL; 648 648 free(spkind); 649 649 spkind = NULL; … … 658 658 return EOK; 659 659 error: 660 free(scap );660 free(scapa); 661 661 free(spkind); 662 662 free(sfstype); … … 907 907 fdisk_part_t *part; 908 908 fdisk_part_info_t pinfo; 909 cap _spec_t cap;910 cap _spec_t mcap;909 capa_spec_t capa; 910 capa_spec_t mcapa; 911 911 fdisk_dev_flags_t dflags; 912 912 char *sltype = NULL; 913 char *sdcap = NULL;914 char *scap = NULL;915 char *smcap = NULL;913 char *sdcapa = NULL; 914 char *scapa = NULL; 915 char *smcapa = NULL; 916 916 char *sfstype = NULL; 917 917 char *svcname = NULL; … … 936 936 } 937 937 938 rc = fdisk_dev_capacity(dev, &cap );938 rc = fdisk_dev_capacity(dev, &capa); 939 939 if (rc != EOK) { 940 940 printf("Error getting device capacity.\n"); … … 942 942 } 943 943 944 cap _simplify(&cap);945 946 rc = cap _format(&cap, &sdcap);944 capa_simplify(&capa); 945 946 rc = capa_format(&capa, &sdcapa); 947 947 if (rc != EOK) { 948 948 printf("Out of memory.\n"); … … 958 958 fdisk_dev_get_flags(dev, &dflags); 959 959 960 printf("Device: %s (%s)\n", svcname, sdcap );961 free(sdcap );962 sdcap = NULL;960 printf("Device: %s (%s)\n", svcname, sdcapa); 961 free(sdcapa); 962 sdcapa = NULL; 963 963 964 964 rc = fdisk_label_get_info(dev, &linfo); … … 996 996 } 997 997 998 cap _simplify(&pinfo.capacity);999 1000 rc = cap _format(&pinfo.capacity, &scap);998 capa_simplify(&pinfo.capacity); 999 1000 rc = capa_format(&pinfo.capacity, &scapa); 1001 1001 if (rc != EOK) { 1002 1002 printf("Out of memory.\n"); … … 1016 1016 1017 1017 if (linfo.ltype == lt_none) 1018 printf("Entire disk: %s %s", label, scap );1018 printf("Entire disk: %s %s", label, scapa); 1019 1019 else 1020 printf("Partition %d: %s %s", npart, label, scap );1020 printf("Partition %d: %s %s", npart, label, scapa); 1021 1021 1022 1022 if ((linfo.flags & lf_ext_supp) != 0) { … … 1037 1037 printf("\n"); 1038 1038 1039 free(scap );1040 scap = NULL;1039 free(scapa); 1040 scapa = NULL; 1041 1041 free(sfstype); 1042 1042 sfstype = NULL; … … 1047 1047 /* Display available space */ 1048 1048 if ((linfo.flags & lf_can_create_pri) != 0) { 1049 rc = fdisk_part_get_max_avail(dev, spc_pri, &mcap );1049 rc = fdisk_part_get_max_avail(dev, spc_pri, &mcapa); 1050 1050 if (rc != EOK) { 1051 1051 rc = EIO; … … 1053 1053 } 1054 1054 1055 cap _simplify(&mcap);1056 1057 rc = cap _format(&mcap, &smcap);1055 capa_simplify(&mcapa); 1056 1057 rc = capa_format(&mcapa, &smcapa); 1058 1058 if (rc != EOK) { 1059 1059 rc = ENOMEM; … … 1062 1062 1063 1063 if ((linfo.flags & lf_ext_supp) != 0) 1064 printf("Maximum free primary block: %s\n", smcap );1064 printf("Maximum free primary block: %s\n", smcapa); 1065 1065 else 1066 printf("Maximum free block: %s\n", smcap );1067 1068 free(smcap );1069 smcap = NULL;1070 1071 rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcap );1066 printf("Maximum free block: %s\n", smcapa); 1067 1068 free(smcapa); 1069 smcapa = NULL; 1070 1071 rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcapa); 1072 1072 if (rc != EOK) { 1073 1073 rc = EIO; … … 1075 1075 } 1076 1076 1077 cap _simplify(&mcap);1078 1079 rc = cap _format(&mcap, &smcap);1077 capa_simplify(&mcapa); 1078 1079 rc = capa_format(&mcapa, &smcapa); 1080 1080 if (rc != EOK) { 1081 1081 rc = ENOMEM; … … 1084 1084 1085 1085 if ((linfo.flags & lf_ext_supp) != 0) 1086 printf("Total free primary space: %s\n", smcap );1086 printf("Total free primary space: %s\n", smcapa); 1087 1087 else 1088 printf("Total free space: %s\n", smcap );1089 1090 free(smcap );1091 smcap = NULL;1088 printf("Total free space: %s\n", smcapa); 1089 1090 free(smcapa); 1091 smcapa = NULL; 1092 1092 } 1093 1093 1094 1094 /* Display available space */ 1095 1095 if ((linfo.flags & lf_can_create_log) != 0) { 1096 rc = fdisk_part_get_max_avail(dev, spc_log, &mcap );1096 rc = fdisk_part_get_max_avail(dev, spc_log, &mcapa); 1097 1097 if (rc != EOK) { 1098 1098 rc = EIO; … … 1100 1100 } 1101 1101 1102 cap _simplify(&mcap);1103 1104 rc = cap _format(&mcap, &smcap);1102 capa_simplify(&mcapa); 1103 1104 rc = capa_format(&mcapa, &smcapa); 1105 1105 if (rc != EOK) { 1106 1106 rc = ENOMEM; … … 1108 1108 } 1109 1109 1110 printf("Maximum free logical block: %s\n", smcap );1111 free(smcap );1112 smcap = NULL;1113 1114 rc = fdisk_part_get_tot_avail(dev, spc_log, &mcap );1110 printf("Maximum free logical block: %s\n", smcapa); 1111 free(smcapa); 1112 smcapa = NULL; 1113 1114 rc = fdisk_part_get_tot_avail(dev, spc_log, &mcapa); 1115 1115 if (rc != EOK) { 1116 1116 rc = EIO; … … 1118 1118 } 1119 1119 1120 cap _simplify(&mcap);1121 1122 rc = cap _format(&mcap, &smcap);1120 capa_simplify(&mcapa); 1121 1122 rc = capa_format(&mcapa, &smcapa); 1123 1123 if (rc != EOK) { 1124 1124 rc = ENOMEM; … … 1126 1126 } 1127 1127 1128 printf("Total free logical space: %s\n", smcap );1129 free(smcap );1130 smcap = NULL;1128 printf("Total free logical space: %s\n", smcapa); 1129 free(smcapa); 1130 smcapa = NULL; 1131 1131 } 1132 1132 … … 1279 1279 return EOK; 1280 1280 error: 1281 free(sdcap );1282 free(scap );1283 free(smcap );1281 free(sdcapa); 1282 free(scapa); 1283 free(smcapa); 1284 1284 free(sfstype); 1285 1285 free(svcname); -
uspace/app/sysinst/sysinst.c
rb093a62 r84876aa4 38 38 #include <block.h> 39 39 #include <byteorder.h> 40 #include <cap .h>40 #include <capa.h> 41 41 #include <errno.h> 42 42 #include <fdisk.h> … … 98 98 fdisk_part_spec_t pspec; 99 99 fdisk_part_info_t pinfo; 100 cap _spec_t cap;100 capa_spec_t capa; 101 101 service_id_t sid; 102 102 errno_t rc; … … 137 137 printf("sysinst_label_dev(): create partition\n"); 138 138 139 rc = fdisk_part_get_max_avail(fdev, spc_pri, &cap );139 rc = fdisk_part_get_max_avail(fdev, spc_pri, &capa); 140 140 if (rc != EOK) { 141 141 printf("Error getting available capacity: %s.\n", str_error(rc)); … … 144 144 145 145 fdisk_pspec_init(&pspec); 146 pspec.capacity = cap ;146 pspec.capacity = capa; 147 147 pspec.pkind = lpk_primary; 148 148 pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */ -
uspace/app/trace/syscalls.c
rb093a62 r84876aa4 38 38 39 39 const sc_desc_t syscall_desc[] = { 40 /* System management syscalls. */ 40 41 [SYS_KIO] = { "kio", 3, V_INT_ERRNO }, 41 42 43 /* Thread and task related syscalls. */ 42 44 [SYS_THREAD_CREATE] = { "thread_create", 3, V_ERRNO }, 43 45 [SYS_THREAD_EXIT] = { "thread_exit", 1, V_ERRNO }, 44 46 [SYS_THREAD_GET_ID] = { "thread_get_id", 1, V_ERRNO }, 47 [SYS_THREAD_USLEEP] = { "thread_usleep", 1, V_ERRNO }, 48 [SYS_THREAD_UDELAY] = { "thread_udelay", 1, V_ERRNO }, 45 49 46 50 [SYS_TASK_GET_ID] = { "task_get_id", 1, V_ERRNO }, 47 51 [SYS_TASK_SET_NAME] = { "task_set_name", 2, V_ERRNO }, 52 [SYS_TASK_KILL] = { "task_kill", 1, V_ERRNO }, 53 [SYS_TASK_EXIT] = { "task_exit", 1, V_ERRNO }, 54 [SYS_PROGRAM_SPAWN_LOADER] = { "program_spawn_loader", 2, V_ERRNO }, 48 55 56 /* Synchronization related syscalls. */ 57 [SYS_WAITQ_CREATE] = { "waitq_create", 1, V_ERRNO }, 58 [SYS_WAITQ_SLEEP] = { "waitq_sleep", 3, V_ERRNO }, 59 [SYS_WAITQ_WAKEUP] = { "waitq_wakeup", 1, V_ERRNO }, 60 [SYS_WAITQ_DESTROY] = { "waitq_destroy", 1, V_ERRNO }, 61 [SYS_SMC_COHERENCE] = { "smc_coherence", 2, V_ERRNO }, 62 63 /* Address space related syscalls. */ 49 64 [SYS_AS_AREA_CREATE] = { "as_area_create", 5, V_ERRNO }, 50 65 [SYS_AS_AREA_RESIZE] = { "as_area_resize", 3, V_ERRNO }, 66 [SYS_AS_AREA_CHANGE_FLAGS] = { "as_area_change_flags", 2, V_ERRNO }, 67 [SYS_AS_AREA_GET_INFO] = { "as_area_get_info", 2, V_ERRNO }, 51 68 [SYS_AS_AREA_DESTROY] = { "as_area_destroy", 1, V_ERRNO }, 52 69 70 /* Page mapping related syscalls. */ 71 [SYS_PAGE_FIND_MAPPING] = { "page_find_mapping", 2, V_ERRNO }, 72 73 /* IPC related syscalls. */ 53 74 [SYS_IPC_CALL_ASYNC_FAST] = { "ipc_call_async_fast", 6, V_HASH }, 54 75 [SYS_IPC_CALL_ASYNC_SLOW] = { "ipc_call_async_slow", 3, V_HASH }, 55 56 76 [SYS_IPC_ANSWER_FAST] = { "ipc_answer_fast", 6, V_ERRNO }, 57 77 [SYS_IPC_ANSWER_SLOW] = { "ipc_answer_slow", 2, V_ERRNO }, … … 61 81 [SYS_IPC_POKE] = { "ipc_poke", 0, V_ERRNO }, 62 82 [SYS_IPC_HANGUP] = { "ipc_hangup", 1, V_ERRNO }, 83 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 2, V_ERRNO }, 63 84 85 /* Event notification syscalls. */ 64 86 [SYS_IPC_EVENT_SUBSCRIBE] = { "ipc_event_subscribe", 2, V_ERRNO }, 65 87 [SYS_IPC_EVENT_UNSUBSCRIBE] = { "ipc_event_unsubscribe", 1, V_ERRNO }, 66 88 [SYS_IPC_EVENT_UNMASK] = { "ipc_event_unmask", 1, V_ERRNO }, 67 89 90 /* Permission related syscalls. */ 68 91 [SYS_PERM_GRANT] = { "perm_grant", 2, V_ERRNO }, 69 92 [SYS_PERM_REVOKE] = { "perm_revoke", 2, V_ERRNO }, 93 94 /* DDI related syscalls. */ 70 95 [SYS_PHYSMEM_MAP] = { "physmem_map", 4, V_ERRNO }, 96 [SYS_PHYSMEM_UNMAP] = { "physmem_unmap", 1, V_ERRNO }, 97 [SYS_DMAMEM_MAP] = { "dmamem_map", 6, V_ERRNO }, 98 [SYS_DMAMEM_UNMAP] = { "dmamem_unmap", 3, V_ERRNO }, 71 99 [SYS_IOSPACE_ENABLE] = { "iospace_enable", 1, V_ERRNO }, 100 [SYS_IOSPACE_DISABLE] = { "iospace_disable", 1, V_ERRNO }, 72 101 73 102 [SYS_IPC_IRQ_SUBSCRIBE] = { "ipc_irq_subscribe", 4, V_ERRNO }, 74 103 [SYS_IPC_IRQ_UNSUBSCRIBE] = { "ipc_irq_unsubscribe", 2, V_ERRNO }, 75 104 105 /* Sysinfo syscalls. */ 106 [SYS_SYSINFO_GET_KEYS_SIZE] = { "sysinfo_get_keys_size", 3, V_ERRNO }, 107 [SYS_SYSINFO_GET_KEYS] = { "sysinfo_get_keys", 5, V_ERRNO }, 76 108 [SYS_SYSINFO_GET_VAL_TYPE] = { "sysinfo_get_val_type", 2, V_INTEGER }, 77 109 [SYS_SYSINFO_GET_VALUE] = { "sysinfo_get_value", 3, V_ERRNO }, … … 79 111 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 5, V_ERRNO }, 80 112 113 /* Kernel console syscalls. */ 81 114 [SYS_DEBUG_CONSOLE] = { "debug_console", 0, V_ERRNO }, 82 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } 115 116 [SYS_KLOG] = { "klog", 5, V_ERRNO } 83 117 }; 84 118 -
uspace/app/trace/trace.c
rb093a62 r84876aa4 47 47 #include <mem.h> 48 48 #include <str.h> 49 #include <loader/loader.h>50 49 #include <io/console.h> 51 50 #include <io/keycode.h> … … 86 85 void thread_trace_start(uintptr_t thread_hash); 87 86 87 static char *cmd_path; 88 static char **cmd_args; 89 88 90 static task_id_t task_id; 89 static loader_t *task_ldr;91 static task_wait_t task_w; 90 92 static bool task_wait_for; 91 93 … … 93 95 display_mask_t display_mask; 94 96 95 static errno_t program_run_fibril(void *arg);96 97 static errno_t cev_fibril(void *arg); 97 98 static void program_run(void)99 {100 fid_t fid;101 102 fid = fibril_create(program_run_fibril, NULL);103 if (fid == 0) {104 printf("Error creating fibril\n");105 exit(1);106 }107 108 fibril_add_ready(fid);109 }110 98 111 99 static void cev_fibril_start(void) … … 122 110 } 123 111 124 static errno_t program_run_fibril(void *arg) 125 { 126 errno_t rc; 127 128 /* 129 * This must be done in background as it will block until 130 * we let the task reply to this call. 131 */ 132 rc = loader_run(task_ldr); 112 static errno_t program_run(void) 113 { 114 errno_t rc; 115 116 rc = task_spawnv_debug(&task_id, &task_w, cmd_path, 117 (const char *const *)cmd_args, &sess); 118 119 if (rc == ENOTSUP) { 120 printf("You do not have userspace debugging support " 121 "compiled in the kernel.\n"); 122 printf("Compile kernel with 'Support for userspace debuggers' " 123 "(CONFIG_UDEBUG) enabled.\n"); 124 } 125 133 126 if (rc != EOK) { 134 printf("Error running program\n"); 135 exit(1); 136 } 137 138 task_ldr = NULL; 139 140 printf("program_run_fibril exiting\n"); 141 return 0; 127 printf("Error running program (%s)\n", str_error_name(rc)); 128 return rc; 129 } 130 131 return EOK; 142 132 } 143 133 144 134 static errno_t connect_task(task_id_t task_id) 145 135 { 146 async_sess_t *ksess = async_connect_kbox(task_id); 147 148 if (!ksess) { 149 if (errno == ENOTSUP) { 150 printf("You do not have userspace debugging support " 151 "compiled in the kernel.\n"); 152 printf("Compile kernel with 'Support for userspace debuggers' " 153 "(CONFIG_UDEBUG) enabled.\n"); 154 return errno; 155 } 156 157 printf("Error connecting\n"); 158 printf("ipc_connect_task(%" PRIu64 ") -> %s ", task_id, str_error_name(errno)); 159 return errno; 160 } 161 162 errno_t rc = udebug_begin(ksess); 163 if (rc != EOK) { 164 printf("udebug_begin() -> %s\n", str_error_name(rc)); 165 return rc; 166 } 167 168 rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL); 136 errno_t rc; 137 bool debug_started = false; 138 bool wait_set_up = false; 139 140 if (sess == NULL) { 141 sess = async_connect_kbox(task_id); 142 if (sess == NULL) { 143 printf("Error connecting to task %" PRIu64 ".\n", 144 task_id); 145 rc = EIO; 146 goto error; 147 } 148 149 rc = udebug_begin(sess); 150 if (rc != EOK) { 151 printf("Error starting debug session.\n"); 152 goto error; 153 } 154 155 debug_started = true; 156 157 rc = task_setup_wait(task_id, &task_w); 158 if (rc != EOK) { 159 printf("Error setting up wait for task termination.\n"); 160 goto error; 161 } 162 163 wait_set_up = true; 164 } 165 166 rc = udebug_set_evmask(sess, UDEBUG_EM_ALL); 169 167 if (rc != EOK) { 170 168 printf("udebug_set_evmask(0x%x) -> %s\n ", UDEBUG_EM_ALL, str_error_name(rc)); … … 172 170 } 173 171 174 sess = ksess; 175 return 0; 172 return EOK; 173 error: 174 if (wait_set_up) 175 task_cancel_wait(&task_w); 176 if (debug_started) 177 udebug_end(sess); 178 if (sess != NULL) 179 async_hangup(sess); 180 return rc; 176 181 } 177 182 … … 198 203 printf("\ntotal of %zu threads\n", tb_needed / sizeof(uintptr_t)); 199 204 200 return 0;205 return EOK; 201 206 } 202 207 … … 488 493 489 494 printf("Finished tracing thread [%d].\n", thread_id); 490 return 0;495 return EOK; 491 496 } 492 497 … … 502 507 } 503 508 fibril_add_ready(fid); 504 }505 506 static loader_t *preload_task(const char *path, char **argv,507 task_id_t *task_id)508 {509 loader_t *ldr;510 errno_t rc;511 512 /* Spawn a program loader */513 ldr = loader_connect();514 if (ldr == NULL)515 return NULL;516 517 /* Get task ID. */518 rc = loader_get_task_id(ldr, task_id);519 if (rc != EOK)520 goto error;521 522 /* Send program. */523 rc = loader_set_program_path(ldr, path);524 if (rc != EOK)525 goto error;526 527 /* Send arguments */528 rc = loader_set_args(ldr, (const char **) argv);529 if (rc != EOK)530 goto error;531 532 /* Send default files */533 int fd_root;534 int fd_stdin;535 int fd_stdout;536 int fd_stderr;537 538 fd_root = vfs_root();539 if (fd_root >= 0) {540 rc = loader_add_inbox(ldr, "root", fd_root);541 vfs_put(fd_root);542 if (rc != EOK)543 goto error;544 }545 546 if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK)) {547 rc = loader_add_inbox(ldr, "stdin", fd_stdin);548 if (rc != EOK)549 goto error;550 }551 552 if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK)) {553 rc = loader_add_inbox(ldr, "stdout", fd_stdout);554 if (rc != EOK)555 goto error;556 }557 558 if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK)) {559 rc = loader_add_inbox(ldr, "stderr", fd_stderr);560 if (rc != EOK)561 goto error;562 }563 564 /* Load the program. */565 rc = loader_load_program(ldr);566 if (rc != EOK)567 goto error;568 569 /* Success */570 return ldr;571 572 /* Error exit */573 error:574 loader_abort(ldr);575 return NULL;576 509 } 577 510 … … 807 740 ++argv; 808 741 task_id = strtol(*argv, &err_p, 10); 809 task_ldr = NULL;810 742 task_wait_for = false; 811 743 if (*err_p) { … … 848 780 printf("'%s'\n", *cp++); 849 781 850 task_ldr = preload_task(*argv, argv, &task_id); 782 cmd_path = *argv; 783 cmd_args = argv; 851 784 task_wait_for = true; 852 785 … … 869 802 870 803 main_init(); 804 805 if (cmd_path != NULL) 806 program_run(); 871 807 872 808 rc = connect_task(task_id); … … 878 814 printf("Connected to task %" PRIu64 ".\n", task_id); 879 815 880 if (task_ldr != NULL)881 program_run();882 883 816 cev_fibril_start(); 884 817 trace_task(task_id); … … 887 820 printf("Waiting for task to exit.\n"); 888 821 889 rc = task_wait _task_id(task_id, &texit, &retval);822 rc = task_wait(&task_w, &texit, &retval); 890 823 if (rc != EOK) { 891 824 printf("Failed waiting for task.\n");
Note:
See TracChangeset
for help on using the changeset viewer.
