|
-
May 27th, 2010, 10:06 AM
#1
Thread Starter
Frenzied Member
Verbose line output at runtime?
We need to start implementing verbose runtime output to assist with debugging on end users machines. If the executable is launched with a particular parameter, we need this to kick in.
This is not necessarily "error" logging, but runtime logging to see exactly which lines of code have been executed. We literally have to add an output line after each line of code in every function. Without question, this is extremely tedious.
I was hoping there might be a better way at doing this, such as possibly using reflection at runtime to somehow output which line of code in which module just completed.
I realize this is probably not possible, but I was hoping for any suggestions someone might have to accomplish this. Any help would be appreciated. Thanks!
-
May 27th, 2010, 10:13 AM
#2
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
Just another thought on this. An even better solution I think would be at the "application" level in which during the lifetime of the application, it is outputting everything it is doing, such as which method was just called, which line number in the method is executing, etc. Just not sure how something like this would be accomplished...
-
May 27th, 2010, 10:15 AM
#3
Re: Verbose line output at runtime?
if you don't find a better method using reflection, you could automate the process of inserting an output line after each line of code
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 27th, 2010, 10:36 AM
#4
Frenzied Member
Re: Verbose line output at runtime?
One thing I would ask myself is, is that really required. I am assuming your users are getting either errors or the application is locking up and you dont know why. Why not start on a smaller scale, put one output line for each function to just narrow down the problem. Once you identify that, maybe the problem will be easier to spot?
-
May 27th, 2010, 10:56 AM
#5
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
 Originally Posted by BrianS
One thing I would ask myself is, is that really required. I am assuming your users are getting either errors or the application is locking up and you dont know why. Why not start on a smaller scale, put one output line for each function to just narrow down the problem. Once you identify that, maybe the problem will be easier to spot?
I hear ya... However, my boss has required us to do this. He literally wants to output EVERY line of code if we have a "debug" flag set.
-
May 27th, 2010, 11:00 AM
#6
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
 Originally Posted by .paul.
if you don't find a better method using reflection, you could automate the process of inserting an output line after each line of code
Thought about that, however, my concern is with impact on performance because you would literally check before calling every one of these output statements to see if the application is in "debug" mode or not. So I really don't think that is feasible.
Seems like there much be some way to use reflection to output the current line of code.
-
May 27th, 2010, 11:25 AM
#7
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
 Originally Posted by .paul.
