Changeset b7fd2a0 in mainline for uspace/app/taskdump


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

Location:
uspace/app/taskdump
Files:
8 edited

Legend:

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

    r36f0738 rb7fd2a0  
    6666
    6767static off64_t align_foff_up(off64_t, uintptr_t, size_t);
    68 static int write_mem_area(int, aoff64_t *, as_area_info_t *, async_sess_t *);
     68static errno_t write_mem_area(int, aoff64_t *, as_area_info_t *, async_sess_t *);
    6969
    7070#define BUFFER_SIZE 0x1000
     
    8484 *
    8585 */
    86 int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n,
     86errno_t elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n,
    8787    async_sess_t *sess, istate_t *istate)
    8888{
     
    9898
    9999        int fd;
    100         int rc;
     100        errno_t rc;
    101101        size_t nwr;
    102102        unsigned int i;
     
    292292 *
    293293 */
    294 static int write_mem_area(int fd, aoff64_t *pos, as_area_info_t *area,
     294static errno_t write_mem_area(int fd, aoff64_t *pos, as_area_info_t *area,
    295295    async_sess_t *sess)
    296296{
     
    298298        size_t total;
    299299        uintptr_t addr;
    300         int rc;
     300        errno_t rc;
    301301        size_t nwr;
    302302
  • uspace/app/taskdump/fibrildump.c

    r36f0738 rb7fd2a0  
    4343#include <udebug.h>
    4444
    45 static int fibrildump_read_uintptr(void *, uintptr_t, uintptr_t *);
     45static errno_t fibrildump_read_uintptr(void *, uintptr_t, uintptr_t *);
    4646
    4747static stacktrace_ops_t fibrildump_st_ops = {
     
    4949};
    5050
    51 static int fibrildump_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data)
     51static errno_t fibrildump_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data)
    5252{
    5353        async_sess_t *sess = (async_sess_t *)arg;
     
    5656}
    5757
    58 static int read_link(async_sess_t *sess, uintptr_t addr, link_t *link)
     58static errno_t read_link(async_sess_t *sess, uintptr_t addr, link_t *link)
    5959{
    60         int rc;
     60        errno_t rc;
    6161
    6262        rc = udebug_mem_read(sess, (void *)link, addr, sizeof(link_t));
     
    6464}
    6565
    66 static int read_fibril(async_sess_t *sess, uintptr_t addr, fibril_t *fibril)
     66static errno_t read_fibril(async_sess_t *sess, uintptr_t addr, fibril_t *fibril)
    6767{
    68         int rc;
     68        errno_t rc;
    6969
    7070        rc = udebug_mem_read(sess, (void *)fibril, addr, sizeof(fibril_t));
     
    7272}
    7373
    74 int fibrils_dump(symtab_t *symtab, async_sess_t *sess)
     74errno_t fibrils_dump(symtab_t *symtab, async_sess_t *sess)
    7575{
    7676        uintptr_t fibril_list_addr;
     
    7979        uintptr_t addr, fibril_addr;
    8080        uintptr_t pc, fp;
    81         int rc;
     81        errno_t rc;
    8282
    8383        /*
  • uspace/app/taskdump/include/elf_core.h

    r36f0738 rb7fd2a0  
    4040#include <libarch/istate.h>
    4141
    42 extern int elf_core_save(const char *, as_area_info_t *, unsigned int,
     42extern errno_t elf_core_save(const char *, as_area_info_t *, unsigned int,
    4343    async_sess_t *, istate_t *);
    4444
  • uspace/app/taskdump/include/fibrildump.h

    r36f0738 rb7fd2a0  
    4040#include <symtab.h>
    4141
    42 extern int fibrils_dump(symtab_t *, async_sess_t *sess);
     42extern errno_t fibrils_dump(symtab_t *, async_sess_t *sess);
    4343
    4444#endif
  • uspace/app/taskdump/include/symtab.h

    r36f0738 rb7fd2a0  
    4848} symtab_t;
    4949
    50 extern int symtab_load(const char *file_name, symtab_t **symtab);
     50extern errno_t symtab_load(const char *file_name, symtab_t **symtab);
    5151extern void symtab_delete(symtab_t *st);
    52 extern int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr);
    53 extern int symtab_addr_to_name(symtab_t *symtab, uintptr_t addr, char **name,
     52extern errno_t symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr);
     53extern errno_t symtab_addr_to_name(symtab_t *symtab, uintptr_t addr, char **name,
    5454    size_t *offs);
    5555
  • uspace/app/taskdump/include/taskdump.h

    r36f0738 rb7fd2a0  
    3939#include <stdint.h>
    4040
    41 extern int td_stacktrace(uintptr_t, uintptr_t);
     41extern errno_t td_stacktrace(uintptr_t, uintptr_t);
    4242
    4343#endif
  • uspace/app/taskdump/symtab.c

    r36f0738 rb7fd2a0  
    4646#include "include/symtab.h"
    4747
    48 static int elf_hdr_check(elf_header_t *hdr);
    49 static int section_hdr_load(int fd, const elf_header_t *ehdr, int idx,
     48static errno_t elf_hdr_check(elf_header_t *hdr);
     49static errno_t section_hdr_load(int fd, const elf_header_t *ehdr, int idx,
    5050    elf_section_header_t *shdr);
    51 static int chunk_load(int fd, off64_t start, size_t size, void **ptr);
     51static errno_t chunk_load(int fd, off64_t start, size_t size, void **ptr);
    5252
    5353/** Load symbol table from an ELF file.
     
    5959 *                      ENOTSUP if file parsing failed.
    6060 */
    61 int symtab_load(const char *file_name, symtab_t **symtab)
     61errno_t symtab_load(const char *file_name, symtab_t **symtab)
    6262{
    6363        symtab_t *stab;
     
    7171
    7272        int fd;
    73         int rc;
     73        errno_t rc;
    7474        size_t nread;
    7575        int i;
     
    204204 * @return      EOK on success, ENOENT if no such symbol was found.
    205205 */
    206 int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr)
     206errno_t symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr)
    207207{
    208208        size_t i;
     
    241241 * @return      EOK on success or ENOENT if no matching symbol was found.
    242242 */
    243 int symtab_addr_to_name(symtab_t *st, uintptr_t addr, char **name,
     243errno_t symtab_addr_to_name(symtab_t *st, uintptr_t addr, char **name,
    244244    size_t *offs)
    245245{
     
    287287 * @return      EOK on success or an error code.
    288288 */
    289 static int elf_hdr_check(elf_header_t *ehdr)
     289static errno_t elf_hdr_check(elf_header_t *ehdr)
    290290{
    291291        /* TODO */
     
    302302 * @return              EOK on success or EIO if I/O failed.
    303303 */
    304 static int section_hdr_load(int fd, const elf_header_t *elf_hdr, int idx,
     304static errno_t section_hdr_load(int fd, const elf_header_t *elf_hdr, int idx,
    305305    elf_section_header_t *sec_hdr)
    306306{
    307         int rc;
     307        errno_t rc;
    308308        size_t nread;
    309309        aoff64_t pos = elf_hdr->e_shoff + idx * sizeof(elf_section_header_t);
     
    327327 * @return              EOK on success or EIO on failure.
    328328 */
    329 static int chunk_load(int fd, off64_t start, size_t size, void **ptr)
    330 {
    331         int rc;
     329static errno_t chunk_load(int fd, off64_t start, size_t size, void **ptr)
     330{
     331        errno_t rc;
    332332        size_t nread;
    333333        aoff64_t pos = start;
  • uspace/app/taskdump/taskdump.c

    r36f0738 rb7fd2a0  
    6363static symtab_t *app_symtab;
    6464
    65 static int connect_task(task_id_t task_id);
     65static errno_t connect_task(task_id_t task_id);
    6666static int parse_args(int argc, char *argv[]);
    6767static void print_syntax(void);
    68 static int threads_dump(void);
    69 static int thread_dump(uintptr_t thash);
    70 static int areas_dump(void);
    71 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
     68static errno_t threads_dump(void);
     69static errno_t thread_dump(uintptr_t thash);
     70static errno_t areas_dump(void);
     71static errno_t td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
    7272
    7373static void autoload_syms(void);
     
    8383int main(int argc, char *argv[])
    8484{
    85         int rc;
     85        errno_t rc;
    8686
    8787        printf("Task Dump Utility\n");
     
    122122}
    123123
    124 static int connect_task(task_id_t task_id)
     124static errno_t connect_task(task_id_t task_id)
    125125{
    126126        async_sess_t *ksess = async_connect_kbox(task_id);
     
    140140        }
    141141       
    142         int rc = udebug_begin(ksess);
     142        errno_t rc = udebug_begin(ksess);
    143143        if (rc != EOK) {
    144144                printf("udebug_begin() -> %s\n", str_error_name(rc));
     
    210210}
    211211
    212 static int threads_dump(void)
     212static errno_t threads_dump(void)
    213213{
    214214        uintptr_t *thash_buf;
     
    219219        size_t needed;
    220220        size_t i;
    221         int rc;
     221        errno_t rc;
    222222
    223223        /* TODO: See why NULL does not work. */
     
    260260}
    261261
    262 static int areas_dump(void)
     262static errno_t areas_dump(void)
    263263{
    264264        as_area_info_t *ainfo_buf;
     
    269269        size_t needed;
    270270        size_t i;
    271         int rc;
     271        errno_t rc;
    272272
    273273        rc = udebug_areas_read(sess, &dummy_buf, 0, &copied, &needed);
     
    320320}
    321321
    322 int td_stacktrace(uintptr_t fp, uintptr_t pc)
     322errno_t td_stacktrace(uintptr_t fp, uintptr_t pc)
    323323{
    324324        uintptr_t nfp;
    325325        stacktrace_t st;
    326326        char *sym_pc;
    327         int rc;
     327        errno_t rc;
    328328
    329329        st.op_arg = NULL;
     
    349349}
    350350
    351 static int thread_dump(uintptr_t thash)
     351static errno_t thread_dump(uintptr_t thash)
    352352{
    353353        istate_t istate;
    354354        uintptr_t pc, fp;
    355355        char *sym_pc;
    356         int rc;
     356        errno_t rc;
    357357
    358358        rc = udebug_regs_read(sess, thash, &istate);
     
    378378}
    379379
    380 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)
     380static errno_t td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)
    381381{
    382382        uintptr_t data;
    383         int rc;
     383        errno_t rc;
    384384
    385385        (void) arg;
     
    399399{
    400400        char *file_name;
    401         int rc;
     401        errno_t rc;
    402402        int ret;
    403403
     
    455455        size_t copied, needed, name_size;
    456456        char *name;
    457         int rc;
     457        errno_t rc;
    458458
    459459        rc = udebug_name_read(sess, &dummy_buf, 0, &copied, &needed);
     
    488488        char *name;
    489489        size_t offs;
    490         int rc;
     490        errno_t rc;
    491491        int ret;
    492492        char *str;
Note: See TracChangeset for help on using the changeset viewer.