Skip to contentSkip to conversation

Fix markup_oops.pl get error in x86

PATCH In review Hui Zhu 3 participants 7 messages Jan 6, 2010 – Jan 12, 2010

lore
Share & tools
lore

Hui Zhu

author
#0 lore raw

PATCH 1/1 Fix markup_oops.pl get error in x86

Hello,

When I try to use markup_oops.pl in x86, I always get:
cat 1 | perl markup_oops.pl ./vmlinux
objdump: --start-address: bad number: NaN
No matching code found
This is because in line:

	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/[a-f0-9]/) {

$function = $1;
$func_offset = $2;
}
$func_offset will get a number like "0x2"
But in follow code:
my $decodestart = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$func_offset");
It add other ox to ox2.
Then this value will be set to NaN.

So I make a small patch to fix it.

Best regards,
Hui

---
 scripts/markup_oops.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/markup_oops.pl +1 -1
@@ -154,7 +154,7 @@ while (<STDIN>) {
 	if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
 		$target = $1;
 	}
-	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/[a-f0-9]/) {
 		$function = $1;
 		$func_offset = $2;
 	}
#1 lore raw

scripts/markup_oops.pl while (<STDIN>) { · line 157

Quoted 12 lines · Hui Zhu

}
$func_offset will get a number like "0x2"
But in follow code:
my $decodestart = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$func_offset");
It add other ox to ox2.
Then this value will be set to NaN.

So I make a small patch to fix it.

scripts/markup_oops.pl +1 -1
-	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/[a-f0-9]/) {

I think this makes sense, but would you not also need to add "x" to the list of allowed characters?
so [a-f0-9x]
?

author
#2 lore raw
Quoted 17 lines · Arjan van de Ven
Quoted 9 lines · Hui Zhu

       }
$func_offset will get a number like "0x2"
But in follow code:
my $decodestart = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$func_offset");
It add other ox to ox2.
Then this value will be set to NaN.

Quoted 6 lines

So I make a small patch to fix it.

-       if ($line =~ /EIP is at
([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+       if ($line =~ /EIP is at
([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/[a-f0-9]/) {

Quoted 6 lines

I think this makes sense, but would you not also need to add "x" to the list of allowed characters?
so   [a-f0-9x]
?

Ah, sorry I make a mistake. I think the last 0x need be keep.

What about this version?

Thanks,
Hui

---
 scripts/markup_oops.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/markup_oops.pl +1 -1
@@ -154,7 +154,7 @@ while (<STDIN>) {
 	if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
 		$target = $1;
 	}
-	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
 		$function = $1;
 		$func_offset = $2;
 	}
#3 lore raw
Quoted 2 lines · Hui Zhu

What about this version?

looks great to me,

Quoted 19 lines

Thanks,
Hui

---
  scripts/markup_oops.pl |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/markup_oops.pl +1 -1
@@ -154,7 +154,7 @@ while (<STDIN>) {
  	if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
  		$target = $1;
  	}
-	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
  		$function = $1;
  		$func_offset = $2;
  	}
author
#4 lore raw

Thanks.

Hui

Quoted 31 lines · Arjan van de Ven
Quoted 2 lines · Hui Zhu

What about this version?

looks great to me,

Quoted 21 lines

Thanks,
Hui

---
 scripts/markup_oops.pl |    2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/markup_oops.pl +1 -1
@@ -154,7 +154,7 @@ while (<STDIN>) {
        if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
                $target = $1;
        }
-       if ($line =~ /EIP is at
 ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+       if ($line =~ /EIP is at
 ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
                $function = $1;

               $func_offset = $2;
       }

author
#5 lore raw

Sorry I forgot the Signed-off-by and CC in prev mail.

When I try to use markup_oops.pl in x86, I always get:
cat 1 | perl markup_oops.pl ./vmlinux
objdump: --start-address: bad number: NaN
No matching code found
This is because in line:

       if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/[a-f0-9]/) {
               $function = $1;
               $func_offset = $2;
       }

$func_offset will get a number like "0x2"
But in follow code:
my $decodestart = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$func_offset");
It add other 0x to 0x2.
Then this value will be set to NaN.
This patch will fix it.

CC Andrew Morton <[email protected]>
CC Arjan van de Ven <[email protected]>
CC Sam Ravnborg <[email protected]>
CC Ozan Çaglayan <[email protected]>
CC Matthew Wilcox <[email protected]>
---
 scripts/markup_oops.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/markup_oops.pl +1 -1
@@ -154,7 +154,7 @@ while (<STDIN>) {
 	if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
 		$target = $1;
 	}
-	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
+	if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
 		$function = $1;
 		$func_offset = $2;
 	}