Date: Fri, 2 Dec 2005 00:04:22 EST-10EDT,10,-1,0,7200,3,-1,0,7200,3600 Subject: [UnixOS2_Archive] No. 657 ************************************************** Thursday 01 December 2005 Number 657 ************************************************** Subjects for today 1 Re: How to use gdb : Stefan.Neis at t-online.de 2 Re: How to use gdb : Dave Bamford 3 Re: How to use gdb : Dave Yeo" 4 Re: How to use gdb : Dave Bamford 5 Re: How to use gdb : Knut St. Osmundsen" 1 Re: How to use gdb : Dave Bamford 2 Re: How to use gdb : Knut St. Osmundsen" 5 Re: How to use gdb : Steven Levine" **= Email 1 ==========================** Date: Wed, 30 Nov 2005 14:43:57 +0100 From: Stefan.Neis at t-online.de Subject: Re: How to use gdb Hi, > OK I found out your don't use the .exe to run gdb. No, you should use the .exe. Note however that it must be compiled in a.out format, OMF is not supported. > Is this version suitable for use with code compiled with 3.3.5? No, it's for use with emx' gcc-2.8. For gcc-3.3.5, you're essentially reduced to debugging your code on a different platform or to using the famous "printf-debugger" (i.e. add as many printf's to the code as needed ...) Or you have to recompile everything for OMF and try to find and use some strange old OS/2 only debugger. Regards, Stefan **= Email 2 ==========================** Date: Wed, 30 Nov 2005 14:19:39 +0000 From: Dave Bamford Subject: Re: How to use gdb Stefan.Neis at t-online.de wrote: > Hi, > > > >>OK I found out your don't use the .exe to run gdb. >> >> > >No, you should use the .exe. >Note however that it must be compiled in a.out format, >OMF is not supported. > > > >>Is this version suitable for use with code compiled with 3.3.5? >> >> > >No, it's for use with emx' gcc-2.8. For gcc-3.3.5, you're >essentially reduced to debugging your code on a different >platform or to using the famous "printf-debugger" (i.e. add >as many printf's to the code as needed ...) > >Or you have to recompile everything for OMF and try to find >and use some strange old OS/2 only debugger. > > Regards, > Stefan > > So the tools for OS2 debugging don't really exist. There is no point in trying to debug this code on a different platform as its the OS2 port that give the problem. Catch 22 I have been using the printf debugger up to now so I guess its back to that. Its strange that the gdb partly works? What do Innotek use to debug? Regards Dave. **= Email 3 ==========================** Date: Wed, 30 Nov 2005 07:20:09 -0800 From: "Dave Yeo" Subject: Re: How to use gdb On Wed, 30 Nov 2005 10:39:47 +0000, Dave Bamford wrote: >Is it possible to use gdb with OS2. If I try I get this > >[D:\boxbackup-0.09\debug\bin\bbackupd]gdb bbackupd >GDB is free software and you are welcome to distribute copies of it > under certain conditions; type "show copying" to see the conditions. >There is absolutely no warranty for GDB; type "show warranty" for details. >GDB 4.16 (emx), Copyright 1996 Free Software Foundation, Inc... > >"d:/boxbackup-0.09/debug/bin/bbackupd/bbackupd.exe": not in executable >format: F >ile format not recognized > >all the code was compile with the -g option > >Thanks http://hobbes.nmsu.edu/pub/os2/dev/util/sd386v50.zip or http://hobbes.nmsu.edu/pub/os2/dev/util/icos0602.zip also perhaps the OpenWatcom debugger will debug OMF binaries produced by Innotek GCC. You need to add -Zomf to the CFLAGS and LDFLAGS as well as -g Dave **= Email 4 ==========================** Date: Wed, 30 Nov 2005 15:53:33 +0000 From: Dave Bamford Subject: Re: How to use gdb Back with printf debugging found the culprit(s) chown utimes chmod setting file attributes Are there some docs available somewhere which explains the differences with the use of the above between Unix and OS2. Otherwise my only option is to lose the file attributes on a restore operation from backups with this app. It would also be nice to store EAs and retrieve them too. Dave Bamford. **= Email 5 ==========================** Date: Wed, 30 Nov 2005 17:16:22 +0100 From: "Knut St. Osmundsen" Subject: Re: How to use gdb Dave Bamford wrote: > Back with printf debugging > found the culprit(s) > > chown > utimes > chmod > > setting file attributes What's the actual failure? > Are there some docs available somewhere which explains the differences > with the use of the above between Unix and OS2. Otherwise my only > option is to lose the file attributes on a restore operation from backups > with this app. There is no documentation except the emxlib one, which probably isn't up to speed with the current libc. The current libc will try put unix attributes in EAs. It escapes me now if chmod has any OS/2 extensions for coping with the system and hidden attributes. (You can of course check the source code: http://svn.netlabs.org/libc/file/branches/libc-0.6/src/emx/src/lib/io/chmod.c) > It would also be nice to store EAs and retrieve them too. Does the backup utility do EAs on unix too? Linux and some other unixes do have EA support these days. If so, it's possible to implement that API which it is using. If not, you're on your own. Kind Regards, knut **= Email 1 ==========================** Date: Wed, 30 Nov 2005 18:11:58 +0000 From: Dave Bamford Subject: Re: How to use gdb Knut St. Osmundsen wrote: > Dave Bamford wrote: > >> Back with printf debugging >> found the culprit(s) >> >> chown >> utimes >> chmod >> >> setting file attributes > > > What's the actual failure? > The application (see www.fluffy.co.uk/boxbackup) stores files on a remote server (I am currently using a Linux box for this). If you need to recover a file there is a utility which retrieves the file or directory. the files are stored encrypted and compressed. The retrieve utility tries to restore the Attributes as well as the data here is some of the code... with my printf statements for debug as you can see most is bypassed for OS2 to work Of course its possible that the routine that stores the attributes in the first place mangles them. Unfortunatley my c++ knowledge is very limited, I was brought up with vanilla c Here is the readattributes bit !************************** struct stat st; if(::lstat(Filename, &st) != 0) { THROW_EXCEPTION(CommonException, OSFileError) } // Modification times etc if(pModTime) {*pModTime = FileModificationTime(st);} if(pAttrModTime) {*pAttrModTime = FileAttrModificationTime(st);} if(pFileSize) {*pFileSize = st.st_size;} if(pInodeNumber) {*pInodeNumber = st.st_ino;} if(pHasMultipleLinks) {*pHasMultipleLinks = (st.st_nlink > 1);} !*************************** Dave. void BackupClientFileAttributes::WriteAttributes(const char *Filename) const { // Got something loaded printf("start of write attributes in BackupClientFileAttributes.cpp:462\n"); if(GetSize() <= 0) { THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); } // Make sure there are clear attributes to use EnsureClearAvailable(); ASSERT(mpClearAttributes != 0); printf("There are clear attributes in BackupClientFileAttributes.cpp:471\n"); // Check if the decrypted attributes are small enough, and the type of attributes stored if(mpClearAttributes->GetSize() < (int)sizeof(int32_t)) { THROW_EXCEPTION(BackupStoreException, AttributesNotUnderstood); } int32_t *type = (int32_t*)mpClearAttributes->GetBuffer(); ASSERT(type != 0); printf("There are clear attributes in BackupClientFileAttributes.cpp:480\n"); if(ntohl(*type) != ATTRIBUTETYPE_GENERIC_UNIX) { // Don't know what to do with these THROW_EXCEPTION(BackupStoreException, AttributesNotUnderstood); } printf("There are clear attributes in BackupClientFileAttributes.cpp:486\n"); // Check there is enough space for an attributes block if(mpClearAttributes->GetSize() < (int)sizeof(attr_StreamFormat)) { // Too small THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); } // Get pointer to structure attr_StreamFormat *pattr = (attr_StreamFormat*)mpClearAttributes->GetBuffer(); printf("There are clear attributes in BackupClientFileAttributes.cpp:497\n"); // is it a symlink? int16_t mode = ntohs(pattr->Mode); if((mode & S_IFMT) == S_IFLNK) { printf("Its a symlink BackupClientFileAttributes.cpp:503\n"); // Check things are sensible if(mpClearAttributes->GetSize() < (int)sizeof(attr_StreamFormat) + 1) { // Too small THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); } // Make a symlink, first deleting anything in the way ::unlink(Filename); if(::symlink((char*)(pattr + 1), Filename) != 0) { THROW_EXCEPTION(CommonException, OSFileError) } } #ifndef OS2 // If working as root, set user IDs if(::geteuid() == 0) { printf("If working as root, set user IDs BackupClientFileAttributes.cpp:522\n"); #ifdef PLATFORM_LCHOWN_NOT_SUPPORTED // only if not a link, can't set their owner on this platform if((mode & S_IFMT) != S_IFLNK) { // Not a link, use normal chown if(::chown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0) { printf("failed here:531\n"); THROW_EXCEPTION(CommonException, OSFileError) } } #else if(::lchown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0) // use the version which sets things on symlinks { printf("failed here:538\n"); THROW_EXCEPTION(CommonException, OSFileError) } #endif printf("done that:539\n"); } // Stop now if symlink, because otherwise it'll just be applied to the target if((mode & S_IFMT) == S_IFLNK) { return; } printf("pre mod time:551\n"); // Set modification time? box_time_t modtime = ntoh64(pattr->ModificationTime); if(modtime != 0) { // Work out times as timevals struct timeval times[2]; BoxTimeToTimeval(modtime, times[1]); // Copy access time as well, why not, got to set it to something times[0] = times[1]; // Attr modification time will be changed anyway, nothing that can be done about it // Try to apply if(::utimes(Filename, times) != 0) { THROW_EXCEPTION(CommonException, OSFileError) } printf("times applied BackupClientFileAttributes.cpp:558\n"); } printf("Apply everything else... (allowable mode flags only) BackupClientFileAttributes.cpp:566\n"); // Apply everything else... (allowable mode flags only) if(::chmod(Filename, mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)) != 0) // mode must be done last (think setuid) { THROW_EXCEPTION(CommonException, OSFileError) } #endif printf("done:574\n"); } **= Email 2 ==========================** Date: Wed, 30 Nov 2005 23:35:52 +0100 From: "Knut St. Osmundsen" Subject: Re: How to use gdb Dave Bamford wrote: > Knut St. Osmundsen wrote: > >> Dave Bamford wrote: >> >>> Back with printf debugging >>> found the culprit(s) >>> >>> chown >>> utimes >>> chmod >>> >>> setting file attributes >> >> >> >> What's the actual failure? >> > The application (see www.fluffy.co.uk/boxbackup) stores files on a remote > server (I am currently using a Linux box for this). If you need to recover > a file there is a utility which retrieves the file or directory. the files > are stored encrypted and compressed. > The retrieve utility tries to restore the Attributes as well as the data > here is some of the code... with my printf statements for debug > as you can see most is bypassed for OS2 to work A possible reason why this isn't work on OS/2 might be that the file which attributes you're trying to change is opened. I know DosSetPathInfo() will not allow you to change the EAs of an open file, I don't recall if that's the case for the FIL_STANDARD info as well. (do anyone recall that?) chown is trying to set the uid EA, utimes is doing a FIL_STANDARD level DosSetPathInfo() and chmod is doing both of them. > Of course its possible that the routine that stores the attributes in the > first place mangles them. > Unfortunatley my c++ knowledge is very limited, I was brought up with > vanilla c > > Here is the readattributes bit > !************************** > struct stat st; > if(::lstat(Filename, &st) != 0) > { > THROW_EXCEPTION(CommonException, OSFileError) > } > // Modification times etc > if(pModTime) {*pModTime = FileModificationTime(st);} > if(pAttrModTime) {*pAttrModTime = FileAttrModificationTime(st);} > if(pFileSize) {*pFileSize = st.st_size;} > if(pInodeNumber) {*pInodeNumber = st.st_ino;} > if(pHasMultipleLinks) {*pHasMultipleLinks = (st.st_nlink > 1);} > !*************************** There is more to it than this. the st_mode mask (pattr->Mode in the restore code) is missing here. But, since they don't support EAs and metadata on MAC I doubt they support it on unix. so, EAs will be some work if you want to do it. Kind Regards, knut **= Email 5 ==========================** Date: Wed, 30 Nov 2005 13:23:53 -0800 From: "Steven Levine" Subject: Re: How to use gdb In <20051130151954.709AFB86E6 at generation.lgisp.net>, on 11/30/05 at 07:20 AM, "Dave Yeo" said: >http://hobbes.nmsu.edu/pub/os2/dev/util/sd386v50.zip or >http://hobbes.nmsu.edu/pub/os2/dev/util/icos0602.zip also perhaps the >OpenWatcom debugger will debug OMF binaries produced by Innotek GCC. You >need to add -Zomf to the CFLAGS and LDFLAGS as well as -g He can also use the VAC idebug and icsdebug. Knud has the -g option setup to do the right thing when passed to emxomfld. I don't think that Watcom supports the HLL debug format yet. Michal and I had discussed this, but I don't see anything in the code that indicates it has been implemented. Regards, Steven -- ---------------------------------------------------------------------- "Steven Levine" MR2/ICE 2.67 #10183 Warp4.something/14.100c_W4 www.scoug.com irc.fyrelizard.com #scoug (Wed 7pm PST) ----------------------------------------------------------------------