Bug 242900 - Line numbers are offset, if any previous line exceeds 256 characters
Summary: Line numbers are offset, if any previous line exceeds 256 characters
Status: RESOLVED FIXED
Alias: None
Product: kcachegrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Josef Weidendorfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-26 21:31 UTC by Peter Toft
Modified: 2010-08-25 01:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Toft 2010-06-26 21:31:57 UTC
Version:           unspecified (using Devel) 
OS:                Linux

We were hacking with kcachegrind, and found a bug regarding long lines                                                                                              
which result in an offset when displaying the line numbers (and picking                                                       
the right lines to display). This gives a highly confusing code-review :-)                                                        
                                                                                                                              
We have packaged a small example from Ubuntu Lucid 10.04, where we compile                                                    
goat.c                                                                                                                        
$ gcc -g -o goat goat.c                                                                                                       
We run callgrind under valgrind                                                                                               
$ valgrind --tool=callgrind ./goat                                                                                            
We display the result                                                                                                         
$ kcachegrind callgrind.out.*                                                                                                 
                                                                                                                              
As you see the "hola" line-numbers are displaced relative to the original                                                     
source.                                                                                                                       
The problem originates from the long lines - which confuse the                                                                
display-unit of kcachegrind.                                                                                                  
As you see, when we exceed 256 characters, we have an offset of one line                                                      
for the remaining part of the code, and if we exceed 512, we get an offset of +2 lines. I.e. it seems that a counter is wrapping or alike.     

The root of the bug is                                                                                      
kcachegrind-0.4.6/kcachegrind/sourceview.cpp line 631, where                                                                  
you define buf[256]                          

Since Josef and I have discussed this offline, we have (thanx Josef)
found this patch, which we have verfied already.
Since the bug is highly annoying for any C/C++ code with long lines, we
would like to see this patched asap.



Reproducible: Always

Steps to Reproduce:
We have packaged a small example from Ubuntu Lucid 10.04, where we compile                                                    
goat.c          
$ wget http://petertoft.dk/kcachegrind/goat.c                                                                                                        
$ gcc -g -o goat goat.c                                                                                                       
We run callgrind under valgrind                                                                                               
$ valgrind --tool=callgrind ./goat                                                                                            
We display the result                                                                                                         
$ kcachegrind callgrind.out.*                                                                                                 
                                                                                                                              
As you see the "hola" line-numbers are displaced relative to the original                                                     
source.                                                                                                                       
The problem originates from the long lines - which confuse the                                                                
display-unit of kcachegrind.                                                                                                  
As you see at http://petertoft.dk/kcachegrind/Screenshot.png, when we exceed 256 characters, we have an offset of one line                                                      
for the remaining part of the code, and if we exceed 512, we get an offset of +2 lines. I.e. it seems that a counter is wrapping or alike.     

Actual Results:  
See http://petertoft.dk/kcachegrind/Screenshot.png

Expected Results:  
The print lines should be shown as lines 7,9, and 11

Josef is aware of the bug :)
Comment 1 Josef Weidendorfer 2010-08-25 01:27:35 UTC
Fixed in trunk r1167564 (KDE 4.6) and backported
to 4.5 branch r1167576 (KDE 4.5.1).