Skip to content

Commit 83ca300

Browse files
committed
Merge branch 'master' into 1984-threadbase-intermittently-hangs-in-join_thread
2 parents b7c6997 + cad3417 commit 83ca300

File tree

7 files changed

+71
-5
lines changed

7 files changed

+71
-5
lines changed

include/trick/attributes.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define TRICK_CHKPNT_OUTPUT 0x04
1515
#define TRICK_CHKPNT_INPUT 0x08
1616
#define TRICK_MODS_UNITSDASHDASH 0x04
17+
#define TRICK_ENUM_UNSIGNED 0x40000000
1718

1819
#define TRICK_MAX_INDEX 8
1920

@@ -33,7 +34,8 @@ typedef struct {
3334

3435
const char *label; /**< -- Enumeration label */
3536
int value; /**< -- Enumeration value */
36-
int mods; /**< -- bit 32 = deprecated var */
37+
int mods; /**< -- bit 31 = deprecated var
38+
bit 30 = unsigned enum underlying type (0x40000000) */
3739

3840
} ENUM_ATTR;
3941

trick_source/codegen/Interface_Code_Gen/EnumValues.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "EnumValues.hh"
55

6-
EnumValues::EnumValues() : has_definition(true) {}
6+
EnumValues::EnumValues() : has_definition(true), is_unsigned(false) {}
77

88
void EnumValues::addEnum( std::string in_name , long long in_val ) {
99
std::pair< std::string , long long > new_enum(in_name, in_val) ;
@@ -24,6 +24,14 @@ bool EnumValues::getHasDefinition() {
2424
return has_definition ;
2525
}
2626

27+
void EnumValues::setIsUnsigned( bool in ) {
28+
is_unsigned = in ;
29+
}
30+
31+
bool EnumValues::getIsUnsigned() {
32+
return is_unsigned ;
33+
}
34+
2735
std::ostream & operator << (std::ostream & ostream , EnumValues & ev ) {
2836
ostream << " name = " << ev.name << std::endl ;
2937
ostream << " file_name = " << ev.file_name << std::endl ;

trick_source/codegen/Interface_Code_Gen/EnumValues.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class EnumValues : public ConstructValues {
3636
void setHasDefinition( bool in ) ;
3737
bool getHasDefinition() ;
3838

39+
void setIsUnsigned( bool in ) ;
40+
bool getIsUnsigned() ;
41+
3942
const std::vector<NameValuePair>& getPairs() {
4043
return enum_values;
4144
}
@@ -57,6 +60,9 @@ class EnumValues : public ConstructValues {
5760

5861
bool has_definition ;
5962

63+
/** Is the enum unsigned? */
64+
bool is_unsigned;
65+
6066
} ;
6167

6268
#endif

trick_source/codegen/Interface_Code_Gen/EnumVisitor.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ bool EnumVisitor::VisitType(clang::Type *t) {
2828

2929
bool EnumVisitor::VisitEnumDecl(clang::EnumDecl *ed) {
3030
eval.setFileName(getFileName(ci , ed->RBRACELOC(), hsd)) ;
31+
32+
// Get the underlying type of the enum regardless of whether it's fixed or not
33+
clang::QualType underlying_type = ed->getIntegerType();
34+
if (underlying_type.isNull()) {
35+
// Fallback to the default int type (non-null QualType) if underlying type is null
36+
underlying_type = ci.getASTContext().IntTy;
37+
}
38+
// Check if the explicit or implicit underlying type is unsigned
39+
bool is_unsigned = underlying_type->isUnsignedIntegerType();
40+
eval.setIsUnsigned(is_unsigned);
41+
42+
if (debug_level >= 3) {
43+
// Print explicit if isFixed(), implicit if not
44+
const std::string ex_im = ed->isFixed()? "explicit" : "implicit";
45+
46+
std::cout << "EnumDecl debug: name=\"" << ed->getName().str()
47+
<< "\" qname=\"" << ed->getQualifiedNameAsString() << "\""
48+
<< " scoped=" << (ed->isScoped()? "true":"false")
49+
<< " fixed=" << (ed->isFixed()? "true":"false")
50+
<< " " << ex_im << "_underlying=\"" << underlying_type.getAsString() << "\""
51+
<< " unsigned=" << (is_unsigned? "true":"false")
52+
<< std::endl;
53+
}
54+
3155
return true;
3256
}
3357

trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,17 @@ void FieldDescription::parseComment(std::string comment) {
291291

292292
// The rest of the comment is the description of the variable.
293293

294-
// remove the c comment end marker.
295-
comment = get_regex_field(comment , "(.*)\\*/" , 1) ;
294+
// remove the c comment end marker if present.
295+
// don't overwrite the comment with an empty string
296+
// when there is no "*/" (e.g. // (var_unit) var description)
297+
// to preserve the description of the variable.
298+
// get_regex_field returns an empty string on no match.
299+
{
300+
std::string tmp = get_regex_field(comment , "(.*)\\*/" , 1) ;
301+
if ( ! tmp.empty() ) {
302+
comment = tmp ;
303+
}
304+
}
296305

297306
// posix c regular expressions are terrible. the regexes above will leave "@" signs because
298307
// the regular expressions are so greedy.

trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ void PrintFileContents10::print_enum_attr(std::ostream & ostream , EnumValues *
4646
print_open_extern_c(ostream) ;
4747
ostream << "ENUM_ATTR enum" << e->getFullyQualifiedTypeName("__") << "[] = {\n" ;
4848
std::string name = e->getNamespacesAndContainerClasses();
49+
50+
// Determine mods value based on enum signedness
51+
// unsigned enum = 0x40000000 (bit 30)
52+
unsigned int mods_value = 0x0;
53+
if (e->getIsUnsigned()) {
54+
mods_value = 0x40000000; // Set unsigned enum flag
55+
}
56+
57+
// Print enum attributes in the form:
58+
// if unsigned {"name", value, 0x40000000}
59+
// if signed {"name", value, 0x0}
4960
for (auto& pair : e->getPairs()) {
50-
ostream << "{\"" << name << pair.first << "\", " << pair.second << ", 0x0},\n" ;
61+
ostream << "{\"" << name << pair.first << "\", " << pair.second << ", 0x"
62+
<< std::hex << mods_value << std::dec << "},\n" ;
5163
}
5264
ostream << "{\"\", 0, 0x0}\n};\n" ;
5365
print_close_extern_c(ostream) ;

trick_source/sim_services/CheckPointAgent/ClassicCheckPointerAgent.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ static int getCompositeSubReference(
322322
}
323323
/*if member is an unarrayed struct, continue to call getCompositeSubReference.*/
324324
if (Ai->num_index == 0) {
325+
/* if left_type specifies the current member, stop here */
326+
if ( (left_type != NULL) && (*left_type != NULL) && (Ai->attr == (*left_type)->attr)) {
327+
return 0;
328+
}
329+
325330
char buf[256];
326331
ret = getCompositeSubReference( rAddr, left_type, sAddr + Ai->offset, (ATTRIBUTES *) Ai->attr, buf);
327332

0 commit comments

Comments
 (0)