if you don't find a better method using reflection, you could automate the process of inserting an output line after each line of code
Okay, this may actually be feasible, IF the Trace.WriteLineIf method works the way I think it does. WriteLineIf takes as it's first parameter, a boolean value, which can be taken from a BooleanSwitch object which looks at the application's configuration file for a particular switch. If it is set to False, does it mean that WriteLineIf somehow doesn't get "compiled" at runtime? I guess my main concern here is that I don't want WriteLineIf to even get called if it is not needed...
-
May 27th, 2010, 11:31 AM
#8
Re: Verbose line output at runtime?
It gets compiled into the app ... the parameter isn't a compile condition... it gets compiled into the code. It's a shortcut for the following:
Code:
If condition = True Then
Debug.Writeline("Output this")
End If
It's used for the very cases you're looking at... based on some arbitrary value, output something (or don't).
Code:
Debug.WriteLineIf(someCondition,"This will get output if someCondition evaluated to True")
does the samethign as the If statement above, but condenses it to one line. (makes it easier to put in a bunch of them, or take a bunch out.
So... the question is, is what you are looking for is a conditional compiler condition? which will affect whether the code is there or not. OR, are you looking for something you can turn on or off at will at run-time?
-tg
-tg
-
May 27th, 2010, 11:35 AM
#9
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
It turns out that even doing something like:
Code:
For i as Integer = 1 to 10000
If ShouldOutput Then
DoSomething()
End If
Next
Returns in 0 milliseconds if ShouldOutput = False. I guess I just assumed the app would take a big hit constantly checking a boolean value in an If statement, but I guess it doesn't.
So now I just have to automate a way to make a call after EVERY line of code to some custom method.
-
May 27th, 2010, 11:36 AM
#10
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
 Originally Posted by techgnome
It gets compiled into the app ... the parameter isn't a compile condition... it gets compiled into the code. It's a shortcut for the following:
Code:
If condition = True Then
Debug.Writeline("Output this")
End If
It's used for the very cases you're looking at... based on some arbitrary value, output something (or don't).
Code:
Debug.WriteLineIf(someCondition,"This will get output if someCondition evaluated to True")
does the samethign as the If statement above, but condenses it to one line. (makes it easier to put in a bunch of them, or take a bunch out.
So... the question is, is what you are looking for is a conditional compiler condition? which will affect whether the code is there or not. OR, are you looking for something you can turn on or off at will at run-time?
-tg
-tg
It needs to be a run-time switch as we don't want to create to compiled versions.
-
May 27th, 2010, 11:37 AM
#11
Re: Verbose line output at runtime?
Would it be an option to simply install the IDE + source on the client's computer and just run it in debug? That would probably be much easier and quicker than writing an output line after every single line of code.. :\
-
May 27th, 2010, 11:50 AM
#12
Re: Verbose line output at runtime?
Would it be an option to simply install the IDE + source on the client's computer and just run it in debug?
as sensible as that may seem... that should never be an option. I'd staple your tongue to the desk for suggesting something like that. Here's why it doesn't work: 1) licensing. And not just the IDE, but potentially other libraries as well. 2) Still doesn't tell you where the app is and when... unless your user is going to sit and press F11 all day (and even *I* do that) 3) ... I forget what #3 was. 4) Your assumption is that there's an error that will reveal itself running in debug. What if there isn't but rather you're looking for code coverage by average users over a given period. 5) You expose your code.
dbassettt74 - I'd push back on that "requirement" it's foolish and non sensical. It's not going to add any value. And as I noted in #5 ... you're going to expose your code to your users. Not to mention it's simply a time waster. If you're interested, I can give you the name of a component that I use for logging purposes... you can have it log to SQL Server, Access, xml, flat files, etc... and it can be turned off an on at will... even in the middle of a logging session... it's also got stack capabilites... so you can PUSH XYZ function, the write out what that function is then POP it... the logging will show that it entered XYZ, and anything logged under that will be nicely indented, then on the POP, it shifts again (much like the indenting most of us prefer) ... so you could PUSH "If something = True Then" ... LOG "This is what I'm doing.... " then POP "If something = True" Anyways.... let me know if you're interested in it or not.
-tg
-
May 27th, 2010, 12:00 PM
#13
Thread Starter
Frenzied Member
Re: Verbose line output at runtime?
 Originally Posted by techgnome
as sensible as that may seem... that should never be an option. I'd staple your tongue to the desk for suggesting something like that. Here's why it doesn't work: 1) licensing. And not just the IDE, but potentially other libraries as well. 2) Still doesn't tell you where the app is and when... unless your user is going to sit and press F11 all day (and even *I* do that) 3) ... I forget what #3 was. 4) Your assumption is that there's an error that will reveal itself running in debug. What if there isn't but rather you're looking for code coverage by average users over a given period. 5) You expose your code.
dbassettt74 - I'd push back on that "requirement" it's foolish and non sensical. It's not going to add any value. And as I noted in #5 ... you're going to expose your code to your users. Not to mention it's simply a time waster. If you're interested, I can give you the name of a component that I use for logging purposes... you can have it log to SQL Server, Access, xml, flat files, etc... and it can be turned off an on at will... even in the middle of a logging session... it's also got stack capabilites... so you can PUSH XYZ function, the write out what that function is then POP it... the logging will show that it entered XYZ, and anything logged under that will be nicely indented, then on the POP, it shifts again (much like the indenting most of us prefer) ... so you could PUSH "If something = True Then" ... LOG "This is what I'm doing.... " then POP "If something = True" Anyways.... let me know if you're interested in it or not.
-tg
Sure, I'd like to take a look at it. Thanks.
-
May 27th, 2010, 01:35 PM
#14
Re: Verbose line output at runtime?
 Originally Posted by techgnome
as sensible as that may seem... that should never be an option. I'd staple your tongue to the desk for suggesting something like that. Here's why it doesn't work: 1) licensing. And not just the IDE, but potentially other libraries as well. 2) Still doesn't tell you where the app is and when... unless your user is going to sit and press F11 all day (and even *I* do that) 3) ... I forget what #3 was. 4) Your assumption is that there's an error that will reveal itself running in debug. What if there isn't but rather you're looking for code coverage by average users over a given period. 5) You expose your code.
I didn't mean to let the user experiment with the IDE for himself. I meant going to the user and doing it yourself, at their computer.
1) Licensing would still be a problem though yeah... VB express is probably not an option, but that might be used if possible.
2) Not the user no, but you I don't see how that is a problem; you're going to run into the exact same problem using the 'print every line' option, except that now you don't have an IDE but are browsing through potentially millions of lines of plain text...
4) See 2
5) Not if you do it yourself.
I agree it's a pretty last resort and wouldn't really work, but I think it's still a better option then printing a debug after every single line of code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|