Skip to content

Commit

Permalink
x86 CPU flags fix; show socket:core and thread in proc list
Browse files Browse the repository at this point in the history
* Bug fix: Some flags are just an index, for example power
  management might have "[13] [14]" as flags. This looks like
  a new section to hardinfo shell and it truncates the CPU
  information there.
* Show the Socket:Core and thread in the processor list, for
  x86 only right now. In the future, the idea is to show only
  one line for each core, and list the threads on that core,
  where currently, there is one line for each thread.

Signed-off-by: Burt P <pburt0@gmail.com>
  • Loading branch information
bp0 authored and lpereira committed Nov 29, 2017
1 parent 9ea63eb commit 44c925e
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions modules/devices/x86/processor.c
Expand Up @@ -351,19 +351,27 @@ gchar *processor_get_capabilities_from_flags(gchar *strflags, gchar *lookup_pref
gchar tmp_flag[64] = ""; gchar tmp_flag[64] = "";
const gchar *meaning; const gchar *meaning;
gchar *tmp = NULL; gchar *tmp = NULL;
gint j = 0; gint j = 0, i = 0;


flags = g_strsplit(strflags, " ", 0); flags = g_strsplit(strflags, " ", 0);
old = flags; old = flags;


while (flags[j]) { while (flags[j]) {
sprintf(tmp_flag, "%s%s", lookup_prefix, flags[j]); if ( sscanf(flags[j], "[%d]", &i) ) {
meaning = x86_flag_meaning(tmp_flag); /* Some flags are indexes, like [13], and that looks like

* a new section to hardinfo shell */
if (meaning) { tmp = h_strdup_cprintf("(%s%d)=\n", tmp,
tmp = h_strdup_cprintf("%s=%s\n", tmp, flags[j], meaning); (lookup_prefix) ? lookup_prefix : "",
i );
} else { } else {
tmp = h_strdup_cprintf("%s=\n", tmp, flags[j]); sprintf(tmp_flag, "%s%s", lookup_prefix, flags[j]);
meaning = x86_flag_meaning(tmp_flag);

if (meaning) {
tmp = h_strdup_cprintf("%s=%s\n", tmp, flags[j], meaning);
} else {
tmp = h_strdup_cprintf("%s=\n", tmp, flags[j]);
}
} }
j++; j++;
} }
Expand Down Expand Up @@ -473,10 +481,13 @@ gchar *processor_get_info(GSList * processors)
for (l = processors; l; l = l->next) { for (l = processors; l; l = l->next) {
processor = (Processor *) l->data; processor = (Processor *) l->data;


tmp = g_strdup_printf("%s$CPU%d$%s=%.2f %s\n", tmp = g_strdup_printf("%s$CPU%d$%s=%.2f %s|%d:%d|%d\n",
tmp, processor->id, tmp, processor->id,
processor->model_name, processor->model_name,
processor->cpu_mhz, _("MHz")); processor->cpu_mhz, _("MHz"),
processor->cputopo->socket_id,
processor->cputopo->core_id,
processor->cputopo->id );


hashkey = g_strdup_printf("CPU%d", processor->id); hashkey = g_strdup_printf("CPU%d", processor->id);
moreinfo_add_with_prefix("DEV", hashkey, moreinfo_add_with_prefix("DEV", hashkey,
Expand All @@ -486,8 +497,10 @@ gchar *processor_get_info(GSList * processors)


ret = g_strdup_printf("[$ShellParam$]\n" ret = g_strdup_printf("[$ShellParam$]\n"
"ViewType=1\n" "ViewType=1\n"
"ColumnTitle$Extra1=%s\n"
"ColumnTitle$Extra2=%s\n"
"[Processors]\n" "[Processors]\n"
"%s", tmp); "%s", _("Socket:Core"), _("Thread" /*TODO: +s*/), tmp);
g_free(tmp); g_free(tmp);


return ret; return ret;
Expand Down

0 comments on commit 44c925e

Please sign in to comment.