开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (29)
master
release_60
release_50
stable
testing
release_40
release_39
release_38
release_37
release_36
release_35
release_35@215010
release_34
release_33
release_32
release_31
release_30
release_29
release_28
release_27
master
分支 (29)
master
release_60
release_50
stable
testing
release_40
release_39
release_38
release_37
release_36
release_35
release_35@215010
release_34
release_33
release_32
release_31
release_30
release_29
release_28
release_27
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (29)
master
release_60
release_50
stable
testing
release_40
release_39
release_38
release_37
release_36
release_35
release_35@215010
release_34
release_33
release_32
release_31
release_30
release_29
release_28
release_27
llvm
/
utils
/
codegen-diff
llvm
/
utils
/
codegen-diff
codegen-diff 4.28 KB
一键复制 编辑 原始数据 按行查看 历史
Brian Gaeke 提交于 2003年10月17日 07:46 +08:00 . Add debug variable.
#!/usr/bin/perl
use Getopt::Std;
$DEBUG = 0;
sub parse_objdump_file {
my ($filename) = @_;
my @result;
open (INPUT, $filename) or die "$filename: $!\n";
print "opened objdump output file $filename\n" if $DEBUG;
while (<INPUT>) {
if (/\s*([0-9a-f]*):\t(([0-9a-f]{2} )+) *\t(.*)$/) {
my ($addr, $bytes, $instr) = ($1, $2, $4);
$addr = "0x" . $addr;
$bytes =~ s/\s*(.*\S)\s*/1ドル/; # trim any remaining whitespace
$instr =~ s/\s*(.*\S)\s*/1ドル/;
push (@result, {'addr' => $addr, 'bytes' => $bytes, 'instr' => $instr});
print "addr=$addr bytes='$bytes' instr='$instr'\n" if $DEBUG;
}
}
close INPUT;
return @result;
}
sub parse_gdb_file {
my ($filename) = @_;
my @result;
my $got_addr;
open (INPUT, $filename) or die "$filename: $!\n";
print "opened gdb output file $filename\n" if $DEBUG;
while (<INPUT>) {
if (/^(0x[0-9a-f]*):\t([^\t]*)\t[^:]*:\t((0x[0-9a-f]{2}\s*)+)\s*$/) {
my ($addr, $bytes, $instr) = ($1, $3, $2);
$bytes =~ s/0x//g;
$bytes =~ s/\s+/ /g; # regularize whitespace
$bytes =~ s/\s*(.*\S)\s*/1ドル/; # trim any remaining whitespace
$instr =~ s/\s*(.*\S)\s*/1ドル/;
push (@result, {'addr' => $addr, 'bytes' => $bytes, 'instr' => $instr});
print "addr=$addr bytes='$bytes' instr='$instr'\n" if $DEBUG;
} elsif (/^(0x[0-9a-f]*):\t$/) { # deal with gdb's line breaker
$got_addr = $1;
} elsif ($got_addr && /^ ([^\t]*)\t[^:]*:\t((0x[0-9a-f]{2}\s*)+)\s*$/) {
my ($addr, $bytes, $instr) = ($got_addr, $2, $1);
$bytes =~ s/0x//g;
$bytes =~ s/\s+/ /g; # regularize whitespace
$bytes =~ s/\s*(.*\S)\s*/1ドル/; # trim any remaining whitespace
$instr =~ s/\s*(.*\S)\s*/1ドル/;
push (@result, {'addr' => $addr, 'bytes' => $bytes, 'instr' => $instr});
print "addr=$addr bytes='$bytes' instr='$instr'\n" if $DEBUG;
undef $got_addr;
}
}
close INPUT;
return @result;
}
sub binary_diffs {
my ($objdump_file, $gdb_file) = @_;
my @file1 = parse_objdump_file ($objdump_file);
my @file2 = parse_gdb_file ($gdb_file);
my $lastrecord = ($#file1 >= $#file2) ? ($#file1) : ($#file2);
for (my $i = 0; $i <= $lastrecord; ++$i) {
my $d1 = $file1[$i];
my $d2 = $file2[$i];
if ($d1->{'bytes'} ne $d2->{'bytes'}) {
next if (($d1->{'instr'} eq $d2->{'instr'}) && $opt_d);
printf "0x%08x:\t%30s \t%s\n", 0+$d1->{'addr'}, $d1->{'bytes'}, $d1->{'instr'};
printf "0x%08x:\t%30s \t%s\n\n", 0+$d2->{'addr'}, $d2->{'bytes'}, $d2->{'instr'};
}
}
}
&getopts('d');
$objdump_file = $ARGV[0];
$gdb_file = $ARGV[1];
binary_diffs ($objdump_file, $gdb_file);
exit (0);
__END__
=pod
=head1 NAME
codegen-diff
=head1 SYNOPSIS
codegen-diff [-d] I<OBJDUMP-OUTPUT-FILE> I<GDB-DISASSEMBLY-FILE>
=head1 DESCRIPTION
B<codegen-diff> is a program that tries to show you the differences
between the code that B<llc> generated and the code that B<lli> generated.
The way you use it is as follows: first, you create I<OBJDUMP-OUTPUT-FILE>
by running B<objdump> on the B<llc> compiled and linked binary. You need to
trim down the result so it contains only the function of interest.
Second, you create I<GDB-DISASSEMBLY-FILE> by running B<gdb>, with my patch
to print out hex bytes in the B<disassemble> command output, on
B<lli>. Set a breakpoint in C<Emitter::finishFunction()> and wait until
the function you want is compiled. Then use the B<disassemble> command
to print out the assembly dump of the function B<lli> just compiled.
(Use C<lli -debug> to find out where the function starts and ends in memory.)
It's easiest to save this output by using B<script>.
Finally, you run B<codegen-diff>, as indicated in the Synopsis section of
this manpage. It will print out a two-line stanza for each mismatched
instruction, with the B<llc> version first, and the B<lli> version second.
=head1 OPTIONS
=over 4
=item -d
Don't show instructions where the bytes are different but they
disassemble to the same thing. This puts a lot of trust in the
disassembler, but it might help you highlight the more egregious cases
of misassembly.
=back
=head1 AUTHOR
B<codegen-diff> was written by Brian Gaeke.
=head1 SEE ALSO
L<gdb(1)>, L<objdump(1)>, L<script(1)>.
You will need my B<gdb> patch:
http://llvm.cs.uiuc.edu/~gaeke/gdb-disassembly-print-bytes.patch
=cut
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

暂无描述
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/treert/llvm.git
git@gitee.com:treert/llvm.git
treert
llvm
llvm
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /