Skip to content

Commit 8d376d2

Browse files
committed
WIP: recursive print causes seg fault at top level
1 parent 24eeecb commit 8d376d2

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

src/sst/core/impl/interactive/simpleDebug.cc

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -474,41 +474,34 @@ SimpleDebugger::cmd_print(std::vector<std::string>& tokens)
474474
// See if have a -r or not
475475
int recurse = 0;
476476
std::string tok = tokens[1];
477-
if ( tok.size() >= 2 && tok[0] == '-' && tok[1] == 'r' ) {
477+
if ( (tok.size() >= 2) && (tok[0] == '-') && (tok[1] == 'r') ) {
478478
// Got a -r
479-
std::string num = tok.substr(2);
480-
if ( num.size() != 0 ) {
481-
try {
482-
recurse = SST::Core::from_string<int>(num);
483-
}
484-
catch ( std::invalid_argument& e ) {
485-
printf("Invalid number format specified with -r: %s\n", tok.c_str());
486-
return;
479+
if (tok.size() == 2) {
480+
recurse = 4;
481+
} else {
482+
std::string num = tok.substr(2);
483+
if (num.size() != 0) {
484+
try {
485+
recurse = SST::Core::from_string<int>(num);
486+
}
487+
catch (std::invalid_argument& e) {
488+
printf("Invalid number format specified with -r: %s\n", tok.c_str());
489+
return;
490+
}
487491
}
488492
}
489-
else {
490-
recurse = 4; // default -r depth
491-
}
492-
493493
var_index = 2;
494494
}
495495

496-
if ( tokens.size() == var_index ) {
497-
// Print current object
498-
obj_->list(recurse);
499-
return;
500-
}
501-
502496
if ( tokens.size() != (var_index + 1) ) {
503497
printf("Invalid format for print command (print [-rN] [<obj>])\n");
504498
return;
505499
}
506500

507501
bool found;
508502
std::string listing = obj_->listVariable(tokens[var_index], found, recurse);
509-
510503
if ( !found ) {
511-
printf("Unknown object in print command: %s\n", tokens[1].c_str());
504+
printf("Unknown object in print command: %s\n", tokens[var_index].c_str());
512505
return;
513506
}
514507
else {

src/sst/core/serialization/objectMap.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,32 @@ ObjectMap::demangle_name(const char* name)
152152
std::string
153153
ObjectMap::listVariable(std::string name, bool& found, int recurse)
154154
{
155+
auto& vars = getVariables();
155156
ObjectMap* var = findVariable(name);
156157
if ( nullptr == var ) {
157158
found = false;
158159
return "";
159160
}
160161
found = true;
161162

163+
//printf("Found %s = true\n", name.c_str());
164+
162165
std::string ret;
163166

164167
// Check to see if this is a loopback
165168
if ( nullptr != var->mdata_ ) {
166169
// Found a loop
170+
//printf("Found a loop\n");
167171
ret = format_string("%s (%s) = <loopback>\n", name.c_str(), var->getType().c_str());
168172
return ret;
169173
}
174+
printf("Before Activate\n");
170175
var->activate(this, name);
176+
printf("After Activate\n");
171177
ret = var->listRecursive(name, 0, recurse);
178+
printf("Before Deactivate\n");
172179
var->deactivate();
180+
printf("After Deactivate\n");
173181
return ret;
174182
}
175183

@@ -186,10 +194,11 @@ ObjectMap::listRecursive(const std::string& name, int level, int recurse)
186194
std::string ret;
187195
std::string indent = std::string(level, ' ');
188196
if ( isFundamental() ) {
197+
printf("Is fundamental\n");
189198
ret = format_string("%s%s = %s (%s)\n", indent.c_str(), name.c_str(), get().c_str(), getType().c_str());
190199
return ret;
191200
}
192-
201+
//printf("Before format_string\n");
193202
ret = format_string("%s%s (%s)\n", indent.c_str(), name.c_str(), getType().c_str());
194203

195204
if ( level <= recurse ) {
@@ -200,9 +209,13 @@ ObjectMap::listRecursive(const std::string& name, int level, int recurse)
200209
"%s %s (%s) = <loopback>\n", indent.c_str(), x.first.c_str(), x.second->getType().c_str());
201210
}
202211
else {
212+
printf(" Before Recurse Activate %s\n", name.c_str());
203213
x.second->activate(this, name);
214+
printf(" After Recurse Activate\n");
204215
ret += x.second->listRecursive(x.first, level + 1, recurse);
216+
printf(" Before Recurse Deactivate\n");
205217
x.second->deactivate();
218+
printf(" After Recurse Deactivate\n");
206219
}
207220
}
208221
}

0 commit comments

Comments
 (0)