From: Thomas S. <ste...@gm...> - 2005-12-20 21:50:25
|
On 12/19/05, Dennis Lubert <pla...@tz...> wrote: > Im not quite sure if you want to have a new tool that does the checking > or a quick hack with the valgrind capabilities it currently offers. I would like to have a tool that does it already, but that does not seem to exist. I might look into creating one, but I don't want to promise more than I can keep, so don't hold your breath. > Assuming that endianess changes are done at a (more or less) central > place you could use valgrind client requests to mark the memory as > uninitialized when the data comes in, and mark it as initialized when > you change the endianess. Yes, we agree on the policy to do endianess in one place (as long as feasible). This place is when dealing with the network packet, so the approach would be applicable. Unfortunately, byte string data is usually referred to by pointer into the original packet (which is both ok and efficient). So there would need to be an exception for byte wise access, because no endianess conversion is necessary. This sounds like a reasonable simple approach: all data received from a socket is marked as network byte order. When copying it by byte, the flag is reset, but copying in bigger units also sets the flag on the copy.The question is where network byte order should not be allowed. On the sending side, the process is more difficult, and probably requires special endianess conversion function that valgrind recognises. Also marking the send buffer might be necessary. So it does look a bit messy. For the time being I will just do some static (manual) checking for the encoding and decoding function on whether it leaks the wrong byte order out of scope. Thomas This way, when the endianess wasnt changed > valgrind should report it as uninitialized. Its just a quick and dirty > hack I think, but might work well depending on your programs size and > structure. > > greets > > Dennis > Am Montag, den 19.12.2005, 15:55 +0100 schrieb Thomas Steffen: > > Dear valgrind users > > > > I am looking for a way to check the correct use of endianess > > conversion in a program. I wonder whether valgrind could help with > > that. I now which data is in network byte order, and all internal > > variables of the program should be in host byte order. I guess that > > something like the tracking of initialised/uninitialised bytes could > > help here. > > > > And if so, has this already been done, or would it be difficult to arch= ive? > > > > I know that there are other alternatives (static type checking, smart > > pointers etc), but they don't seem to be really comprehensive. > > > > I do already use valgrind for checking my programs, and both the > > verification of the memory management and the detection of > > uninitialised values is very helpful. > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users > |