[PATCH] Getter and setter for Dwfl's offline_next_address

Aaron Merey amerey@redhat.com
Fri Mar 15 17:27:45 GMT 2024


Hi Martin,

On Wed, Mar 6, 2024 at 2:23 PM Martin Rodriguez Reboredo
<yakoyoku@gmail.com> wrote:
>
> diff --git a/tests/dwfl-offline-address.c b/tests/dwfl-offline-address.c
> new file mode 100644
> index 00000000..9a33b95a
> --- /dev/null
> +++ b/tests/dwfl-offline-address.c
> @@ -0,0 +1,43 @@
> +#include <config.h>
> +#include <assert.h>
> +#include <inttypes.h>
> +#include <sys/types.h>
> +#include <stdio.h>
> +#include <stdio_ext.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <locale.h>
> +#include <argp.h>
> +#include ELFUTILS_HEADER(dwfl)
> +#include <dwarf.h>
> +#include "system.h"
> +
> +#define OFFLINE_REDZONE 0x10000
> +
> +static const Dwfl_Callbacks offline_callbacks =
> +  {
> +    .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
> +    .section_address = INTUSE(dwfl_offline_section_address),
> +  };
> +
> +int
> +main (int argc, char **argv)
> +{
> +  Dwfl *dwfl = dwfl_begin (&offline_callbacks);
> +  assert (dwfl != NULL);
> +
> +  if (dwfl_get_offline_next_address (dwfl) != OFFLINE_REDZONE)
> +    {
> +      dwfl_end (dwfl);
> +      return 1;
> +    }
> +
> +  int result = 0;
> +  dwfl_set_offline_next_address (dwfl, 0);
> +  if (dwfl_get_offline_next_address (dwfl) != 0)
> +         result = 1;
> +
> +  dwfl_end (dwfl);
> +
> +  return result;
> +}

This test needs to be run under a testrun command in a tests/run-*.sh script
in order to have the result recorded by 'make check'.

Also there are a few places in libdwfl/ and src/ where we manually set
dwfl->offline_next_address.  We could use the setter here instead.

Aaron



More information about the Elfutils-devel mailing list