-------- Original-Nachricht --------
> Datum: Wed, 21 Mar 2012 10:46:41 +1300
> Von: Daniel Beer <dlb...@gmail.com>
> An: "qbert biker" <qbe...@gmx.de>
> CC: mspgcc-users@lists.sourceforge.net
> Betreff: Re: [Mspgcc-users] mspdebug tilib v3 update error

> At Mon, 19 Mar 2012 15:18:28 +0100, qbert biker wrote:
> > > That's correct, although the patch you've linked to may not work
> > > correctly for 64-bit systems. A better fix would be to change the
> > > argument type of getTiFileBytes from size_t * to uint32_t *.
> > 
> > I'm very late but I just discovered this discussion. 
> > The patch was created to support 64 Bit and works fine with
> > my 64 Bit machines. If a 32-Bit system is used, the patch 
> > may be unnecessary. 
> 
> Hi Hubert,
> 
> The reason for my comment above was that on amd64, size_t is a 64-bit
> type. So, if you cast segment.size (which is of type uint32_t) instead
> of changing the argument type, you end up with getTiFileBytes writing
> 8 bytes to a memory location for which only 4 bytes are guaranteed to
> be allocated.
> 
> You're correct that this does appear to work, but this is due to the
> fact that (a) amd64 is little-endian, so the lower 32 bits end up in
> the right place anyway, and (b) segment.size is located at the very
> end of the object, which is heap-allocated and probably contains a bit
> of unused padding which can be trashed without consequence.
> 
> This fix may not work if the class layout is altered. What I'd suggest
> is something like the following:
> 
> ---
>  DLL430_v3/src/TI/DLL430/FileFuncImpl.cpp |    2 +-
>  DLL430_v3/src/TI/DLL430/FileFuncImpl.h   |    2 +-
>  DLL430_v3/src/TI/DLL430/HalResponse.h    |    1 +
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/DLL430_v3/src/TI/DLL430/FileFuncImpl.cpp
> b/DLL430_v3/src/TI/DLL430/FileFuncImpl.cpp
> index 95877ab..79e3cb1 100644
> --- a/DLL430_v3/src/TI/DLL430/FileFuncImpl.cpp
> +++ b/DLL430_v3/src/TI/DLL430/FileFuncImpl.cpp
> @@ -199,7 +199,7 @@ bool FileFuncImpl::getTiFileAddress(const string&
> record, uint32_t * address)
>  //            WORD* ByteCnt (receives the number of values stored)
>  // Result:    bool (true if line is ok, otherwise false)
>  
> -bool FileFuncImpl::getTiFileBytes(const string& Record, size_t* ByteCnt)
> +bool FileFuncImpl::getTiFileBytes(const string& Record, uint32_t*
> ByteCnt)
>  {
>       stringstream stream(Record);
>       int numBytes = 0;
> diff --git a/DLL430_v3/src/TI/DLL430/FileFuncImpl.h
> b/DLL430_v3/src/TI/DLL430/FileFuncImpl.h
> index 4819c1b..466879b 100644
> --- a/DLL430_v3/src/TI/DLL430/FileFuncImpl.h
> +++ b/DLL430_v3/src/TI/DLL430/FileFuncImpl.h
> @@ -185,7 +185,7 @@ namespace TI
>  
>                       void trimWhitespace(string& str);
>                       bool getTiFileAddress(const string& record, uint32_t* 
> address);
> -                     bool getTiFileBytes(const string& Record, size_t* 
> ByteCnt);
> +                     bool getTiFileBytes(const string& Record, uint32_t* 
> ByteCnt);
>  
>                       bool gotoIntelRecordStart();
>                       void readIntelData(istream& stream, uint8_t size, 
> uint32_t address,
> bool firstData);
> diff --git a/DLL430_v3/src/TI/DLL430/HalResponse.h
> b/DLL430_v3/src/TI/DLL430/HalResponse.h
> index c4c19c9..c7f04ec 100644
> --- a/DLL430_v3/src/TI/DLL430/HalResponse.h
> +++ b/DLL430_v3/src/TI/DLL430/HalResponse.h
> @@ -43,6 +43,7 @@
>  
>  #include <inttypes.h>
>  #include <vector>
> +#include <cstdio>
>  
>  namespace TI
>  {

Hi Daniel,

thanks for the detailed information. I just checked the TI-Wiki and there is an 
new version of the msp430-lib with the letter 'b' (slac460b.zip). The bug in 
FileFuncImpl is still not fixed and a patch is needed again on 64Bit systems.

I removed the old patch and added a new one (slac460b.patch) which changes the 
parameter type instead of the typecast. The new patch can be used to update to 
the latest version of the msp430 lib.

Hubert

-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                          
        
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to