summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/xmltohb/xmltohb.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/targeting/xmltohb/xmltohb.pl')
-rwxr-xr-xsrc/usr/targeting/xmltohb/xmltohb.pl147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/usr/targeting/xmltohb/xmltohb.pl b/src/usr/targeting/xmltohb/xmltohb.pl
index c67532047..b69d1fe0d 100755
--- a/src/usr/targeting/xmltohb/xmltohb.pl
+++ b/src/usr/targeting/xmltohb/xmltohb.pl
@@ -182,6 +182,15 @@ if( !($cfgSrcOutputDir =~ "none") )
writeFapiPlatAttrMacrosHeaderFileContent($attributes,$fapiAttributes,$fapiPlatAttrMacrosHeaderFile);
writeFapiPlatAttrMacrosHeaderFileFooter ($fapiPlatAttrMacrosHeaderFile);
close $fapiPlatAttrMacrosHeaderFile;
+
+ #fixme-Remove when RTC:38197 is done
+ open(ATTR_DUMP_FILE,">$cfgSrcOutputDir"."attributedump.C")
+ or fatal ("Attribute dump file: \"$cfgSrcOutputDir"
+ . "attributedump.C\" could not be opened.");
+ my $dumpFile = *ATTR_DUMP_FILE;
+ writeDumpFile($attributes,$dumpFile);
+ close $dumpFile;
+
}
if( !($cfgImgOutputDir =~ "none") )
@@ -1300,6 +1309,142 @@ sub writeTraitFileFooter {
VERBATIM
}
+#fixme-Remove when RTC:38197 is done
+######
+#Create a .C file to dump all possible attributes
+#####
+sub writeDumpFile {
+ my($attributes,$outFile) = @_;
+
+ #First setup the includes and function definition
+ print $outFile "#include <targeting/targetservice.H>\n";
+ print $outFile "#include <stdio.h>\n";
+ print $outFile "\n";
+ print $outFile "namespace TARGETING\n";
+ print $outFile "{\n";
+ print $outFile " void dumpAllAttributes( trace_desc_t* i_trac )\n";
+ print $outFile " {\n";
+ print $outFile " using namespace TARGETING;\n";
+ print $outFile "\n";
+ print $outFile " TargetService& l_targetService = targetService();\n";
+ print $outFile "\n";
+ print $outFile " // Loop through every Target\n";
+ print $outFile " for( TargetIterator l_targ = l_targetService.begin();\n";
+ print $outFile " l_targ != l_targetService.end();\n";
+ print $outFile " ++l_targ )\n";
+ print $outFile " {\n";
+
+ # add the physical path first so we know where we are
+ print $outFile " { //Physical Path\n";
+ print $outFile " AttributeTraits<ATTR_PHYS_PATH>::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_PHYS_PATH>(tmp) ) {\n";
+ print $outFile " char* tmpstring = tmp.toString();\n";
+ print $outFile " TRACFCOMP( i_trac, \"DUMP: --ATTR_PHYS_PATH=%s--\", tmpstring );\n";
+ print $outFile " free(tmpstring);\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+
+ # loop through every attribute
+ foreach my $attribute (@{$attributes->{attribute}})
+ {
+ # skip write-only attributes
+ if(!(exists $attribute->{readable})) {
+ next;
+ }
+
+ # skip the PHYS_PATH that we already added
+ if( $attribute->{id} =~ /PHYS_PATH/ ) {
+ next;
+ }
+
+ # Enums have strings defined already, use them
+ if(exists $attribute->{simpleType} && (exists $attribute->{simpleType}->{enumeration}) ) {
+ print $outFile " { //simpleType:enum\n";
+ print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n";
+ print $outFile " const char* tmpstr = (*l_targ)->getAttrAsString<ATTR_",$attribute->{id},">();\n";
+ print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%s\", tmpstr );\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+ }
+ # signed ints dump as decimals
+ elsif(exists $attribute->{simpleType}
+ && ( (exists $attribute->{simpleType}->{int8_t}) ||
+ (exists $attribute->{simpleType}->{int16_t}) ||
+ (exists $attribute->{simpleType}->{int32_t}) ||
+ (exists $attribute->{simpleType}->{int64_t})
+ )
+ )
+ {
+ print $outFile " { //simpleType:int\n";
+ print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n";
+ print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%d\", tmp );\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+ }
+ # unsigned ints dump as hex
+ elsif(exists $attribute->{simpleType}
+ && ( (exists $attribute->{simpleType}->{uint8_t}) ||
+ (exists $attribute->{simpleType}->{uint16_t}) ||
+ (exists $attribute->{simpleType}->{uint32_t}) ||
+ (exists $attribute->{simpleType}->{uint64_t})
+ )
+ )
+ {
+ print $outFile " { //simpleType:uint\n";
+ print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n";
+ print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=0x%X\", tmp );\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+ }
+ # makes no sense to dump mutex attributes, so skipping
+ elsif(exists $attribute->{simpleType} && (exists $attribute->{simpleType}->{hbmutex}) ) {
+ print $outFile " //Skipping Mutex ",$attribute->{id},"\n";
+ }
+ # use the built-in stringifier for EntityPaths
+ elsif(exists $attribute->{nativeType} && ($attribute->{nativeType}->{name} eq "EntityPath")) {
+ print $outFile " { //nativeType:EntityPath\n";
+ print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n";
+ print $outFile " char* tmpstring = tmp.toString();\n";
+ print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%s\", tmpstring );\n";
+ print $outFile " free(tmpstring);\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+ }
+ # any other nativeTypes are just decimals... (I never saw one)
+ elsif(exists $attribute->{nativeType}) {
+ print $outFile " { //nativeType\n";
+ print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n";
+ print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%d\", tmp );\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+ }
+ # any complicated types just get dumped as raw hex binary
+ elsif(exists $attribute->{complexType}) {
+ print $outFile " { //complexType\n";
+ print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n";
+ print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n";
+ print $outFile " TRACFBIN( i_trac, \"DUMP: ",$attribute->{id},"=\", &tmp, sizeof(tmp) );\n";
+ print $outFile " }\n";
+ print $outFile " }\n";
+ }
+ # just in case, add a comment about missing types
+ else
+ {
+ print $outFile " //Skipping ",$attribute->{id},"\n";
+ }
+ }
+
+ print $outFile " }\n";
+ print $outFile " }\n";
+ print $outFile "}\n";
+ print $outFile "\n";
+}
+
sub UTILITY_FUNCTIONS { }
################################################################################
@@ -1311,6 +1456,8 @@ sub getAttributeIdEnumeration {
my $attributeValue = 0;
my $enumeration = { } ;
+
+ # add the N/A value
$enumeration->{description} = "Internal enum for attribute IDs\n";
$enumeration->{default} = "NA";
$enumeration->{enumerator}->[0]->{name} = "NA";
OpenPOWER on IntegriCloud