#endif
#include <dwarf.h>
+#include <cassert>
+
#include "checked_read.hh"
#include "messages.hh"
}
bool
-checked_read_sleb128 (struct read_ctx *ctx, int64_t *ret,
- struct where *where, const char *what)
+checked_read_sleb128 (read_ctx *ctx, int64_t *ret,
+ where *where, const char *what)
{
const unsigned char *ptr = ctx->ptr;
int st = read_ctx_read_sleb128 (ctx, ret);
}
return st >= 0;
}
+
+bool
+checked_read_leb128 (read_ctx *ctx, form_width_t width, uint64_t *ret,
+ where *where, const char *what)
+{
+ assert (width == fw_sleb || width == fw_uleb);
+ if (width == fw_sleb)
+ {
+ int64_t svalue;
+ if (!checked_read_sleb128 (ctx, &svalue, where, what))
+ return false;
+ *ret = (uint64_t) svalue;
+ return true;
+ }
+ else
+ return checked_read_uleb128 (ctx, ret, where, what);
+}
#define DWARFLINT_CHECKED_READ_HH
#include "readctx.h"
+#include "where.h"
+#include "tables.hh"
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+bool read_size_extra (read_ctx *ctx, uint32_t size32, uint64_t *sizep,
+ int *offset_sizep, where *where);
-bool read_size_extra (struct read_ctx *ctx, uint32_t size32, uint64_t *sizep,
- int *offset_sizep, struct where *where);
-
-bool read_address_size (struct read_ctx *ctx,
+bool read_address_size (read_ctx *ctx,
bool addr_64,
int *address_sizep,
- struct where const *where);
+ where const *where);
-bool checked_read_uleb128 (struct read_ctx *ctx, uint64_t *ret,
- struct where *where, const char *what);
+bool checked_read_uleb128 (read_ctx *ctx, uint64_t *ret,
+ where *where, const char *what);
-bool checked_read_sleb128 (struct read_ctx *ctx, int64_t *ret,
- struct where *where, const char *what);
+bool checked_read_sleb128 (read_ctx *ctx, int64_t *ret,
+ where *where, const char *what);
-#ifdef __cplusplus
-}
-#endif
+bool checked_read_leb128 (read_ctx *ctx, form_width_t width, uint64_t *ret,
+ where *where, const char *what);
#endif//DWARFLINT_CHECKED_READ_HH