@@ -28,9 +28,11 @@ void printUsage()
28
28
{
29
29
SWSS_LOG_ENTER ();
30
30
31
- std::cout << " Usage: saidump [-t] [-h]" << std::endl;
31
+ std::cout << " Usage: saidump [-t] [-g] [- h]" << std::endl;
32
32
std::cout << " -t --tempView:" << std::endl;
33
33
std::cout << " Dump temp view" << std::endl;
34
+ std::cout << " -g --dumpGraph:" << std::endl;
35
+ std::cout << " Dump current graph" << std::endl;
34
36
std::cout << " -h --help:" << std::endl;
35
37
std::cout << " Print out this message" << std::endl;
36
38
}
@@ -160,7 +162,10 @@ void print_attributes(size_t indent, const TableMap& map)
160
162
}
161
163
}
162
164
163
- #define SAI_OBJECT_TYPE_PREFIX_LEN 16
165
+ // colors are in HSV
166
+ #define GV_ARROW_COLOR " 0.650 0.700 0.700"
167
+ #define GV_ROOT_COLOR " 0.650 0.200 1.000"
168
+ #define GV_NODE_COLOR " 0.650 0.500 1.000"
164
169
165
170
void dumpGraph (const TableDump& td)
166
171
{
@@ -170,8 +175,8 @@ void dumpGraph(const TableDump& td)
170
175
std::map<sai_object_type_t ,const sai_object_type_info_t *> typemap;
171
176
172
177
std::cout << " digraph \" SAI Object Dependency Graph\" {" << std::endl;
173
- std::cout << " size= \" 30,12\" ; ratio = fill;" << std::endl;
174
- std::cout << " node [style= filled];" << std::endl;
178
+ std::cout << " size = \" 30,12\" ; ratio = fill;" << std::endl;
179
+ std::cout << " node [ style = filled ];" << std::endl;
175
180
176
181
// build object type map first
177
182
@@ -202,6 +207,8 @@ void dumpGraph(const TableDump& td)
202
207
std::set<sai_object_type_t > ref;
203
208
std::set<sai_object_type_t > attrref;
204
209
210
+ #define SAI_OBJECT_TYPE_PREFIX_LEN (sizeof (" SAI_OBJECT_TYPE_" ) - 1 )
211
+
205
212
for (const auto & key: td)
206
213
{
207
214
sai_object_meta_key_t meta_key;
@@ -231,7 +238,7 @@ void dumpGraph(const TableDump& td)
231
238
232
239
ss << std::string (member_info->objecttypename + SAI_OBJECT_TYPE_PREFIX_LEN) << " -> "
233
240
<< std::string (info->objecttypename + SAI_OBJECT_TYPE_PREFIX_LEN)
234
- << " [color=\" 0.650 0.700 0.700 \" , style = dashed, penwidth=2 ]" ;
241
+ << " [ color=\" " << GV_ARROW_COLOR << " \" , style = dashed, penwidth = 2 ]" ;
235
242
236
243
std::string link = ss.str ();
237
244
@@ -261,7 +268,7 @@ void dumpGraph(const TableDump& td)
261
268
262
269
sai_deserialize_attr_value (field.second , *meta, attr, false );
263
270
264
- sai_object_list_t list = {0 , NULL };
271
+ sai_object_list_t list = { 0 , NULL };
265
272
266
273
switch (meta->attrvaluetype )
267
274
{
@@ -322,7 +329,7 @@ void dumpGraph(const TableDump& td)
322
329
323
330
ss << std::string (attr_oid_info->objecttypename + SAI_OBJECT_TYPE_PREFIX_LEN) << " -> "
324
331
<< std::string (info->objecttypename + SAI_OBJECT_TYPE_PREFIX_LEN)
325
- << " [color= \" 0.650 0.700 0.700 \" ]" ;
332
+ << " [ color = \" " << GV_ARROW_COLOR << " \" ]" ;
326
333
327
334
std::string link = ss.str ();
328
335
@@ -347,36 +354,44 @@ void dumpGraph(const TableDump& td)
347
354
348
355
if (info->isnonobjectid )
349
356
{
350
- std::cout << name << " [color=plum, shape = rect];\n " ;
357
+ /* non object id leafs */
358
+
359
+ std::cout << name << " [ color = plum, shape = rect ];\n " ;
351
360
continue ;
352
361
}
353
362
354
363
if (ref.find (ot) != ref.end () && attrref.find (ot) != attrref.end ())
355
364
{
356
- std::cout << name << " [color=\" 0.650 0.500 1.000\" ];\n " ;
365
+ /* middle nodes */
366
+
367
+ std::cout << name << " [ color =\" " << GV_NODE_COLOR << " \" ];\n " ;
357
368
continue ;
358
369
}
359
370
360
371
if (ref.find (ot) != ref.end () && attrref.find (ot) == attrref.end ())
361
372
{
362
- std::cout << name << " [color=\" 0.355 0.563 1.000\" , shape = rect];\n " ;
373
+ /* leafs */
374
+
375
+ std::cout << name << " [ color = palegreen, shape = rect ];\n " ;
363
376
continue ;
364
377
}
365
378
366
379
if (ref.find (ot) == ref.end () && attrref.find (ot) != attrref.end ())
367
380
{
368
- std::cout << name << " [color=\" 0.650 0.200 1.000\" ];\n " ;
381
+ /* roots */
382
+
383
+ std::cout << name << " [ color = \" " << GV_ROOT_COLOR << " \" ];\n " ;
369
384
continue ;
370
385
}
371
386
372
387
/* objects which are there but not referenced nowhere for example STP */
373
388
374
- std::cout << name << " [color= \" 0.650 0.200 1.000 \" shape= rect];\n " ;
389
+ std::cout << name << " [ color = \" " << GV_ROOT_COLOR << " \" , shape = rect ];\n " ;
375
390
}
376
391
377
- std::cout << " SWITCH -> PORT[ dir= \" none\" , color= \" red\" , peripheries = 2, penwidth=2.0 , style = dashed ];" <<std::endl;
378
- std::cout << " SWITCH [color= orange, shape = parallelogram, peripheries = 2];" <<std::endl;
379
- std::cout << " PORT [color= gold, shape = diamond, peripheries=2 ];" << std::endl;
392
+ std::cout << " SWITCH -> PORT [ dir = none, color = red, peripheries = 2, penwidth = 2 , style = dashed ];" << std::endl;
393
+ std::cout << " SWITCH [ color = orange, fillcolor = orange, shape = parallelogram, peripheries = 2 ];" << std::endl;
394
+ std::cout << " PORT [ color = gold, shape = diamond, peripheries = 2 ];" << std::endl;
380
395
std::cout << " }" << std::endl;
381
396
}
382
397
0 commit comments