Motr
M0
debug.c
Go to the documentation of this file.
1
/* -*- C -*- */
2
/*
3
* Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
* For any questions about this software or licensing,
18
* please email opensource@seagate.com or cortx-questions@seagate.com.
19
*
20
*/
21
22
/*
23
M0_INTERNAL void m0_save_m0_xcode_type(int fd, char tab[], const struct m0_xcode_type *xf_type)
24
{
25
if (xf_type == NULL)
26
return;
27
int buffer_len = 4096;
28
char buffer[buffer_len] = {0};
29
int i = 0;
30
sprintf(buffer, "%sstruct m0_xcode_type: %p { \n", tab,xf_type);
31
write(fd, buffer, strlen(buffer));
32
sprintf(buffer, "\t%sxct_aggr: %d\n", tab, xf_type->xct_aggr);
33
write(fd, buffer, strlen(buffer));
34
sprintf(buffer, "\t%sxct_name: %s\n", tab, xf_type->xct_name);
35
write(fd, buffer, strlen(buffer));
36
sprintf(buffer, "\t%sxct_ops: %p\n", tab, xf_type->xct_ops);
37
write(fd, buffer, strlen(buffer));
38
sprintf(buffer, "\t%sxct_atype: %d\n", tab, xf_type->xct_atype);
39
write(fd, buffer, strlen(buffer));
40
sprintf(buffer, "\t%sxct_flags: %d\n", tab, xf_type->xct_flags);
41
write(fd, buffer, strlen(buffer));
42
sprintf(buffer, "\t%sxct_decor: %p\n", tab, xf_type->xct_decor);
43
write(fd, buffer, strlen(buffer));
44
sprintf(buffer, "\t%sxct_sizeof: %d\n", tab, (int)xf_type->xct_sizeof);
45
write(fd, buffer, strlen(buffer));
46
sprintf(buffer, "\t%sxct_nr: %d\n", tab, (int)xf_type->xct_nr);
47
write(fd, buffer, strlen(buffer));
48
49
for ( i = 0;i < (int)xf_type->xct_nr; i++) {
50
sprintf(buffer, "\t%sstruct m0_xcode_field: { \n", tab);
51
write(fd, buffer, strlen(buffer));
52
sprintf(buffer, "\t\t%sxf_name: %s\n", tab, xf_type->xct_child[i].xf_name);
53
write(fd, buffer, strlen(buffer));
54
55
strcat(tab,"\t");
56
m0_save_m0_xcode_type(fd, tab, xf_type->xct_child[i].xf_type);
57
58
sprintf(buffer, "\t\t%sxf_tag: %lu\n", tab, xf_type->xct_child[i].xf_tag);
59
write(fd, buffer, strlen(buffer));
60
sprintf(buffer, "\t\t%sxf_offset: %d\n", tab, xf_type->xct_child[i].xf_offset);
61
write(fd, buffer, strlen(buffer));
62
63
sprintf(buffer, "\t%s}\n", tab); //struct m0_xcode_field
64
write(fd, buffer, strlen(buffer));
65
}
66
67
sprintf(buffer, "%s}\n", tab); //struct m0_xcode_type
68
write(fd, buffer, strlen(buffer));
69
}
70
71
M0_INTERNAL void m0_save_m0_fol_rec(struct m0_fol_rec *rec, const char *prefix)
72
{
73
char filename[32] = {0};
74
int buffer_len = 4096;
75
char buffer[buffer_len] = {0};
76
int fd = 0;
77
static int fc = 0;
78
sprintf(filename, "/tmp/fol_rec_%s_%p_%d", prefix, rec, fc);
79
M0_ENTRY("m0_save_m0_fol_rec fol rec=%p\n ", rec);
80
++fc;
81
82
//open the file
83
fd = open(filename, O_WRONLY | O_CREAT);
84
if (fd == -1)
85
return;
86
87
//using m0_fol_rec_to_str
88
//int len = m0_fol_rec_to_str(rec, buffer, buffer_len);
89
//write(fd, buffer, len);
90
91
//fill the buffer and write buffer
92
sprintf(buffer, "\nstruct m0_fol_rec {\n");
93
write(fd, buffer, strlen(buffer));
94
sprintf(buffer, "\tm0_fol: %p\n", rec->fr_fol);
95
write(fd, buffer, strlen(buffer));
96
sprintf(buffer, "\tfr_tid: %lu\n", rec->fr_tid);
97
write(fd, buffer, strlen(buffer));
98
99
//struct m0_fol_rec_header
100
sprintf(buffer, "\tstruct m0_fol_rec_header {\n");
101
write(fd, buffer, strlen(buffer));
102
sprintf(buffer, "\t\trh_frags_nr: %u\n", rec->fr_header.rh_frags_nr);
103
write(fd, buffer, strlen(buffer));
104
sprintf(buffer, "\t\trh_data_len: %u\n", rec->fr_header.rh_data_len);
105
write(fd, buffer, strlen(buffer));
106
107
//struct m0_update_id
108
sprintf(buffer, "\t\tstruct m0_update_id {\n");
109
write(fd, buffer, strlen(buffer));
110
sprintf(buffer, "\t\t\tui_node: %u\n", rec->fr_header.rh_self.ui_node);
111
write(fd, buffer, strlen(buffer));
112
sprintf(buffer, "\t\t\tui_update: %lu\n", rec->fr_header.rh_self.ui_update);
113
write(fd, buffer, strlen(buffer));
114
sprintf(buffer, "\t\t}\n");
115
write(fd, buffer, strlen(buffer));
116
117
sprintf(buffer, "\t\trh_magic: %lu\n", rec->fr_header.rh_magic);
118
write(fd, buffer, strlen(buffer));
119
sprintf(buffer, "\t}\n");
120
write(fd, buffer, strlen(buffer));
121
122
sprintf(buffer, "\tfr_epoch: %p\n", rec->fr_epoch);
123
write(fd, buffer, strlen(buffer));
124
sprintf(buffer, "\tfr_sibling: %p\n", rec->fr_sibling);
125
write(fd, buffer, strlen(buffer));
126
127
//m0_fol_frag:rp_link to this list
128
struct m0_fol_frag *frag;
129
sprintf(buffer, "\tstruct m0_tl {\n");
130
m0_tl_for(m0_rec_frag, &rec->fr_frags, frag) {
131
sprintf(buffer, "\t\tstruct m0_fol_frag {\n");
132
write(fd, buffer, strlen(buffer));
133
sprintf(buffer, "\t\t\t struct m0_fol_frag_ops = %p {\n", frag->rp_ops);
134
write(fd, buffer, strlen(buffer));
135
sprintf(buffer, "\t\t\t\t struct m0_fol_frag_type : %p{\n", frag->rp_ops->rpo_type);
136
write(fd, buffer, strlen(buffer));
137
sprintf(buffer, "\t\t\t\t\trpt_index: %d\n", frag->rp_ops->rpo_type->rpt_index);
138
write(fd, buffer, strlen(buffer));
139
sprintf(buffer, "\t\t\t\t\trpt_name: %s\n", frag->rp_ops->rpo_type->rpt_name);
140
write(fd, buffer, strlen(buffer));
141
142
//const struct m0_xcode_type *rpt_xt;
143
char tab[100] = "\t\t\t\t\t";
144
m0_save_m0_xcode_type(fd, tab, frag->rp_ops->rpo_type->rpt_xt);
145
146
sprintf(buffer, "\t\t\t\t}\n");//struct m0_fol_frag_ops
147
write(fd, buffer, strlen(buffer));
148
sprintf(buffer, "\t\t\t}\n");
149
write(fd, buffer, strlen(buffer));
150
151
struct m0_fop_fol_frag *fp_frag = frag->rp_data;
152
sprintf(buffer, "\t\t\tstruct m0_fop_fol_frag: %p{\n", fp_frag);
153
write(fd, buffer, strlen(buffer));
154
sprintf(buffer, "\t\t\t\tffrp_fop_code: %d\n", fp_frag->ffrp_fop_code);
155
write(fd, buffer, strlen(buffer));
156
sprintf(buffer, "\t\t\t\tffrp_rep_code: %d\n", fp_frag->ffrp_rep_code);
157
write(fd, buffer, strlen(buffer));
158
struct m0_xcode_obj obj = {
159
//.xo_type = m0_fop_fol_frag_xc,
160
.xo_type = m0_cas_op_xc,
161
.xo_ptr = fp_frag->ffrp_fop
162
//.xo_ptr = frag->rp_data
163
};
164
//m0_xcode_print(&obj, buffer, buffer_len);
165
166
struct m0_cas_op *cas_op = fp_frag->ffrp_fop;
167
M0_LOG(M0_DEBUG, "m0_save rec: %p cas_op=%p ", rec, cas_op);
168
sprintf(buffer, "\t\t\t\tstruct m0_cas_op: %p {\n", cas_op);
169
write(fd, buffer, strlen(buffer));
170
sprintf(buffer, "\t\t\t\t\t\tfid:"FID_F"\n", FID_P(&cas_op->cg_id.ci_fid));
171
write(fd, buffer, strlen(buffer));
172
173
sprintf(buffer, "\t\t\t\t\tstruct m0_cas_recv: {\n");
174
write(fd, buffer, strlen(buffer));
175
sprintf(buffer, "\t\t\t\t\t\tcr_nr: %lu\n", cas_op->cg_rec.cr_nr);
176
write(fd, buffer, strlen(buffer));
177
int i=0;
178
for (i = 0; i < cas_op->cg_rec.cr_nr; i++) {
179
sprintf(buffer, "\n\t\t\t\t\t\tcr_key: %lu bytes ", cas_op->cg_rec.cr_rec[i].cr_key.u.ab_buf.b_nob);
180
write(fd, buffer, strlen(buffer));
181
write(fd, cas_op->cg_rec.cr_rec[i].cr_key.u.ab_buf.b_addr,
182
cas_op->cg_rec.cr_rec[i].cr_key.u.ab_buf.b_nob);
183
sprintf(buffer, "\n\t\t\t\t\t\tcr_val: %lu bytes ", cas_op->cg_rec.cr_rec[i].cr_val.u.ab_buf.b_nob);
184
write(fd, buffer, strlen(buffer));
185
write(fd, cas_op->cg_rec.cr_rec[i].cr_val.u.ab_buf.b_addr,
186
cas_op->cg_rec.cr_rec[i].cr_val.u.ab_buf.b_nob);
187
M0_LOG(M0_DEBUG, "op = %p key: %lu value=%lu ", cas_op, cas_op->cg_rec.cr_rec[i].cr_key.u.ab_buf.b_nob,
188
cas_op->cg_rec.cr_rec[i].cr_val.u.ab_buf.b_nob);
189
}
190
sprintf(buffer, "\n\t\t\t\t\t}\n"); //struct m0_cas_recv
191
write(fd, buffer, strlen(buffer));
192
193
sprintf(buffer, "\t\t\t\t\t\tcg_flags: %d\n", cas_op->cg_flags);
194
write(fd, buffer, strlen(buffer));
195
sprintf(buffer, "\t\t\t\t}\n"); //struct m0_cas_op
196
write(fd, buffer, strlen(buffer));
197
198
sprintf(buffer, "\t\t\t}\n"); //struct m0_fop_fol_frag
199
write(fd, buffer, strlen(buffer));
200
201
sprintf(buffer, "\t\t\trp_magic: %lu\n", frag->rp_magic);
202
write(fd, buffer, strlen(buffer));
203
sprintf(buffer, "\t\t\trp_flag: %d\n", frag->rp_flag);
204
write(fd, buffer, strlen(buffer));
205
206
sprintf(buffer, "\t\t}\n");
207
write(fd, buffer, strlen(buffer));
208
209
} m0_tl_endfor;
210
sprintf(buffer, "\t}\n");
211
212
//struct m0_fdmi_src_rec
213
sprintf(buffer, "\tstruct m0_fdmi_src_rec {\n");
214
write(fd, buffer, strlen(buffer));
215
sprintf(buffer, "\t\tfsr_magic: %lu\n",rec->fr_fdmi_rec.fsr_magic);
216
write(fd, buffer, strlen(buffer));
217
sprintf(buffer, "\t\tstruct *m0_fdmi_src fsr_src =%p{\n",rec->fr_fdmi_rec.fsr_src);
218
write(fd, buffer, strlen(buffer));
219
220
sprintf(buffer, "\t\t}\n");
221
write(fd, buffer, strlen(buffer));
222
223
sprintf(buffer, "\t\tfsr_rec_id:"U128X_F"\n",U128_P(&rec->fr_fdmi_rec.fsr_rec_id));
224
write(fd, buffer, strlen(buffer));
225
sprintf(buffer, "\t\tfsr_matched: %d\n",rec->fr_fdmi_rec.fsr_matched);
226
write(fd, buffer, strlen(buffer));
227
sprintf(buffer, "\t\tfsr_dryrun: %d\n",rec->fr_fdmi_rec.fsr_dryrun);
228
write(fd, buffer, strlen(buffer));
229
sprintf(buffer, "\t}\n");
230
write(fd, buffer, strlen(buffer));
231
232
sprintf(buffer, "}\n");
233
write(fd, buffer, strlen(buffer));
234
235
close(fd);
236
M0_LEAVE("fol rec ptr=%p\n", rec);
237
}
238
*/
239
fdmi
plugins
debug.c
Generated on Thu Apr 14 2022 14:02:55 for Motr by
1.8.14