Changeset 79ae36dd in mainline for uspace/app/taskdump
- Timestamp:
- 2011-06-08T19:01:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/app/taskdump
- Files:
-
- 3 edited
-
elf_core.c (modified) (5 diffs)
-
include/elf_core.h (modified) (1 diff)
-
taskdump.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskdump/elf_core.c
r764d71e r79ae36dd 62 62 #include "include/elf_core.h" 63 63 64 static off64_t align_foff_up(off64_t foff, uintptr_t vaddr, size_t page_size);65 static int write_all(int fd, void *data, size_t len);66 static int write_mem_area(int fd, as_area_info_t *area, int phoneid);64 static off64_t align_foff_up(off64_t, uintptr_t, size_t); 65 static int write_all(int, void *, size_t); 66 static int write_mem_area(int, as_area_info_t *, async_sess_t *); 67 67 68 68 #define BUFFER_SIZE 0x1000 … … 71 71 /** Save ELF core file. 72 72 * 73 * @param file_name Name of file to save to. 74 * @param ainfo Array of @a n memory area info structures. 75 * @param n Number of memory areas. 76 * @param phoneid Debugging phone. 77 * 78 * @return EOK on sucess, ENOENT if file cannot be created, 79 * ENOMEM on out of memory, EIO on write error. 80 */ 81 int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n, int phoneid) 73 * @param file_name Name of file to save to. 74 * @param ainfo Array of @a n memory area info structures. 75 * @param n Number of memory areas. 76 * @param sess Debugging session. 77 * 78 * @return EOK on sucess. 79 * @return ENOENT if file cannot be created. 80 * @return ENOMEM on out of memory. 81 * @return EIO on write error. 82 * 83 */ 84 int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n, 85 async_sess_t *sess) 82 86 { 83 87 elf_header_t elf_hdr; … … 189 193 return EIO; 190 194 } 191 if (write_mem_area(fd, &ainfo[i], phoneid) != EOK) {195 if (write_mem_area(fd, &ainfo[i], sess) != EOK) { 192 196 printf("Failed writing memory data.\n"); 193 197 free(p_hdr); … … 215 219 /** Write memory area from application to core file. 216 220 * 217 * @param fd File to write to. 218 * @param area Memory area info structure. 219 * @param phoneid Debugging phone. 220 * 221 * @return EOK on success, EIO on failure. 222 */ 223 static int write_mem_area(int fd, as_area_info_t *area, int phoneid) 221 * @param fd File to write to. 222 * @param area Memory area info structure. 223 * @param sess Debugging session. 224 * 225 * @return EOK on success, EIO on failure. 226 * 227 */ 228 static int write_mem_area(int fd, as_area_info_t *area, async_sess_t *sess) 224 229 { 225 230 size_t to_copy; … … 233 238 while (total < area->size) { 234 239 to_copy = min(area->size - total, BUFFER_SIZE); 235 rc = udebug_mem_read( phoneid, buffer, addr, to_copy);240 rc = udebug_mem_read(sess, buffer, addr, to_copy); 236 241 if (rc < 0) { 237 242 printf("Failed reading task memory.\n"); -
uspace/app/taskdump/include/elf_core.h
r764d71e r79ae36dd 36 36 #define ELF_CORE_H_ 37 37 38 int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n, int phoneid); 38 #include <async.h> 39 40 extern int elf_core_save(const char *, as_area_info_t *, unsigned int, 41 async_sess_t *); 39 42 40 43 #endif -
uspace/app/taskdump/taskdump.c
r764d71e r79ae36dd 54 54 #define LINE_BYTES 16 55 55 56 static int phoneid;56 static async_sess_t *sess; 57 57 static task_id_t task_id; 58 58 static bool write_core_file; … … 104 104 printf("Failed dumping address space areas.\n"); 105 105 106 udebug_end( phoneid);107 async_hangup( phoneid);106 udebug_end(sess); 107 async_hangup(sess); 108 108 109 109 return 0; … … 112 112 static int connect_task(task_id_t task_id) 113 113 { 114 int rc; 115 116 rc = async_connect_kbox(task_id); 117 118 if (rc == ENOTSUP) { 119 printf("You do not have userspace debugging support " 120 "compiled in the kernel.\n"); 121 printf("Compile kernel with 'Support for userspace debuggers' " 122 "(CONFIG_UDEBUG) enabled.\n"); 123 return rc; 124 } 125 126 if (rc < 0) { 114 async_sess_t *ksess = async_connect_kbox(task_id); 115 116 if (!ksess) { 117 if (errno == ENOTSUP) { 118 printf("You do not have userspace debugging support " 119 "compiled in the kernel.\n"); 120 printf("Compile kernel with 'Support for userspace debuggers' " 121 "(CONFIG_UDEBUG) enabled.\n"); 122 return errno; 123 } 124 127 125 printf("Error connecting\n"); 128 printf("async_connect_kbox(%" PRIu64 ") -> %d ", task_id, rc); 129 return rc; 130 } 131 132 phoneid = rc; 133 134 rc = udebug_begin(phoneid); 126 printf("async_connect_kbox(%" PRIu64 ") -> %d ", task_id, errno); 127 return errno; 128 } 129 130 int rc = udebug_begin(ksess); 135 131 if (rc < 0) { 136 132 printf("udebug_begin() -> %d\n", rc); 137 133 return rc; 138 134 } 139 135 136 sess = ksess; 140 137 return 0; 141 138 } … … 213 210 214 211 /* TODO: See why NULL does not work. */ 215 rc = udebug_thread_read( phoneid, &dummy_buf, 0, &copied, &needed);212 rc = udebug_thread_read(sess, &dummy_buf, 0, &copied, &needed); 216 213 if (rc < 0) { 217 214 printf("udebug_thread_read() -> %d\n", rc); … … 227 224 thash_buf = malloc(buf_size); 228 225 229 rc = udebug_thread_read( phoneid, thash_buf, buf_size, &copied, &needed);226 rc = udebug_thread_read(sess, thash_buf, buf_size, &copied, &needed); 230 227 if (rc < 0) { 231 228 printf("udebug_thread_read() -> %d\n", rc); … … 262 259 int rc; 263 260 264 rc = udebug_areas_read( phoneid, &dummy_buf, 0, &copied, &needed);261 rc = udebug_areas_read(sess, &dummy_buf, 0, &copied, &needed); 265 262 if (rc < 0) { 266 263 printf("udebug_areas_read() -> %d\n", rc); … … 271 268 ainfo_buf = malloc(buf_size); 272 269 273 rc = udebug_areas_read( phoneid, ainfo_buf, buf_size, &copied, &needed);270 rc = udebug_areas_read(sess, ainfo_buf, buf_size, &copied, &needed); 274 271 if (rc < 0) { 275 272 printf("udebug_areas_read() -> %d\n", rc); … … 296 293 if (write_core_file) { 297 294 printf("Writing core file '%s'\n", core_file_name); 298 rc = elf_core_save(core_file_name, ainfo_buf, n_areas, phoneid);295 rc = elf_core_save(core_file_name, ainfo_buf, n_areas, sess); 299 296 if (rc != EOK) { 300 297 printf("Failed writing core file.\n"); … … 316 313 int rc; 317 314 318 rc = udebug_regs_read( phoneid, thash, &istate);315 rc = udebug_regs_read(sess, thash, &istate); 319 316 if (rc < 0) { 320 317 printf("Failed reading registers (%d).\n", rc); … … 359 356 (void) arg; 360 357 361 rc = udebug_mem_read( phoneid, &data, addr, sizeof(data));358 rc = udebug_mem_read(sess, &data, addr, sizeof(data)); 362 359 if (rc < 0) { 363 360 printf("Warning: udebug_mem_read() failed.\n"); … … 430 427 int rc; 431 428 432 rc = udebug_name_read( phoneid, &dummy_buf, 0, &copied, &needed);429 rc = udebug_name_read(sess, &dummy_buf, 0, &copied, &needed); 433 430 if (rc < 0) 434 431 return NULL; … … 436 433 name_size = needed; 437 434 name = malloc(name_size + 1); 438 rc = udebug_name_read( phoneid, name, name_size, &copied, &needed);435 rc = udebug_name_read(sess, name, name_size, &copied, &needed); 439 436 if (rc < 0) { 440 437 free(name);
Note:
See TracChangeset
for help on using the changeset viewer.
