PC Review


Reply
Thread Tools Rate Thread

Debugging question wrt hex offsets

 
 
Glyn Meek
Guest
Posts: n/a
 
      20th Nov 2004
When one gets an error message of the format:

ArgumentException
Could not find resource assembly

Strings::Mid+0x2e
Opportunity::isYYYYMMDD+0X29F
Opportunity::XmlOpportunityProcess+0x260
PocketSalesManager::LoadTree+0x1ce
PSMLogo::PSMLogo_Load+0x3ba
Form::OnLoad+0x15
Form::_SetVisibleNotify+0x1d
Control::set_VisibleNotify+0x1f
Application::Run+0x7

what tools are available in the development/debug environment to tell me
which source code instruction corresponds to a hex offset such as :

Opportunity::isYYYYMMDD+0X29F

I can figure out which routine I am in, but cannot figure out how to get the
object code<->source code mappings anywhere. (I remember (back in the
day...LOL) when you could get printouts which would list source code down
the left hand side of those giant 11"x17" sheets of paper, and the generated
assembler code with offsets was listed down the right hand side along with
the hex machine code...ahhh, the good old days !)

Does anything like this exist for VB?

I can't reproduce this error in the debugger and go straight to the line in
error, because this was reported to me by a user and I cannot reporduce the
error but want to 'dig around' in the relevant code.

Thanks

Glyn


 
Reply With Quote
 
 
 
 
Alex Feinman
Guest
Posts: n/a
 
      20th Nov 2004
Glyn Meek wrote:
> When one gets an error message of the format:
>
> ArgumentException
> Could not find resource assembly
>
> Strings::Mid+0x2e
> Opportunity::isYYYYMMDD+0X29F
> Opportunity::XmlOpportunityProcess+0x260
> PocketSalesManager::LoadTree+0x1ce
> PSMLogo::PSMLogo_Load+0x3ba
> Form::OnLoad+0x15
> Form::_SetVisibleNotify+0x1d
> Control::set_VisibleNotify+0x1f
> Application::Run+0x7
>
> what tools are available in the development/debug environment to tell me
> which source code instruction corresponds to a hex offset such as :
>
> Opportunity::isYYYYMMDD+0X29F
>


If you use ildasm to open the module you will see the offsets on the
left. FOr example let's open Microsoft.VisualBasic.DLL and find the
method Strings::Mid

..method public hidebysig static string Mid(string str,
int32 Start,
int32 Length) cil managed
{
// Code size 119 (0x77)
.maxstack 3
.locals init (int32 V_0,
string V_1)
IL_0000: ldarg.1
IL_0001: ldc.i4.0
IL_0002: bgt.s IL_0018
IL_0004: ldc.i4.s -4
IL_0006: ldstr "Start"
IL_000b: call string
Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(int32,

string)
IL_0010: newobj instance void
[mscorlib]System.ArgumentException::.ctor(string)
IL_0015: throw
IL_0016: br.s IL_003f
IL_0018: ldarg.2
IL_0019: ldc.i4.0
IL_001a: bge.s IL_0030
IL_001c: ldc.i4.s -3
IL_001e: ldstr "Length"
IL_0023: call string
Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(int32,

string)
IL_0028: newobj instance void
[mscorlib]System.ArgumentException::.ctor(string)
IL_002d: throw
IL_002e: br.s IL_003f
IL_0030: ldarg.2
IL_0031: ldc.i4.0
IL_0032: beq.s IL_0037
IL_0034: ldarg.0
IL_0035: brtrue.s IL_003f
IL_0037: ldstr ""
IL_003c: stloc.1
IL_003d: br.s IL_0075
IL_003f: ldarg.0
IL_0040: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_0045: stloc.0
IL_0046: ldarg.1
IL_0047: ldloc.0
IL_0048: ble.s IL_0054
IL_004a: ldstr ""
IL_004f: stloc.1
IL_0050: br.s IL_0075
IL_0052: br.s IL_0075
IL_0054: ldarg.1
IL_0055: ldarg.2
IL_0056: add.ovf
IL_0057: ldloc.0
IL_0058: ble.s IL_0068
IL_005a: ldarg.0
IL_005b: ldarg.1
IL_005c: ldc.i4.1
IL_005d: sub.ovf
IL_005e: callvirt instance string
[mscorlib]System.String::Substring(int32)
IL_0063: stloc.1
IL_0064: br.s IL_0075
IL_0066: br.s IL_0075
IL_0068: ldarg.0
IL_0069: ldarg.1
IL_006a: ldc.i4.1
IL_006b: sub.ovf
IL_006c: ldarg.2
IL_006d: callvirt instance string
[mscorlib]System.String::Substring(int32,

int32)
IL_0072: stloc.1
IL_0073: br.s IL_0075
IL_0075: ldloc.1
IL_0076: ret
} // end of method Strings::Mid

As you can see from disassembly, the last instruction before IL_002e is
throw at IL_0028, which throws ArgumentException. In this particlular
case the exception is caused by the Length parameter = 0. In a similar
manner you could look inside your own module. Of course running it under
debugger might be easier, especially if you have debug symbols
 
Reply With Quote
 
Glyn Meek
Guest
Posts: n/a
 
      20th Nov 2004
ALEX...perfect. Dear god, I've been doing this since .net came out and
NEVER knew you could do this!!


My Thanks

Glyn



"Glyn Meek" <(E-Mail Removed)> wrote in message
news:24Bnd.480$(E-Mail Removed)...
> When one gets an error message of the format:
>
> ArgumentException
> Could not find resource assembly
>
> Strings::Mid+0x2e
> Opportunity::isYYYYMMDD+0X29F
> Opportunity::XmlOpportunityProcess+0x260
> PocketSalesManager::LoadTree+0x1ce
> PSMLogo::PSMLogo_Load+0x3ba
> Form::OnLoad+0x15
> Form::_SetVisibleNotify+0x1d
> Control::set_VisibleNotify+0x1f
> Application::Run+0x7
>
> what tools are available in the development/debug environment to tell me
> which source code instruction corresponds to a hex offset such as :
>
> Opportunity::isYYYYMMDD+0X29F
>
> I can figure out which routine I am in, but cannot figure out how to get
> the object code<->source code mappings anywhere. (I remember (back in the
> day...LOL) when you could get printouts which would list source code down
> the left hand side of those giant 11"x17" sheets of paper, and the
> generated assembler code with offsets was listed down the right hand side
> along with the hex machine code...ahhh, the good old days !)
>
> Does anything like this exist for VB?
>
> I can't reproduce this error in the debugger and go straight to the line
> in error, because this was reported to me by a user and I cannot reporduce
> the error but want to 'dig around' in the relevant code.
>
> Thanks
>
> Glyn
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Offsets Jon M. Microsoft Excel Programming 5 12th Feb 2010 05:54 PM
offsets (I think) Stan Microsoft Excel Misc 4 31st Jan 2010 04:48 PM
Cinditional formatting question - offsets Pete Rooney Microsoft Excel Misc 5 24th Apr 2008 05:07 PM
offsets - using ranges Theo Microsoft Excel Programming 3 25th Jan 2008 05:40 PM
Offsets =?Utf-8?B?RG9vbW5hdGlvbg==?= Microsoft Powerpoint 1 30th Aug 2007 04:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:48 PM.