hwid_tool: Improve debug output on HWID unmatch.

To provide complete information on what has been matched and why other data
failed, we should provide more messages for match results.

TEST=gooftool -v 4 verify_hwid

Change-Id: I2184b93c328c5f6c659755a311913e01b57ecdb7
Reviewed-on: https://gerrit.chromium.org/gerrit/24177
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Jay Kim <yongjaek@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
diff --git a/py/hwid_tool.py b/py/hwid_tool.py
index 9b39997..67042ce 100755
--- a/py/hwid_tool.py
+++ b/py/hwid_tool.py
@@ -536,6 +536,18 @@
   values where the index values correspond to existing board data that
   matches the probe results.
+  def CompareMaps(caption, map1, map2):
+    if all(map2.get(c, None) == v for c, v in map1.items()):
+      return True
+    # Try to provide more debug information
+    logging.debug('Unmatchd set: %s', caption)
+    logging.debug('---')
+    for c, v1 in map2.items():
+      v2 = map2.get(c, None)
+      logging.debug('%s: Expected="%s", Probed="%s" (%s)', c, v1, v2,
+                    'matched' if (v1 == v2) else 'UNMATCHED')
+    logging.debug('---')
   results = Obj(
@@ -554,13 +566,11 @@
       for c, v in probe_results.volatiles.items()
       if v in volatile_reference_map)
   for volatile_tag, volatile_map in device.volatile_map.items():
-    if (all(results.matched_volatiles.get(c, None) == v
-            for c, v in volatile_map.items())
+    if (CompareMaps(volatile_tag, volatile_map, results.matched_volatiles)
         and volatile_tag not in results.matched_volatile_tags):
-      results.matched_volatile_tags.append(volatile_tag)
+        results.matched_volatile_tags.append(volatile_tag)
   for initial_config_tag, ic_map in device.initial_config_map.items():
-    if (all(probe_results.initial_configs.get(ic_class, None) == ic_value
-           for ic_class, ic_value in ic_map.items())
+    if (CompareMaps(initial_config_tag, ic_map, probe_results.initial_configs)
         and initial_config_tag not in results.matched_initial_config_tags):
   return results