Changeset 79ae36dd in mainline for uspace/app/taskdump


Ignore:
Timestamp:
2011-06-08T19:01:55Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
Location:
uspace/app/taskdump
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskdump/elf_core.c

    r764d71e r79ae36dd  
    6262#include "include/elf_core.h"
    6363
    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);
     64static off64_t align_foff_up(off64_t, uintptr_t, size_t);
     65static int write_all(int, void *, size_t);
     66static int write_mem_area(int, as_area_info_t *, async_sess_t *);
    6767
    6868#define BUFFER_SIZE 0x1000
     
    7171/** Save ELF core file.
    7272 *
    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 */
     84int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n,
     85    async_sess_t *sess)
    8286{
    8387        elf_header_t elf_hdr;
     
    189193                        return EIO;
    190194                }
    191                 if (write_mem_area(fd, &ainfo[i], phoneid) != EOK) {
     195                if (write_mem_area(fd, &ainfo[i], sess) != EOK) {
    192196                        printf("Failed writing memory data.\n");
    193197                        free(p_hdr);
     
    215219/** Write memory area from application to core file.
    216220 *
    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 */
     228static int write_mem_area(int fd, as_area_info_t *area, async_sess_t *sess)
    224229{
    225230        size_t to_copy;
     
    233238        while (total < area->size) {
    234239                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);
    236241                if (rc < 0) {
    237242                        printf("Failed reading task memory.\n");
  • uspace/app/taskdump/include/elf_core.h

    r764d71e r79ae36dd  
    3636#define ELF_CORE_H_
    3737
    38 int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n, int phoneid);
     38#include <async.h>
     39
     40extern int elf_core_save(const char *, as_area_info_t *, unsigned int,
     41    async_sess_t *);
    3942
    4043#endif
  • uspace/app/taskdump/taskdump.c

    r764d71e r79ae36dd  
    5454#define LINE_BYTES 16
    5555
    56 static int phoneid;
     56static async_sess_t *sess;
    5757static task_id_t task_id;
    5858static bool write_core_file;
     
    104104                printf("Failed dumping address space areas.\n");
    105105
    106         udebug_end(phoneid);
    107         async_hangup(phoneid);
     106        udebug_end(sess);
     107        async_hangup(sess);
    108108
    109109        return 0;
     
    112112static int connect_task(task_id_t task_id)
    113113{
    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               
    127125                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);
    135131        if (rc < 0) {
    136132                printf("udebug_begin() -> %d\n", rc);
    137133                return rc;
    138134        }
    139 
     135       
     136        sess = ksess;
    140137        return 0;
    141138}
     
    213210
    214211        /* 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);
    216213        if (rc < 0) {
    217214                printf("udebug_thread_read() -> %d\n", rc);
     
    227224        thash_buf = malloc(buf_size);
    228225
    229         rc = udebug_thread_read(phoneid, thash_buf, buf_size, &copied, &needed);
     226        rc = udebug_thread_read(sess, thash_buf, buf_size, &copied, &needed);
    230227        if (rc < 0) {
    231228                printf("udebug_thread_read() -> %d\n", rc);
     
    262259        int rc;
    263260
    264         rc = udebug_areas_read(phoneid, &dummy_buf, 0, &copied, &needed);
     261        rc = udebug_areas_read(sess, &dummy_buf, 0, &copied, &needed);
    265262        if (rc < 0) {
    266263                printf("udebug_areas_read() -> %d\n", rc);
     
    271268        ainfo_buf = malloc(buf_size);
    272269
    273         rc = udebug_areas_read(phoneid, ainfo_buf, buf_size, &copied, &needed);
     270        rc = udebug_areas_read(sess, ainfo_buf, buf_size, &copied, &needed);
    274271        if (rc < 0) {
    275272                printf("udebug_areas_read() -> %d\n", rc);
     
    296293        if (write_core_file) {
    297294                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);
    299296                if (rc != EOK) {
    300297                        printf("Failed writing core file.\n");
     
    316313        int rc;
    317314
    318         rc = udebug_regs_read(phoneid, thash, &istate);
     315        rc = udebug_regs_read(sess, thash, &istate);
    319316        if (rc < 0) {
    320317                printf("Failed reading registers (%d).\n", rc);
     
    359356        (void) arg;
    360357
    361         rc = udebug_mem_read(phoneid, &data, addr, sizeof(data));
     358        rc = udebug_mem_read(sess, &data, addr, sizeof(data));
    362359        if (rc < 0) {
    363360                printf("Warning: udebug_mem_read() failed.\n");
     
    430427        int rc;
    431428
    432         rc = udebug_name_read(phoneid, &dummy_buf, 0, &copied, &needed);
     429        rc = udebug_name_read(sess, &dummy_buf, 0, &copied, &needed);
    433430        if (rc < 0)
    434431                return NULL;
     
    436433        name_size = needed;
    437434        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);
    439436        if (rc < 0) {
    440437                free(name);
Note: See TracChangeset for help on using the changeset viewer.