diff options
| -rw-r--r-- | ChangeLog | 14 | ||||
| -rw-r--r-- | src/format/dwarf/abbrev.c | 70 | ||||
| -rw-r--r-- | src/format/dwarf/abbrev.h | 6 | ||||
| -rw-r--r-- | src/format/dwarf/dwarf-int.h | 2 | ||||
| -rw-r--r-- | src/format/dwarf/info.c | 510 | 
5 files changed, 282 insertions, 320 deletions
| @@ -1,4 +1,16 @@ -2008-08-22  Cyrille Bagard <nocbos@gmail.com> +2008-08-24  Cyrille Bagard <nocbos@gmail.com> + +	* src/format/dwarf/abbrev.c: +	* src/format/dwarf/abbrev.h: +	Remove old code. Add a function to test if an attribute exists. + +	* src/format/dwarf/dwarf-int.h: +	Typo in the debug functions array definition. + +	* src/format/dwarf/info.c: +	Clean the code. Register found debug functions. Handle the void type. + +2008-08-23  Cyrille Bagard <nocbos@gmail.com>  	* src/format/dwarf/abbrev.c:  	Support the DW_FORM_sdata and DW_FORM_udata values. diff --git a/src/format/dwarf/abbrev.c b/src/format/dwarf/abbrev.c index ba6cfb0..3cb2c4a 100644 --- a/src/format/dwarf/abbrev.c +++ b/src/format/dwarf/abbrev.c @@ -305,29 +305,6 @@ const dw_abbrev *_find_dwarf_abbreviations(const dw_abbrev *abbrev, uint8_t *ind  } -const dw_abbrev *find_dwarf_abbreviations_old(dwarf_format *format, const off_t *offset, uint8_t index) -{ -    const dw_abbrev *result;                /* Structure à retourner       */ -    size_t i;                               /* Boucle de parcours          */ - -    if (index == 0) return NULL; - -    result = NULL; - -    for (i = 0; i < format->abbrevs_count; i++) -        if (format->abbrevs[i]->offset == *offset) break; - -    if (i < format->abbrevs_count) -    { -        index--; -        result = _find_dwarf_abbreviations(format->abbrevs[i], &index); -    } - -    return result; - -} - -  /******************************************************************************  *                                                                             *  *  Paramètres  : format = informations de débogage à consulter.               * @@ -376,6 +353,34 @@ const dw_abbrev *find_dwarf_abbreviations(dwarf_format *format, const off_t *off  /******************************************************************************  *                                                                             * +*  Paramètres  : abbrev = informations à parcourir.                           * +*                attrib = attribut visé par la lecture.                       * +*                                                                             * +*  Description : Indique la présence ou l'absence d'un attribut donné.        * +*                                                                             * +*  Retour      : true si l'attribut est présent, false sinon.                 * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool test_dwarf_abbrev_attribute(const dw_abbrev *abbrev, DwarfAttrib attrib) +{ +    bool result;                            /* Bilan à retourner           */ +    size_t i;                               /* Boucle de parcours          */ + +    result = false; + +    for (i = 0; i < abbrev->attribs_count && !result; i++) +        result = (abbrev->attribs[i].attrib == attrib); + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : format = informations de débogage à compléter.               *  *                pos    = tête de lecture à mettre à jour. [OUT]              *  *                form   = format des données à lire.                          * @@ -748,12 +753,31 @@ bool skip_dwarf_abbrev(dwarf_format *format, off_t *pos, const dw_abbrev *abbrev  {      bool result;                            /* Bilan à revoyer             */      size_t i;                               /* Boucle de parcours          */ +    uint64_t index;                         /* Code de padding             */      result = true; +    /* Ecartement du corps */ +      for (i = 0; i < abbrev->attribs_count && result; i++)          result = _read_dwarf_abbrev_attribute(format, pos, abbrev->attribs[i].form, NULL); +    /* Ecartement du padding */ + +    do +    { +        if (!read_uleb128(format, pos, &index, false)) +        { +            printf("error skipping padding...\n"); +            return false; +        } + +        if (index == 0) +            read_uleb128(format, pos, &index, true); + +    } +    while (index == 0); +      return result;  } diff --git a/src/format/dwarf/abbrev.h b/src/format/dwarf/abbrev.h index cbc394e..6f00608 100644 --- a/src/format/dwarf/abbrev.h +++ b/src/format/dwarf/abbrev.h @@ -40,11 +40,11 @@ bool load_dwarf_abbreviations(dwarf_format *);  void unload_dwarf_abbreviations(dwarf_format *);  /* Recherche une abréviation DWARF donnée. */ -const dw_abbrev *find_dwarf_abbreviations_old(dwarf_format *, const off_t *, uint8_t); - -/* Recherche une abréviation DWARF donnée. */  const dw_abbrev *find_dwarf_abbreviations(dwarf_format *, const off_t *, off_t *); +/* Indique la présence ou l'absence d'un attribut donné. */ +bool test_dwarf_abbrev_attribute(const dw_abbrev *, DwarfAttrib); +  /* Lit la valeur d'un attribut DWARF. */  bool read_dwarf_abbrev_attribute(dwarf_format *, off_t *, bool, const dw_abbrev *, DwarfAttrib, ...); diff --git a/src/format/dwarf/dwarf-int.h b/src/format/dwarf/dwarf-int.h index 4863bfe..2b27256 100644 --- a/src/format/dwarf/dwarf-int.h +++ b/src/format/dwarf/dwarf-int.h @@ -92,7 +92,7 @@ struct _dwarf_format      dw_abbrev **abbrevs;                    /* Liste des abréviations      */      size_t abbrevs_count;                   /* Nombre de ces abréviations  */ -    dw_dbg_function dbg_functions;          /* Liste de fonctions trouvées */ +    dw_dbg_function **dbg_functions;        /* Liste de fonctions trouvées */      size_t dbg_fc_count;                    /* Nombre de ces fonctions     */  }; diff --git a/src/format/dwarf/info.c b/src/format/dwarf/info.c index a45b556..75d11b6 100644 --- a/src/format/dwarf/info.c +++ b/src/format/dwarf/info.c @@ -46,12 +46,17 @@ typedef struct _compil_unit +#define _(str) str +  /* Procède à la lecture d'une unité de compilation. */  bool read_dwarf_compilation_unit(dwarf_format *, off_t *, compil_unit *); +/* Récupère toutes les déclarations DWARF utiles trouvées. */ +bool parse_dwarf_compilation_unit(dwarf_format *, off_t *, const compil_unit *); +  /* Enregistre toutes les déclarations de fonction trouvées. */ -bool look_for_dwarf_subprograms(dwarf_format *, off_t *, const compil_unit *); +dw_dbg_function *look_for_dwarf_subprograms(dwarf_format *, const dw_abbrev *, off_t *, const compil_unit *);  /* Obtient la description humaine d'un type. */  char *resolve_dwarf_function_type(dwarf_format *, const dw_abbrev *, const off_t *, const compil_unit *); @@ -119,12 +124,16 @@ bool load_dwarf_information(dwarf_format *format)          result = read_dwarf_compilation_unit(format, &offset, &cu);          if (result) -            look_for_dwarf_subprograms(format, &offset, &cu); - -        //break; +            parse_dwarf_compilation_unit(format, &offset, &cu);      } + +    printf("##############\nRegistered functions:\n"); + +    for (i = 0; i < format->dbg_fc_count; i++) +        printf(" > [0x%08llx] %s\n", format->dbg_functions[i]->low_pc, format->dbg_functions[i]->prototype); +      return result;  } @@ -166,69 +175,28 @@ void unload_dwarf_information(dwarf_format *format)  bool read_dwarf_compilation_unit(dwarf_format *format, off_t *pos, compil_unit *cu)  { -    bool result;                            /* Bilan à retourner           */      off_t ulength;                          /* Taille de l'unité           */      uint16_t version;                       /* Version du format DWARF     */ -    off_t abbrev_pos;                       /* Position dans les abréviat° */ -    uint8_t memsize;                        /* Taille des adresses mémoire */ - -    off_t oldpos; - -    uint8_t index; - - - -    result = true; -      cu->startpos = *pos; -    if (read_unit_length(format, pos, &ulength)) -        printf("Unit Length :: %d  (0x%x)\n", ulength, ulength); - -    else printf("error ul\n"); +    if (!read_unit_length(format, pos, &ulength)) +        return false;      cu->endpos = *pos + ulength; -    oldpos = *pos; - -    if (read_uhalf(format, pos, &version)) -        printf("version :: %hd\n", version); - -    else printf("error version\n"); +    if (!read_uhalf(format, pos, &version)) +        return false;      if (version > 3) return false; -    if (read_abbrev_offset(format, pos, &abbrev_pos)) -        printf("abbrev offset :: %d\n", abbrev_pos); - -    else printf("error abbrev offset\n"); - -    if (read_address_size(format, pos, &memsize)) -        printf("mem size :: %hhd\n", memsize); - -    else printf("error memsize\n"); - +    if (!read_abbrev_offset(format, pos, &cu->offset)) +        return false; -    cu->offset = abbrev_pos; -    cu->ptrsize = memsize; +    if (!read_address_size(format, pos, &cu->ptrsize)) +        return false; - -    printf(" =+> Next :: 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx\n", -           DBG_FORMAT(format)->content[*pos], -           DBG_FORMAT(format)->content[*pos + 1], -           DBG_FORMAT(format)->content[*pos + 2], -           DBG_FORMAT(format)->content[*pos + 3], -           DBG_FORMAT(format)->content[*pos + 4]); - - - -    /* -    *pos = oldpos + ulength; -    */ - - -    return result; +    return true;  } @@ -239,7 +207,7 @@ bool read_dwarf_compilation_unit(dwarf_format *format, off_t *pos, compil_unit *  *                pos    = tête de lecture à mettre à jour. [OUT]              *  *                cu     = unité de compilation courante.                      *  *                                                                             * -*  Description : Enregistre toutes les déclarations de fonction trouvées.     * +*  Description : Récupère toutes les déclarations DWARF utiles trouvées.      *  *                                                                             *  *  Retour      : true en cas de succès de la lecture, false sinon.            *  *                                                                             * @@ -247,43 +215,17 @@ bool read_dwarf_compilation_unit(dwarf_format *format, off_t *pos, compil_unit *  *                                                                             *  ******************************************************************************/ -bool look_for_dwarf_subprograms(dwarf_format *format, off_t *pos, const compil_unit *cu) +bool parse_dwarf_compilation_unit(dwarf_format *format, off_t *pos, const compil_unit *cu)  {      bool result;                            /* Bilan à retourner           */ -    uint8_t index;                          /* Indice de l'abbréviation    */ - -    result = true; - - -    off_t oldpos; -    off_t oldpos2; - -    const dw_abbrev *abbrev; -    const dw_abbrev *subabbrev; -    const dw_abbrev *subabbrev2; - - -    char *name; -    uint64_t low_pc; -    uint64_t high_pc; - -    uint32_t type_pos; -    char *retstr; +    const dw_abbrev *abbrev;                /* Abréviation rencontrée      */ +    dw_dbg_function *function;              /* Nouvelle fonction lue       */ -    uint64_t tempo; -    size_t i;                               /* Boucle de parcours          */ - -    char *prototype = NULL; -    size_t proto_len = 0; - - - -    bool first_arg;                         /* Marque le 1er argument      */ -    bool is_pointer;                        /* Mémorise le type 'pointeur' */ +    result = true; -    while (*pos < cu->endpos) +    while (*pos < cu->endpos && result)      { @@ -295,21 +237,12 @@ bool look_for_dwarf_subprograms(dwarf_format *format, off_t *pos, const compil_u                 DBG_FORMAT(format)->content[*pos + 4]); -        if (read_address_size/*leb128*/(format, pos, &index)) -            printf("abbrev index :: %hhd\n", index); -        else printf("abbrev index error\n"); - -        /* Contraintes d'alignement... */ -        if (index == 0) continue; - - -        abbrev = find_dwarf_abbreviations_old(format, &cu->offset, index); - - +        abbrev = find_dwarf_abbreviations(format, &cu->offset, pos); +        if (abbrev == NULL) +            break; -        //abbrev = find_dwarf_abbreviations(format, &cu->offset, pos);          printf(" --> %p\n", abbrev); @@ -317,286 +250,280 @@ bool look_for_dwarf_subprograms(dwarf_format *format, off_t *pos, const compil_u          printf("    == 0x%02x (matched ? %d)\n", abbrev->tag, abbrev->tag == DWT_SUBPROGRAM); -        oldpos = *pos; -        if (abbrev->tag == DWT_SUBPROGRAM) +        switch (abbrev->tag)          { +            case DWT_SUBPROGRAM: +                function = look_for_dwarf_subprograms(format, abbrev, pos, cu); +                if (function != NULL) +                { +                    format->dbg_functions = (dw_dbg_function **)realloc(format->dbg_functions, ++format->dbg_fc_count * sizeof(dw_dbg_function *)); +                    format->dbg_functions[format->dbg_fc_count - 1] = function; +                } +                else result = false; -            if (read_dwarf_abbrev_attribute(format, &oldpos, false, abbrev, DWA_NAME, &name)) -                printf(" ## Name :: %s\n", name); -            else printf(" error: no name\n"); - - -            if (read_dwarf_abbrev_attribute(format, &oldpos, false, abbrev, DWA_LOW_PC, &low_pc)) -                printf(" ## LOW PC :: 0x%08x\n", low_pc); -            else printf(" error: no low pc\n"); - - -            if (read_dwarf_abbrev_attribute(format, &oldpos, false, abbrev, DWA_HIGH_PC, &high_pc)) -                printf(" ## HIGH PC :: 0x%08x\n", high_pc); -            else printf(" error: no high pc\n"); - - - -            /* Type de la fonction */ - -            if (read_dwarf_abbrev_attribute(format, &oldpos, false, abbrev, DWA_TYPE, &type_pos)) -                printf(" ## type :: 0x%08x\n", type_pos); -            else printf(" error: no type\n"); - - -            oldpos = cu->startpos + type_pos; - - - - -            subabbrev2 = find_dwarf_abbreviations(format, &cu->offset, &oldpos); - -            retstr = resolve_dwarf_function_type(format, subabbrev2, &oldpos, cu); - -            if (retstr == NULL) -            { -                proto_len += 3; -                prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                strcat(prototype, "???"); - -                is_pointer = false; - -            } -            else -            { -                proto_len += strlen(retstr); -                prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                strcat(prototype, retstr); - -                is_pointer = (retstr[strlen(retstr) - 1] == '*'); - -                free(retstr); - -            } - +                break; +            default: +                break; +        } -            /* On saute l'abréviation de la déclaration de fonction... */ -            oldpos = *pos; -            if (!read_uleb128(format, &oldpos, &tempo, true)) -                printf("error skipping index\n"); -            if (!skip_dwarf_abbrev(format, &oldpos, abbrev)) -                printf("error skipping\n"); -            do -            { -                if (!read_uleb128(format, &oldpos, &tempo, false)) -                    printf("error skipping padding...\n"); -                if (tempo == 0) -                    read_uleb128(format, &oldpos, &tempo, true); -            } -            while (tempo == 0); -            /* Lecture des différents arguments */ -            proto_len += (!is_pointer ? 1 : 0) + strlen(name) + 1; -            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -            if (!is_pointer) strcat(prototype, " "); -            strcat(prototype, name); -            strcat(prototype, "("); -            first_arg = true; - -            while (1) -            { -                subabbrev = find_dwarf_abbreviations(format, &cu->offset, &oldpos); -                printf("subabbrev == %p\n", subabbrev); - -                switch (subabbrev->tag) -                { -                    case DWT_UNSPECIFIED_PARAMETERS: -                        /* Virgule de séparation */ -                        if (first_arg) first_arg = false; -                        else -                        { -                            proto_len += 2; -                            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                            strcat(prototype, ", "); -                        } +        if (!skip_dwarf_abbrev(format, pos, abbrev)) +            printf("error skipping :(\n"); -                        /* Marque de l'absence de type */ -                        proto_len += 3; -                        prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                        strcat(prototype, "..."); +    } -                        break; -                    case DWT_FORMAL_PARAMETER: +    printf(" =+> Next :: 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx\n", +           DBG_FORMAT(format)->content[*pos], +           DBG_FORMAT(format)->content[*pos + 1], +           DBG_FORMAT(format)->content[*pos + 2], +           DBG_FORMAT(format)->content[*pos + 3], +           DBG_FORMAT(format)->content[*pos + 4]); -                        oldpos2 = oldpos; +    return result; +} -                        if (read_dwarf_abbrev_attribute(format, &oldpos2, true, subabbrev, DWA_TYPE, &type_pos)) -                            printf(" ## type :: 0x%08x\n", type_pos); -                        else printf(" error: no type\n"); +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = informations de débogage à compléter.               * +*                abbrev = abréviation trouvée à traiter.                      * +*                pos    = tête de lecture à mettre à jour. [OUT]              * +*                cu     = unité de compilation courante.                      * +*                                                                             * +*  Description : Enregistre toutes les déclarations de fonction trouvées.     * +*                                                                             * +*  Retour      : Fonction chargée en mémoire ou NULL en cas d'échec.          * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ -                        oldpos2 = cu->startpos + type_pos; +dw_dbg_function *look_for_dwarf_subprograms(dwarf_format *format, const dw_abbrev *abbrev, off_t *pos, const compil_unit *cu) +{ +    dw_dbg_function *result;                /* Structure à retourner       */ +    uint32_t type_pos;                      /* Décallage p/r au pt courant */ +    off_t subpos;                           /* Sous-position de lecture #1 */ +    const dw_abbrev *subabbrev;             /* Abréviation fille à lire    */ +    char *retstr;                           /* Elément du prototype        */ +    char *prototype;                        /* Stockage temporaire         */ +    size_t proto_len;                       /* Taille du prototype         */ +    bool is_pointer;                        /* Mémorise le type 'pointeur' */ +    uint64_t index;                         /* Index de la fonction        */ +    bool first_arg;                         /* Marque le 1er argument      */ +    off_t subpos2;                          /* Sous-position de lecture #2 */ +    const dw_abbrev *subabbrev2;            /* Abréviation fille à lire #2 */ +    result = (dw_dbg_function *)calloc(1, sizeof(dw_dbg_function)); +    /* Récupération des informations de base */ +    if (!read_dwarf_abbrev_attribute(format, pos, false, abbrev, DWA_NAME, &result->name)) +        goto lfds_error; -            printf(" =+> Next arg :: 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx\n", -                   DBG_FORMAT(format)->content[oldpos2], -                   DBG_FORMAT(format)->content[oldpos2 + 1], -                   DBG_FORMAT(format)->content[oldpos2 + 2], -                   DBG_FORMAT(format)->content[oldpos2 + 3], -                   DBG_FORMAT(format)->content[oldpos2 + 4]); +    if (!read_dwarf_abbrev_attribute(format, pos, false, abbrev, DWA_LOW_PC, &result->low_pc)) +        goto lfds_error; +    if (!read_dwarf_abbrev_attribute(format, pos, false, abbrev, DWA_HIGH_PC, &result->high_pc)) +        goto lfds_error; +    /* Type de la fonction */ +    if (test_dwarf_abbrev_attribute(abbrev, DWA_TYPE)) +    { +        if (!read_dwarf_abbrev_attribute(format, pos, false, abbrev, DWA_TYPE, &type_pos)) +            goto lfds_error; -                        subabbrev2 = find_dwarf_abbreviations(format, &cu->offset, &oldpos2); -                        printf("subabbrev2 == %p\n", subabbrev2); +        subpos = cu->startpos + type_pos; +        subabbrev = find_dwarf_abbreviations(format, &cu->offset, &subpos); +        retstr = resolve_dwarf_function_type(format, subabbrev, &subpos, cu); +    } +    else retstr = strdup("void"); -                        retstr = resolve_dwarf_function_type(format, subabbrev2, &oldpos2, cu); -                        printf("  ----) '%s'\n", retstr); +    if (retstr == NULL) +    { +        proto_len = 3; +        prototype = (char *)calloc(proto_len + 1, sizeof(char)); +        strcat(prototype, "???"); -                        /* Virgule de séparation */ +        is_pointer = false; -                        if (first_arg) first_arg = false; -                        else -                        { -                            proto_len += 2; -                            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                            strcat(prototype, ", "); -                        } +    } +    else +    { +        proto_len = strlen(retstr); +        prototype = (char *)calloc(proto_len + 1, sizeof(char)); +        strcat(prototype, retstr); -                        /* Type de l'argument */ +        is_pointer = (retstr[strlen(retstr) - 1] == '*'); -                        if (retstr == NULL) -                        { -                            proto_len += 3; -                            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                            strcat(prototype, "???"); +        free(retstr); -                            is_pointer = false; +    } -                        } -                        else -                        { -                            proto_len += strlen(retstr); -                            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                            strcat(prototype, retstr); +    /* On saute l'abréviation de la déclaration de fonction... */ -                            is_pointer = (retstr[strlen(retstr) - 1] == '*'); +    subpos = *pos; -                            free(retstr); +    if (!read_uleb128(format, &subpos, &index, true)) +        goto lfds_error; -                        } +    if (!skip_dwarf_abbrev(format, &subpos, abbrev)) +        goto lfds_error; +    /* Lecture des différents arguments */ +    proto_len += (!is_pointer ? 1 : 0) + strlen(result->name) + 1; +    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +    if (!is_pointer) strcat(prototype, " "); +    strcat(prototype, result->name); +    strcat(prototype, "("); -                        oldpos2 = oldpos; +    first_arg = true; -                        if (read_dwarf_abbrev_attribute(format, &oldpos2, true, subabbrev, DWA_NAME, &retstr)) -                            printf(" ## Name :: %s\n", retstr); -                        else printf(" error: no name\n"); +    while (1) +    { +        subabbrev = find_dwarf_abbreviations(format, &cu->offset, &subpos); +        if (subabbrev == NULL) goto exit_loop; +        switch (subabbrev->tag) +        { +            case DWT_UNSPECIFIED_PARAMETERS: -                        if (retstr != NULL) -                        { -                            proto_len += strlen(retstr) + (!is_pointer ? 1 : 0) + 1; -                            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -                            if (!is_pointer) strcat(prototype, " "); -                            strcat(prototype, retstr); +                /* Virgule de séparation */ -                            free(retstr); +                if (first_arg) first_arg = false; +                else +                { +                    proto_len += 2; +                    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +                    strcat(prototype, ", "); +                } -                        } +                /* Marque de l'absence de type */ +                proto_len += 3; +                prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +                strcat(prototype, "..."); +                break; +            case DWT_FORMAL_PARAMETER: +                if (!read_dwarf_abbrev_attribute(format, &subpos, false, subabbrev, DWA_TYPE, &type_pos)) +                    goto lfds_error; +                subpos2 = cu->startpos + type_pos; +                subabbrev2 = find_dwarf_abbreviations(format, &cu->offset, &subpos2); -                        break; +                retstr = resolve_dwarf_function_type(format, subabbrev2, &subpos2, cu); -                    default: -                        goto exit_loop; -                        break; +                /* Virgule de séparation */ +                if (first_arg) first_arg = false; +                else +                { +                    proto_len += 2; +                    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +                    strcat(prototype, ", ");                  } -                if (!skip_dwarf_abbrev(format, &oldpos, subabbrev)) -                    printf("error skipping\n"); +                /* Type de l'argument */ -                /* -                do +                if (retstr == NULL)                  { -                    if (!read_uleb128(format, &oldpos, &tempo, false)) -                        printf("error skipping padding...\n"); +                    proto_len += 3; +                    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +                    strcat(prototype, "???"); -                    if (tempo == 0) -                        read_uleb128(format, &oldpos, &tempo, true); +                    is_pointer = false;                  } -                while (tempo == 0); -                */ +                else +                { +                    proto_len += strlen(retstr); +                    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +                    strcat(prototype, retstr); -            } +                    is_pointer = (retstr[strlen(retstr) - 1] == '*'); - exit_loop: +                    free(retstr); -            proto_len += 1; -            prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); -            strcat(prototype, ")"); +                } -            printf(" |\n"); -            printf(" | %s\n", prototype); -            printf(" |\n"); +                /* Nom de l'argument */ -            prototype = NULL; -            proto_len = 0; +                if (test_dwarf_abbrev_attribute(abbrev, DWA_NAME)) +                { +                    if (!read_dwarf_abbrev_attribute(format, &subpos, false, subabbrev, DWA_NAME, &retstr)) +                        goto lfds_error; +                } +                else retstr = strdup(_("[no name]")); +                if (retstr != NULL) +                { +                    proto_len += strlen(retstr) + (!is_pointer ? 1 : 0) + 1; +                    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +                    if (!is_pointer) strcat(prototype, " "); +                    strcat(prototype, retstr); +                    free(retstr); +                } +                break; +            default: +                goto exit_loop; +                break;          } +        if (!skip_dwarf_abbrev(format, &subpos, subabbrev)) +            goto lfds_error; +    } -        if (!skip_dwarf_abbrev(format, pos, abbrev)) -            printf("error skipping :(\n"); + exit_loop: +    proto_len += 1; +    prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); +    strcat(prototype, ")"); -    } +    result->prototype = prototype; +    return result; -    printf(" =+> Next :: 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx 0x%02hhx\n", -           DBG_FORMAT(format)->content[*pos], -           DBG_FORMAT(format)->content[*pos + 1], -           DBG_FORMAT(format)->content[*pos + 2], -           DBG_FORMAT(format)->content[*pos + 3], -           DBG_FORMAT(format)->content[*pos + 4]); + lfds_error: +    if (result->name != NULL) free(result->name); +    if (result->prototype != NULL) free(result->prototype); +    free(result); -    return result; +    return NULL;  } @@ -651,20 +578,19 @@ char *resolve_dwarf_function_type(dwarf_format *format, const dw_abbrev *abbrev,          /* 0x0f */          case DWT_POINTER_TYPE: -            if (read_dwarf_abbrev_attribute(format, &oldpos, true, abbrev, DWA_TYPE, &type_pos)) -                printf(" ## sub type :: 0x%08x\n", type_pos); -            else printf(" error: no type\n"); - -            oldpos = cu->startpos + type_pos; - - -            subabbrev = find_dwarf_abbreviations(format, &cu->offset, &oldpos); -            printf("subabbrev == %p\n", subabbrev); +            if (test_dwarf_abbrev_attribute(abbrev, DWA_TYPE)) +            { +                if (!read_dwarf_abbrev_attribute(format, &oldpos, true, abbrev, DWA_TYPE, &type_pos)) +                    return NULL; +                oldpos = cu->startpos + type_pos; +                subabbrev = find_dwarf_abbreviations(format, &cu->offset, &oldpos); +                result = resolve_dwarf_function_type(format, subabbrev, &oldpos, cu); -            result = resolve_dwarf_function_type(format, subabbrev, &oldpos, cu); +            } +            else result = strdup("void");              if (result != NULL)              { | 
