From: Petr Machata Date: Tue, 17 Feb 2009 15:04:17 +0000 (+0100) Subject: New class hl_ctx for storing information useful across high-level checks X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=16808c40b5fc89c7dfc907b2f372c9306f925438;p=thirdparty%2Felfutils.git New class hl_ctx for storing information useful across high-level checks --- diff --git a/src/dwarflint-hl.cc b/src/dwarflint-hl.cc index 1c7c495d3..970b86215 100644 --- a/src/dwarflint-hl.cc +++ b/src/dwarflint-hl.cc @@ -47,18 +47,38 @@ namespace } } -bool -check_matching_ranges (Dwarf *dwarf) +struct hl_ctx +{ + elfutils::dwarf dw; + + hl_ctx (Dwarf *dwarf) + : dw (dwarf) + { + } +}; + +hl_ctx * +hl_ctx_new (Dwarf *dwarf) { - elfutils::dwarf dw(dwarf); + return new hl_ctx (dwarf); +} + +void +hl_ctx_delete (hl_ctx *hlctx) +{ + delete hlctx; +} +bool +check_matching_ranges (struct hl_ctx *hlctx) +{ struct where where_ref = WHERE (sec_info, NULL); struct where where_ar = WHERE (sec_aranges, NULL); where_ar.ref = &where_ref; struct where where_r = WHERE (sec_ranges, NULL); where_r.ref = &where_ref; - const elfutils::dwarf::aranges_map &aranges = dw.aranges (); + const elfutils::dwarf::aranges_map &aranges = hlctx->dw.aranges (); for (elfutils::dwarf::aranges_map::const_iterator i = aranges.begin (); i != aranges.end (); ++i) { @@ -98,5 +118,5 @@ check_matching_ranges (Dwarf *dwarf) it->first, it->second); } - return dwarf != NULL; + return true; } diff --git a/src/dwarflint.c b/src/dwarflint.c index 65df84775..ddc480f70 100644 --- a/src/dwarflint.c +++ b/src/dwarflint.c @@ -998,12 +998,14 @@ process_file (int fd __attribute__((unused)), if (loc_data.data != NULL && cu_chain != NULL) check_loc_or_range_structural (dwarf, &loc_data, cu_chain); + struct hl_ctx *hlctx = hl_ctx_new (dwarf); + if (aranges_data.data != NULL) { read_ctx_init (&ctx, dwarf, aranges_data.data); if (check_aranges_structural (&ctx, cu_chain) && ranges_sound) - check_matching_ranges (dwarf); + check_matching_ranges (hlctx); } if (pubnames_data.data != NULL) @@ -1023,6 +1025,7 @@ process_file (int fd __attribute__((unused)), if (file.ebl != NULL) ebl_closebackend (file.ebl); free (file.sec); + hl_ctx_delete (hlctx); } static void diff --git a/src/dwarflint.h b/src/dwarflint.h index b05ee9927..e92d343cb 100644 --- a/src/dwarflint.h +++ b/src/dwarflint.h @@ -12,8 +12,12 @@ extern "C" /* Entry points for high-level checks. */ + struct hl_ctx; + /* Check that .debug_aranges and .debug_ranges match. */ - extern bool check_matching_ranges (Dwarf *dwarf); + extern struct hl_ctx *hl_ctx_new (Dwarf *dwarf); + extern void hl_ctx_delete (struct hl_ctx *hlctx); + extern bool check_matching_ranges (struct hl_ctx *hlctx); /* Functions and data structures describing location in Dwarf. */