Hi Roland,
jankratochvil/readelf-bitmap
when you insist on src/readelf.c fixes the displayed bitmaps were already very
wrong when trying to fix the handling around.
Just I haven't found it worth some thorough testcase. I used some adjustments
of the attached reproducer to produce a core file with bitmap.
Particularly
ioperm: ~<-65535>
->
ioperm: ~<0-63>
and
ioperm: ~<-0,2,4,6,8,10,12,14-65535>
->
ioperm: ~<0,2,4,6,8,10,12,14>
.
Regards,
Jan
commit 69a2852e1d5661bc042dcc90c16e9aa7777c7340
Author: Jan Kratochvil <jan.kratochvil(a)redhat.com>
Date: Thu Oct 11 21:47:26 2012 +0200
src/
2012-10-11 Jan Kratochvil <jan.kratochvil(a)redhat.com>
* readelf.c (handle_core_item) <b>: Make run an outer block variable.
Increase run only if LASTBIT != 0. Print last element only if RUN > 0.
Signed-off-by: Jan Kratochvil <jan.kratochvil(a)redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index 5d167eb..470af4d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7515,19 +7515,19 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void
*desc,
}
unsigned int lastbit = 0;
+ unsigned int run = 0;
for (const unsigned int *i = data;
(void *) i < data + count * size; ++i)
{
unsigned int bit = ((void *) i - data) * 8;
unsigned int w = negate ? ~*i : *i;
- unsigned int run = 0;
while (w != 0)
{
int n = ffs (w);
w >>= n;
bit += n;
- if (lastbit + 1 == bit)
+ if (lastbit != 0 && lastbit + 1 == bit)
++run;
else
{
@@ -7543,8 +7543,8 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void
*desc,
lastbit = bit;
}
}
- if (lastbit > 0 && lastbit + 1 != nbits)
- p += sprintf (p, "-%u", nbits - bias);
+ if (lastbit > 0 && run > 0 && lastbit + 1 != nbits)
+ p += sprintf (p, "-%u", lastbit - bias);
colno = print_core_item (colno, ',', ITEM_WRAP_COLUMN, 0, item->name,
4 + nbits * 4,
#define _GNU_SOURCE
#include <sys/io.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
int
main (void)
{
for (int j = 0; j < 0xf; j+=2)
{
int i = ioperm (j, 1, 1);
assert_perror (errno);
assert (i == 0);
}
raise (SIGSEGV);
assert (0);
return 0;
}
Show replies by date
I merged the branch. Thanks for the fix!
Roland
Hi Roland,
On Thu, 11 Oct 2012 22:14:48 +0200, Roland McGrath wrote:
I merged the branch. Thanks for the fix!
sorry but the branch was FYI, not for merge.
It had ChangeLog only in its commit message - not in the file - to prevent
ChangeLog file conflicts.
I am not used to GIT with ChangeLog files.
Please fix up master as you find appropriate yourself.
Thanks,
Jan
sorry but the branch was FYI, not for merge.
It had ChangeLog only in its commit message - not in the file - to prevent
ChangeLog file conflicts.
Oops! Sorry, I should have noticed that.
Next time I'll leave the final commits/merges to the author.
I am not used to GIT with ChangeLog files.
Different people have different ways of dealing with it. Myself, I modify
ChangeLog in the normal (final) way and include that in the commit from the
start. With the gnulib git-merge-changelog tool, it's usually painless to
do rebases and merges and such. For posting patches, I use the scripts
that implement 'git show-gnu' for me. See
http://sourceware.org/ml/libc-alpha/2012-07/msg00543.html
and Mark's blog posting to which it points.
Please fix up master as you find appropriate yourself.
Done.
Thanks,
Roland