Hello,
patch attached. Please consider to add the changes mainline. But
please also check back all changes.
Some comments:
  gdb/dwarf2-frame.c:
    - I think the buf += overwrites the ++, at least my tests with
      some test codes showed that.
  
  tools.c:
    - this is really strange, if index = 0, then the assignment
      doesn't make sense. If it's random, it also doesn't make sense.  :)
      Didn't have time to dig into the whole logic of this hashtable.
Regards,
 Bernhard