2

I have huge code which has a bug and I have no knowledge of the code. The only thing I know is that when a particular input field is giiven a +ve value it generates correct output and is a -ve value is given an invalid output is generated. From the analysis of the output it was concluded that the issue could be due to improper initialization of a variable (garbage value). I believe the fastest way to resolve the issue would be the analysis of the variables present in the uncommon code of the two executions(success and failure). What I need now is a way to log the file name and line number of the code that was executed, in proper sequence. I'll be able to compare both the log files and determine the section of code that might have the bug. The code is in C and VS2010 is the available tool.

Thanks & Regards - Mustafa

Mustafa
  • 51
  • 7
  • What is wrong with `Console.WriteLine` in the files that you think are causing the problems? – Danny Jan 30 '13 at 15:53
  • 3
    @Danny Perhaps that it's not a C function, right? –  Jan 30 '13 at 15:57
  • @H2CO3 Wow. Really misread that question. I feel stupid now :( – Danny Jan 30 '13 at 16:50
  • Thank you guys for the replies. I think using trace points as suggested by Soundararajan with right set of commands will help me achieve what I want. – Mustafa Feb 01 '13 at 07:11

3 Answers3

2

While line and file are good:

__LINE__ - The line number

__FILE__ - The current file

The currently executing function is also very helpful:

__FUNCTION__ - The name of the current function

C.J.
  • 15,637
  • 9
  • 61
  • 77
1

There are some predefined macros that will help you out here like __FILE__ or __LINE__

junix
  • 3,161
  • 13
  • 27
0

Use the tracepoint feature of Visual studio. http://msdn.microsoft.com/en-us/library/232dxah7(v=VS.90).aspx

Soundararajan
  • 2,000
  • 21
  • 23
  • I believe i can use the tracepoints to achieve what i want. Have a trace point at every line in the code and make it print whatever that is required. – Mustafa Feb 01 '13 at 07:07
  • Thanks Everyone for your time and replies. Really appreciate it. Kindly let me know if there is a better solution. – Mustafa Feb 01 '13 at 07:08