summaryrefslogtreecommitdiff
path: root/src/format/dwarf/utils.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2008-08-22 21:57:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2008-08-22 21:57:08 (GMT)
commit1b2ad075c4929cfc2b1efe9ff633a12c31dc7594 (patch)
tree9c535020b1519b0f94513cab561adeb8f4b212cc /src/format/dwarf/utils.c
parentf6f110acb8bf3243dffc527271c17619a078fcc4 (diff)
Made a first try to get all registered prototypes of functions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@18 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/dwarf/utils.c')
-rw-r--r--src/format/dwarf/utils.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/format/dwarf/utils.c b/src/format/dwarf/utils.c
index fa8ef20..359cc52 100644
--- a/src/format/dwarf/utils.c
+++ b/src/format/dwarf/utils.c
@@ -36,40 +36,45 @@
* Paramètres : format = informations de débogage à consulter. *
* pos = tête de lecture à mettre à jour. [OUT] *
* value = valeur au format LEB128 lue. [OUT] *
+* update = indique si la position est à mettre à jour. *
* *
* Description : Lit une valeur Little Endian Base 128 signée. *
* *
* Retour : Bilan de l'opération. *
* *
-* Remarques : - *
+* Remarques : En cas d'échec, la tête de lecture est indéterminée. *
* *
******************************************************************************/
-bool read_leb128(dwarf_format *format, off_t *pos, int64_t *value)
+bool read_leb128(dwarf_format *format, off_t *pos, int64_t *value, bool update)
{
+ off_t curpos; /* Tête de lecture effective */
int shift; /* Décallage à appliquer */
off_t i; /* Boucle de parcours */
+ curpos = *pos;
shift = 0;
*value = 0;
for (i = 0; i < 8; i++)
{
/* On évite les débordements... */
- if ((*pos + i) >= DBG_FORMAT(format)->length) return false;
+ if (curpos >= DBG_FORMAT(format)->length) return false;
- *value |= (DBG_FORMAT(format)->content[*pos + i] & 0x7f) << shift;
+ *value |= (DBG_FORMAT(format)->content[curpos] & 0x7f) << shift;
shift += 7;
- (*pos)++;
+ curpos++;
- if ((DBG_FORMAT(format)->content[*pos] & 0x80) == 0x00) break;
+ if ((DBG_FORMAT(format)->content[*pos + i] & 0x80) == 0x00) break;
}
- if ((shift < 64) && (DBG_FORMAT(format)->content[*pos - 1] & 0x40) == 0x40)
+ if ((shift < 64) && (DBG_FORMAT(format)->content[curpos - 1] & 0x40) == 0x40)
*value |= - (1 << shift);
+ if (update) *pos = curpos;
+
return (i < 8);
}
@@ -80,37 +85,42 @@ bool read_leb128(dwarf_format *format, off_t *pos, int64_t *value)
* Paramètres : format = informations de débogage à consulter. *
* pos = tête de lecture à mettre à jour. [OUT] *
* value = valeur au format LEB128 lue. [OUT] *
+* update = indique si la position est à mettre à jour. *
* *
* Description : Lit une valeur Little Endian Base 128 non signée. *
* *
* Retour : Bilan de l'opération. *
* *
-* Remarques : - *
+* Remarques : En cas d'échec, la tête de lecture est indéterminée. *
* *
******************************************************************************/
-bool read_uleb128(dwarf_format *format, off_t *pos, uint64_t *value)
+bool read_uleb128(dwarf_format *format, off_t *pos, uint64_t *value, bool update)
{
+ off_t curpos; /* Tête de lecture effective */
int shift; /* Décallage à appliquer */
off_t i; /* Boucle de parcours */
+ curpos = *pos;
shift = 0;
*value = 0;
for (i = 0; i < 8; i++)
{
/* On évite les débordements... */
- if ((*pos + i) >= DBG_FORMAT(format)->length) return false;
+ if (curpos >= DBG_FORMAT(format)->length) return false;
- *value |= (DBG_FORMAT(format)->content[*pos + i] & 0x7f) << shift;
+ *value |= (DBG_FORMAT(format)->content[curpos] & 0x7f) << shift;
shift += 7;
- (*pos)++;
+ curpos++;
- if ((DBG_FORMAT(format)->content[*pos] & 0x80) == 0x00) break;
+ if ((DBG_FORMAT(format)->content[*pos + i] & 0x80) == 0x00) break;
}
+ if (update) *pos = curpos;
+
return (i < 8);
}