diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-09-30 22:48:52 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-09-30 22:48:52 +0200 |
commit | dd675f3045c0b8fcce25e08134ce67ea38a62596 (patch) | |
tree | 7674e92339d6f0fb41224f9aff978dd3341812ec | |
parent | 4bca64c56977873d503304a2a7f30dd3c70ffcf2 (diff) | |
download | gdb-bt-reformat-dd675f3045c0b8fcce25e08134ce67ea38a62596.tar.gz gdb-bt-reformat-dd675f3045c0b8fcce25e08134ce67ea38a62596.tar.xz gdb-bt-reformat-dd675f3045c0b8fcce25e08134ce67ea38a62596.zip |
Print certain diagnostic to stderr incl. line number
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rwxr-xr-x | gdb-bt-reformat | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gdb-bt-reformat b/gdb-bt-reformat index 28461f5..2935ada 100755 --- a/gdb-bt-reformat +++ b/gdb-bt-reformat @@ -54,7 +54,7 @@ class BtLine(object): self._found = RE_BT.search(self._line) if self._found: for k, v in self._found.groupdict().iteritems(): - #print "\t{0}: {1}".format(k, v) + #print >>stderr, "\t{0}: {1}".format(k, v) setattr(self, k, v if v is not None else '') else: raise BtLineError(fill(line.strip(), initial_indent=self._space * 2, @@ -75,14 +75,20 @@ class BtLine(object): def main(**kwargs): line = '__dummy__' firstline = True - while line: + cnt = 1 + while line != '': + cnt += 1 line = stdin.readline() + if not line.strip(): + # unfortunately, textwrap.fill would alias, e.g., '\n' and '' cases + print line + continue try: btline = BtLine(line, **kwargs) print ('' if firstline else '\n') + str(btline) except BtLineError as ble: line = str(ble) - #print >>stderr, "bad line:", line + print >>stderr, ">> bad line:%i" % cnt print line finally: firstline = False |