1
#############################################
2
# EcDoRpc Dump utility for mapitrace tool
3
# Copyright Julien Kerihuel 2007
4
# <j.kerihuel@openchange.org>
6
# released under the GNU GPL v3 or later
8
package MAPI::Dump_EcDoRpc;
13
use vars qw($AUTOLOAD $VERSION);
19
#######################################################
20
# convenient sort functions #
21
#######################################################
24
my ($aa) = $a =~ /(\d+)/;
25
my($bb) = $b =~ /(\d+)/;
32
#######################################################
33
# BRACE DUMPING FUNCTIONS
34
#######################################################
41
foreach my $key (sort asc_num (keys(%{$self->{BRACES_ERROR}}))) {
42
my $inout = $self->{BRACES_ERROR}->{$key}->{error};
44
print "[mapitrace] error in [$inout]: ";
45
print $self->{BRACES_ERROR}->{$key}->{$inout}->{filename} . "\n";
56
print MAPI::EcDoRpc->get_filename($in->{filename});
58
print MAPI::EcDoRpc->get_filename($out->{filename});
60
print "----------------------------------------------\n";
68
#######################################################
69
# DUMP FUNCTIONS FOR THE ANALYZE PART
70
#######################################################
73
# Dump the handles array from a request or response
81
print $self->{filename} . " :\n";
82
print "handles array (" . ($#handles + 1) . "):\n";
83
print "\t$_\n" foreach (@handles);
88
# Provides a dual dump view for the handle array
89
# both in request and response
91
# MAPI Semantic tells that request and response have the same
92
# number of handles elements
94
sub dump_brace_handles
97
my $mapi_call = shift;
99
my @handles_in = @{$mapi_call->{handles_in}};
100
my @handles_out = @{$mapi_call->{handles_out}};
102
print "handles array (" . ($#handles_in + 1) . "):\n";
103
for (my $i = 0; $handles_in[$i]; $i++) {
104
printf "\t[%.2x] %s -> %s\n", $i, $handles_in[$i], $handles_out[$i];
114
my $mapi_call = shift;
116
my $call_idx = shift;
119
my $in = $mapi_call->{calls}->{REQ};
120
my $out = $mapi_call->{calls}->{REPL};
125
$new_idx = MAPI::EcDoRpc->get_call_index($mapi_call, $call_idx);
126
printf "\t%s+-- [0x%.2x] [%s] (opnum = %s) %15s (handle_idx = %s) (child of %s)\n",
127
$space, hex($call_idx),
128
(exists $out->{$new_idx}->{retval}) ? $out->{$new_idx}->{retval}:'',
129
$in->{$call_idx}->{opnum}, $in->{$call_idx}->{opname},
130
$in->{$call_idx}->{handle_idx}, $in->{$key}->{opname};
132
$new_idx = MAPI::EcDoRpc->get_call_index($mapi_call, $key);
133
printf "\t[0x%.2x] [%s] (opnum = %s) %25s (handle_idx = %s) (self_handle_idx = %s)\n",
135
(exists $out->{$new_idx}->{retval}) ? $out->{$new_idx}->{retval} : '',
136
$in->{$key}->{opnum}, $in->{$key}->{opname},
137
$in->{$key}->{handle_idx},
138
$in->{$key}->{self_handle_idx};
145
# Since calls with self_handles have a smaller index than other calls relying on them
146
# When a parent value is > than the current idx, we can skip display the call.
147
# It should have normally been printing earlier when checking for call children
148
# Return -1 if we have an error
154
my $mapi_call = shift;
156
my $in = $mapi_call->{calls}->{REQ};
157
my $out = $mapi_call->{calls}->{REPL};
159
my $in_call_count = MAPI::EcDoRpc->get_mapi_calls_request_count($in);
161
if ($in_call_count != keys(%{$out})) {
162
print "[mapitrace] error: Oops seems like we have some trouble ...\n";
163
print "[mapitrace] error: Mismatch call count between request ($in_call_count) and response (". keys(%{$out}) .")\n";
167
printf "serialized mapi calls (count = %.2d):\n", $in_call_count;
168
foreach my $key (sort asc_num (keys(%{$in}))) {
169
if ($in->{$key}->{self_handle_idx}) {
170
# If this self_handle call has a child ;p
172
if (exists $in->{$key}->{parent}) {
175
dump_call($mapi_call, $key, 0, 0);
177
# Check if the call with self_handle_idx has children
178
# The dump will fail if we have Release call.
179
# In order to avoid this problem we use out instead
181
if ($in->{$key}->{children}) {
182
foreach my $call_idx (sort asc_num @{$in->{$key}->{children}}) {
183
dump_call($mapi_call, $key, $call_idx, $space);
188
if (exists $in->{$key}->{parent} && hex($in->{$key}->{parent}) < hex($key)) {
190
printf "\t[0x%.2x] [%s] (opnum = %s) %25s (handle_idx = %s)\n",
192
(exists $out->{$key}->{retval}) ? $out->{$key}->{retval}: '',
193
$in->{$key}->{opnum}, $in->{$key}->{opname}, $in->{$key}->{handle_idx};