Skip to content

Commit 14ab4ed

Browse files
committed
core: improve insertion error messages
Add subtype if any, display group kind/subkind (useful for finding where the existing conflicting group came from). Also cleanup the code a bit to factorize conditionals about fields to show or not. Signed-off-by: Brice Goglin <[email protected]>
1 parent d62dbd8 commit 14ab4ed

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

hwloc/topology.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,24 @@ report_insert_error_format_obj(char *buf, size_t buflen, hwloc_obj_t obj)
146146
char typestr[64];
147147
char *cpusetstr;
148148
char *nodesetstr = NULL;
149+
char indexstr[64] = "";
150+
char groupstr[64] = "";
149151

150152
hwloc_obj_type_snprintf(typestr, sizeof(typestr), obj, 0);
151153
hwloc_bitmap_asprintf(&cpusetstr, obj->cpuset);
154+
if (obj->os_index != HWLOC_UNKNOWN_INDEX)
155+
snprintf(indexstr, sizeof(indexstr), "P#%u ", obj->os_index);
156+
if (obj->type == HWLOC_OBJ_GROUP)
157+
snprintf(groupstr, sizeof(groupstr), "groupkind %u-%u ", obj->attr->group.kind, obj->attr->group.subkind);
152158
if (obj->nodeset) /* may be missing during insert */
153159
hwloc_bitmap_asprintf(&nodesetstr, obj->nodeset);
154-
if (obj->os_index != HWLOC_UNKNOWN_INDEX)
155-
snprintf(buf, buflen, "%s (P#%u cpuset %s%s%s)",
156-
typestr, obj->os_index, cpusetstr,
157-
nodesetstr ? " nodeset " : "",
158-
nodesetstr ? nodesetstr : "");
159-
else
160-
snprintf(buf, buflen, "%s (cpuset %s%s%s)",
161-
typestr, cpusetstr,
162-
nodesetstr ? " nodeset " : "",
163-
nodesetstr ? nodesetstr : "");
160+
snprintf(buf, buflen, "%s (%s%s%s%s%scpuset %s%s%s)",
161+
typestr,
162+
indexstr,
163+
obj->subtype ? "subtype " : "", obj->subtype ? obj->subtype : "", obj->subtype ? " " : "",
164+
groupstr,
165+
cpusetstr,
166+
nodesetstr ? " nodeset " : "", nodesetstr ? nodesetstr : "");
164167
free(cpusetstr);
165168
free(nodesetstr);
166169
}
@@ -178,8 +181,9 @@ static void report_insert_error(hwloc_obj_t new, hwloc_obj_t old, const char *ms
178181
fprintf(stderr, "****************************************************************************\n");
179182
fprintf(stderr, "* hwloc %s received invalid information from the operating system.\n", HWLOC_VERSION);
180183
fprintf(stderr, "*\n");
181-
fprintf(stderr, "* Failed with: %s\n", msg);
182-
fprintf(stderr, "* while inserting %s at %s\n", newstr, oldstr);
184+
fprintf(stderr, "* Failed with error: %s\n", msg);
185+
fprintf(stderr, "* while inserting %s\n", newstr);
186+
fprintf(stderr, "* at %s\n", oldstr);
183187
fprintf(stderr, "* coming from: %s\n", reason);
184188
fprintf(stderr, "*\n");
185189
fprintf(stderr, "* The following FAQ entry in the hwloc documentation may help:\n");

0 commit comments

Comments
 (0)