From imker at mail.berlios.de Mon Jun 1 12:26:58 2009 From: imker at mail.berlios.de (imker at BerliOS) Date: Mon, 1 Jun 2009 12:26:58 +0200 Subject: [Haiku-commits] r30936 - haiku/trunk/data/develop Message-ID: <200906011026.n51AQwCV017603@sheep.berlios.de> Author: imker Date: 2009-06-01 12:26:58 +0200 (Mon, 01 Jun 2009) New Revision: 30936 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30936&view=rev Modified: haiku/trunk/data/develop/makefile haiku/trunk/data/develop/makefile-engine Log: - added preprocessing of RDEF scripts during resource compilation; - version of makefile template increased to 2.3 because of adding RDEFS list in previous commit. Modified: haiku/trunk/data/develop/makefile =================================================================== --- haiku/trunk/data/develop/makefile 2009-05-31 19:38:25 UTC (rev 30935) +++ haiku/trunk/data/develop/makefile 2009-06-01 10:26:58 UTC (rev 30936) @@ -1,4 +1,4 @@ -## BeOS Generic Makefile v2.2 ## +## BeOS Generic Makefile v2.3 ## ## Fill in this file to specify the project being created, and the referenced ## makefile-engine will do all of the hard work for you. This handles both Modified: haiku/trunk/data/develop/makefile-engine =================================================================== --- haiku/trunk/data/develop/makefile-engine 2009-05-31 19:38:25 UTC (rev 30935) +++ haiku/trunk/data/develop/makefile-engine 2009-06-01 10:26:58 UTC (rev 30936) @@ -2,7 +2,7 @@ ## Does all the hard work for the Generic Makefile ## which simply defines the project parameters -## Supports Generic Makefile v2.0, 2.01, 2.1, 2.2 +## Supports Generic Makefile v2.0, 2.01, 2.1, 2.2, 2.3 # determine wheather running on x86 or ppc MACHINE=$(shell uname -m) @@ -351,9 +351,9 @@ # rules to compile resource definition files $(OBJ_DIR)/%.rsrc : %.rdef - $(RESCOMP) -o $@ $< + cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -o $@ - $(OBJ_DIR)/%.rsrc : %.RDEF - $(RESCOMP) -o $@ $< + cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -o $@ - # rules to handle lex/flex and yacc/bison files From bonefish at mail.berlios.de Mon Jun 1 13:12:21 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 1 Jun 2009 13:12:21 +0200 Subject: [Haiku-commits] r30937 - haiku/trunk/src/system/kernel/fs Message-ID: <200906011112.n51BCLmW027635@sheep.berlios.de> Author: bonefish Date: 2009-06-01 13:12:12 +0200 (Mon, 01 Jun 2009) New Revision: 30937 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30937&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: vnode_path_to_vnode(): Don't propagate the traverseLeafLink flag, if we've decided to recursively resolve a symlink. We only have to do the resolution when the flag is true anyway or the symlink is not the last component of our path, in which case we have to resolve it anyway. Fixes #3986. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2009-06-01 10:26:58 UTC (rev 30936) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2009-06-01 11:12:12 UTC (rev 30937) @@ -2318,8 +2318,8 @@ // symlink was just "/" nextVnode = vnode; } else { - status = vnode_path_to_vnode(vnode, path, traverseLeafLink, - count + 1, ioContext, &nextVnode, &lastParentID); + status = vnode_path_to_vnode(vnode, path, true, count + 1, + ioContext, &nextVnode, &lastParentID); } free(buffer); From axeld at pinc-software.de Mon Jun 1 17:22:38 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 01 Jun 2009 17:22:38 +0200 CEST Subject: [Haiku-commits] r30934 - haiku/trunk/src/kits/storage/disk_device In-Reply-To: <200905310555.n4V5ttdR031497@sheep.berlios.de> Message-ID: <1414013114-BeMail@zon> anevilyak at BerliOS wrote: > Log: > When we dynamically create a mount point directory, add a special > marker subdirectory in it so the disk system knows the directory was > not created by the user. When unmounting, look for the marker and > remove the mountpoint directory if found. This fixes the issue where > mount / unmount / > mounting a volume via Tracker would result in > extra empty dirs in the rootfs. Why wouldn't the disk device manager not know if it created a directory anyway? > Ideally I'd rather solve this by being able to tag the mount points > with > attributes, but this isn't currently possible since the attribute > overlay is > a module and thus not available when mounting the rootfs. The attribute overlay would be overkill here, anyway; if that attribute is really needed, one could make the rootfs accept a single attribute for this purpose easily. Bye, Axel. From axeld at pinc-software.de Mon Jun 1 17:27:03 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 01 Jun 2009 17:27:03 +0200 CEST Subject: [Haiku-commits] r30922 - haiku/trunk/src/kits/network/dns/irs In-Reply-To: <200905301233.n4UCXDnp013464@sheep.berlios.de> Message-ID: <1679012097-BeMail@zon> bonefish at mail.berlios.de wrote: > Log: > * Removed unused find_own_image(). > * sv_rewind(): Init the cookie to 0 before using it for > get_next_image_info() > iteration. This could cause the function not to find the libnetwork > path and > thus fail to open the "services" attribute. The getserv*() > functions would > always fail and the net server wouldn't be able to listen on the > telnet and > ftp ports. Damn, looks like I forgot to commit this, sorry! But thanks for looking into it! Bye, Axel. From anevilyak at gmail.com Mon Jun 1 17:33:24 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Mon, 1 Jun 2009 10:33:24 -0500 Subject: [Haiku-commits] r30934 - haiku/trunk/src/kits/storage/disk_device In-Reply-To: <1414013114-BeMail@zon> References: <200905310555.n4V5ttdR031497@sheep.berlios.de> <1414013114-BeMail@zon> Message-ID: On Mon, Jun 1, 2009 at 10:22 AM, Axel D?rfler wrote: > Why wouldn't the disk device manager not know if it created a directory > anyway? Unless I'm missing something, that fact isn't being tracked anywhere in the disk device manager code. The directory creation happens solely in the kit classes in userland, so there's no persistent spot where any client using the disk device framework would be aware of the dynamically created directory except the VFS itself. Unless you'd rather have some notification sent to the kernel-side disk device manager to let it know about it, I don't see a better way to keep track. Thoughts? > The attribute overlay would be overkill here, anyway; if that attribute > is really needed, one could make the rootfs accept a single attribute > for this purpose easily. Well, I was thinking more in case other kinds of metadata might be nice there, but understood. Regards, Rene From rudolfc at mail.berlios.de Mon Jun 1 22:06:23 2009 From: rudolfc at mail.berlios.de (rudolfc at mail.berlios.de) Date: Mon, 1 Jun 2009 22:06:23 +0200 Subject: [Haiku-commits] r30938 - in haiku/trunk: headers/private/graphics/nvidia src/add-ons/accelerants/nvidia/engine Message-ID: <200906012006.n51K6NUl013041@sheep.berlios.de> Author: rudolfc Date: 2009-06-01 22:06:21 +0200 (Mon, 01 Jun 2009) New Revision: 30938 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30938&view=rev Modified: haiku/trunk/headers/private/graphics/nvidia/nv_macros.h haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c Log: added enabling I2C buses for NV40 arch cards. hopefully this makes the buses work on GF6100 (noted in bug #2780) and maybe others. added a few registerdefines (wip). Modified: haiku/trunk/headers/private/graphics/nvidia/nv_macros.h =================================================================== --- haiku/trunk/headers/private/graphics/nvidia/nv_macros.h 2009-06-01 11:12:12 UTC (rev 30937) +++ haiku/trunk/headers/private/graphics/nvidia/nv_macros.h 2009-06-01 20:06:21 UTC (rev 30938) @@ -759,6 +759,9 @@ #define NVCRTCX_WR_I2CBUS_0 0x3f #define NVCRTCX_EXTRA 0x41 #define NVCRTCX_OWNER 0x44 +#define NVCRTCX_I2C_LOCK 0x49 +#define NVCRTCX_RD_I2CBUS_2 0x50 +#define NVCRTCX_WR_I2CBUS_2 0x51 #define NVCRTCX_FP_HTIMING 0x53 #define NVCRTCX_FP_VTIMING 0x54 #define NVCRTCX_0x59 0x59 Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c 2009-06-01 11:12:12 UTC (rev 30937) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c 2009-06-01 20:06:21 UTC (rev 30938) @@ -2,7 +2,7 @@ * i2c interface. * Bus should be run at max. 100kHz: see original Philips I2C specification * - * Rudolf Cornelissen 12/2002-5/2009 + * Rudolf Cornelissen 12/2002-6/2009 */ #define MODULE_BIT 0x00004000 @@ -296,6 +296,10 @@ /* enable access to primary head */ set_crtc_owner(0); + /* on some NV40 architecture cards the i2c busses can be disabled: enable them */ + if (si->ps.card_arch == NV40A) + CRTCW(I2C_LOCK ,(CRTCR(I2C_LOCK) | 0x04)); + /* preset no board wired buses */ si->ps.i2c_bus0 = false; si->ps.i2c_bus1 = false; From imker at mail.berlios.de Mon Jun 1 22:21:56 2009 From: imker at mail.berlios.de (imker at BerliOS) Date: Mon, 1 Jun 2009 22:21:56 +0200 Subject: [Haiku-commits] r30939 - haiku/trunk/build/jam Message-ID: <200906012021.n51KLuHe015648@sheep.berlios.de> Author: imker Date: 2009-06-01 22:21:55 +0200 (Mon, 01 Jun 2009) New Revision: 30939 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30939&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Optional package for vim editor added. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2009-06-01 20:06:21 UTC (rev 30938) +++ haiku/trunk/build/jam/OptionalPackages 2009-06-01 20:21:55 UTC (rev 30939) @@ -46,6 +46,7 @@ # Subversion # Tar # UserlandFS +# Vim # Vision # VLC # Welcome @@ -770,6 +771,30 @@ } +# Vim +if [ IsOptionalHaikuImagePackageAdded Vim ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package Vim available for $(TARGET_ARCH)" ; + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + local baseURL = http://haiku-ports.de/packages/app-editors/vim ; + InstallOptionalHaikuImagePackage vim-7.2-gcc4-20090531 + : $(baseURL)/vim-7.2-gcc4-haiku-2009-05-31.zip + : + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/common/bin/gvim ; + } else { + local baseURL = http://haiku-ports.de/packages/app-editors/vim ; + InstallOptionalHaikuImagePackage vim-7.2-gcc2-20090531 + : $(baseURL)/vim-7.2-gcc2-haiku-2009-05-31.zip + : + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/common/bin/gvim ; + } +} + + # Vision if [ IsOptionalHaikuImagePackageAdded Vision ] { if $(TARGET_ARCH) != x86 { From axeld at mail.berlios.de Mon Jun 1 22:44:59 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 1 Jun 2009 22:44:59 +0200 Subject: [Haiku-commits] r30940 - haiku/trunk/src/servers/net Message-ID: <200906012044.n51Kixd1018588@sheep.berlios.de> Author: axeld Date: 2009-06-01 22:44:59 +0200 (Mon, 01 Jun 2009) New Revision: 30940 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30940&view=rev Modified: haiku/trunk/src/servers/net/Services.cpp Log: * Minor cleanup. Modified: haiku/trunk/src/servers/net/Services.cpp =================================================================== --- haiku/trunk/src/servers/net/Services.cpp 2009-06-01 20:21:55 UTC (rev 30939) +++ haiku/trunk/src/servers/net/Services.cpp 2009-06-01 20:44:59 UTC (rev 30940) @@ -181,7 +181,8 @@ _Update(services); - fListener = spawn_thread(_Listener, "services listener", B_NORMAL_PRIORITY, this); + fListener = spawn_thread(_Listener, "services listener", B_NORMAL_PRIORITY, + this); if (fListener >= B_OK) resume_thread(fListener); } @@ -419,6 +420,7 @@ if (i == 0 && (serviceFamily < 0 || servicePort < 0)) { // no address specified + printf("service %s has no address specified\n", name); delete service; return B_BAD_VALUE; } @@ -512,7 +514,7 @@ close(socket); // build argument array - + const char** args = (const char**)malloc(2 * sizeof(void *)); if (args == NULL) exit(1); From axeld at mail.berlios.de Mon Jun 1 22:47:41 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 1 Jun 2009 22:47:41 +0200 Subject: [Haiku-commits] r30941 - haiku/trunk/src/kits/network/dns/irs Message-ID: <200906012047.n51KlfDE018961@sheep.berlios.de> Author: axeld Date: 2009-06-01 22:47:41 +0200 (Mon, 01 Jun 2009) New Revision: 30941 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30941&view=rev Modified: haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp Log: * Reintroduced the find_own_image() function, as I think this is the cleaner approach. * Made get_next_line() static as it should have been in the first place. Modified: haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp =================================================================== --- haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp 2009-06-01 20:44:59 UTC (rev 30940) +++ haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp 2009-06-01 20:47:41 UTC (rev 30941) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ @@ -85,13 +85,32 @@ struct service_private { FILE* file; - char line[BUFSIZ+1]; + char line[BUFSIZ + 1]; struct servent servent; char* aliases[IRS_SV_MAXALIASES]; }; -char * +static status_t +find_own_image(image_info* _info) +{ + int32 cookie = 0; + image_info info; + while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + if (((uint32)info.text <= (uint32)find_own_image + && (uint32)info.text + (uint32)info.text_size + > (uint32)find_own_image)) { + // found us + *_info = info; + return B_OK; + } + } + + return B_ENTRY_NOT_FOUND; +} + + +static char* get_next_line(struct service_private* service) { if (service->file == NULL) @@ -139,24 +158,12 @@ // opening the standard file has file has failed, use the attribute // find our library image - addr_t addressInImage = (addr_t)&sv_rewind; - const char* path = NULL; image_info info; - int32 cookie = 0; - - while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { - if (addressInImage >= (addr_t)info.text - && addressInImage < (addr_t)info.text + info.text_size) { - path = info.name; - break; - } - } - - if (path == NULL) + if (find_own_image(&info) != B_OK) return; // open the library - int libraryFD = open(path, O_RDONLY); + int libraryFD = open(info.name, O_RDONLY); if (libraryFD < 0) return; From ingo_weinhold at gmx.de Mon Jun 1 22:42:20 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 01 Jun 2009 22:42:20 +0200 Subject: [Haiku-commits] r30934 - haiku/trunk/src/kits/storage/disk_device In-Reply-To: References: <200905310555.n4V5ttdR031497@sheep.berlios.de> <1414013114-BeMail@zon> Message-ID: <20090601224220.474.1@knochen-vm.localdomain> On 2009-06-01 at 17:33:24 [+0200], Rene Gollent wrote: > On Mon, Jun 1, 2009 at 10:22 AM, Axel D?rfler > wrote: > > Why wouldn't the disk device manager not know if it created a directory > > anyway? > > Unless I'm missing something, that fact isn't being tracked anywhere > in the disk device manager code. The directory creation happens solely > in the kit classes in userland, so there's no persistent spot where > any client using the disk device framework would be aware of the > dynamically created directory except the VFS itself. Unless you'd > rather have some notification sent to the kernel-side disk device > manager to let it know about it, I don't see a better way to keep > track. Thoughts? I like your solution. :-) > > The attribute overlay would be overkill here, anyway; if that attribute > > is really needed, one could make the rootfs accept a single attribute > > for this purpose easily. > > Well, I was thinking more in case other kinds of metadata might be > nice there, but understood. When other metadata of interest for rootfs nodes comes up, we can still consider adding attribute support. CU, Ingo From axeld at pinc-software.de Tue Jun 2 09:32:17 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 02 Jun 2009 09:32:17 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30934_-_haiku/trunk/src/kits/storage/d?= =?utf-8?q?isk=5Fdevice?= In-Reply-To: Message-ID: <3010238160-BeMail@zon> Rene Gollent wrote: > On Mon, Jun 1, 2009 at 10:22 AM, Axel D?rfler > wrote: > > Why wouldn't the disk device manager not know if it created a > > directory > > anyway? > Unless I'm missing something, that fact isn't being tracked anywhere > in the disk device manager code. The directory creation happens > solely > in the kit classes in userland, so there's no persistent spot where > any client using the disk device framework would be aware of the > dynamically created directory except the VFS itself. Unless you'd > rather have some notification sent to the kernel-side disk device > manager to let it know about it, I don't see a better way to keep > track. Thoughts? I was thinking of a way to tell the disk device manager to delete the mount point on unmount. But I guess your solution is good enough for now. Bye, Axel. From dlmcpaul at mail.berlios.de Tue Jun 2 11:15:15 2009 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Tue, 2 Jun 2009 11:15:15 +0200 Subject: [Haiku-commits] r30942 - haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser Message-ID: <200906020915.n529FFDI028465@sheep.berlios.de> Author: dlmcpaul Date: 2009-06-02 11:15:14 +0200 (Tue, 02 Jun 2009) New Revision: 30942 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30942&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.h haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/StreamIO.cpp Log: Update to v1.61 of MatroskaParser library Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c 2009-06-01 20:47:41 UTC (rev 30941) +++ haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c 2009-06-02 09:15:14 UTC (rev 30942) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 Mike Matsnev. All Rights Reserved. + * Copyright (c) 2004-2006 Mike Matsnev. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: MatroskaParser.c,v 1.31 2005/03/07 11:22:16 mike Exp $ + * $Id: MatroskaParser.c,v 1.61 2006/10/28 10:39:45 mike Exp $ * */ @@ -50,23 +50,20 @@ #include "MatroskaParser.h" #ifdef MATROSKA_COMPRESSION_SUPPORT -#include +#include "zlib.h" #endif #define EBML_VERSION 1 #define EBML_MAX_ID_LENGTH 4 #define EBML_MAX_SIZE_LENGTH 8 -#define MATROSKA_VERSION 1 +#define MATROSKA_VERSION 2 #define MATROSKA_DOCTYPE "matroska" #define MAX_STRING_LEN 1023 #define QSEGSIZE 512 #define MAX_TRACKS 32 -#define MAX_READAHEAD (512*1024) +#define MAX_READAHEAD (256*1024) -#define DEFAULT_PAGE_SIZE 65536 -#define MIN_PAGE_SIZE 4096 -#define MIN_PAGES 2 #define MAXCLUSTER (64*1048576) #define MAXFRAME (4*1048576) @@ -90,7 +87,7 @@ return NULL; len = strlen(src); - dst = (char *)is->memalloc(is,len+1); + dst = is->memalloc(is,len+1); if (dst==NULL) return NULL; @@ -236,12 +233,15 @@ char pc = zero ? '0' : ' '; *--np = '\0'; - while (val != 0) { - int rem = (int)(val % base); - val = val / base; + if (val == 0) + *--np = '0'; + else + while (val != 0) { + int rem = (int)(val % base); + val = val / base; - *--np = rem < 10 ? rem + '0' : rem - 10 + letter; - } + *--np = rem < 10 ? rem + '0' : rem - 10 + letter; + } rw = (int)(tmp - np + sizeof(tmp) - 1); if (ms) @@ -290,7 +290,7 @@ static void myvsnprintf(char *dest,unsigned dsize,const char *fmt,va_list ap) { // s,d,x,u,ll char *de = dest + dsize - 1; - int state = 0, width, zero, neg, ll; + int state = 0, width = 0, zero = 0, neg = 0, ll = 0; if (dsize <= 1) { if (dsize > 0) @@ -315,6 +315,8 @@ state = 2; break; } + if (*fmt == '0') + zero = 1; state = 2; case 2: if (*fmt >= '0' && *fmt <= '9') { @@ -537,7 +539,7 @@ } static void readbytes(MatroskaFile *mf,void *buffer,int len) { - char *cp = (char *)buffer; + char *cp = buffer; int nb = mf->buflen - mf->bufpos; if (nb > len) @@ -852,6 +854,14 @@ buffer[nread] = '\0'; } +static void readLangCC(MatroskaFile *mf, ulonglong len, char lcc[4]) { + unsigned todo = len > 3 ? 3 : (int)len; + + lcc[0] = lcc[1] = lcc[2] = lcc[3] = 0; + readbytes(mf, lcc, todo); + skipbytes(mf, len - todo); +} + /////////////////////////////////////////////////////////////////////////// // file parser #define FOREACH(f,tl) \ @@ -888,7 +898,7 @@ { \ char *TmpVal; \ unsigned TmpLen = (len)>MAX_STRING_LEN ? MAX_STRING_LEN : (unsigned)(len); \ - TmpVal = (char *)func(f->cache,TmpLen+1); \ + TmpVal = func(f->cache,TmpLen+1); \ if (TmpVal == NULL) \ errorjmp(mf,"Out of memory"); \ readString(f,len,TmpVal,TmpLen+1); \ @@ -1006,7 +1016,7 @@ } static void parseSegmentInfo(MatroskaFile *mf,ulonglong toplen) { - MKFLOAT duration; + MKFLOAT duration = mkfi(0); if (mf->seen.SegmentInfo) { skipbytes(mf,toplen); @@ -1051,6 +1061,7 @@ break; case 0x4461: // DateUTC mf->Seg.DateUTC = readUInt(mf,(unsigned)len); + mf->Seg.DateUTCValid = 1; break; case 0x7ba9: // Title STRGETM(mf,mf->Seg.Title,len); @@ -1074,6 +1085,12 @@ case 0xe7: // Timecode mf->firstTimecode += readUInt(mf,(unsigned)len); break; + case 0xa3: // BlockEx + readVLUInt(mf); // track number + mf->firstTimecode += readSInt(mf, 2); + + skipbytes(mf,start + toplen - filepos(mf)); + return; case 0xa0: // BlockGroup FOREACH(mf,len) case 0xa1: // Block @@ -1093,61 +1110,85 @@ FOREACH(mf,toplen) case 0x9a: // FlagInterlaced - ti->Video.Interlaced = readUInt(mf,(unsigned)len)!=0; + ti->AV.Video.Interlaced = readUInt(mf,(unsigned)len)!=0; break; case 0x53b8: // StereoMode v = readUInt(mf,(unsigned)len); if (v>3) errorjmp(mf,"Invalid stereo mode"); - ti->Video.StereoMode = (unsigned char)v; + ti->AV.Video.StereoMode = (unsigned char)v; break; case 0xb0: // PixelWidth v = readUInt(mf,(unsigned)len); if (v>0xffffffff) errorjmp(mf,"PixelWidth is too large"); - ti->Video.PixelWidth = (unsigned)v; + ti->AV.Video.PixelWidth = (unsigned)v; if (!dW) - ti->Video.DisplayWidth = ti->Video.PixelWidth; + ti->AV.Video.DisplayWidth = ti->AV.Video.PixelWidth; break; case 0xba: // PixelHeight v = readUInt(mf,(unsigned)len); if (v>0xffffffff) errorjmp(mf,"PixelHeight is too large"); - ti->Video.PixelHeight = (unsigned)v; + ti->AV.Video.PixelHeight = (unsigned)v; if (!dH) - ti->Video.DisplayHeight = ti->Video.PixelHeight; + ti->AV.Video.DisplayHeight = ti->AV.Video.PixelHeight; break; case 0x54b0: // DisplayWidth v = readUInt(mf,(unsigned)len); if (v>0xffffffff) errorjmp(mf,"DisplayWidth is too large"); - ti->Video.DisplayWidth = (unsigned)v; + ti->AV.Video.DisplayWidth = (unsigned)v; dW = 1; break; case 0x54ba: // DisplayHeight v = readUInt(mf,(unsigned)len); if (v>0xffffffff) errorjmp(mf,"DisplayHeight is too large"); - ti->Video.DisplayHeight = (unsigned)v; + ti->AV.Video.DisplayHeight = (unsigned)v; dH = 1; break; case 0x54b2: // DisplayUnit v = readUInt(mf,(unsigned)len); if (v>2) errorjmp(mf,"Invalid DisplayUnit: %d",(int)v); - ti->Video.DisplayUnit = (unsigned char)v; + ti->AV.Video.DisplayUnit = (unsigned char)v; break; case 0x54b3: // AspectRatioType v = readUInt(mf,(unsigned)len); if (v>2) errorjmp(mf,"Invalid AspectRatioType: %d",(int)v); - ti->Video.AspectRatioType = (unsigned char)v; + ti->AV.Video.AspectRatioType = (unsigned char)v; break; + case 0x54aa: // PixelCropBottom + v = readUInt(mf,(unsigned)len); + if (v>0xffffffff) + errorjmp(mf,"PixelCropBottom is too large"); + ti->AV.Video.CropB = (unsigned)v; + break; + case 0x54bb: // PixelCropTop + v = readUInt(mf,(unsigned)len); + if (v>0xffffffff) + errorjmp(mf,"PixelCropTop is too large"); + ti->AV.Video.CropT = (unsigned)v; + break; + case 0x54cc: // PixelCropLeft + v = readUInt(mf,(unsigned)len); + if (v>0xffffffff) + errorjmp(mf,"PixelCropLeft is too large"); + ti->AV.Video.CropL = (unsigned)v; + break; + case 0x54dd: // PixelCropRight + v = readUInt(mf,(unsigned)len); + if (v>0xffffffff) + errorjmp(mf,"PixelCropRight is too large"); + ti->AV.Video.CropR = (unsigned)v; + break; case 0x2eb524: // ColourSpace - ti->Video.ColourSpace = (unsigned)readUInt(mf,4); + ti->AV.Video.ColourSpace = (unsigned)readUInt(mf,4); break; case 0x2fb523: // GammaValue - ti->Video.GammaValue = readFloat(mf,(unsigned)len); + ti->AV.Video.GammaValue = readFloat(mf,(unsigned)len); break; ENDFOR(mf); } @@ -1157,30 +1198,36 @@ FOREACH(mf,toplen) case 0xb5: // SamplingFrequency - ti->Audio.SamplingFreq = readFloat(mf,(unsigned)len); + ti->AV.Audio.SamplingFreq = readFloat(mf,(unsigned)len); break; case 0x78b5: // OutputSamplingFrequency - ti->Audio.OutputSamplingFreq = readFloat(mf,(unsigned)len); + ti->AV.Audio.OutputSamplingFreq = readFloat(mf,(unsigned)len); break; case 0x9f: // Channels v = readUInt(mf,(unsigned)len); if (v<1 || v>255) errorjmp(mf,"Invalid Channels value"); - ti->Audio.Channels = (unsigned char)v; + ti->AV.Audio.Channels = (unsigned char)v; break; case 0x7d7b: // ChannelPositions skipbytes(mf,len); break; case 0x6264: // BitDepth v = readUInt(mf,(unsigned)len); +#if 0 if ((v<1 || v>255) && !IsWritingApp(mf,"AVI-Mux GUI")) errorjmp(mf,"Invalid BitDepth: %d",(int)v); - ti->Audio.BitDepth = (unsigned char)v; +#endif + ti->AV.Audio.BitDepth = (unsigned char)v; break; ENDFOR(mf); - if (mkv_TruncFloat(ti->Audio.OutputSamplingFreq)==0) - ti->Audio.OutputSamplingFreq = ti->Audio.SamplingFreq; + if (ti->AV.Audio.Channels == 0) + ti->AV.Audio.Channels = 1; + if (mkv_TruncFloat(ti->AV.Audio.SamplingFreq) == 0) + ti->AV.Audio.SamplingFreq = mkfi(8000); + if (mkv_TruncFloat(ti->AV.Audio.OutputSamplingFreq)==0) + ti->AV.Audio.OutputSamplingFreq = ti->AV.Audio.SamplingFreq; } static void CopyStr(char **src,char **dst) { @@ -1198,8 +1245,9 @@ static void parseTrackEntry(MatroskaFile *mf,ulonglong toplen) { struct TrackInfo t,*tp,**tpp; ulonglong v; - char *cp = NULL; - size_t cplen = 0, cpadd = 0; + char *cp = NULL, *cs = NULL; + size_t cplen = 0, cslen = 0, cpadd = 0; + unsigned CompScope = 0, num_comp = 0; if (mf->nTracks >= MAX_TRACKS) errorjmp(mf,"Too many tracks."); @@ -1229,10 +1277,6 @@ if (v<1 || v>254) errorjmp(mf,"Invalid track type: %d",(int)v); t.Type = (unsigned char)v; - if (t.Type == 2) { // fill defaults for audio tracks - t.Audio.Channels = 1; - t.Audio.SamplingFreq = mkfi(8000); - } break; case 0xb9: // Enabled t.Enabled = readUInt(mf,(unsigned)len)!=0; @@ -1261,15 +1305,16 @@ case 0x23314f: // TrackTimecodeScale t.TimecodeScale = readFloat(mf,(unsigned)len); break; + case 0x55ee: // MaxBlockAdditionID + t.MaxBlockAdditionID = (unsigned)readUInt(mf,(unsigned)len); + break; case 0x536e: // Name if (t.Name) errorjmp(mf,"Duplicate Track Name"); STRGETA(mf,t.Name,len); break; case 0x22b59c: // Language - if (t.Language) - errorjmp(mf,"Duplicate Track Language"); - STRGETA(mf,t.Language,len); + readLangCC(mf, len, t.Language); break; case 0x86: // CodecID if (t.CodecID) @@ -1282,7 +1327,7 @@ if (len>262144) // 256KB errorjmp(mf,"CodecPrivate is too large: %d",(int)len); cplen = (unsigned)len; - cp = (char *)alloca(cplen); + cp = alloca(cplen); readbytes(mf,cp,(int)cplen); break; case 0x258688: // CodecName @@ -1315,30 +1360,45 @@ case 0x6d80: // ContentEncodings FOREACH(mf,len) case 0x6240: // ContentEncoding + // fill in defaults + t.CompEnabled = 1; + t.CompMethod = COMP_ZLIB; + CompScope = 1; + if (++num_comp > 1) + return; // only one compression layer supported FOREACH(mf,len) case 0x5031: // ContentEncodingOrder readUInt(mf,(unsigned)len); break; case 0x5032: // ContentEncodingScope - readUInt(mf,(unsigned)len); + CompScope = (unsigned)readUInt(mf,(unsigned)len); break; case 0x5033: // ContentEncodingType - readUInt(mf,(unsigned)len); + if (readUInt(mf,(unsigned)len) != 0) + return; // encryption is not supported break; case 0x5034: // ContentCompression - // fill in defaults - t.CompEnabled = 1; - t.CompMethod = COMP_ZLIB; FOREACH(mf,len) case 0x4254: // ContentCompAlgo v = readUInt(mf,(unsigned)len); - if (v != 0) - errorjmp(mf,"Unsupported compression algorithm: %d",(int)v); t.CompEnabled = 1; - t.CompMethod = COMP_ZLIB; + switch (v) { + case 0: // Zlib + t.CompMethod = COMP_ZLIB; + break; + case 3: // prepend fixed data + t.CompMethod = COMP_PREPEND; + break; + default: + return; // unsupported compression, skip track + } break; case 0x4255: // ContentCompSettings - skipbytes(mf,len); + if (len > 256) + return; + cslen = (unsigned)len; + cs = alloca(cslen); + readbytes(mf, cs, (int)cslen); break; ENDFOR(mf); break; @@ -1353,36 +1413,95 @@ if (!t.CodecID) errorjmp(mf,"Track has no Codec ID"); + if (t.UID != 0) { + unsigned i; + for (i = 0; i < mf->nTracks; ++i) + if (mf->Tracks[i]->UID == t.UID) // duplicate track entry + return; + } + +#ifdef MATROSKA_COMPRESSION_SUPPORT + // handle compressed CodecPrivate + if (t.CompEnabled && t.CompMethod == COMP_ZLIB && (CompScope & 2) && cplen > 0) { + z_stream zs; + char tmp[64], *ncp; + int code; + uLong ncplen; + + memset(&zs,0,sizeof(zs)); + if (inflateInit(&zs) != Z_OK) + errorjmp(mf, "inflateInit failed"); + + zs.next_in = cp; + zs.avail_in = cplen; + + do { + zs.next_out = tmp; + zs.avail_out = sizeof(tmp); + + code = inflate(&zs, Z_NO_FLUSH); + } while (code == Z_OK); + + if (code != Z_STREAM_END) + errorjmp(mf, "invalid compressed data in CodecPrivate"); + + ncplen = zs.total_out; + ncp = alloca(ncplen); + + inflateReset(&zs); + + zs.next_in = cp; + zs.avail_in = cplen; + zs.next_out = ncp; + zs.avail_out = ncplen; + + if (inflate(&zs, Z_FINISH) != Z_STREAM_END) + errorjmp(mf, "inflate failed"); + + inflateEnd(&zs); + + cp = ncp; + cplen = ncplen; + } +#endif + + if (t.CompEnabled && !(CompScope & 1)) { + t.CompEnabled = 0; + cslen = 0; + } + // allocate new track - tpp = (TrackInfo **)AGET(mf,Tracks); + tpp = AGET(mf,Tracks); // copy strings if (t.Name) cpadd += strlen(t.Name)+1; - if (t.Language) - cpadd += strlen(t.Language)+1; if (t.CodecID) cpadd += strlen(t.CodecID)+1; - tp = (TrackInfo *)mf->cache->memalloc(mf->cache,sizeof(*tp) + cplen + cpadd); + tp = mf->cache->memalloc(mf->cache,sizeof(*tp) + cplen + cslen + cpadd); if (tp == NULL) errorjmp(mf,"Out of memory"); memcpy(tp,&t,sizeof(*tp)); - memcpy(tp+1,cp,cplen); if (cplen) { tp->CodecPrivate = tp+1; tp->CodecPrivateSize = (unsigned)cplen; + memcpy(tp->CodecPrivate,cp,cplen); } + if (cslen) { + tp->CompMethodPrivate = (char *)(tp+1) + cplen; + tp->CompMethodPrivateSize = cslen; + memcpy(tp->CompMethodPrivate, cs, cslen); + } - cp = (char*)(tp+1) + cplen; + cp = (char*)(tp+1) + cplen + cslen; CopyStr(&tp->Name,&cp); - CopyStr(&tp->Language,&cp); CopyStr(&tp->CodecID,&cp); // set default language - if (!tp->Language) - tp->Language="eng"; + if (!tp->Language[0]) + memcpy(tp->Language, "eng", 4); *tpp = tp; } @@ -1478,7 +1597,7 @@ ENDFOR(mf); if (mf->nCues == 0 && mf->pCluster - mf->pSegment != cc.Position) - addCue(mf,mf->pCluster - mf->pSegment,mf->firstTimecode); + addCue(mf,mf->pCluster - mf->pSegment,mf->firstTimecode); memcpy(AGET(mf,Cues),&cc,sizeof(cc)); break; @@ -1498,8 +1617,6 @@ mf->Cues[j] = tmp; ++k; } - - fixupCues(mf); } static void parseAttachment(MatroskaFile *mf,ulonglong toplen) { @@ -1554,7 +1671,7 @@ struct ChapterDisplay *disp; struct ChapterProcess *proc; struct ChapterCommand *cmd; - struct Chapter *ch = (Chapter *)ASGET(mf,parent,Children); + struct Chapter *ch = ASGET(mf,parent,Children); memset(ch,0,sizeof(*ch)); @@ -1564,6 +1681,12 @@ case 0x73c4: // ChapterUID ch->UID = readUInt(mf,(unsigned)len); break; + case 0x6e67: // ChapterSegmentUID + if (len != sizeof(ch->SegmentUID)) + skipbytes(mf, len); + else + readbytes(mf, ch->SegmentUID, sizeof(ch->SegmentUID)); + break; case 0x91: // ChapterTimeStart ch->Start = readUInt(mf,(unsigned)len); break; @@ -1602,28 +1725,19 @@ disp = ASGET(mf,ch,Display); memset(disp, 0, sizeof(*disp)); } - if (disp->Language) - skipbytes(mf,len); - else - STRGETM(mf,disp->Language,len); + readLangCC(mf, len, disp->Language); break; case 0x437e: // ChapterCountry if (disp==NULL) { disp = ASGET(mf,ch,Display); memset(disp, 0, sizeof(*disp)); } - if (disp->Country) - skipbytes(mf,len); - else - STRGETM(mf,disp->Country,len); + readLangCC(mf, len, disp->Country); break; ENDFOR(mf); - if (disp && !disp->String) { - mf->cache->memfree(mf->cache,disp->Language); - mf->cache->memfree(mf->cache,disp->Country); + if (disp && !disp->String) --ch->nDisplay; - } break; case 0x6944: // ChapProcess proc = NULL; @@ -1703,7 +1817,7 @@ FOREACH(mf,toplen) case 0x45b9: // EditionEntry - ch = (Chapter *)AGET(mf,Chapters); + ch = AGET(mf,Chapters); memset(ch, 0, sizeof(*ch)); FOREACH(mf,len) case 0x45bc: // EditionUID @@ -1735,7 +1849,7 @@ FOREACH(mf,toplen) case 0x7373: // Tag - tag = (Tag *)AGET(mf,Tags); + tag = AGET(mf,Tags); memset(tag,0,sizeof(*tag)); FOREACH(mf,len) @@ -1781,10 +1895,7 @@ STRGETM(mf,st->Value,len); break; case 0x447a: // TagLanguage - if (st->Language) - skipbytes(mf,len); - else - STRGETM(mf,st->Language,len); + readLangCC(mf, len, st->Language); break; case 0x4484: // TagDefault st->Default = readUInt(mf,(unsigned)len)!=0; @@ -1841,24 +1952,31 @@ } static void parsePointers(MatroskaFile *mf) { + jmp_buf jb; + if (mf->pSegmentInfo && !mf->seen.SegmentInfo) parseContainerPos(mf,mf->pSegmentInfo); if (mf->pCluster && !mf->seen.Cluster) parseContainerPos(mf,mf->pCluster); if (mf->pTracks && !mf->seen.Tracks) parseContainerPos(mf,mf->pTracks); - if (mf->pCues && !mf->seen.Cues) { - parseContainerPos(mf,mf->pCues); - // ignore errors - mf->flags &= ~MPF_ERROR; + memcpy(&jb,&mf->jb,sizeof(jb)); + + if (setjmp(mf->jb)) + mf->flags &= ~MPF_ERROR; // ignore errors + else { + if (mf->pCues && !mf->seen.Cues) + parseContainerPos(mf,mf->pCues); + if (mf->pAttachments && !mf->seen.Attachments) + parseContainerPos(mf,mf->pAttachments); + if (mf->pChapters && !mf->seen.Chapters) + parseContainerPos(mf,mf->pChapters); + if (mf->pTags && !mf->seen.Tags) + parseContainerPos(mf,mf->pTags); } - if (mf->pAttachments && !mf->seen.Attachments) - parseContainerPos(mf,mf->pAttachments); - if (mf->pChapters && !mf->seen.Chapters) - parseContainerPos(mf,mf->pChapters); - if (mf->pTags && !mf->seen.Tags) - parseContainerPos(mf,mf->pTags); + + memcpy(&mf->jb,&jb,sizeof(jb)); } static void parseSegment(MatroskaFile *mf,ulonglong toplen) { @@ -1882,9 +2000,9 @@ seek(mf,mf->pSeekHead); id = readID(mf); if (id==EOF) // chained SeekHead points to EOF? - goto resume; + break; if (id != 0x114d9b74) // chained SeekHead doesnt point to a SeekHead? - goto resume; + break; len = readSize(mf); } else if (mf->pSegmentInfo && mf->pTracks && mf->pCues && mf->pCluster) { // we have pointers to all key elements // XXX EVIL HACK @@ -1899,10 +2017,6 @@ dontstop = 1; } } while (mf->pSeekHead); -resume: - // XXX workaround for AVI-Mux GUI - if (mf->pSegmentInfo && !mf->seen.SegmentInfo) - parseContainerPos(mf,mf->pSegmentInfo); seek(mf,nextpos); // resume reading segment break; case 0x1549a966: // SegmentInfo @@ -1945,10 +2059,43 @@ parsePointers(mf); } -static void parseBlockGroup(MatroskaFile *mf,ulonglong toplen,ulonglong timecode) { +static void parseBlockAdditions(MatroskaFile *mf, ulonglong toplen, ulonglong timecode, unsigned track) { + ulonglong add_id = 1, add_pos = 0, add_len = 0; + unsigned char have_add; + + FOREACH(mf, toplen) + case 0xa6: // BlockMore + have_add = 0; + FOREACH(mf, len) + case 0xee: // BlockAddId + add_id = readUInt(mf, (unsigned)len); + break; + case 0xa5: // BlockAddition + add_pos = filepos(mf); + add_len = len; + skipbytes(mf, len); + ++have_add; + break; + ENDFOR(mf); + if (have_add == 1 && id > 0 && id < 255) { + struct QueueEntry *qe = QAlloc(mf); + qe->Start = qe->End = timecode; + qe->Position = add_pos; + qe->Length = (unsigned)add_len; + qe->flags = FRAME_UNKNOWN_START | FRAME_UNKNOWN_END | + (((unsigned)add_id << FRAME_STREAM_SHIFT) & FRAME_STREAM_MASK); + + QPut(&mf->Queues[track],qe); + } + break; + ENDFOR(mf); +} + +static void parseBlockGroup(MatroskaFile *mf,ulonglong toplen,ulonglong timecode, int blockex) { ulonglong v; ulonglong duration = 0; ulonglong dpos; +// unsigned add_id = 0; struct QueueEntry *qe,*qf = NULL; unsigned char have_duration = 0, have_block = 0; unsigned char gap = 0; @@ -1961,11 +2108,17 @@ unsigned *sizes; signed short block_timecode; + if (blockex) + goto blockex; + FOREACH(mf,toplen) case 0xfb: // ReferenceBlock readSInt(mf,(unsigned)len); ref = 1; break; +blockex: + cur = start = filepos(mf); + len = tmplen = toplen; case 0xa1: // Block have_block = 1; @@ -1977,16 +2130,17 @@ trackid = (unsigned char)v; for (tracknum=0;tracknumnTracks;++tracknum) - if (mf->Tracks[tracknum]->Number == trackid) + if (mf->Tracks[tracknum]->Number == trackid) { + if (mf->trackMask & (1<trackMask & (1<> 1) & 3; @@ -2007,7 +2164,7 @@ nframes = c+1; } else nframes = 1; - sizes = (unsigned *)alloca(nframes*sizeof(*sizes)); + sizes = alloca(nframes*sizeof(*sizes)); switch (lacing) { case 0: // No lacing @@ -2071,39 +2228,50 @@ mf->cache->read(mf->cache,v,NULL,0); // touch page skipbytes(mf,len - filepos(mf) + dpos); + + if (blockex) + goto out; break; case 0x9b: // BlockDuration duration = readUInt(mf,(unsigned)len); have_duration = 1; break; + case 0x75a1: // BlockAdditions + if (nframes > 0) // have some frames + parseBlockAdditions(mf, len, timecode, tracknum); + else + skipbytes(mf, len); + break; ENDFOR(mf); +out: if (!have_block) errorjmp(mf,"Found a BlockGroup without Block"); if (nframes > 1) { + ulonglong defd = mf->Tracks[tracknum]->DefaultDuration; + v = qf->Start; + if (have_duration) { duration = mul3(mf->Tracks[tracknum]->TimecodeScale, duration * mf->Seg.TimecodeScale); - dpos = duration / nframes; - v = qf->Start; for (qe = qf; nframes > 1; --nframes, qe = qe->next) { qe->Start = v; - v += dpos; - duration -= dpos; + v += defd; + duration -= defd; qe->End = v; +#if 0 qe->flags &= ~(FRAME_UNKNOWN_START|FRAME_UNKNOWN_END); +#endif } qe->Start = v; qe->End = v + duration; - qe->flags &= ~(FRAME_UNKNOWN_START|FRAME_UNKNOWN_END); + qe->flags &= ~FRAME_UNKNOWN_END; } else if (mf->Tracks[tracknum]->DefaultDuration) { - dpos = mf->Tracks[tracknum]->DefaultDuration; - v = qf->Start; for (qe = qf; nframes > 0; --nframes, qe = qe->next) { qe->Start = v; - v += dpos; + v += defd; qe->End = v; qe->flags &= ~(FRAME_UNKNOWN_START|FRAME_UNKNOWN_END); } @@ -2159,16 +2327,18 @@ memcpy(&jb,&mf->jb,sizeof(jb)); if (setjmp(mf->jb)) { // something evil happened here, try to resync + // always advance read position no matter what so + // we don't get caught in an endless loop + mf->readPosition = filepos(mf); + ret = EOF; if (++retries > 3) // don't try too hard goto ex; for (;;) { - if (filepos(mf) >= mf->pSegmentTop) { - mf->readPosition = filepos(mf); + if (filepos(mf) >= mf->pSegmentTop) goto ex; - } cp = mf->cache->scan(mf->cache,filepos(mf),0x1f43b675); // cluster @@ -2194,7 +2364,7 @@ mf->readPosition = cp; } - cstop = mf->cache->getsize(mf->cache)>>1; + cstop = mf->cache->getcachesize(mf->cache)>>1; if (cstop > MAX_READAHEAD) cstop = MAX_READAHEAD; cstop += mf->readPosition; @@ -2223,18 +2393,39 @@ case 0xab: // PrevSize readUInt(mf,(unsigned)len); break; + case 0x5854: { // SilentTracks + unsigned stmask = 0, i, trk; + FOREACH(mf, len) + case 0x58d7: // SilentTrackNumber + trk = (unsigned)readUInt(mf, (unsigned)len); + for (i = 0; i < mf->nTracks; ++i) + if (mf->Tracks[i]->Number == trk) { + stmask |= 1 << i; + break; + } + break; + ENDFOR(mf); + // TODO pass stmask to reading app + break; } case 0xa0: // BlockGroup if (!have_timecode) errorjmp(mf,"Found BlockGroup before cluster TimeCode"); - parseBlockGroup(mf,len,mf->tcCluster); + parseBlockGroup(mf,len,mf->tcCluster, 0); goto out; + case 0xa3: // BlockEx + if (!have_timecode) + errorjmp(mf,"Found BlockGroup before cluster TimeCode"); + parseBlockGroup(mf, len, mf->tcCluster, 1); + goto out; ENDFOR(mf); out:; } else { if (toplen > MAXFRAME) errorjmp(mf,"Element in a cluster is too large around %llu, %X [%u]",filepos(mf),cid,(unsigned)toplen); if (cid == 0xa0) // BlockGroup - parseBlockGroup(mf,toplen,mf->tcCluster); + parseBlockGroup(mf,toplen,mf->tcCluster, 0); + else if (cid == 0xa3) // BlockEx + parseBlockGroup(mf, toplen, mf->tcCluster, 1); else skipbytes(mf,toplen); } @@ -2283,7 +2474,7 @@ jmp_buf jb; ulonglong pos = mf->pCluster; ulonglong step = 10*1024*1024; - ulonglong size, tc, isize; + ulonglong size, tc = 0, isize; longlong next_cluster; int id, have_tc, bad; struct Cue *cue; @@ -2412,7 +2603,7 @@ ulonglong nd = 0; unsigned n,vtrack; - if (mf->nCues == 0 || mf->nTracks == 0) + if (mf->nTracks == 0) return -1; for (n=vtrack=0;nnTracks;++n) @@ -2424,9 +2615,16 @@ return -1; ok: + EmptyQueues(mf); + + if (mf->nCues == 0) { + mf->readPosition = mf->pCluster + 13000000 > mf->pSegmentTop ? mf->pCluster : mf->pSegmentTop - 13000000; + mf->tcCluster = 0; + } else { + mf->readPosition = mf->Cues[mf->nCues - 1].Position + mf->pSegment; + mf->tcCluster = mf->Cues[mf->nCues - 1].Time / mf->Seg.TimecodeScale; + } mf->trackMask = ~(1 << vtrack); - mf->readPosition = mf->Cues[mf->nCues - 1].Position + mf->pSegment; - mf->tcCluster = mf->Cues[mf->nCues - 1].Time / mf->Seg.TimecodeScale; do while (mf->Queues[vtrack].head) @@ -2437,10 +2635,19 @@ nd = tc; QFree(mf,QGet(&mf->Queues[vtrack])); } - while (readMoreBlocks(mf) != EOF); + while (fillQueues(mf,0) != EOF); mf->trackMask = 0; + EmptyQueues(mf); + + // there may have been an error, but at this point we will ignore it + if (mf->flags & MPF_ERROR) { + mf->flags &= ~MPF_ERROR; + if (nd == 0) + return -1; + } + return nd; } @@ -2480,22 +2687,30 @@ // found it mf->pSegment = filepos(mf); - mf->pSegmentTop = len == MAXU64 ? MAXU64 : mf->pSegment + len; + if (len == MAXU64) { + mf->pSegmentTop = MAXU64; + if (mf->cache->getfilesize) { + longlong seglen = mf->cache->getfilesize(mf->cache); + if (seglen > 0) + mf->pSegmentTop = seglen; + } + } else + mf->pSegmentTop = mf->pSegment + len; parseSegment(mf,len); // check if we got all data if (!mf->seen.SegmentInfo) errorjmp(mf,"Couldn't find SegmentInfo"); - if (!mf->seen.Tracks) - errorjmp(mf,"Couldn't find Tracks"); if (!mf->seen.Cluster) - errorjmp(mf,"Couldn't find any Clusters"); + mf->pCluster = mf->pSegmentTop; [... truncated: 242 lines follow ...] From dlmcpaul at mail.berlios.de Tue Jun 2 11:34:17 2009 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Tue, 2 Jun 2009 11:34:17 +0200 Subject: [Haiku-commits] r30943 - in haiku/trunk/src/add-ons/media/plugins/matroska: . libMatroskaParser libebml libebml/ebml libmatroska Message-ID: <200906020934.n529YHaQ031046@sheep.berlios.de> Author: dlmcpaul Date: 2009-06-02 11:34:16 +0200 (Tue, 02 Jun 2009) New Revision: 30943 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30943&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.h haiku/trunk/src/add-ons/media/plugins/matroska/libebml/Jamfile haiku/trunk/src/add-ons/media/plugins/matroska/libebml/ebml/EbmlTypes.h haiku/trunk/src/add-ons/media/plugins/matroska/libmatroska/Jamfile haiku/trunk/src/add-ons/media/plugins/matroska/matroska_reader.cpp Log: Bring matroska library up to latest version. Allows V2 matroska file playback Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c 2009-06-02 09:15:14 UTC (rev 30942) +++ haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c 2009-06-02 09:34:16 UTC (rev 30943) @@ -1,32 +1,32 @@ /* - * Copyright (c) 2004-2006 Mike Matsnev. All Rights Reserved. + * Copyright (c) 2004-2009 Mike Matsnev. All Rights Reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Absolutely no warranty of function or purpose is made by the author + * Mike Matsnev. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * 1. Redistributions of source code must retain the above copyright - * notice immediately at the beginning of the file, without modification, - * this list of conditions, and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Absolutely no warranty of function or purpose is made by the author - * Mike Matsnev. + * $Id: MatroskaParser.c,v >1.61 Unknown mike Exp $ * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: MatroskaParser.c,v 1.61 2006/10/28 10:39:45 mike Exp $ - * */ #include @@ -50,7 +50,7 @@ #include "MatroskaParser.h" #ifdef MATROSKA_COMPRESSION_SUPPORT -#include "zlib.h" +#include #endif #define EBML_VERSION 1 @@ -96,8 +96,7 @@ return dst; } -#ifdef _WIN32 -static void strlcpy(char *dst,const char *src,unsigned size) { +static void mystrlcpy(char *dst,const char *src,unsigned size) { unsigned i; for (i=0;i+1 0) @@ -687,7 +685,7 @@ c = readch(mf); if (c == EOF) - return EOF; + return 0; // XXX should errorjmp()? if (c == 0) errorjmp(mf,"Invalid first byte of EBML integer: 0"); @@ -1078,6 +1076,8 @@ } static void parseFirstCluster(MatroskaFile *mf,ulonglong toplen) { + ulonglong end = filepos(mf) + toplen; + mf->seen.Cluster = 1; mf->firstTimecode = 0; @@ -1089,7 +1089,7 @@ readVLUInt(mf); // track number mf->firstTimecode += readSInt(mf, 2); - skipbytes(mf,start + toplen - filepos(mf)); + skipbytes(mf,end - filepos(mf)); return; case 0xa0: // BlockGroup FOREACH(mf,len) @@ -1097,7 +1097,7 @@ readVLUInt(mf); // track number mf->firstTimecode += readSInt(mf,2); - skipbytes(mf,start + toplen - filepos(mf)); + skipbytes(mf,end - filepos(mf)); return; ENDFOR(mf); break; @@ -1247,7 +1247,7 @@ ulonglong v; char *cp = NULL, *cs = NULL; size_t cplen = 0, cslen = 0, cpadd = 0; - unsigned CompScope = 0, num_comp = 0; + unsigned CompScope, num_comp = 0; if (mf->nTracks >= MAX_TRACKS) errorjmp(mf,"Too many tracks."); @@ -1424,7 +1424,7 @@ // handle compressed CodecPrivate if (t.CompEnabled && t.CompMethod == COMP_ZLIB && (CompScope & 2) && cplen > 0) { z_stream zs; - char tmp[64], *ncp; + Bytef tmp[64], *ncp; int code; uLong ncplen; @@ -1432,7 +1432,7 @@ if (inflateInit(&zs) != Z_OK) errorjmp(mf, "inflateInit failed"); - zs.next_in = cp; + zs.next_in = (Bytef *)cp; zs.avail_in = cplen; do { @@ -1450,7 +1450,7 @@ inflateReset(&zs); - zs.next_in = cp; + zs.next_in = (Bytef *)cp; zs.avail_in = cplen; zs.next_out = ncp; zs.avail_out = ncplen; @@ -1460,7 +1460,7 @@ inflateEnd(&zs); - cp = ncp; + cp = (char *)ncp; cplen = ncplen; } #endif @@ -1491,7 +1491,7 @@ } if (cslen) { tp->CompMethodPrivate = (char *)(tp+1) + cplen; - tp->CompMethodPrivateSize = cslen; + tp->CompMethodPrivateSize = (unsigned)cslen; memcpy(tp->CompMethodPrivate, cs, cslen); } @@ -1982,85 +1982,84 @@ static void parseSegment(MatroskaFile *mf,ulonglong toplen) { ulonglong nextpos; unsigned nSeekHeads = 0, dontstop = 0; + jmp_buf jb; - // we want to read data until we find a seekhead or a trackinfo - FOREACH(mf,toplen) - case 0x114d9b74: // SeekHead - if (mf->flags & MKVF_AVOID_SEEKS) { - skipbytes(mf,len); - break; - } + memcpy(&jb,&mf->jb,sizeof(jb)); - nextpos = filepos(mf) + len; - do { - mf->pSeekHead = 0; - parseSeekHead(mf,len); - ++nSeekHeads; - if (mf->pSeekHead) { // this is possibly a chained SeekHead - seek(mf,mf->pSeekHead); - id = readID(mf); - if (id==EOF) // chained SeekHead points to EOF? - break; - if (id != 0x114d9b74) // chained SeekHead doesnt point to a SeekHead? - break; - len = readSize(mf); - } else if (mf->pSegmentInfo && mf->pTracks && mf->pCues && mf->pCluster) { // we have pointers to all key elements - // XXX EVIL HACK - // Some software doesnt index tags via SeekHead, so we continue - // reading the segment after the second SeekHead - if (mf->pTags || nSeekHeads<2 || filepos(mf)>=start+toplen) { - parsePointers(mf); - return; + if (setjmp(mf->jb)) + mf->flags &= ~MPF_ERROR; + else { + // we want to read data until we find a seekhead or a trackinfo + FOREACH(mf,toplen) + case 0x114d9b74: // SeekHead + if (mf->flags & MKVF_AVOID_SEEKS) { + skipbytes(mf,len); + break; + } + + nextpos = filepos(mf) + len; + do { + mf->pSeekHead = 0; + parseSeekHead(mf,len); + ++nSeekHeads; + if (mf->pSeekHead) { // this is possibly a chained SeekHead + seek(mf,mf->pSeekHead); + id = readID(mf); + if (id==EOF) // chained SeekHead points to EOF? + break; + if (id != 0x114d9b74) // chained SeekHead doesnt point to a SeekHead? + break; + len = readSize(mf); } - // reset nextpos pointer to current position - nextpos = filepos(mf); - dontstop = 1; - } - } while (mf->pSeekHead); - seek(mf,nextpos); // resume reading segment - break; - case 0x1549a966: // SegmentInfo - mf->pSegmentInfo = cur; - parseSegmentInfo(mf,len); - break; - case 0x1f43b675: // Cluster - if (!mf->pCluster) - mf->pCluster = cur; - if (mf->seen.Cluster) - skipbytes(mf,len); - else - parseFirstCluster(mf,len); - break; - case 0x1654ae6b: // Tracks - mf->pTracks = cur; - parseTracks(mf,len); - break; - case 0x1c53bb6b: // Cues - mf->pCues = cur; - parseCues(mf,len); - break; - case 0x1941a469: // Attachments - mf->pAttachments = cur; - parseAttachments(mf,len); - break; - case 0x1043a770: // Chapters - mf->pChapters = cur; - parseChapters(mf,len); - break; - case 0x1254c367: // Tags - mf->pTags = cur; - parseTags(mf,len); - break; - ENDFOR1(mf); - // if we have pointers to all key elements - if (!dontstop && mf->pSegmentInfo && mf->pTracks && mf->pCluster) - break; - ENDFOR2(); + } while (mf->pSeekHead && nSeekHeads < 10); + seek(mf,nextpos); // resume reading segment + break; + case 0x1549a966: // SegmentInfo + mf->pSegmentInfo = cur; + parseSegmentInfo(mf,len); + break; + case 0x1f43b675: // Cluster + if (!mf->pCluster) + mf->pCluster = cur; + if (mf->seen.Cluster) + skipbytes(mf,len); + else + parseFirstCluster(mf,len); + break; + case 0x1654ae6b: // Tracks + mf->pTracks = cur; + parseTracks(mf,len); + break; + case 0x1c53bb6b: // Cues + mf->pCues = cur; + parseCues(mf,len); + break; + case 0x1941a469: // Attachments + mf->pAttachments = cur; + parseAttachments(mf,len); + break; + case 0x1043a770: // Chapters + mf->pChapters = cur; + parseChapters(mf,len); + break; + case 0x1254c367: // Tags + mf->pTags = cur; + parseTags(mf,len); + break; + ENDFOR1(mf); + // if we have pointers to all key elements + if (!dontstop && mf->pSegmentInfo && mf->pTracks && mf->pCluster) + break; + ENDFOR2(); + } + + memcpy(&mf->jb,&jb,sizeof(jb)); + parsePointers(mf); } static void parseBlockAdditions(MatroskaFile *mf, ulonglong toplen, ulonglong timecode, unsigned track) { - ulonglong add_id = 1, add_pos = 0, add_len = 0; + ulonglong add_id = 1, add_pos, add_len; unsigned char have_add; FOREACH(mf, toplen) @@ -2095,7 +2094,6 @@ ulonglong v; ulonglong duration = 0; ulonglong dpos; -// unsigned add_id = 0; struct QueueEntry *qe,*qf = NULL; unsigned char have_duration = 0, have_block = 0; unsigned char gap = 0; @@ -2152,10 +2150,10 @@ errorjmp(mf,"Unexpected EOF while reading Block flags"); if (blockex) - ref = !(c & 0x80); + ref = (unsigned char)!(c & 0x80); - gap = c & 0x1; - lacing = (c >> 1) & 3; + gap = (unsigned char)(c & 0x1); + lacing = (unsigned char)((c >> 1) & 3); if (lacing) { c = readch(mf); @@ -2474,7 +2472,7 @@ jmp_buf jb; ulonglong pos = mf->pCluster; ulonglong step = 10*1024*1024; - ulonglong size, tc = 0, isize; + ulonglong size, tc, isize; longlong next_cluster; int id, have_tc, bad; struct Cue *cue; @@ -2762,7 +2760,7 @@ { MatroskaFile *mf = io->memalloc(io,sizeof(*mf)); if (mf == NULL) { - strlcpy(err_msg,"Out of memory",msgsize); + mystrlcpy(err_msg,"Out of memory",msgsize); return NULL; } @@ -2776,7 +2774,7 @@ seek(mf,base); parseFile(mf); } else { // parser error - strlcpy(err_msg,mf->errmsg,msgsize); + mystrlcpy(err_msg,mf->errmsg,msgsize); mkv_Close(mf); return NULL; } @@ -2917,7 +2915,7 @@ mkv_SetTrackMask(mf,mf->trackMask); - if (flags & MKVF_SEEK_TO_PREV_KEYFRAME) { + if (flags & (MKVF_SEEK_TO_PREV_KEYFRAME | MKVF_SEEK_TO_PREV_KEYFRAME_STRICT)) { // we do this in two stages // a. find the last keyframes before the require position // b. seek to them @@ -2932,7 +2930,7 @@ EmptyQueues(mf); mf->readPosition = mf->Cues[j].Position + mf->pSegment; - mf->tcCluster = mf->Cues[j].Time / mf->Seg.TimecodeScale; + mf->tcCluster = mf->Cues[j].Time; for (;;) { if ((ret = fillQueues(mf,0)) < 0 || ret == RBRESYNC) @@ -2940,7 +2938,7 @@ // drain queues until we get to the required timecode for (n=0;nnTracks;++n) { - if (mf->Queues[n].head && mf->Queues[n].head->StartQueues[n].head && (mf->Queues[n].head->StartQueues[n].head)) m_seendf[n] = 1; else @@ -2956,9 +2954,14 @@ QFree(mf,QGet(&mf->Queues[n])); } - if (mf->Queues[n].head && (mf->Tracks[n]->Type != TT_AUDIO || mf->Queues[n].head->Start<=timecode)) - if (!IS_DELTA(mf->Queues[n].head)) - m_kftime[n] = mf->Queues[n].head->Start; + // We've drained the queue, so the frame at head is the next one past the requered point. + // In strict mode we are done, but when seeking is not strict we use the head frame + // if it's not an audio track (we accept preroll within a frame for audio), and the head frame + // is a keyframe + if (!(flags & MKVF_SEEK_TO_PREV_KEYFRAME_STRICT)) + if (mf->Queues[n].head && (mf->Tracks[n]->Type != TT_AUDIO || mf->Queues[n].head->Start<=timecode)) + if (!IS_DELTA(mf->Queues[n].head)) + m_kftime[n] = mf->Queues[n].head->Start; } for (n=0;nnTracks;++n) @@ -2987,7 +2990,7 @@ EmptyQueues(mf); mf->readPosition = mf->Cues[j].Position + mf->pSegment; - mf->tcCluster = mf->Cues[j].Time / mf->Seg.TimecodeScale; + mf->tcCluster = mf->Cues[j].Time; for (mask=0;;) { if ((ret = fillQueues(mf,mask)) < 0 || ret == RBRESYNC) @@ -3182,30 +3185,30 @@ ti = mkv_GetTrackInfo(mf, tracknum); if (ti == NULL) { - strlcpy(errormsg, "No such track.", msgsize); + mystrlcpy(errormsg, "No such track.", msgsize); return NULL; } if (!ti->CompEnabled) { - strlcpy(errormsg, "Track is not compressed.", msgsize); + mystrlcpy(errormsg, "Track is not compressed.", msgsize); return NULL; } if (ti->CompMethod != COMP_ZLIB) { - strlcpy(errormsg, "Unsupported compression method.", msgsize); + mystrlcpy(errormsg, "Unsupported compression method.", msgsize); return NULL; } cs = mf->cache->memalloc(mf->cache,sizeof(*cs)); if (cs == NULL) { - strlcpy(errormsg, "Ouf of memory.", msgsize); + mystrlcpy(errormsg, "Ouf of memory.", msgsize); return NULL; } memset(&cs->zs,0,sizeof(cs->zs)); code = inflateInit(&cs->zs); if (code != Z_OK) { - strlcpy(errormsg, "ZLib error.", msgsize); + mystrlcpy(errormsg, "ZLib error.", msgsize); mf->cache->memfree(mf->cache,cs); return NULL; } @@ -3243,7 +3246,6 @@ return (mf->cache->read(mf->cache, FilePos, Buffer, Count) != Count); } - /* read and decode more data from current frame, return number of bytes decoded, * 0 on end of frame, or -1 on error */ int cs_ReadData(CompressedStream *cs,char *buffer,unsigned bufsize) @@ -3267,7 +3269,7 @@ cs->decoded_ptr += todo; } else { /* setup output buffer */ - cs->zs.next_out = cs->decoded_buffer; + cs->zs.next_out = (Bytef *)cs->decoded_buffer; cs->zs.avail_out = sizeof(cs->decoded_buffer); /* try to read more data */ @@ -3277,11 +3279,11 @@ todo = sizeof(cs->frame_buffer); if (cs->mf->cache->read(cs->mf->cache, cs->frame_pos, cs->frame_buffer, todo) != (int)todo) { - strlcpy(cs->errmsg, "File read failed", sizeof(cs->errmsg)); + mystrlcpy(cs->errmsg, "File read failed", sizeof(cs->errmsg)); return -1; } - cs->zs.next_in = cs->frame_buffer; + cs->zs.next_in = (Bytef *)cs->frame_buffer; cs->zs.avail_in = todo; cs->frame_pos += todo; @@ -3291,7 +3293,7 @@ /* try to decode more data */ code = inflate(&cs->zs,Z_NO_FLUSH); if (code != Z_OK && code != Z_STREAM_END) { - strlcpy(cs->errmsg, "ZLib error.", sizeof(cs->errmsg)); + mystrlcpy(cs->errmsg, "ZLib error.", sizeof(cs->errmsg)); return -1; } Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.h 2009-06-02 09:15:14 UTC (rev 30942) +++ haiku/trunk/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.h 2009-06-02 09:34:16 UTC (rev 30943) @@ -1,32 +1,32 @@ /* - * Copyright (c) 2004-2006 Mike Matsnev. All Rights Reserved. + * Copyright (c) 2004-2009 Mike Matsnev. All Rights Reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice immediately at the beginning of the file, without modification, - * this list of conditions, and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Absolutely no warranty of function or purpose is made by the author - * Mike Matsnev. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * $Id: MatroskaParser.h,v 1.19 2006/03/11 10:57:13 mike Exp $ + * 1. Redistributions of source code must retain the above copyright + * notice immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Absolutely no warranty of function or purpose is made by the author + * Mike Matsnev. * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: MatroskaParser.h,v >1.19 Unknown mike Exp $ + * */ #ifndef MATROSKA_PARSER_H @@ -128,14 +128,13 @@ void *CompMethodPrivate; unsigned CompMethodPrivateSize; unsigned MaxBlockAdditionID; - struct { - unsigned int Enabled:1; - unsigned int Default:1; - unsigned int Lacing:1; - unsigned int DecodeAll:1; - unsigned int CompEnabled:1; - }; + unsigned int Enabled:1; + unsigned int Default:1; + unsigned int Lacing:1; + unsigned int DecodeAll:1; + unsigned int CompEnabled:1; + union { struct { unsigned char StereoMode; @@ -148,9 +147,8 @@ unsigned int CropL, CropT, CropR, CropB; unsigned int ColourSpace; MKFLOAT GammaValue; - struct { - unsigned int Interlaced:1; - }; + + unsigned int Interlaced:1; } Video; struct { MKFLOAT SamplingFreq; @@ -233,14 +231,12 @@ char SegmentUID[16]; - struct { - unsigned int Hidden:1; - unsigned int Enabled:1; + unsigned int Hidden:1; + unsigned int Enabled:1; - // Editions - unsigned int Default:1; - unsigned int Ordered:1; - }; + // Editions + unsigned int Default:1; + unsigned int Ordered:1; }; typedef struct Chapter Chapter; @@ -319,7 +315,8 @@ * all tracks are set to return EOF * on next read */ -#define MKVF_SEEK_TO_PREV_KEYFRAME 1 +#define MKVF_SEEK_TO_PREV_KEYFRAME 1 +#define MKVF_SEEK_TO_PREV_KEYFRAME_STRICT 2 X void mkv_Seek(/* in */ MatroskaFile *mf, /* in */ ulonglong timecode /* in ns */, @@ -366,7 +363,6 @@ int mkv_ReadData(MatroskaFile *mf,ulonglong FilePos, void *Buffer,unsigned int Count); - #ifdef MATROSKA_COMPRESSION_SUPPORT /* Compressed streams support */ struct CompressedStream; Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libebml/Jamfile =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/libebml/Jamfile 2009-06-02 09:15:14 UTC (rev 30942) +++ haiku/trunk/src/add-ons/media/plugins/matroska/libebml/Jamfile 2009-06-02 09:34:16 UTC (rev 30943) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src add-ons media plugins matroska libebml ; +SubDirHdrs [ FDirName $(SUBDIR) ebml ] ; + StaticLibrary libebml.a : Debug.cpp EbmlBinary.cpp Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libebml/ebml/EbmlTypes.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/libebml/ebml/EbmlTypes.h 2009-06-02 09:15:14 UTC (rev 30942) +++ haiku/trunk/src/add-ons/media/plugins/matroska/libebml/ebml/EbmlTypes.h 2009-06-02 09:34:16 UTC (rev 30943) @@ -36,8 +36,8 @@ #include #include -#include "ebml/c/libebml_t.h" -#include "ebml/EbmlConfig.h" +#include "c/libebml_t.h" +#include "EbmlConfig.h" #include "EbmlEndian.h" // binary needs to be defined START_LIBEBML_NAMESPACE Modified: haiku/trunk/src/add-ons/media/plugins/matroska/libmatroska/Jamfile =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/libmatroska/Jamfile 2009-06-02 09:15:14 UTC (rev 30942) +++ haiku/trunk/src/add-ons/media/plugins/matroska/libmatroska/Jamfile 2009-06-02 09:34:16 UTC (rev 30943) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons media plugins matroska libmatroska ; SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) libebml ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) libebml ebml ] ; StaticLibrary libmatroska.a : FileKax.cpp Modified: haiku/trunk/src/add-ons/media/plugins/matroska/matroska_reader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/matroska/matroska_reader.cpp 2009-06-02 09:15:14 UTC (rev 30942) +++ haiku/trunk/src/add-ons/media/plugins/matroska/matroska_reader.cpp 2009-06-02 09:34:16 UTC (rev 30943) @@ -78,7 +78,7 @@ }; static uint8 -matroska_samplerate_to_samplerateindex(float samplerate) +matroska_samplerate_to_samplerateindex(double samplerate) { if (samplerate <= 7350.0) { return 12; @@ -142,15 +142,15 @@ profile = 3; } - uint8 sampleRateIndex = matroska_samplerate_to_samplerateindex(track->Audio.SamplingFreq); + uint8 sampleRateIndex = matroska_samplerate_to_samplerateindex(track->AV.Audio.SamplingFreq); - TRACE("Profile %d, SampleRate %f, SampleRateIndex %d\n",profile, track->Audio.SamplingFreq, sampleRateIndex); + TRACE("Profile %d, SampleRate %f, SampleRateIndex %d\n",profile, track->AV.Audio.SamplingFreq, sampleRateIndex); // profile 5 bits // SampleRateIndex 4 bits // Channels 4 Bits (*fakeExtraData)[0] = (profile << 3) | ((sampleRateIndex & 0x0E) >> 1); - (*fakeExtraData)[1] = ((sampleRateIndex & 0x01) << 7) | (track->Audio.Channels << 3); + (*fakeExtraData)[1] = ((sampleRateIndex & 0x01) << 7) | (track->AV.Audio.Channels << 3); if (strstr(track->CodecID, "SBR")) { TRACE("Extension SBR Needs more configuration\n"); // Sync Extension 0x2b7 11 bits @@ -160,7 +160,7 @@ // if SampleRateIndex = 15 // ExtendedSamplingFrequency 24 bits - sampleRateIndex = matroska_samplerate_to_samplerateindex(track->Audio.OutputSamplingFreq); + sampleRateIndex = matroska_samplerate_to_samplerateindex(track->AV.Audio.OutputSamplingFreq); (*fakeExtraData)[2] = 0x56; (*fakeExtraData)[3] = 0xE5; if (sampleRateIndex != 15) { @@ -168,7 +168,7 @@ return 5; } - uint32 sampleRate = uint32(track->Audio.OutputSamplingFreq); + uint32 sampleRate = uint32(track->AV.Audio.OutputSamplingFreq); (*fakeExtraData)[4] = 0x80 | (sampleRateIndex << 3) | ((sampleRate & 0xFFF0 ) >> 4); (*fakeExtraData)[5] = (sampleRate & 0x0FFF) << 4; @@ -185,7 +185,7 @@ const char * mkvReader::Copyright() { - return "Matroska reader, " B_UTF8_COPYRIGHT " by Marcus Overhagen"; + return "Matroska reader, " B_UTF8_COPYRIGHT " by Marcus Overhagen\nUsing MatroskaParser " B_UTF8_COPYRIGHT " by Mike Matsnev"; } status_t @@ -296,23 +296,23 @@ cookie->audio = false; - TRACE("video StereoMode: %d\n", cookie->track_info->Video.StereoMode); - TRACE("video DisplayUnit: %d\n", cookie->track_info->Video.DisplayUnit); - TRACE("video AspectRatioType: %d\n", cookie->track_info->Video.AspectRatioType); - TRACE("video PixelWidth: %d\n", cookie->track_info->Video.PixelWidth); - TRACE("video PixelHeight: %d\n", cookie->track_info->Video.PixelHeight); - TRACE("video DisplayWidth: %d\n", cookie->track_info->Video.DisplayWidth); - TRACE("video DisplayHeight: %d\n", cookie->track_info->Video.DisplayHeight); - TRACE("video ColourSpace: %d\n", cookie->track_info->Video.ColourSpace); - TRACE("video GammaValue: %.4f\n", cookie->track_info->Video.GammaValue); + TRACE("video StereoMode: %d\n", cookie->track_info->AV.Video.StereoMode); + TRACE("video DisplayUnit: %d\n", cookie->track_info->AV.Video.DisplayUnit); + TRACE("video AspectRatioType: %d\n", cookie->track_info->AV.Video.AspectRatioType); + TRACE("video PixelWidth: %d\n", cookie->track_info->AV.Video.PixelWidth); + TRACE("video PixelHeight: %d\n", cookie->track_info->AV.Video.PixelHeight); + TRACE("video DisplayWidth: %d\n", cookie->track_info->AV.Video.DisplayWidth); + TRACE("video DisplayHeight: %d\n", cookie->track_info->AV.Video.DisplayHeight); + TRACE("video ColourSpace: %d\n", cookie->track_info->AV.Video.ColourSpace); + TRACE("video GammaValue: %.4f\n", cookie->track_info->AV.Video.GammaValue); - TRACE("video Interlaced: %d\n", cookie->track_info->Video.Interlaced); + TRACE("video Interlaced: %d\n", cookie->track_info->AV.Video.Interlaced); cookie->frame_rate = get_frame_rate(cookie->track_info->DefaultDuration); cookie->duration = get_duration_in_us(fFileInfo->Duration); cookie->frame_count = get_frame_count_by_default_duration(fFileInfo->Duration, cookie->track_info->DefaultDuration); - cookie->line_count = cookie->track_info->Video.PixelHeight; + cookie->line_count = cookie->track_info->AV.Video.PixelHeight; TRACE("mkvReader::Sniff: TimecodeScale %Ld\n", fFileInfo->TimecodeScale); TRACE("mkvReader::Sniff: Duration %Ld\n", fFileInfo->Duration); @@ -334,10 +334,10 @@ uint16 width_aspect_ratio; uint16 height_aspect_ratio; get_pixel_aspect_ratio(&width_aspect_ratio, &height_aspect_ratio, - cookie->track_info->Video.PixelWidth, - cookie->track_info->Video.PixelHeight, - cookie->track_info->Video.DisplayWidth, - cookie->track_info->Video.DisplayHeight); + cookie->track_info->AV.Video.PixelWidth, + cookie->track_info->AV.Video.PixelHeight, + cookie->track_info->AV.Video.DisplayWidth, + cookie->track_info->AV.Video.DisplayHeight); // cookie->format.u.encoded_video.max_bit_rate = // cookie->format.u.encoded_video.avg_bit_rate = @@ -349,8 +349,8 @@ cookie->format.u.encoded_video.output.pixel_width_aspect = width_aspect_ratio; cookie->format.u.encoded_video.output.pixel_height_aspect = height_aspect_ratio; // cookie->format.u.encoded_video.output.display.format = 0; - cookie->format.u.encoded_video.output.display.line_width = cookie->track_info->Video.PixelWidth; - cookie->format.u.encoded_video.output.display.line_count = cookie->track_info->Video.PixelHeight; + cookie->format.u.encoded_video.output.display.line_width = cookie->track_info->AV.Video.PixelWidth; + cookie->format.u.encoded_video.output.display.line_count = cookie->track_info->AV.Video.PixelHeight; cookie->format.u.encoded_video.output.display.bytes_per_row = 0; cookie->format.u.encoded_video.output.display.pixel_offset = 0; cookie->format.u.encoded_video.output.display.line_offset = 0; @@ -373,14 +373,14 @@ cookie->audio = true; - TRACE("audio SamplingFreq: %.3f\n", cookie->track_info->Audio.SamplingFreq); - TRACE("audio OutputSamplingFreq: %.3f\n", cookie->track_info->Audio.OutputSamplingFreq); - TRACE("audio Channels: %d\n", cookie->track_info->Audio.Channels); - TRACE("audio BitDepth: %d\n", cookie->track_info->Audio.BitDepth); + TRACE("audio SamplingFreq: %.3f\n", cookie->track_info->AV.Audio.SamplingFreq); + TRACE("audio OutputSamplingFreq: %.3f\n", cookie->track_info->AV.Audio.OutputSamplingFreq); + TRACE("audio Channels: %d\n", cookie->track_info->AV.Audio.Channels); + TRACE("audio BitDepth: %d\n", cookie->track_info->AV.Audio.BitDepth); TRACE("CodecID: %s\n", cookie->track_info->CodecID); - cookie->frame_rate = cookie->track_info->Audio.SamplingFreq; + cookie->frame_rate = cookie->track_info->AV.Audio.SamplingFreq; cookie->duration = get_duration_in_us(fFileInfo->Duration); cookie->frame_count = get_frame_count_by_frame_rate(fFileInfo->Duration, cookie->frame_rate); @@ -394,8 +394,8 @@ } cookie->format.u.encoded_audio.output.frame_rate = cookie->frame_rate; - cookie->format.u.encoded_audio.output.channel_count = cookie->track_info->Audio.Channels; - cookie->format.u.encoded_audio.bit_rate = cookie->track_info->Audio.BitDepth * cookie->format.u.encoded_audio.output.channel_count * cookie->frame_rate; + cookie->format.u.encoded_audio.output.channel_count = cookie->track_info->AV.Audio.Channels; + cookie->format.u.encoded_audio.bit_rate = cookie->track_info->AV.Audio.BitDepth * cookie->format.u.encoded_audio.output.channel_count * cookie->frame_rate; cookie->private_data = (uint8 *)cookie->track_info->CodecPrivate; cookie->private_data_size = cookie->track_info->CodecPrivateSize; From threedeyes at mail.berlios.de Tue Jun 2 14:23:46 2009 From: threedeyes at mail.berlios.de (threedeyes at mail.berlios.de) Date: Tue, 2 Jun 2009 14:23:46 +0200 Subject: [Haiku-commits] r30944 - in haiku/trunk/src/add-ons/kernel/file_systems/ntfs: . libntfs settings Message-ID: <200906021223.n52CNk5t027320@sheep.berlios.de> Author: threedeyes Date: 2009-06-02 14:21:10 +0200 (Tue, 02 Jun 2009) New Revision: 30944 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30944&view=rev Removed: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fsproto.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/version.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/version.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/Jamfile haiku/trunk/src/add-ons/kernel/file_systems/ntfs/attributes.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrlist.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/bitmap.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/bitmap.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/bootsect.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/compress.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/debug.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/endians.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/layout.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logfile.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mst.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/runlist.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/security.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/security.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unix_io.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/win32_io.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/lock.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/ntfs.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/ntfsdir.h haiku/trunk/src/add-ons/kernel/file_systems/ntfs/settings/ntfs haiku/trunk/src/add-ons/kernel/file_systems/ntfs/utils.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/volume_util.c Log: Update NTFS-3g Library to stable 2009.4.4 version. Clean up code. Now write support enabled by default. Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/Jamfile 2009-06-02 09:34:16 UTC (rev 30943) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/Jamfile 2009-06-02 12:21:10 UTC (rev 30944) @@ -2,8 +2,6 @@ SubDirHdrs [ FDirName $(SUBDIR) libntfs ] ; -SetSubDirSupportedPlatformsBeOSCompatible ; - SubDirCcFlags -DHAVE_CONFIG_H=1 ; SubDirC++Flags -DHAVE_CONFIG_H=1 ; Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/attributes.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/attributes.c 2009-06-02 09:34:16 UTC (rev 30943) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/attributes.c 2009-06-02 12:21:10 UTC (rev 30944) @@ -54,18 +54,11 @@ } -#ifdef __HAIKU__ status_t fs_open_attrib_dir(fs_volume *_vol, fs_vnode *_node, void **_cookie) { nspace *ns = (nspace *)_vol->private_volume; -#else -int -fs_open_attrib_dir(void *_ns, void *_node, void **_cookie) -{ - nspace *ns = (nspace *)_ns; -#endif - + int result = B_NO_ERROR; ERRPRINT("fs_open_attrdir - ENTER\n"); @@ -88,17 +81,10 @@ return result; } -#ifdef __HAIKU__ status_t fs_close_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie) { nspace *ns = (nspace *)_vol->private_volume; -#else -int -fs_close_attrib_dir(void *_ns, void *_node, void *_cookie) -{ - nspace *ns = (nspace *)_ns; -#endif ERRPRINT("fs_close_attrdir - ENTER\n"); @@ -113,17 +99,10 @@ return B_NO_ERROR; } -#ifdef __HAIKU__ status_t fs_free_attrib_dir_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie) { nspace *ns = (nspace *)_vol->private_volume; -#else -int -fs_free_attrib_dir_cookie(void *_ns, void *_node, void *_cookie) -{ - nspace *ns = (nspace *)_ns; -#endif int result = B_NO_ERROR; @@ -149,17 +128,11 @@ return result; } -#ifdef __HAIKU__ status_t fs_rewind_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie) { nspace *ns = (nspace *)_vol->private_volume; -#else -int -fs_rewind_attrib_dir(void *_ns, void *_node, void *_cookie) -{ - nspace *ns = (nspace *)_ns; -#endif + int result = B_NO_ERROR; LOCK_VOL(ns); @@ -184,19 +157,12 @@ } -#ifdef __HAIKU__ status_t fs_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *entry, size_t bufsize, uint32 *num) { nspace *ns = (nspace *)_vol->private_volume; vnode *node = (vnode *)_node->private_node; -#else -int -fs_read_attrib_dir(void *_ns, void *_node, void *_cookie, long *num, struct dirent *entry, size_t bufsize) -{ - nspace *ns = (nspace *)_ns; - vnode *node = (vnode *)_node; -#endif + int32 *cookie = (int32 *)_cookie; LOCK_VOL(ns); @@ -223,28 +189,6 @@ return B_NO_ERROR; } -#ifndef __HAIKU__ -int -fs_read_attrib_stat(void *_ns, void *_node, const char *name, struct attr_info *buf) -{ - nspace *ns = (nspace *)_ns; - vnode *node = (vnode *)_node; - - if (strcmp(name, "BEOS:TYPE")) - return ENOENT; - - if (node->mime == NULL) { - return ENOENT; - } - - buf->type = MIME_STRING_TYPE; - buf->size = strlen(node->mime) + 1; - - return 0; -} -#endif - -#ifdef __HAIKU__ status_t fs_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name, int openMode, void **_cookie) { @@ -276,25 +220,22 @@ return result; } -#endif -#ifdef __HAIKU__ + status_t fs_close_attrib(fs_volume *_vol, fs_vnode *_node, void *cookie) { return B_NO_ERROR; } -#endif -#ifdef __HAIKU__ + status_t fs_free_attrib_cookie(fs_volume *_vol, fs_vnode *_node, void *cookie) { return B_NO_ERROR; } -#endif -#ifdef __HAIKU__ + status_t fs_read_attrib_stat(fs_volume *_vol, fs_vnode *_node, void *_cookie,struct stat *stat) { @@ -327,33 +268,24 @@ return B_NO_ERROR; } -#endif -#ifdef __HAIKU__ + status_t fs_read_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos,void *buffer, size_t *_length) { nspace *ns = (nspace *)_vol->private_volume; vnode *node = (vnode *)_node->private_node; -#else -int -fs_read_attrib(void *_ns, void *_node, const char *name, int type, void *buffer, size_t *_length, off_t pos) -{ - nspace *ns = (nspace *)_ns; - vnode *node = (vnode *)_node; -#endif + int result = B_NO_ERROR; LOCK_VOL(ns); ERRPRINT("fs_read_attr - ENTER\n"); -#ifdef __HAIKU_ if (_cookie != &kBeOSTypeCookie) { result = ENOENT; goto exit; } -#endif if (node->mime == NULL) { result = ENOENT; @@ -379,17 +311,11 @@ } -#ifdef __HAIKU__ status_t fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie,off_t pos, const void *buffer, size_t *_length) { nspace *ns = (nspace *)_vol->private_volume; -#else -int -fs_write_attrib(void *_ns, void *_node, const char *name, int type, const void *buffer, size_t *_length, off_t pos) -{ - nspace *ns = (nspace *)_ns; -#endif + int result = B_NO_ERROR; LOCK_VOL(ns); @@ -397,11 +323,10 @@ ERRPRINT("fs_write_attr - ENTER\n"); *_length = 0; -#ifdef __HAIKU_ + if (_cookie != &kBeOSTypeCookie) { result = ENOSYS; } -#endif ERRPRINT("fs_write_attrib - EXIT, result is %s\n", strerror(result)); Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c 2009-06-02 09:34:16 UTC (rev 30943) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c 2009-06-02 12:21:10 UTC (rev 30944) @@ -123,7 +123,7 @@ if(!ioctl(fd,B_GET_PATH_FOR_DEVICE,devpath)) return -1; //try mount - ntVolume = utils_mount_volume(devpath,MS_RDONLY|MS_NOATIME,true); + ntVolume = utils_mount_volume(devpath,MS_RDONLY,true); if(!ntVolume) return -1; @@ -208,8 +208,8 @@ mnt_flags |= MS_RDONLY; ns->flags |= B_MOUNT_READ_ONLY; } - if (ns->noatime) - mnt_flags |= MS_NOATIME; +// if (ns->noatime) +// mnt_flags |= MS_NOATIME; ns->ntvol=utils_mount_volume(device,mnt_flags,true); if(ns->ntvol!=NULL) @@ -367,7 +367,7 @@ result = ENOENT; } else { unicode = ntfs_calloc(MAX_PATH); - len = ntfs_mbstoucs(file, &unicode, MAX_PATH); + len = ntfs_mbstoucs(file, &unicode); if (len < 0) { result = EILSEQ; goto exit; @@ -882,7 +882,7 @@ goto exit; } - uname_len = ntfs_mbstoucs(name, &uname, 0); + uname_len = ntfs_mbstoucs(name, &uname); if (uname_len < 0) { result = EINVAL; goto exit; @@ -1285,13 +1285,13 @@ goto exit; } - uname_len = ntfs_mbstoucs(name, &uname, 0); + uname_len = ntfs_mbstoucs(name, &uname); if (uname_len < 0) { result = EINVAL; goto exit; } - utarget_len = ntfs_mbstoucs(target, &utarget, 0); + utarget_len = ntfs_mbstoucs(target, &utarget); if (utarget_len < 0) { result = EINVAL; goto exit; @@ -1380,7 +1380,7 @@ goto exit; } - uname_len = ntfs_mbstoucs(name, &uname, 0); + uname_len = ntfs_mbstoucs(name, &uname); if (uname_len < 0) { result = EINVAL; goto exit; @@ -1475,13 +1475,13 @@ goto exit; //convert names from utf8 to unicode string - unewname_len = ntfs_mbstoucs(newname, &unewname, 0); + unewname_len = ntfs_mbstoucs(newname, &unewname); if (unewname_len < 0) { result = EINVAL; goto exit; } - uoldname_len = ntfs_mbstoucs(oldname, &uoldname, 0); + uoldname_len = ntfs_mbstoucs(oldname, &uoldname); if (uoldname_len < 0) { result = EINVAL; goto exit; @@ -1544,13 +1544,14 @@ goto exit; } - ntfs_delete(oi, odi, uoldname, uoldname_len); - onode->parent_vnid = MREF( ndi->mft_no ); - + notify_entry_moved(ns->id, MREF( odi->mft_no ), oldname, MREF( ndi->mft_no ), newname, onode->vnid ); notify_attribute_changed(ns->id, onode->vnid, "BEOS:TYPE", B_ATTR_CHANGED); + ntfs_delete(oi, odi, uoldname, uoldname_len); + oi = odi = NULL; /* ntfs_delete() always closes ni and dir_ni */ + put_vnode(_vol, onode->vnid ); } else { //renaming @@ -1590,10 +1591,12 @@ goto exit; } - ntfs_delete(oi, odi, uoldname, uoldname_len); notify_entry_moved(ns->id, MREF( odi->mft_no ), oldname, MREF( odi->mft_no ), newname, onode->vnid ); notify_attribute_changed(ns->id, onode->vnid, "BEOS:TYPE", B_ATTR_CHANGED); put_vnode(_vol, onode->vnid ); + + ntfs_delete(oi, odi, uoldname, uoldname_len); + oi = odi = NULL; /* ntfs_delete() always closes ni and dir_ni */ } @@ -1626,7 +1629,7 @@ int uname_len; status_t result = B_NO_ERROR; - uname_len = ntfs_mbstoucs(name, &uname, 0); + uname_len = ntfs_mbstoucs(name, &uname); if (uname_len < 0) { result = EINVAL; goto exit1; @@ -1675,9 +1678,9 @@ if(ntfs_delete(ni, bi, uname, uname_len)) result = errno; - else - ni = NULL; + ni = bi = NULL; + node->parent_vnid = dir->vnid; notify_entry_removed(vol->id, dir->vnid, name, vnid); @@ -1760,7 +1763,7 @@ ERRPRINT("fs_unlink - ENTER: name %s\n", name==NULL?"NULL":name); - if( ns == NULL || dir == NULL || name ==NULL) { + if( ns == NULL || dir == NULL || name == NULL) { result = EINVAL; goto exit; } Deleted: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fsproto.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile 2009-06-02 09:34:16 UTC (rev 30943) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile 2009-06-02 12:21:10 UTC (rev 30944) @@ -1,7 +1,5 @@ SubDir HAIKU_TOP src add-ons kernel file_systems ntfs libntfs ; -SetSubDirSupportedPlatformsBeOSCompatible ; - SubDirCcFlags -Wall -Wno-multichar -DHAVE_CONFIG_H=1 ; StaticLibrary libntfs.a : @@ -27,7 +25,6 @@ runlist.c security.c unistr.c - version.c volume.c ; Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c 2009-06-02 09:34:16 UTC (rev 30943) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c 2009-06-02 12:21:10 UTC (rev 30944) @@ -3,8 +3,9 @@ * * Copyright (c) 2000-2005 Anton Altaparmakov * Copyright (c) 2002-2005 Richard Russon - * Copyright (c) 2002-2006 Szabolcs Szakacsits - * Copyright (c) 2004-2006 Yura Pakhuchiy + * Copyright (c) 2002-2008 Szabolcs Szakacsits + * Copyright (c) 2004-2007 Yura Pakhuchiy + * Copyright (c) 2007-2008 Jean-Pierre Andre * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -60,6 +61,37 @@ ntfschar AT_UNNAMED[] = { const_cpu_to_le16('\0') }; +static int NAttrFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag) +{ + if (na->type == AT_DATA && na->name == AT_UNNAMED) + return (na->ni->flags & flag); + return 0; +} + +static void NAttrSetFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag) +{ + if (na->type == AT_DATA && na->name == AT_UNNAMED) + na->ni->flags |= flag; + else + ntfs_log_trace("Denied setting flag %d for not unnamed data " + "attribute\n", flag); +} + +static void NAttrClearFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag) +{ + if (na->type == AT_DATA && na->name == AT_UNNAMED) + na->ni->flags &= ~flag; +} + +#define GenNAttrIno(func_name, flag) \ +int NAttr##func_name(ntfs_attr *na) { return NAttrFlag (na, flag); } \ +void NAttrSet##func_name(ntfs_attr *na) { NAttrSetFlag (na, flag); } \ +void NAttrClear##func_name(ntfs_attr *na){ NAttrClearFlag(na, flag); } + +GenNAttrIno(Compressed, FILE_ATTR_COMPRESSED) +GenNAttrIno(Encrypted, FILE_ATTR_ENCRYPTED) +GenNAttrIno(Sparse, FILE_ATTR_SPARSE_FILE) + /** * ntfs_get_attribute_value_length - Find the length of an attribute * @a: @@ -343,63 +375,82 @@ ntfschar *name, u32 name_len) { ntfs_attr_search_ctx *ctx; - ntfs_attr *na; + ntfs_attr *na = NULL; + ntfschar *newname = NULL; ATTR_RECORD *a; - int err; BOOL cs; - ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", - (unsigned long long)ni->mft_no, type); + ntfs_log_enter("Entering for inode %lld, attr 0x%x.\n", + (unsigned long long)ni->mft_no, type); + if (!ni || !ni->vol || !ni->mrec) { errno = EINVAL; - return NULL; + goto out; } - na = calloc(sizeof(ntfs_attr), 1); + na = ntfs_calloc(sizeof(ntfs_attr)); if (!na) - return NULL; + goto out; if (name && name != AT_UNNAMED && name != NTFS_INDEX_I30) { name = ntfs_ucsndup(name, name_len); - if (!name) { - free(na); - return NULL; - } + if (!name) + goto err_out; + newname = name; } ctx = ntfs_attr_get_search_ctx(ni, NULL); - if (!ctx) { - err = errno; + if (!ctx) goto err_out; - } - if (ntfs_attr_lookup(type, name, name_len, 0, 0, NULL, 0, ctx)) { - err = errno; + + if (ntfs_attr_lookup(type, name, name_len, 0, 0, NULL, 0, ctx)) goto put_err_out; - } a = ctx->attr; - /* - * Wipe the flags in case they are not zero for an attribute list - * attribute. Windows does not complain about invalid flags and chkdsk - * does not detect or fix them so we need to cope with it, too. - */ - if (type == AT_ATTRIBUTE_LIST) - a->flags = 0; - cs = a->flags & (ATTR_IS_COMPRESSED | ATTR_IS_SPARSE); + if (!name) { if (a->name_length) { name = ntfs_ucsndup((ntfschar*)((u8*)a + le16_to_cpu( a->name_offset)), a->name_length); - if (!name) { - err = errno; + if (!name) goto put_err_out; - } + newname = name; name_len = a->name_length; } else { name = AT_UNNAMED; name_len = 0; } } + __ntfs_attr_init(na, ni, type, name, name_len); + + /* + * Wipe the flags in case they are not zero for an attribute list + * attribute. Windows does not complain about invalid flags and chkdsk + * does not detect or fix them so we need to cope with it, too. + */ + if (type == AT_ATTRIBUTE_LIST) + a->flags = 0; + + cs = a->flags & (ATTR_IS_COMPRESSED | ATTR_IS_SPARSE); + + if (na->type == AT_DATA && na->name == AT_UNNAMED && + ((!(a->flags & ATTR_IS_COMPRESSED) != !NAttrCompressed(na)) || + (!(a->flags & ATTR_IS_SPARSE) != !NAttrSparse(na)) || + (!(a->flags & ATTR_IS_ENCRYPTED) != !NAttrEncrypted(na)))) { + errno = EIO; + ntfs_log_perror("Inode %lld has corrupt attribute flags " + "(0x%x <> 0x%x)",(unsigned long long)ni->mft_no, + a->flags, na->ni->flags); + goto put_err_out; + } + if (a->non_resident) { + if ((a->flags & ATTR_IS_COMPRESSED) && !a->compression_unit) { + errno = EIO; + ntfs_log_perror("Compressed inode %lld attr 0x%x has " + "no compression unit", + (unsigned long long)ni->mft_no, type); + goto put_err_out; + } ntfs_attr_init(na, TRUE, a->flags & ATTR_IS_COMPRESSED, a->flags & ATTR_IS_ENCRYPTED, a->flags & ATTR_IS_SPARSE, @@ -416,13 +467,17 @@ cs ? (l + 7) & ~7 : 0, 0); } ntfs_attr_put_search_ctx(ctx); +out: + ntfs_log_leave("\n"); return na; + put_err_out: ntfs_attr_put_search_ctx(ctx); err_out: + free(newname); free(na); - errno = err; - return NULL; + na = NULL; + goto out; } /** @@ -449,7 +504,7 @@ * @na: ntfs attribute for which to map (part of) a runlist * @vcn: map runlist part containing this vcn * - * Map the part of a runlist containing the @vcn of an the ntfs attribute @na. + * Map the part of a runlist containing the @vcn of the ntfs attribute @na. * * Return 0 on success and -1 on error with errno set to the error code. */ @@ -492,8 +547,8 @@ * ntfs_attr_map_whole_runlist - map the whole runlist of an ntfs attribute * @na: ntfs attribute for which to map the runlist * - * Map the whole runlist of an the ntfs attribute @na. For an attribute made - * up of only one attribute extent this is the same as calling + * Map the whole runlist of the ntfs attribute @na. For an attribute made up + * of only one attribute extent this is the same as calling * ntfs_attr_map_runlist(na, 0) but for an attribute with multiple extents this * will map the runlist fragments from each of the extents thus giving access * to the entirety of the disk allocation of an attribute. @@ -506,14 +561,14 @@ ntfs_attr_search_ctx *ctx; ntfs_volume *vol = na->ni->vol; ATTR_RECORD *a; - int err; + int ret = -1; - ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x.\n", - (unsigned long long)na->ni->mft_no, na->type); + ntfs_log_enter("Entering for inode %llu, attr 0x%x.\n", + (unsigned long long)na->ni->mft_no, na->type); ctx = ntfs_attr_get_search_ctx(na->ni, NULL); if (!ctx) - return -1; + goto out; /* Map all attribute extents one by one. */ next_vcn = last_vcn = highest_vcn = 0; @@ -584,17 +639,13 @@ (long long)highest_vcn, (long long)last_vcn); goto err_out; } - err = errno; + if (errno == ENOENT) + ret = 0; +err_out: ntfs_attr_put_search_ctx(ctx); - if (err == ENOENT) - return 0; -out_now: - errno = err; - return -1; -err_out: - err = errno; - ntfs_attr_put_search_ctx(ctx); - goto out_now; +out: + ntfs_log_leave("\n"); + return ret; } /** @@ -727,41 +778,16 @@ } /** - * ntfs_attr_pread - read from an attribute specified by an ntfs_attr structure - * @na: ntfs attribute to read from - * @pos: byte position in the attribute to begin reading from - * @count: number of bytes to read - * @b: output data buffer - * - * This function will read @count bytes starting at offset @pos from the ntfs - * attribute @na into the data buffer @b. - * - * On success, return the number of successfully read bytes. If this number is - * lower than @count this means that the read reached end of file or that an - * error was encountered during the read so that the read is partial. 0 means - * end of file or nothing was read (also return 0 when @count is 0). - * - * On error and nothing has been read, return -1 with errno set appropriately - * to the return code of ntfs_pread(), or to EINVAL in case of invalid - * arguments. - */ -s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b) + * ntfs_attr_pread_i - see description at ntfs_attr_pread() + */ +static s64 ntfs_attr_pread_i(ntfs_attr *na, const s64 pos, s64 count, void *b) { s64 br, to_read, ofs, total, total2; ntfs_volume *vol; runlist_element *rl; - ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, pos 0x%llx, count " - "0x%llx.\n", (unsigned long long)na->ni->mft_no, - na->type, (long long)pos, (long long)count); - if (!na || !na->ni || !na->ni->vol || !b || pos < 0 || count < 0) { - errno = EINVAL; - return -1; - } - /* - * If this is a compressed attribute it needs special treatment, but - * only if it is non-resident. - */ + /* Sanity checking arguments is done in ntfs_attr_pread(). */ + if (NAttrCompressed(na) && NAttrNonResident(na)) return ntfs_compressed_attr_pread(na, pos, count, b); /* @@ -773,10 +799,7 @@ return -1; } vol = na->ni->vol; - /* Update access time if needed. */ - if (na->type == AT_DATA || na->type == AT_INDEX_ROOT || - na->type == AT_INDEX_ALLOCATION) - ntfs_inode_update_atime(na->ni); + if (!count) return 0; /* Truncate reads beyond end of attribute. */ @@ -804,6 +827,7 @@ le32_to_cpu(ctx->attr->value_length) > (char*)ctx->mrec + vol->mft_record_size) { errno = EIO; + ntfs_log_perror("%s: Sanity check failed", __FUNCTION__); goto res_err_out; } memcpy(b, val + pos, count); @@ -829,8 +853,10 @@ * However, we already truncated the read to the data_size, * so getting this here is an error. */ - if (errno == ENOENT) + if (errno == ENOENT) { errno = EIO; + ntfs_log_perror("%s: Failed to find VCN #1", __FUNCTION__); + } return -1; } /* @@ -843,18 +869,28 @@ if (rl->lcn == LCN_RL_NOT_MAPPED) { rl = ntfs_attr_find_vcn(na, rl->vcn); if (!rl) { - if (errno == ENOENT) + if (errno == ENOENT) { errno = EIO; + ntfs_log_perror("%s: Failed to find VCN #2", + __FUNCTION__); + } goto rl_err_out; } /* Needed for case when runs merged. */ ofs = pos + total - (rl->vcn << vol->cluster_size_bits); } - if (!rl->length) + if (!rl->length) { + errno = EIO; + ntfs_log_perror("%s: Zero run length", __FUNCTION__); goto rl_err_out; + } if (rl->lcn < (LCN)0) { - if (rl->lcn != (LCN)LCN_HOLE) + if (rl->lcn != (LCN)LCN_HOLE) { + ntfs_log_perror("%s: Bad run (%lld)", + __FUNCTION__, + (long long)rl->lcn); goto rl_err_out; + } /* It is a hole, just zero the matching @b range. */ to_read = min(count, (rl->length << vol->cluster_size_bits) - ofs); @@ -869,8 +905,9 @@ to_read = min(count, (rl->length << vol->cluster_size_bits) - ofs); retry: - ntfs_log_trace("Reading 0x%llx bytes from vcn 0x%llx, lcn 0x%llx, " - "ofs 0x%llx.\n", to_read, rl->vcn, rl->lcn, ofs); + ntfs_log_trace("Reading %lld bytes from vcn %lld, lcn %lld, ofs" + " %lld.\n", (long long)to_read, (long long)rl->vcn, + (long long )rl->lcn, (long long)ofs); br = ntfs_pread(vol->dev, (rl->lcn << vol->cluster_size_bits) + ofs, to_read, b); /* If everything ok, update progress counters and continue. */ @@ -878,8 +915,9 @@ total += br; count -= br; b = (u8*)b + br; + } + if (br == to_read) continue; - } /* If the syscall was interrupted, try again. */ if (br == (s64)-1 && errno == EINTR) goto retry; @@ -887,6 +925,7 @@ return total; if (!br) errno = EIO; + ntfs_log_perror("%s: ntfs_pread failed", __FUNCTION__); return -1; } /* Finally, return the number of bytes read. */ @@ -898,6 +937,47 @@ return -1; } +/** + * ntfs_attr_pread - read from an attribute specified by an ntfs_attr structure + * @na: ntfs attribute to read from + * @pos: byte position in the attribute to begin reading from + * @count: number of bytes to read + * @b: output data buffer + * + * This function will read @count bytes starting at offset @pos from the ntfs + * attribute @na into the data buffer @b. + * + * On success, return the number of successfully read bytes. If this number is + * lower than @count this means that the read reached end of file or that an + * error was encountered during the read so that the read is partial. 0 means + * end of file or nothing was read (also return 0 when @count is 0). + * + * On error and nothing has been read, return -1 with errno set appropriately + * to the return code of ntfs_pread(), or to EINVAL in case of invalid + * arguments. + */ +s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b) +{ + s64 ret; + + if (!na || !na->ni || !na->ni->vol || !b || pos < 0 || count < 0) { + errno = EINVAL; + ntfs_log_perror("%s: na=%p b=%p pos=%lld count=%lld", + __FUNCTION__, na, b, (long long)pos, + (long long)count); + return -1; + } + + ntfs_log_enter("Entering for inode %lld attr 0x%x pos %lld count " + "%lld\n", (unsigned long long)na->ni->mft_no, + na->type, (long long)pos, (long long)count); + + ret = ntfs_attr_pread_i(na, pos, count, b); + + ntfs_log_leave("\n"); + return ret; +} + static int ntfs_attr_fill_zero(ntfs_attr *na, s64 pos, s64 count) { char *buf; @@ -949,7 +1029,8 @@ from_vcn = (*rl)->vcn + (*ofs >> vol->cluster_size_bits); ntfs_log_trace("count: %lld, cur_vcn: %lld, from: %lld, to: %lld, ofs: " - "%lld\n", count, cur_vcn, from_vcn, to_write, *ofs); + "%lld\n", (long long)count, (long long)cur_vcn, + (long long)from_vcn, (long long)to_write, (long long)*ofs); /* Map whole runlist to be able update mapping pairs later. */ if (ntfs_attr_map_whole_runlist(na)) @@ -1081,17 +1162,20 @@ ntfs_volume *vol; ntfs_attr_search_ctx *ctx = NULL; runlist_element *rl; + s64 hole_end; int eo; struct { unsigned int undo_initialized_size : 1; unsigned int undo_data_size : 1; } need_to = { 0, 0 }; - ntfs_log_trace("Entering for inode 0x%llx, attr 0x%x, pos 0x%llx, count " - "0x%llx.\n", na->ni->mft_no, na->type, (long long)pos, - (long long)count); + ntfs_log_enter("Entering for inode %lld, attr 0x%x, pos 0x%llx, count " + "0x%llx.\n", (long long)na->ni->mft_no, na->type, + (long long)pos, (long long)count); + if (!na || !na->ni || !na->ni->vol || !b || pos < 0 || count < 0) { errno = EINVAL; + ntfs_log_perror("%s", __FUNCTION__); goto errno_set; } vol = na->ni->vol; @@ -1111,10 +1195,7 @@ errno = EOPNOTSUPP; goto errno_set; } - /* Update access and change times if needed. */ - if (na->type == AT_DATA || na->type == AT_INDEX_ROOT || - na->type == AT_INDEX_ALLOCATION) - ntfs_inode_update_time(na->ni); + if (!count) goto out; /* If the write reaches beyond the end, extend the attribute. */ @@ -1135,13 +1216,16 @@ if (!ctx) goto err_out; if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0, - 0, NULL, 0, ctx)) + 0, NULL, 0, ctx)) { + ntfs_log_perror("%s: lookup failed", __FUNCTION__); goto err_out; + } val = (char*)ctx->attr + le16_to_cpu(ctx->attr->value_offset); if (val < (char*)ctx->attr || val + le32_to_cpu(ctx->attr->value_length) > (char*)ctx->mrec + vol->mft_record_size) { errno = EIO; + ntfs_log_perror("%s: Sanity check failed", __FUNCTION__); goto err_out; } memcpy(val + pos, b, count); @@ -1154,6 +1238,7 @@ * it is unlikely to fail writing it, so is ok to just * return error here... (AIA) */ + ntfs_log_perror("%s: failed to write mft record", __FUNCTION__); goto err_out; } ntfs_attr_put_search_ctx(ctx); @@ -1211,8 +1296,10 @@ * However, we already extended the size of the attribute, * so getting this here must be an error of some kind. */ - if (errno == ENOENT) + if (errno == ENOENT) { errno = EIO; + ntfs_log_perror("%s: Failed to find VCN #1", __FUNCTION__); + } goto err_out; } /* @@ -1221,12 +1308,15 @@ * length. */ ofs = pos - (rl->vcn << vol->cluster_size_bits); - for (; count; rl++, ofs = 0) { + for (hole_end = 0; count; rl++, ofs = 0, hole_end = 0) { if (rl->lcn == LCN_RL_NOT_MAPPED) { rl = ntfs_attr_find_vcn(na, rl->vcn); if (!rl) { - if (errno == ENOENT) + if (errno == ENOENT) { errno = EIO; + ntfs_log_perror("%s: Failed to find VCN" + " #2", __FUNCTION__); + } goto rl_err_out; } /* Needed for case when runs merged. */ @@ -1234,12 +1324,18 @@ } if (!rl->length) { errno = EIO; + ntfs_log_perror("%s: Zero run length", __FUNCTION__); goto rl_err_out; } if (rl->lcn < (LCN)0) { + + hole_end = rl->vcn + rl->length; if (rl->lcn != (LCN)LCN_HOLE) { errno = EIO; + ntfs_log_perror("%s: Unexpected LCN (%lld)", + __FUNCTION__, + (long long)rl->lcn); goto rl_err_out; } @@ -1250,20 +1346,53 @@ to_write = min(count, (rl->length << vol->cluster_size_bits) - ofs); retry: ntfs_log_trace("Writing %lld bytes to vcn %lld, lcn %lld, ofs " - "%lld.\n", to_write, rl->vcn, rl->lcn, ofs); - if (!NVolReadOnly(vol)) - written = ntfs_pwrite(vol->dev, (rl->lcn << - vol->cluster_size_bits) + ofs, - to_write, b); - else + "%lld.\n", (long long)to_write, (long long)rl->vcn, + (long long)rl->lcn, (long long)ofs); + if (!NVolReadOnly(vol)) { + + s64 wpos = (rl->lcn << vol->cluster_size_bits) + ofs; + s64 wend = (rl->vcn << vol->cluster_size_bits) + ofs + to_write; + u32 bsize = vol->cluster_size; + /* Byte size needed to zero fill a cluster */ + s64 rounding = ((wend + bsize - 1) & ~(s64)(bsize - 1)) - wend; + /** + * Zero fill to cluster boundary if we're writing at the + * end of the attribute or into an ex-sparse cluster. + * This will cause the kernel not to seek and read disk + * blocks during write(2) to fill the end of the buffer + * which increases write speed by 2-10 fold typically. + */ + if (rounding && ((wend == na->initialized_size) || + (wend < (hole_end << vol->cluster_size_bits)))){ + + char *cb; + [... truncated: 8746 lines follow ...] From superstippi at gmx.de Tue Jun 2 15:11:24 2009 From: superstippi at gmx.de (=?ISO-8859-1?Q?Stephan_A=DFmus?=) Date: Tue, 02 Jun 2009 15:11:24 +0200 Subject: [Haiku-commits] r30944 - in haiku/trunk/src/add-ons/kernel/file_systems/ntfs: . libntfs settings In-Reply-To: <200906021223.n52CNk5t027320@sheep.berlios.de> References: <200906021223.n52CNk5t027320@sheep.berlios.de> Message-ID: <4A2524FC.70802@gmx.de> threedeyes at mail.berlios.de schrieb: > Author: threedeyes > Date: 2009-06-02 14:21:10 +0200 (Tue, 02 Jun 2009) > New Revision: 30944 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30944&view=rev > > Removed: > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fsproto.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/version.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/version.h > Modified: > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/Jamfile > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/attributes.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/attrlist.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/bitmap.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/bitmap.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/bootsect.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/compress.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/debug.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/endians.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/index.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/layout.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logfile.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/mst.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/runlist.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/security.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/security.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/unix_io.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/libntfs/win32_io.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/lock.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/ntfs.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/ntfsdir.h > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/settings/ntfs > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/utils.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/volume_util.c > Log: > Update NTFS-3g Library to stable 2009.4.4 version. Clean up code. Now write support enabled by default. That's awesome! How much can it be trusted? What kind of file system tests have you performed? Ciao, -Stephan From korli at mail.berlios.de Tue Jun 2 22:24:19 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 2 Jun 2009 22:24:19 +0200 Subject: [Haiku-commits] r30945 - in haiku/trunk: headers/posix src/system/libroot/posix/glibc/arch/generic src/system/libroot/posix/glibc/arch/m68k src/system/libroot/posix/glibc/arch/ppc Message-ID: <200906022024.n52KOJ5g008820@sheep.berlios.de> Author: korli Date: 2009-06-02 22:24:18 +0200 (Tue, 02 Jun 2009) New Revision: 30945 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30945&view=rev Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrint.c haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintf.c haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintl.c haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrint.c haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintf.c haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintl.c Modified: haiku/trunk/headers/posix/math.h haiku/trunk/src/system/libroot/posix/glibc/arch/m68k/Jamfile haiku/trunk/src/system/libroot/posix/glibc/arch/ppc/Jamfile Log: added lrint and llrint functions to math.h added generic implementations for ppc and m68k Modified: haiku/trunk/headers/posix/math.h =================================================================== --- haiku/trunk/headers/posix/math.h 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/headers/posix/math.h 2009-06-02 20:24:18 UTC (rev 30945) @@ -100,10 +100,12 @@ extern float hypotf(float x, float y); extern float ldexpf(float x, int exponent); extern float lgammaf(float x); +extern long long llrintf(float x); extern float log10f(float x); extern float log1pf(float x); extern float logbf(float x); extern float logf(float x); +extern long lrintf(float x); extern long lroundf(float x); extern float modff(float x, float *y); extern float nearbyintf(float x); @@ -135,8 +137,10 @@ extern double gamma(double x); extern double ldexp(double x, int exponent); extern double lgamma(double x); +extern long long llrint(double x); extern double log(double x); extern double log10(double x); +extern long lrint(double x); extern long lround(double x); extern double modf(double x, double *y); extern double nearbyint(double x); @@ -159,9 +163,11 @@ extern long double atan2l(long double y, long double x); extern long double lgammal(long double x); extern long double nearbyintl(long double x); -extern long double roundl(long double x); +extern long long llrintl(long double x); +extern long lrintl(long double x); extern long lroundl(long double x); extern long double remquol(long double x, long double y, int *quo); +extern long double roundl(long double x); /* some BSD non-ANSI or POSIX math functions */ extern double cbrt(double x); Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrint.c =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrint.c 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrint.c 2009-06-02 20:24:18 UTC (rev 30945) @@ -0,0 +1,93 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + +static const double two52[2] = +{ + 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ + -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ +}; + + +long long int +__llrint (double x) +{ + int32_t j0; + u_int32_t i1, i0; + long long int result; + volatile double w; + double t; + int sx; + + EXTRACT_WORDS (i0, i1, x); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + sx = i0 >> 31; + i0 &= 0xfffff; + i0 |= 0x100000; + + if (j0 < 20) + { + w = two52[sx] + x; + t = w - two52[sx]; + EXTRACT_WORDS (i0, i1, t); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + i0 &= 0xfffff; + i0 |= 0x100000; + + result = (j0 < 0 ? 0 : i0 >> (20 - j0)); + } + else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1) + { + if (j0 >= 52) + result = (((long long int) i0 << 32) | i1) << (j0 - 52); + else + { + w = two52[sx] + x; + t = w - two52[sx]; + EXTRACT_WORDS (i0, i1, t); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + i0 &= 0xfffff; + i0 |= 0x100000; + + if (j0 == 20) + result = (long long int) i0; + else + result = ((long long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); + } + } + else + { + /* The number is too large. It is left implementation defined + what happens. */ + return (long long int) x; + } + + return sx ? -result : result; +} + +weak_alias (__llrint, llrint) +#ifdef NO_LONG_DOUBLE +strong_alias (__llrint, __llrintl) +weak_alias (__llrint, llrintl) +#endif Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintf.c =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintf.c 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintf.c 2009-06-02 20:24:18 UTC (rev 30945) @@ -0,0 +1,76 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + +static const float two23[2] = +{ + 8.3886080000e+06, /* 0x4B000000 */ + -8.3886080000e+06, /* 0xCB000000 */ +}; + + +long long int +__llrintf (float x) +{ + int32_t j0; + u_int32_t i0; + volatile float w; + float t; + long long int result; + int sx; + + GET_FLOAT_WORD (i0, x); + + sx = i0 >> 31; + j0 = ((i0 >> 23) & 0xff) - 0x7f; + i0 &= 0x7fffff; + i0 |= 0x800000; + + if (j0 < (int32_t) (sizeof (long long int) * 8) - 1) + { + if (j0 >= 23) + result = (long long int) i0 << (j0 - 23); + else + { + w = two23[sx] + x; + t = w - two23[sx]; + GET_FLOAT_WORD (i0, t); + j0 = ((i0 >> 23) & 0xff) - 0x7f; + i0 &= 0x7fffff; + i0 |= 0x800000; + + result = (j0 < 0 ? 0 : i0 >> (23 - j0)); + } + } + else + { + /* The number is too large. It is left implementation defined + what happens. */ + return (long long int) x; + } + + return sx ? -result : result; +} + +weak_alias (__llrintf, llrintf) Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintl.c =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintl.c 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintl.c 2009-06-02 20:24:18 UTC (rev 30945) @@ -0,0 +1,77 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + +static const long double two63[2] = +{ + 9.223372036854775808000000e+18, /* 0x403E, 0x00000000, 0x00000000 */ + -9.223372036854775808000000e+18 /* 0xC03E, 0x00000000, 0x00000000 */ +}; + + +long long int +__llrintl (long double x) +{ + int32_t se,j0; + u_int32_t i0, i1; + long long int result; + volatile long double w; + long double t; + int sx; + + GET_LDOUBLE_WORDS (se, i0, i1, x); + + sx = (se >> 15) & 1; + j0 = (se & 0x7fff) - 0x3fff; + + if (j0 < (int32_t) (8 * sizeof (long long int)) - 1) + { + if (j0 >= 63) + result = (((long long int) i0 << 32) | i1) << (j0 - 63); + else + { + w = two63[sx] + x; + t = w - two63[sx]; + GET_LDOUBLE_WORDS (se, i0, i1, t); + j0 = (se & 0x7fff) - 0x3fff; + + if (j0 < 0) + result = 0; + else if (j0 <= 31) + result = i0 >> (31 - j0); + else + result = ((long long int) i0 << (j0 - 31)) | (i1 >> (63 - j0)); + } + } + else + { + /* The number is too large. It is left implementation defined + what happens. */ + return (long long int) x; + } + + return sx ? -result : result; +} + +weak_alias (__llrintl, llrintl) Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrint.c =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrint.c 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrint.c 2009-06-02 20:24:18 UTC (rev 30945) @@ -0,0 +1,93 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + +static const double two52[2] = +{ + 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ + -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ +}; + + +long int +__lrint (double x) +{ + int32_t j0; + u_int32_t i0,i1; + volatile double w; + double t; + long int result; + int sx; + + EXTRACT_WORDS (i0, i1, x); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + sx = i0 >> 31; + i0 &= 0xfffff; + i0 |= 0x100000; + + if (j0 < 20) + { + w = two52[sx] + x; + t = w - two52[sx]; + EXTRACT_WORDS (i0, i1, t); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + i0 &= 0xfffff; + i0 |= 0x100000; + + result = (j0 < 0 ? 0 : i0 >> (20 - j0)); + } + else if (j0 < (int32_t) (8 * sizeof (long int)) - 1) + { + if (j0 >= 52) + result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52)); + else + { + w = two52[sx] + x; + t = w - two52[sx]; + EXTRACT_WORDS (i0, i1, t); + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + i0 &= 0xfffff; + i0 |= 0x100000; + + if (j0 == 20) + result = (long int) i0; + else + result = ((long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); + } + } + else + { + /* The number is too large. It is left implementation defined + what happens. */ + return (long int) x; + } + + return sx ? -result : result; +} + +weak_alias (__lrint, lrint) +#ifdef NO_LONG_DOUBLE +strong_alias (__lrint, __lrintl) +weak_alias (__lrint, lrintl) +#endif Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintf.c =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintf.c 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintf.c 2009-06-02 20:24:18 UTC (rev 30945) @@ -0,0 +1,76 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + +static const float two23[2] = +{ + 8.3886080000e+06, /* 0x4B000000 */ + -8.3886080000e+06, /* 0xCB000000 */ +}; + + +long int +__lrintf (float x) +{ + int32_t j0; + u_int32_t i0; + volatile float w; + float t; + long int result; + int sx; + + GET_FLOAT_WORD (i0, x); + + sx = i0 >> 31; + j0 = ((i0 >> 23) & 0xff) - 0x7f; + i0 &= 0x7fffff; + i0 |= 0x800000; + + if (j0 < (int32_t) (sizeof (long int) * 8) - 1) + { + if (j0 >= 23) + result = (long int) i0 << (j0 - 23); + else + { + w = two23[sx] + x; + t = w - two23[sx]; + GET_FLOAT_WORD (i0, t); + j0 = ((i0 >> 23) & 0xff) - 0x7f; + i0 &= 0x7fffff; + i0 |= 0x800000; + + result = (j0 < 0 ? 0 : i0 >> (23 - j0)); + } + } + else + { + /* The number is too large. It is left implementation defined + what happens. */ + return (long int) x; + } + + return sx ? -result : result; +} + +weak_alias (__lrintf, lrintf) Added: haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintl.c =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintl.c 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintl.c 2009-06-02 20:24:18 UTC (rev 30945) @@ -0,0 +1,84 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + +static const long double two63[2] = +{ + 9.223372036854775808000000e+18, /* 0x403E, 0x00000000, 0x00000000 */ + -9.223372036854775808000000e+18 /* 0xC03E, 0x00000000, 0x00000000 */ +}; + + +long int +__lrintl (long double x) +{ + int32_t se,j0; + u_int32_t i0, i1; + long int result; + volatile long double w; + long double t; + int sx; + + GET_LDOUBLE_WORDS (se, i0, i1, x); + + sx = (se >> 15) & 1; + j0 = (se & 0x7fff) - 0x3fff; + + if (j0 < 31) + { + w = two63[sx] + x; + t = w - two63[sx]; + GET_LDOUBLE_WORDS (se, i0, i1, t); + j0 = (se & 0x7fff) - 0x3fff; + + result = (j0 < 0 ? 0 : i0 >> (31 - j0)); + } + else if (j0 < (int32_t) (8 * sizeof (long int)) - 1) + { + if (j0 >= 63) + result = ((long int) i0 << (j0 - 31)) | (i1 << (j0 - 63)); + else + { + w = two63[sx] + x; + t = w - two63[sx]; + GET_LDOUBLE_WORDS (se, i0, i1, t); + j0 = (se & 0x7fff) - 0x3fff; + + if (j0 == 31) + result = (long int) i0; + else + result = ((long int) i0 << (j0 - 31)) | (i1 >> (63 - j0)); + } + } + else + { + /* The number is too large. It is left implementation defined + what happens. */ + return (long int) x; + } + + return sx ? -result : result; +} + +weak_alias (__lrintl, lrintl) Modified: haiku/trunk/src/system/libroot/posix/glibc/arch/m68k/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/m68k/Jamfile 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/m68k/Jamfile 2009-06-02 20:24:18 UTC (rev 30945) @@ -77,8 +77,10 @@ s_ilogb.c s_ilogbf.c s_isinf.c s_isinff.c # s_isinfl.c s_ldexp.c s_ldexpf.c # s_ldexpl.c + s_llrint.c s_llrintf.c # s_llrintl.c s_log1p.c s_log1pf.c s_logb.c s_logbf.c # s_logbl.c + s_lrint.c s_lrintf.c # s_lrintl.c s_lround.c s_lroundf.c s_modf.c s_modff.c # s_modfl.c s_nan.c s_nanf.c # s_nanl.c Modified: haiku/trunk/src/system/libroot/posix/glibc/arch/ppc/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/glibc/arch/ppc/Jamfile 2009-06-02 12:21:10 UTC (rev 30944) +++ haiku/trunk/src/system/libroot/posix/glibc/arch/ppc/Jamfile 2009-06-02 20:24:18 UTC (rev 30945) @@ -75,8 +75,10 @@ s_ilogb.c s_ilogbf.c s_isinf.c s_isinff.c # s_isinfl.c s_ldexp.c s_ldexpf.c # s_ldexpl.c + s_llrint.c s_llrintf.c # s_llrintl.c s_log1p.c s_log1pf.c s_logb.c s_logbf.c # s_logbl.c + s_lrint.c s_lrintf.c # s_lrintl.c s_lround.c s_lroundf.c s_modf.c s_modff.c # s_modfl.c s_nan.c s_nanf.c # s_nanl.c From rudolfc at mail.berlios.de Tue Jun 2 22:38:02 2009 From: rudolfc at mail.berlios.de (rudolfc at mail.berlios.de) Date: Tue, 2 Jun 2009 22:38:02 +0200 Subject: [Haiku-commits] r30946 - in haiku/trunk: headers/private/graphics/nvidia src/add-ons/accelerants/nvidia/engine Message-ID: <200906022038.n52Kc2ut010414@sheep.berlios.de> Author: rudolfc Date: 2009-06-02 22:37:59 +0200 (Tue, 02 Jun 2009) New Revision: 30946 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30946&view=rev Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c Log: modified I2C code to read the third bus on cards that can support it. Dumping EDID scanning results in logfile only for now (testing..) Bumped version to 0.92. Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2009-06-02 20:24:18 UTC (rev 30945) +++ haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2009-06-02 20:37:59 UTC (rev 30946) @@ -5,7 +5,7 @@ Other authors: Mark Watson; Apsed; - Rudolf Cornelissen 10/2002-5/2009. + Rudolf Cornelissen 10/2002-6/2009. */ #ifndef DRIVERINTERFACE_H @@ -356,7 +356,6 @@ bool i2c_bus0; /* we have a wired I2C bus 0 on board */ bool i2c_bus1; /* we have a wired I2C bus 1 on board */ bool i2c_bus2; /* we have a wired I2C bus 2 on board */ - bool i2c_bus3; /* we have a wired I2C bus 3 on board */ struct { uint32 type; /* see tvchip_type enum above */ Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2009-06-02 20:24:18 UTC (rev 30945) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2009-06-02 20:37:59 UTC (rev 30946) @@ -92,7 +92,7 @@ { status_t status; - LOG(1,("POWERUP: Haiku nVidia Accelerant 0.91 running.\n")); + LOG(1,("POWERUP: Haiku nVidia Accelerant 0.92 running.\n")); /* log VBLANK INT usability status */ if (si->ps.int_assigned) Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c 2009-06-02 20:24:18 UTC (rev 30945) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c 2009-06-02 20:37:59 UTC (rev 30946) @@ -32,13 +32,12 @@ if (!si->ps.secondary_head) return; /* select GPU I/O pins set to connect to I2C 'registers' */ - if (set) - { + if (set) { + /* this setup wires the 'I2C registers' to unknown I/O pins on the GPU? */ NV_REG32(NV32_FUNCSEL) &= ~0x00000010; NV_REG32(NV32_2FUNCSEL) |= 0x00000010; - } - else - { + } else { + /* this setup wires the 'I2C registers' to the I2C buses */ NV_REG32(NV32_2FUNCSEL) &= ~0x00000010; NV_REG32(NV32_FUNCSEL) |= 0x00000010; } @@ -48,21 +47,28 @@ { uint8 data; - if (BusNR & 0x01) - { + switch (BusNR) { + case 0: + data = (CRTCR(WR_I2CBUS_0) & 0xf0) | 0x01; + if (Bit) + CRTCW(WR_I2CBUS_0, (data | 0x20)); + else + CRTCW(WR_I2CBUS_0, (data & ~0x20)); + break; + case 1: data = (CRTCR(WR_I2CBUS_1) & 0xf0) | 0x01; if (Bit) CRTCW(WR_I2CBUS_1, (data | 0x20)); else CRTCW(WR_I2CBUS_1, (data & ~0x20)); - } - else - { - data = (CRTCR(WR_I2CBUS_0) & 0xf0) | 0x01; + break; + case 2: + data = (CRTCR(WR_I2CBUS_2) & 0xf0) | 0x01; if (Bit) - CRTCW(WR_I2CBUS_0, (data | 0x20)); + CRTCW(WR_I2CBUS_2, (data | 0x20)); else - CRTCW(WR_I2CBUS_0, (data & ~0x20)); + CRTCW(WR_I2CBUS_2, (data & ~0x20)); + break; } } @@ -70,48 +76,61 @@ { uint8 data; - if (BusNR & 0x01) - { + switch (BusNR) { + case 0: + data = (CRTCR(WR_I2CBUS_0) & 0xf0) | 0x01; + if (Bit) + CRTCW(WR_I2CBUS_0, (data | 0x10)); + else + CRTCW(WR_I2CBUS_0, (data & ~0x10)); + break; + case 1: data = (CRTCR(WR_I2CBUS_1) & 0xf0) | 0x01; if (Bit) CRTCW(WR_I2CBUS_1, (data | 0x10)); else CRTCW(WR_I2CBUS_1, (data & ~0x10)); - } - else - { - data = (CRTCR(WR_I2CBUS_0) & 0xf0) | 0x01; + break; + case 2: + data = (CRTCR(WR_I2CBUS_2) & 0xf0) | 0x01; if (Bit) - CRTCW(WR_I2CBUS_0, (data | 0x10)); + CRTCW(WR_I2CBUS_2, (data | 0x10)); else - CRTCW(WR_I2CBUS_0, (data & ~0x10)); + CRTCW(WR_I2CBUS_2, (data & ~0x10)); + break; } } static bool InSCL(uint8 BusNR) { - if (BusNR & 0x01) - { + switch (BusNR) { + case 0: + if ((CRTCR(RD_I2CBUS_0) & 0x04)) return true; + break; + case 1: if ((CRTCR(RD_I2CBUS_1) & 0x04)) return true; + break; + case 2: + if ((CRTCR(RD_I2CBUS_2) & 0x04)) return true; + break; } - else - { - if ((CRTCR(RD_I2CBUS_0) & 0x04)) return true; - } return false; } static bool InSDA(uint8 BusNR) { - if (BusNR & 0x01) - { + switch (BusNR) { + case 0: + if ((CRTCR(RD_I2CBUS_0) & 0x08)) return true; + break; + case 1: if ((CRTCR(RD_I2CBUS_1) & 0x08)) return true; + break; + case 2: + if ((CRTCR(RD_I2CBUS_2) & 0x08)) return true; + break; } - else - { - if ((CRTCR(RD_I2CBUS_0) & 0x08)) return true; - } return false; } @@ -119,14 +138,11 @@ static void TXBit (uint8 BusNR, bool Bit) { /* send out databit */ - if (Bit) - { + if (Bit) { OutSDA(BusNR, true); snooze(3); if (!InSDA(BusNR)) i2c_flag_error (2); - } - else - { + } else { OutSDA(BusNR, false); } /* generate clock pulse */ @@ -162,9 +178,6 @@ void i2c_bstart (uint8 BusNR) { - /* select GPU I/O pins set */ - i2c_select_bus_set(BusNR & 0x02); - /* enable access to primary head */ set_crtc_owner(0); @@ -187,9 +200,6 @@ void i2c_bstop (uint8 BusNR) { - /* select GPU I/O pins set */ - i2c_select_bus_set(BusNR & 0x02); - /* enable access to primary head */ set_crtc_owner(0); @@ -214,15 +224,11 @@ { uint8 cnt, bit, byte = 0; - /* select GPU I/O pins set */ - i2c_select_bus_set(BusNR & 0x02); - /* enable access to primary head */ set_crtc_owner(0); /* read data */ - for (cnt = 8; cnt > 0; cnt--) - { + for (cnt = 8; cnt > 0; cnt--) { byte <<= 1; bit = RXBit (BusNR); byte += bit; @@ -242,15 +248,11 @@ bool bit; uint8 tmp = byte; - /* select GPU I/O pins set */ - i2c_select_bus_set(BusNR & 0x02); - /* enable access to primary head */ set_crtc_owner(0); /* write data */ - for (cnt = 8; cnt > 0; cnt--) - { + for (cnt = 8; cnt > 0; cnt--) { bit = (tmp & 0x80); TXBit (BusNR, bit); tmp <<= 1; @@ -270,9 +272,7 @@ uint8 cnt; for (cnt = 0; cnt < size; cnt++) - { buf[cnt] = i2c_readbyte(BusNR, buf[cnt]); - } } void i2c_writebuffer (uint8 BusNR, uint8* buf, uint8 size) @@ -280,9 +280,7 @@ uint8 cnt; for (cnt = 0; cnt < size; cnt++) - { i2c_writebyte(BusNR, buf[cnt]); - } } status_t i2c_init(void) @@ -293,6 +291,9 @@ LOG(4,("I2C: searching for wired I2C buses...\n")); + /* select GPU I/O pins for I2C buses */ + i2c_select_bus_set(false); + /* enable access to primary head */ set_crtc_owner(0); @@ -304,15 +305,16 @@ si->ps.i2c_bus0 = false; si->ps.i2c_bus1 = false; si->ps.i2c_bus2 = false; - si->ps.i2c_bus3 = false; /* set number of buses to test for */ buses = 2; - if (si->ps.secondary_head) buses = 4; + /* newer cards (can) have a third bus.. */ + if (((si->ps.card_arch == NV10A) && (si->ps.card_type >= NV17)) || (si->ps.card_arch >= NV30A)) + buses = 3; + /* find existing buses */ - for (bus = 0; bus < buses; bus++) - { + for (bus = 0; bus < buses; bus++) { /* reset status */ i2c_flag_error (-1); snooze(6); @@ -335,30 +337,29 @@ i2c_bstop(bus); } - for (bus = 0; bus < buses; bus++) - { - if (i2c_bus[bus]) - { + for (bus = 0; bus < buses; bus++) { + if (i2c_bus[bus]) { LOG(4,("I2C: bus #%d wiring check: passed\n", bus)); result = B_OK; + } else { + LOG(4,("I2C: bus #%d wiring check: failed\n", bus)); } - else - LOG(4,("I2C: bus #%d wiring check: failed\n", bus)); } - //i2c_TestEDID(); - i2c_DetectScreens(); - LOG(4,("I2C: dumping EDID specs for connector 1:\n")); - i2c_DumpSpecsEDID(&si->ps.con1_screen); - LOG(4,("I2C: dumping EDID specs for connector 2:\n")); - i2c_DumpSpecsEDID(&si->ps.con2_screen); + //fixme: testing again.. + i2c_TestEDID(); +// i2c_DetectScreens(); +// LOG(4,("I2C: dumping EDID specs for connector 1:\n")); +// i2c_DumpSpecsEDID(&si->ps.con1_screen); +// LOG(4,("I2C: dumping EDID specs for connector 2:\n")); +// i2c_DumpSpecsEDID(&si->ps.con2_screen); return result; } /*** DDC/EDID library use ***/ typedef struct { - uint32 port; + uint8 port; } ddc_port_info; /* Dump EDID info in driver's logfile */ @@ -558,8 +559,8 @@ bus.get_signals = &get_signals; ddc2_init_timing(&bus); - /* select GPU I/O pins set */ - i2c_select_bus_set(BusNR & 0x02); + /* select GPU I/O pins for I2C buses */ + i2c_select_bus_set(false); /* enable access to primary head */ set_crtc_owner(0); @@ -584,7 +585,7 @@ bool *i2c_bus = &(si->ps.i2c_bus0); /* test wired bus(es) */ - for (bus = 0; bus < 4; bus++) { + for (bus = 0; bus < 3; bus++) { if (i2c_bus[bus]) i2c_ReadEDID(bus, &edid); } @@ -683,6 +684,7 @@ * not depend on the way screens are connected to the cards (DVI/VGA, 1 or 2 screens). * - con1 has CRTC1 and DAC1, and con2 has CRTC2 and DAC2 if nv_general_output_select() * is set to 'straight' and there are only VGA type screens connected. */ +//fixme: take third I2C bus into account.. void i2c_DetectScreens(void) { edid1_info edid; From axeld at pinc-software.de Tue Jun 2 23:18:53 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 02 Jun 2009 23:18:53 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30946_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/graphics/nvidia_src/add-ons/accelerants/nvidia/engine?= In-Reply-To: <200906022038.n52Kc2ut010414@sheep.berlios.de> Message-ID: <52606096969-BeMail@zon> rudolfc at mail.berlios.de wrote: > Log: > modified I2C code to read the third bus on cards that can support it. > Dumping EDID scanning results in logfile only for now (testing..) BTW, is there any reason you're not using the common I2C/EDID code? Bye, Axel. From axeld at mail.berlios.de Wed Jun 3 14:14:16 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 3 Jun 2009 14:14:16 +0200 Subject: [Haiku-commits] r30947 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200906031214.n53CEGV8014388@sheep.berlios.de> Author: axeld Date: 2009-06-03 14:14:16 +0200 (Wed, 03 Jun 2009) New Revision: 30947 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30947&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp Log: * Removed debug output of the old pad fields that no longer exist. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2009-06-02 20:37:59 UTC (rev 30946) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2009-06-03 12:14:16 UTC (rev 30947) @@ -133,8 +133,6 @@ dump_data_stream(&(inode->data)); kprintf(" --\n pad[0] = %08x\n", (int)inode->pad[0]); kprintf(" pad[1] = %08x\n", (int)inode->pad[1]); - kprintf(" pad[2] = %08x\n", (int)inode->pad[2]); - kprintf(" pad[3] = %08x\n", (int)inode->pad[3]); } From axeld at mail.berlios.de Wed Jun 3 14:16:26 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 3 Jun 2009 14:16:26 +0200 Subject: [Haiku-commits] r30948 - haiku/trunk/src/tests/add-ons/kernel/file_systems/random_file_actions Message-ID: <200906031216.n53CGQnY015018@sheep.berlios.de> Author: axeld Date: 2009-06-03 14:16:25 +0200 (Wed, 03 Jun 2009) New Revision: 30948 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30948&view=rev Modified: haiku/trunk/src/tests/add-ons/kernel/file_systems/random_file_actions/random_file_actions.cpp Log: * Improved output. Modified: haiku/trunk/src/tests/add-ons/kernel/file_systems/random_file_actions/random_file_actions.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/file_systems/random_file_actions/random_file_actions.cpp 2009-06-03 12:14:16 UTC (rev 30947) +++ haiku/trunk/src/tests/add-ons/kernel/file_systems/random_file_actions/random_file_actions.cpp 2009-06-03 12:16:25 UTC (rev 30948) @@ -167,7 +167,7 @@ "\t\t\t\tmeaning only check once at the end.\n" " -n, --no-cache\t\tDisables the file cache when doing I/O on\n" "\t\t\t\ta file.\n" - " -a, --always-check\tAlways check contents before removing data.\n" + " -a, --always-check\t\tAlways check contents before removing data.\n" " -k, --keep-dirty\t\tDo not remove the working files on quit.\n" " -v, --verbose\t\t\tShow the actions as being performed\n", kProgramName, kDefaultRunCount, kDefaultFileCount, kDefaultDirCount, @@ -486,7 +486,7 @@ std::string parent = choose_parent(dirs); std::string name = create_name(parent, "dir"); - action("create dir %s", name.c_str()); + action("create dir %s (identifier %lu)", name.c_str(), sCount); if (mkdir(name.c_str(), 0777) != 0) error("creating dir \"%s\" failed: %s", name.c_str(), strerror(errno)); @@ -534,7 +534,7 @@ std::string parent = choose_parent(dirs); std::string name = create_name(parent, "file"); - action("create file %s", name.c_str()); + action("create file %s (identifier %lu)", name.c_str(), sCount); int fd = open_file(name, O_RDWR | O_CREAT | O_TRUNC); if (fd < 0) From bonefish at mail.berlios.de Wed Jun 3 14:28:54 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 3 Jun 2009 14:28:54 +0200 Subject: [Haiku-commits] r30949 - in haiku/trunk: build/config_headers headers/private/kernel src/system/kernel/debug Message-ID: <200906031228.n53CSsoS016510@sheep.berlios.de> Author: bonefish Date: 2009-06-03 14:28:49 +0200 (Wed, 03 Jun 2009) New Revision: 30949 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30949&view=rev Added: haiku/trunk/headers/private/kernel/debug_heap.h haiku/trunk/src/system/kernel/debug/debug_heap.cpp Modified: haiku/trunk/build/config_headers/kernel_debug_config.h haiku/trunk/src/system/kernel/debug/Jamfile haiku/trunk/src/system/kernel/debug/debug.cpp haiku/trunk/src/system/kernel/debug/debug_commands.cpp haiku/trunk/src/system/kernel/debug/debug_parser.cpp Log: Replaced the temporary storage used in the kernel debug command parser. We now have a simple dedicated heap for the kernel debugger with stacked allocation pools (deleting a pool frees all memory allocated in it). The heap should eventually be used for all commands that need temporary storage too large for the stack instead of each using its own static buffer. Modified: haiku/trunk/build/config_headers/kernel_debug_config.h =================================================================== --- haiku/trunk/build/config_headers/kernel_debug_config.h 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/build/config_headers/kernel_debug_config.h 2009-06-03 12:28:49 UTC (rev 30949) @@ -18,6 +18,9 @@ // benaphore-style. #define KDEBUG KDEBUG_LEVEL_2 +// Size of the heap used by the kernel debugger. +#define KDEBUG_HEAP (64 * 1024) + // Set to 0 to disable support for kernel breakpoints. #define KERNEL_BREAKPOINTS 1 Added: haiku/trunk/headers/private/kernel/debug_heap.h =================================================================== --- haiku/trunk/headers/private/kernel/debug_heap.h 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/headers/private/kernel/debug_heap.h 2009-06-03 12:28:49 UTC (rev 30949) @@ -0,0 +1,71 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_DEBUG_HEAP_H +#define _KERNEL_DEBUG_HEAP_H + +#include + + +struct DebugAllocPool; +typedef struct DebugAllocPool debug_alloc_pool; + + +#ifdef __cplusplus +extern "C" { +#endif + +debug_alloc_pool* create_debug_alloc_pool(); +void delete_debug_alloc_pool(debug_alloc_pool* pool); +void* debug_malloc(size_t size); +void debug_free(void* address); +void debug_heap_init(); + +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus + +struct kdebug_alloc_t {}; +extern const kdebug_alloc_t kdebug_alloc; + +inline void* +operator new(size_t size, const kdebug_alloc_t&) throw() +{ + return debug_malloc(size); +} + +namespace DebugAlloc { + template + inline void + destroy(Type* object) + { + if (object != NULL) { + object->~Type(); + debug_free(object); + // NOTE: Doesn't work for multiple inheritence! + } + } +} + +struct DebugAllocPoolScope { + DebugAllocPoolScope() + { + fPool = create_debug_alloc_pool(); + } + + ~DebugAllocPoolScope() + { + delete_debug_alloc_pool(fPool); + } + +private: + DebugAllocPool* fPool; +}; + +#endif // __cplusplus + +#endif /* _KERNEL_DEBUG_HEAP_H */ Modified: haiku/trunk/src/system/kernel/debug/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/debug/Jamfile 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/src/system/kernel/debug/Jamfile 2009-06-03 12:28:49 UTC (rev 30949) @@ -10,6 +10,7 @@ debug.cpp debug_builtin_commands.cpp debug_commands.cpp + debug_heap.cpp debug_paranoia.cpp debug_parser.cpp debug_variables.cpp Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2009-06-03 12:28:49 UTC (rev 30949) @@ -1,5 +1,5 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold at gmx.de. * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -665,6 +666,8 @@ int32 previousCPU = sDebuggerOnCPU; sDebuggerOnCPU = smp_get_current_cpu(); + DebugAllocPool* allocPool = create_debug_alloc_pool(); + kprintf("Welcome to Kernel Debugging Land...\n"); if (struct thread* thread = thread_get_current_thread()) { @@ -721,6 +724,8 @@ sCurrentLine = 0; } + delete_debug_alloc_pool(allocPool); + sDebuggerOnCPU = previousCPU; } @@ -1210,6 +1215,7 @@ debug_builtin_commands_init(); + debug_heap_init(); debug_variables_init(); frame_buffer_console_init(args); arch_debug_console_init_settings(args); Modified: haiku/trunk/src/system/kernel/debug/debug_commands.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/src/system/kernel/debug/debug_commands.cpp 2009-06-03 12:28:49 UTC (rev 30949) @@ -1,5 +1,5 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de + * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold at gmx.de * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de * Distributed under the terms of the MIT License. * @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -273,6 +274,9 @@ // replace argv[0] with the actual command name argv[0] = (char *)command->name; + DebugAllocPoolScope allocPoolScope; + // Will automatically clean up all allocations the command leaves over. + // Invoking the command directly might be useful when debugging debugger // commands. if (gInvokeCommandDirectly) Added: haiku/trunk/src/system/kernel/debug/debug_heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug_heap.cpp 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/src/system/kernel/debug/debug_heap.cpp 2009-06-03 12:28:49 UTC (rev 30949) @@ -0,0 +1,302 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de + * Distributed under the terms of the MIT License. + */ + +#include + +#include + +#include + + +#define INITIAL_HEAP_SIZE B_PAGE_SIZE + +static char sInitialHeap[INITIAL_HEAP_SIZE]; +static void* sHeapBase = sInitialHeap; +static size_t sHeapSize = INITIAL_HEAP_SIZE; + +const kdebug_alloc_t kdebug_alloc = {}; + + +struct allocation_header { + uint32 size : 31; // size in allocation_header units + bool free : 1; + uint32 previous; +}; + +struct free_entry : allocation_header { + uint32 previous_free; + uint32 next_free; +}; + + +struct DebugAllocPool { + void Init(void* heap, size_t heapSize) + { + fParent = NULL; + fChild = NULL; + + uint32 size = heapSize / 8; + fBase = (allocation_header*)heap - 1; + fEnd = size + 1; + fFirstFree = 0; + fLastFree = 0; + + // add free entry spanning the whole area + fBase[1].size = size - 1; + fBase[1].previous = 0; + _InsertFreeEntry(1); + } + + DebugAllocPool* CreateChildPool() + { + // do we already have a child pool? + if (fChild != NULL) + return NULL; + + // create the pool object + DebugAllocPool* pool + = (DebugAllocPool*)Allocate(sizeof(DebugAllocPool)); + if (pool == NULL) + return NULL; + + // do we have enough free space? + if (fLastFree == 0 || fBase[fLastFree].size < 2) { + Free(pool); + return NULL; + } + + allocation_header* header = &fBase[fLastFree]; + _RemoveFreeEntry(fLastFree); + + pool->Init(header + 1, header->size * 8); + pool->fParent = this; + + return fChild = pool; + } + + void Destroy() + { + if (fParent != NULL) { + fParent->fChild = NULL; + fParent->Free(fBase + 1); + } + } + + DebugAllocPool* Parent() const + { + return fParent; + } + + void* Allocate(size_t size) + { + size = (size + 7) / 8; + uint32 index = fFirstFree; + while (index != 0 && fBase[index].size < size) + index = ((free_entry*)&fBase[index])->next_free; + + if (index == 0) + return NULL; + + _RemoveFreeEntry(index); + + // if the entry is big enough, we split it + if (fBase[index].size - size >= 2) { + uint32 next = index + 1 + size; + uint32 nextNext = index + 1 + fBase[index].size; + fBase[next].size = fBase[index].size - size - 1; + fBase[next].previous = index; + fBase[index].size = size; + _InsertFreeEntry(next); + + if (nextNext < fEnd) + fBase[nextNext].previous = next; + } + + return &fBase[index + 1]; + } + + void Free(void* address) + { + // check address + if (((addr_t)address & 7) != 0 || address <= fBase + 1 + || address >= fBase + fEnd) { + kprintf("DebugAllocator::Free(%p): bad address\n", address); + return; + } + + // get header + allocation_header* header = (allocation_header*)address - 1; + uint32 index = header - fBase; + if (header->free) { + kprintf("DebugAllocator::Free(%p): double free\n", address); + return; + } + + uint32 next = index + 1 + header->size; + + // join with previous, if possible + if (index > 1 && fBase[header->previous].free) { + uint32 previous = header->previous; + _RemoveFreeEntry(previous); + + fBase[previous].size += 1 + header->size; + fBase[next].previous = previous; + + index = previous; + header = fBase + index; + } + + // join with next, if possible + if (next < fEnd && fBase[next].free) { + _RemoveFreeEntry(next); + + header->size += 1 + fBase[next].size; + + uint32 nextNext = index + 1 + header->size; + if (nextNext < fEnd) + fBase[nextNext].previous = index; + } + + _InsertFreeEntry(index); + } + +private: + void _InsertFreeEntry(uint32 index) + { + // find the insertion point -- list is sorted by ascending size + uint32 size = fBase[index].size; + uint32 next = fFirstFree; + while (next != 0 && size > fBase[next].size) + next = ((free_entry*)&fBase[next])->next_free; + + // insert + uint32 previous; + if (next != 0) { + previous = ((free_entry*)&fBase[next])->previous_free; + ((free_entry*)&fBase[next])->previous_free = index; + } else { + previous = fLastFree; + fLastFree = index; + } + + if (previous != 0) + ((free_entry*)&fBase[previous])->next_free = index; + else + fFirstFree = index; + + ((free_entry*)&fBase[index])->previous_free = previous; + ((free_entry*)&fBase[index])->next_free = next; + + fBase[index].free = true; + } + + void _RemoveFreeEntry(uint32 index) + { + uint32 previous = ((free_entry*)&fBase[index])->previous_free; + uint32 next = ((free_entry*)&fBase[index])->next_free; + + if (previous != 0) + ((free_entry*)&fBase[previous])->next_free = next; + else + fFirstFree = next; + + if (next != 0) + ((free_entry*)&fBase[next])->previous_free = previous; + else + fLastFree = previous; + + fBase[index].free = false; + } + +private: + DebugAllocPool* fParent; + DebugAllocPool* fChild; + allocation_header* fBase; // actually base - 1, so that index 0 is + // invalid + uint32 fEnd; + uint32 fFirstFree; + uint32 fLastFree; +}; + + +static DebugAllocPool* sCurrentPool; +static DebugAllocPool sInitialPool; + + +debug_alloc_pool* +create_debug_alloc_pool() +{ + if (sCurrentPool == NULL) { + sInitialPool.Init(sHeapBase, sHeapSize); + sCurrentPool = &sInitialPool; + return sCurrentPool; + } + + DebugAllocPool* pool = sCurrentPool->CreateChildPool(); + if (pool == NULL) + return NULL; + + sCurrentPool = pool; + return sCurrentPool; +} + + +void +delete_debug_alloc_pool(debug_alloc_pool* pool) +{ + if (pool == NULL || sCurrentPool == NULL) + return; + + // find the pool in the hierarchy + DebugAllocPool* otherPool = sCurrentPool; + while (otherPool != NULL && otherPool != pool) + otherPool = otherPool->Parent(); + + if (otherPool == NULL) + return; + + // destroy the pool + sCurrentPool = pool->Parent(); + pool->Destroy(); + + if (pool != &sInitialPool) + debug_free(pool); +} + + +void* +debug_malloc(size_t size) +{ + if (sCurrentPool == NULL) + return NULL; + + return sCurrentPool->Allocate(size); +} + + +void +debug_free(void* address) +{ + if (address != NULL && sCurrentPool != NULL) + sCurrentPool->Free(address); +} + + +void +debug_heap_init() +{ + // create the heap area + void* base; + area_id area = create_area("kdebug heap", (void**)&base, + B_ANY_KERNEL_ADDRESS, KDEBUG_HEAP, B_FULL_LOCK, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + if (area < 0) + return; + + // switch from the small static buffer to the area + InterruptsLocker locker; + sHeapBase = base; + sHeapSize = KDEBUG_HEAP; +} Modified: haiku/trunk/src/system/kernel/debug/debug_parser.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug_parser.cpp 2009-06-03 12:16:25 UTC (rev 30948) +++ haiku/trunk/src/system/kernel/debug/debug_parser.cpp 2009-06-03 12:28:49 UTC (rev 30949) @@ -1,5 +1,5 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de + * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold at gmx.de * Copyright 2006, Stephan A?mus, superstippi at gmx.de * Distributed under the terms of the MIT License. */ @@ -14,6 +14,8 @@ #include +#include + #include "debug_commands.h" #include "debug_variables.h" @@ -46,7 +48,6 @@ static const int kJumpBufferCount = 10; static const int kMaxArgumentCount = 64; -static const size_t kTemporaryStorageSize = 10240; static jmp_buf sJumpBuffers[kJumpBufferCount]; static int sNextJumpBufferIndex = 0; @@ -57,10 +58,6 @@ static char sTempBuffer[128]; // for composing debug output etc. -// temporary storage for command argument vectors and the arguments itself -static uint8 sTemporaryStorage[kTemporaryStorageSize]; -static size_t sTemporaryStorageUsed = 0; - enum { TOKEN_ASSIGN_FLAG = 0x100, TOKEN_FLAGS = TOKEN_ASSIGN_FLAG, @@ -143,47 +140,19 @@ } -// #pragma mark - temporary storage - - static void* -allocate_temp_storage(size_t size) +checked_malloc(size_t size) { - // 8 byte align - size = (size + 7) & ~7; - - if (sTemporaryStorageUsed + size > kTemporaryStorageSize) { - parse_exception("out of temporary storage for command execution", -1); + void* address = debug_malloc(size); + if (address == NULL) { + parse_exception("out of memory for command execution", -1); return NULL; } - void* buffer = sTemporaryStorage + sTemporaryStorageUsed; - sTemporaryStorageUsed += size; - - return buffer; + return address; } -static void -free_temp_storage(void* _buffer) -{ - uint8* buffer = (uint8*)_buffer; - - if (buffer == NULL) - return; - - // must be freed in the reverse allocation order - if (buffer < sTemporaryStorage - || buffer > sTemporaryStorage + sTemporaryStorageUsed) { - panic("Invalid pointer passed to free_temp_storage(): %p, temp " - "storage base: %p", buffer, sTemporaryStorage); - return; - } - - sTemporaryStorageUsed = buffer - sTemporaryStorage; -} - - // #pragma mark - Tokenizer @@ -750,7 +719,7 @@ uint64 ExpressionParser::_ParseCommandPipe(int& returnCode) { - debugger_command_pipe* pipe = (debugger_command_pipe*)allocate_temp_storage( + debugger_command_pipe* pipe = (debugger_command_pipe*)checked_malloc( sizeof(debugger_command_pipe)); pipe->segment_count = 0; @@ -773,7 +742,7 @@ // invoke the pipe returnCode = invoke_debugger_command_pipe(pipe); - free_temp_storage(pipe); + debug_free(pipe); return get_debug_variable("_", 0); } @@ -806,8 +775,7 @@ } // allocate temporary buffer for the argument vector - char** argv = (char**)allocate_temp_storage( - kMaxArgumentCount * sizeof(char*)); + char** argv = (char**)checked_malloc(kMaxArgumentCount * sizeof(char*)); int argc = 0; argv[argc++] = (char*)command->name; @@ -955,7 +923,7 @@ if (length < 0) length = strlen(argument); length++; - char* buffer = (char*)allocate_temp_storage(length); + char* buffer = (char*)checked_malloc(length); strlcpy(buffer, argument, length); argv[argc++] = buffer; @@ -1169,9 +1137,8 @@ bool success; uint64 result; - void* temporaryStorageMark = allocate_temp_storage(0); - // get a temporary storage mark, so we can cleanup everything that - // is allocated during the evaluation + DebugAllocPoolScope allocPoolScope; + // Will clean up all allocations when we return. if (setjmp(sJumpBuffers[sNextJumpBufferIndex++]) == 0) { result = ExpressionParser().EvaluateExpression(expression); @@ -1190,9 +1157,6 @@ sNextJumpBufferIndex--; - // cleanup temp allocations - free_temp_storage(temporaryStorageMark); - if (success && _result != NULL) *_result = result; @@ -1210,9 +1174,8 @@ } int returnCode = 0; - void* temporaryStorageMark = allocate_temp_storage(0); - // get a temporary storage mark, so we can cleanup everything that - // is allocated during the evaluation + DebugAllocPoolScope allocPoolScope; + // Will clean up all allocations when we return. if (setjmp(sJumpBuffers[sNextJumpBufferIndex++]) == 0) { ExpressionParser().EvaluateCommand(commandLine, returnCode); @@ -1226,9 +1189,6 @@ sNextJumpBufferIndex--; - // cleanup temp allocations - free_temp_storage(temporaryStorageMark); - return returnCode; } @@ -1244,9 +1204,8 @@ } status_t error; - void* temporaryStorageMark = allocate_temp_storage(0); - // get a temporary storage mark, so we can cleanup everything that - // is allocated during the evaluation + DebugAllocPoolScope allocPoolScope; + // Will clean up all allocations when we return. if (setjmp(sJumpBuffers[sNextJumpBufferIndex++]) == 0) { error = ExpressionParser().ParseNextCommandArgument(expressionString, @@ -1262,8 +1221,5 @@ sNextJumpBufferIndex--; - // cleanup temp allocations - free_temp_storage(temporaryStorageMark); - return error; } From bonefish at mail.berlios.de Wed Jun 3 15:36:37 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 3 Jun 2009 15:36:37 +0200 Subject: [Haiku-commits] r30950 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200906031336.n53Dab1u026395@sheep.berlios.de> Author: bonefish Date: 2009-06-03 15:36:35 +0200 (Wed, 03 Jun 2009) New Revision: 30950 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30950&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp Log: print_demangled_call(): Use a heap allocated buffer. This allows us to be more generous with the size. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2009-06-03 12:28:49 UTC (rev 30949) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2009-06-03 13:36:35 UTC (rev 30950) @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -116,12 +117,18 @@ print_demangled_call(const char* image, const char* symbol, addr_t args, bool noObjectMethod, bool addDebugVariables) { + static const size_t kBufferSize = 256; + char* buffer = (char*)debug_malloc(kBufferSize); + if (buffer == NULL) + return B_NO_MEMORY; + bool isObjectMethod; - char buffer[64]; - const char* name = debug_demangle_symbol(symbol, buffer, sizeof(buffer), + const char* name = debug_demangle_symbol(symbol, buffer, kBufferSize, &isObjectMethod); - if (name == NULL) + if (name == NULL) { + debug_free(buffer); return B_ERROR; + } uint32* arg = (uint32*)args; @@ -145,7 +152,7 @@ int32 type, i = 0; uint32 cookie = 0; while (debug_get_next_demangled_argument(&cookie, symbol, buffer, - sizeof(buffer), &type, &length) == B_OK) { + kBufferSize, &type, &length) == B_OK) { if (i++ > 0) kprintf(", "); @@ -223,7 +230,7 @@ if (type == B_STRING_TYPE) { if (value == 0) kprintf(" \33[31m\"\"\33[0m"); - else if (user_strlcpy(buffer, (char*)value, sizeof(buffer)) < B_OK) + else if (user_strlcpy(buffer, (char*)value, kBufferSize) < B_OK) kprintf(" \33[31m\"\"\33[0m"); else kprintf(" \33[36m\"%s\"\33[0m", buffer); @@ -234,6 +241,8 @@ arg = (uint32*)((uint8*)arg + length); } + debug_free(buffer); + kprintf(")"); return B_OK; } From rudolf.cornelissen at gmail.com Wed Jun 3 13:56:24 2009 From: rudolf.cornelissen at gmail.com (Rudolf Cornelissen) Date: Wed, 3 Jun 2009 13:56:24 +0200 Subject: [Haiku-commits] r30946 - in haiku/trunk: headers/private/graphics/nvidia src/add-ons/accelerants/nvidia/engine In-Reply-To: <52606096969-BeMail@zon> References: <200906022038.n52Kc2ut010414@sheep.berlios.de> <52606096969-BeMail@zon> Message-ID: Hi Axel, actually I am using it. Just not where I want something else than this code provides, like dumping stuff in my own logfile instead of syslog. Were you thinking of something specific? Bye! Rudolf. On Tue, Jun 2, 2009 at 11:18 PM, Axel D?rfler wrote: > rudolfc at mail.berlios.de wrote: > > Log: > > modified I2C code to read the third bus on cards that can support it. > > Dumping EDID scanning results in logfile only for now (testing..) > > BTW, is there any reason you're not using the common I2C/EDID code? > > Bye, > Axel. > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rudolfc at mail.berlios.de Wed Jun 3 21:20:06 2009 From: rudolfc at mail.berlios.de (rudolfc at mail.berlios.de) Date: Wed, 3 Jun 2009 21:20:06 +0200 Subject: [Haiku-commits] r30951 - haiku/trunk/src/add-ons/accelerants/nvidia/engine Message-ID: <200906031920.n53JK6gR016168@sheep.berlios.de> Author: rudolfc Date: 2009-06-03 21:20:04 +0200 (Wed, 03 Jun 2009) New Revision: 30951 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30951&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c Log: re-enabled EDID native modeline grabbing with I2C bus 2 enabled. Now EDID is correctly fetched on all my cards, including G72 id0x1d1 and NV43 id0x141. info is stored in shared_info, not actually used yet though. (wip) Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c 2009-06-03 13:36:35 UTC (rev 30950) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_i2c.c 2009-06-03 19:20:04 UTC (rev 30951) @@ -346,13 +346,11 @@ } } - //fixme: testing again.. - i2c_TestEDID(); -// i2c_DetectScreens(); -// LOG(4,("I2C: dumping EDID specs for connector 1:\n")); -// i2c_DumpSpecsEDID(&si->ps.con1_screen); -// LOG(4,("I2C: dumping EDID specs for connector 2:\n")); -// i2c_DumpSpecsEDID(&si->ps.con2_screen); + i2c_DetectScreens(); + LOG(4,("I2C: dumping EDID specs for connector 1:\n")); + i2c_DumpSpecsEDID(&si->ps.con1_screen); + LOG(4,("I2C: dumping EDID specs for connector 2:\n")); + i2c_DumpSpecsEDID(&si->ps.con2_screen); return result; } @@ -682,9 +680,10 @@ * architecture cards. On later cards it's vice versa. These connections do not depend * on the analog VGA switch setting (see nv_general_output_select()). It also does * not depend on the way screens are connected to the cards (DVI/VGA, 1 or 2 screens). + * - on some NV40 architecture cards i2c bus2 connects to con2 instead of i2c bus0. This + * is confirmed on GeForce FX 6600 (NV43, id 0x0141) and GeForce 7300 (G72, id 0x01d1). * - con1 has CRTC1 and DAC1, and con2 has CRTC2 and DAC2 if nv_general_output_select() * is set to 'straight' and there are only VGA type screens connected. */ -//fixme: take third I2C bus into account.. void i2c_DetectScreens(void) { edid1_info edid; @@ -693,34 +692,54 @@ si->ps.con2_screen.have_edid = false; /* check existance of bus 0 */ - if (!si->ps.i2c_bus0) return; - - /* check I2C bus 0 for an EDID capable screen */ - if (i2c_ReadEDID(0, &edid) == B_OK) { - /* fetch optimum (native) modeline */ - switch (si->ps.card_arch) { - case NV40A: - i2c_ExtractSpecsEDID(&edid, &si->ps.con2_screen); - break; - default: - i2c_ExtractSpecsEDID(&edid, &si->ps.con1_screen); - break; + if (si->ps.i2c_bus0) { + /* check I2C bus 0 for an EDID capable screen */ + if (i2c_ReadEDID(0, &edid) == B_OK) { + /* fetch optimum (native) modeline */ + switch (si->ps.card_arch) { + case NV40A: + i2c_ExtractSpecsEDID(&edid, &si->ps.con2_screen); + break; + default: + i2c_ExtractSpecsEDID(&edid, &si->ps.con1_screen); + break; + } } } /* check existance of bus 1 */ - if (!si->ps.i2c_bus1) return; + if (si->ps.i2c_bus1) { + /* check I2C bus 1 for an EDID screen */ + if (i2c_ReadEDID(1, &edid) == B_OK) { + /* fetch optimum (native) modeline */ + switch (si->ps.card_arch) { + case NV40A: + i2c_ExtractSpecsEDID(&edid, &si->ps.con1_screen); + break; + default: + i2c_ExtractSpecsEDID(&edid, &si->ps.con2_screen); + break; + } + } + } - /* check I2C bus 1 for an EDID screen */ - if (i2c_ReadEDID(1, &edid) == B_OK) { - /* fetch optimum (native) modeline */ - switch (si->ps.card_arch) { - case NV40A: - i2c_ExtractSpecsEDID(&edid, &si->ps.con1_screen); - break; - default: - i2c_ExtractSpecsEDID(&edid, &si->ps.con2_screen); - break; + /* check existance of bus 2 */ + if (si->ps.i2c_bus2) { + /* check I2C bus 2 for an EDID screen */ + if (i2c_ReadEDID(2, &edid) == B_OK) { + /* fetch optimum (native) modeline */ + switch (si->ps.card_arch) { + case NV40A: + if (!si->ps.con2_screen.have_edid) { + i2c_ExtractSpecsEDID(&edid, &si->ps.con2_screen); + } else { + LOG(4,("I2C: DetectScreens: WARNING, unexpected behaviour detected!\n")); + } + break; + default: + LOG(4,("I2C: DetectScreens: WARNING, unexpected behaviour detected!\n")); + break; + } } } } From dev at m-phasis.de Wed Jun 3 22:26:30 2009 From: dev at m-phasis.de (Michael Weirauch) Date: Wed, 3 Jun 2009 22:26:30 +0200 Subject: [Haiku-commits] r30945 - in haiku/trunk: headers/posix src/system/libroot/posix/glibc/arch/generic src/system/libroot/posix/glibc/arch/m68k src/system/libroot/posix/glibc/arch/ppc In-Reply-To: <200906022024.n52KOJ5g008820@sheep.berlios.de> References: <200906022024.n52KOJ5g008820@sheep.berlios.de> Message-ID: 2009/6/2 korli at BerliOS : > Author: korli > Date: 2009-06-02 22:24:18 +0200 (Tue, 02 Jun 2009) > New Revision: 30945 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30945&view=rev > > Added: > ? haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrint.c > ? haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintf.c > ? haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_llrintl.c > ? haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrint.c > ? haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintf.c > ? haiku/trunk/src/system/libroot/posix/glibc/arch/generic/s_lrintl.c > Modified: > ? haiku/trunk/headers/posix/math.h > ? haiku/trunk/src/system/libroot/posix/glibc/arch/m68k/Jamfile > ? haiku/trunk/src/system/libroot/posix/glibc/arch/ppc/Jamfile > Log: > added lrint and llrint functions to math.h > added generic implementations for ppc and m68k Can it be that the following is required for the gcc4 build now? Index: src/add-ons/media/plugins/avcodec/libavcodec/config.h =================================================================== --- src/add-ons/media/plugins/avcodec/libavcodec/config.h (Revision 30951) +++ src/add-ons/media/plugins/avcodec/libavcodec/config.h (Arbeitskopie) @@ -73,7 +73,7 @@ #define HAVE_LIBDC1394_2 0 #define HAVE_LLRINT 1 #define HAVE_LRINT 1 -#define HAVE_LRINTF 0 +#define HAVE_LRINTF 1 #define HAVE_MACHINE_IOCTL_BT848_H 0 #define HAVE_MACHINE_IOCTL_METEOR_H 0 #define HAVE_MALLOC_H 1 Asking because of: Cc /store/data/devel/haiku/svn/trunk/generated4/objects/haiku/x86/release/add-ons/media/plugins/avcodec/libavcodec/4xm.o In file included from /store/data/devel/haiku/svn/trunk/src/add-ons/media/plugins/avcodec/libavcodec/../libavutil/common.h:283, from /store/data/devel/haiku/svn/trunk/src/add-ons/media/plugins/avcodec/libavcodec/../libavutil/bswap.h:31, from /store/data/devel/haiku/svn/trunk/src/add-ons/media/plugins/avcodec/libavcodec/../libavutil/intreadwrite.h:24, from /store/data/devel/haiku/svn/trunk/src/add-ons/media/plugins/avcodec/libavcodec/4xm.c:27: /store/data/devel/haiku/svn/trunk/src/add-ons/media/plugins/avcodec/libavcodec/../libavutil/internal.h:290: error: static declaration of 'lrintf' follows non-static declaration Michael From korli at mail.berlios.de Wed Jun 3 22:36:30 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 3 Jun 2009 22:36:30 +0200 Subject: [Haiku-commits] r30952 - haiku/trunk/src/add-ons/media/plugins/avcodec/libavcodec Message-ID: <200906032036.n53KaUq0026761@sheep.berlios.de> Author: korli Date: 2009-06-03 22:36:29 +0200 (Wed, 03 Jun 2009) New Revision: 30952 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30952&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/avcodec/libavcodec/config.h Log: Adding lrintf declarations conflicts on avcodec when building gcc4. Noticed by Michael Weirauch. Modified: haiku/trunk/src/add-ons/media/plugins/avcodec/libavcodec/config.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/avcodec/libavcodec/config.h 2009-06-03 19:20:04 UTC (rev 30951) +++ haiku/trunk/src/add-ons/media/plugins/avcodec/libavcodec/config.h 2009-06-03 20:36:29 UTC (rev 30952) @@ -73,7 +73,7 @@ #define HAVE_LIBDC1394_2 0 #define HAVE_LLRINT 1 #define HAVE_LRINT 1 -#define HAVE_LRINTF 0 +#define HAVE_LRINTF 1 #define HAVE_MACHINE_IOCTL_BT848_H 0 #define HAVE_MACHINE_IOCTL_METEOR_H 0 #define HAVE_MALLOC_H 1 From korli at users.berlios.de Wed Jun 3 22:37:12 2009 From: korli at users.berlios.de (=?ISO-8859-1?B?Suly9G1lIER1dmFs?=) Date: Wed, 3 Jun 2009 22:37:12 +0200 Subject: [Haiku-commits] r30945 - in haiku/trunk: headers/posix src/system/libroot/posix/glibc/arch/generic src/system/libroot/posix/glibc/arch/m68k src/system/libroot/posix/glibc/arch/ppc In-Reply-To: References: <200906022024.n52KOJ5g008820@sheep.berlios.de> Message-ID: 2009/6/3 Michael Weirauch : > > Can it be that the following is required for the gcc4 build now? Indeed. Committed in r30952. Bye, J?r?me From axeld at mail.berlios.de Wed Jun 3 23:05:29 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 3 Jun 2009 23:05:29 +0200 Subject: [Haiku-commits] r30953 - haiku/trunk/src/system/kernel/debug Message-ID: <200906032105.n53L5T5P031599@sheep.berlios.de> Author: axeld Date: 2009-06-03 23:05:29 +0200 (Wed, 03 Jun 2009) New Revision: 30953 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30953&view=rev Modified: haiku/trunk/src/system/kernel/debug/debug.cpp Log: * Don't overwrite the history buffer when you issue the same command more than once. Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2009-06-03 20:36:29 UTC (rev 30952) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2009-06-03 21:05:29 UTC (rev 30953) @@ -714,14 +714,23 @@ int rc = evaluate_debug_command(line); - if (rc == B_KDEBUG_QUIT) - break; // okay, exit now. + if (rc == B_KDEBUG_QUIT) { + // okay, exit now. + break; + } // If the command is continuable, remember the current line index. continuableLine = (rc == B_KDEBUG_CONT ? sCurrentLine : -1); - if (++sCurrentLine >= HISTORY_SIZE) - sCurrentLine = 0; + int previousLine = sCurrentLine - 1; + if (previousLine < 0) + previousLine = HISTORY_SIZE - 1; + + // Only use the next slot in the history, if the entries differ + if (strcmp(sLineBuffer[sCurrentLine], sLineBuffer[previousLine])) { + if (++sCurrentLine >= HISTORY_SIZE) + sCurrentLine = 0; + } } delete_debug_alloc_pool(allocPool); From bonefish at mail.berlios.de Thu Jun 4 03:47:10 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Thu, 4 Jun 2009 03:47:10 +0200 Subject: [Haiku-commits] r30954 - in haiku/trunk: build/jam src/add-ons/kernel/debugger/demangle Message-ID: <200906040147.n541lAlk005834@sheep.berlios.de> Author: bonefish Date: 2009-06-04 03:47:05 +0200 (Thu, 04 Jun 2009) New Revision: 30954 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30954&view=rev Added: haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.cpp haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/add-ons/kernel/debugger/demangle/Jamfile haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp Log: * Implemented demangling support for the current gcc ABI. Looks good so far save for the additional '&'/'*' print_demangled_call() is printing for reference/pointer arguments. * Moved the new demangler and the gcc 2 demangler into the same module always supporting both (the right one is chosen). In mixed gcc 2/gcc 4 environments we obviously need both of them. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-03 21:05:29 UTC (rev 30953) +++ haiku/trunk/build/jam/HaikuImage 2009-06-04 01:47:05 UTC (rev 30954) @@ -183,8 +183,8 @@ : uhci ohci ehci ; AddFilesToHaikuImage system add-ons kernel console : vga_text ; AddFilesToHaikuImage system add-ons kernel debugger - : $(X86_ONLY)disasm hangman invalidate_on_exit - usb_keyboard run_on_exit ; + : demangle $(X86_ONLY)disasm hangman + invalidate_on_exit usb_keyboard run_on_exit ; AddFilesToHaikuImage system add-ons kernel file_systems : $(SYSTEM_ADD_ONS_FILE_SYSTEMS) ; AddFilesToHaikuImage system add-ons kernel generic @@ -197,11 +197,6 @@ if $(TARGET_ARCH) = x86 { AddFilesToHaikuImage system add-ons kernel cpu : generic_x86 ; - - if $(HAIKU_GCC_VERSION[1]) = 2 { - AddFilesToHaikuImage system add-ons kernel debugger demangle : - gcc2 ; - } } # drivers Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/Jamfile 2009-06-03 21:05:29 UTC (rev 30953) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/Jamfile 2009-06-04 01:47:05 UTC (rev 30954) @@ -2,34 +2,8 @@ UsePrivateHeaders kernel ; -# GCC3/4 only solution (using parts of libsubc++) -if $(HAIKU_GCC_VERSION[1]) >= 3 { - rule ExtractObject - { - SetupKernel $(2) ; - Depends $(1) : $(2) ; - Objects $(1) ; - - MakeLocateDebug $(1) ; - } - - actions ExtractObject - { - #$(TARGET_AR) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; - pwd - echo $(TARGET_AR) -x "$(2)" "$(1)" - } - - ExtractObject cp-demangle.o : $(TARGET_STATIC_LIBSUPC++) foo ; - - KernelAddon gcc3+ : - gcc3+.cpp - cp-demangle.o - ; -} - -# GCC2 solution - -KernelAddon gcc2 : +KernelAddon demangle : + demangle.cpp gcc2.cpp + gcc3+.cpp ; Added: haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.cpp 2009-06-03 21:05:29 UTC (rev 30953) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.cpp 2009-06-04 01:47:05 UTC (rev 30954) @@ -0,0 +1,84 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "demangle.h" + +#include + +#include + + +static inline bool +looks_like_gcc3_symbol(const char* symbol) +{ + return strncmp(symbol, "_Z", 2) == 0; +} + + +static const char* +demangle_symbol(const char* mangledName, char* buffer, size_t bufferSize, + bool* _isObjectMethod) +{ + // try the gcc3 demangler, if it looks like a gcc3 symbol + const char* demangled = NULL; + if (looks_like_gcc3_symbol(mangledName)) { + demangled = demangle_symbol_gcc3(mangledName, buffer, bufferSize, + _isObjectMethod); + if (demangled != NULL) + return demangled; + } + + // fallback is gcc2 + return demangle_symbol_gcc2(mangledName, buffer, bufferSize, + _isObjectMethod); +} + + +static status_t +get_next_argument(uint32* _cookie, const char* mangledName, char* name, + size_t nameSize, int32* _type, size_t* _argumentLength) +{ + // try the gcc3 demangler, if it looks like a gcc3 symbol + if (looks_like_gcc3_symbol(mangledName)) { + status_t error = get_next_argument_gcc3(_cookie, mangledName, name, + nameSize, _type, _argumentLength); + if (error == B_OK) + return B_OK; + } + + // fallback is gcc2 + return get_next_argument_gcc2(_cookie, mangledName, name, nameSize, _type, + _argumentLength); +} + + +static status_t +std_ops(int32 op, ...) +{ + switch (op) { + case B_MODULE_INIT: + case B_MODULE_UNINIT: + return B_OK; + } + + return B_BAD_VALUE; +} + + +static struct debugger_demangle_module_info sModuleInfo = { + { + "debugger/demangle/v1", + 0, + std_ops + }, + + demangle_symbol, + get_next_argument, +}; + +module_info* modules[] = { + (module_info*)&sModuleInfo, + NULL +}; Added: haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h 2009-06-03 21:05:29 UTC (rev 30953) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h 2009-06-04 01:47:05 UTC (rev 30954) @@ -0,0 +1,27 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef DEMANGLE_H +#define DEMANGLE_H + +#include + + +// gcc 2 +const char* demangle_symbol_gcc2(const char* name, char* buffer, + size_t bufferSize, bool* _isObjectMethod); +status_t get_next_argument_gcc2(uint32* _cookie, const char* symbol, + char* name, size_t nameSize, int32* _type, + size_t* _argumentLength); + + +// gcc 3+ +const char* demangle_symbol_gcc3(const char* name, char* buffer, + size_t bufferSize, bool* _isObjectMethod); +status_t get_next_argument_gcc3(uint32* _cookie, const char* symbol, + char* name, size_t nameSize, int32* _type, + size_t* _argumentLength); + + +#endif // DEMANGLE_H Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp 2009-06-03 21:05:29 UTC (rev 30953) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp 2009-06-04 01:47:05 UTC (rev 30954) @@ -12,7 +12,9 @@ #include +#include "demangle.h" + //#define TRACE_GCC2_DEMANGLER #ifdef TRACE_GCC2_DEMANGLER # define TRACE(x...) kprintf(x) @@ -420,7 +422,7 @@ const char* -demangle_symbol(const char* name, char* buffer, size_t bufferSize, +demangle_symbol_gcc2(const char* name, char* buffer, size_t bufferSize, bool* _isObjectMethod) { size_t nameLength; @@ -467,44 +469,9 @@ status_t -get_next_argument(uint32* _cookie, const char* symbol, char* name, +get_next_argument_gcc2(uint32* _cookie, const char* symbol, char* name, size_t nameSize, int32* _type, size_t* _argumentLength) { return get_next_argument_internal(_cookie, symbol, name, nameSize, _type, _argumentLength, false); } - - -static status_t -std_ops(int32 op, ...) -{ -#if __GNUC__ != 2 - return B_NOT_SUPPORTED; -#else - switch (op) { - case B_MODULE_INIT: - case B_MODULE_UNINIT: - return B_OK; - } - - return B_BAD_VALUE; -#endif -} - - -static struct debugger_demangle_module_info sModuleInfo = { - { - "debugger/demangle/gcc2/v1", - 0, - std_ops - }, - - demangle_symbol, - get_next_argument, -}; - -module_info *modules[] = { - (module_info *)&sModuleInfo, - NULL -}; - Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp 2009-06-03 21:05:29 UTC (rev 30953) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp 2009-06-04 01:47:05 UTC (rev 30954) @@ -1,174 +1,3872 @@ /* - * Copyright 2008, Fran?ois Revol, revol at free.fr + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. * Distributed under the terms of the MIT License. */ #include -#include +#include +#include #include #include -#include +#include -#define DEMANGLE_BUFFER_SIZE (16*1024) -static char sDemangleBuffer[DEMANGLE_BUFFER_SIZE]; +#include -extern "C" void set_debug_demangle_hook(const char *(*demangle_hook)(const char *)); +#include -/* gcc's __cxa_demangle calls malloc and friends... - * we don't want to let it call the real one from inside the kernel debugger... - * instead we just return it a static buffer. - */ +#include "demangle.h" -void * -malloc(size_t len) + +// C++ ABI: http://www.codesourcery.com/public/cxx-abi/abi.html + + +//#define TRACE_GCC3_DEMANGLER +#ifdef TRACE_GCC3_DEMANGLER +# define TRACE(x...) PRINT(x) +# define DEBUG_SCOPE(name) DebugScope debug(name, fInput.String()) +#else +# define TRACE(x...) ; +# define DEBUG_SCOPE(name) do {} while (false) +#endif + +#ifdef _KERNEL_MODE +# define PRINT(format...) kprintf(format) +# define VPRINT(format, args) PRINT("%s", format) + // no vkprintf() +# define NEW(constructor) new(kdebug_alloc) constructor +# define DELETE(object) DebugAlloc::destroy(object) +#else +# define PRINT(format...) printf(format) +# define VPRINT(format, args) vprintf(format, args) +# define NEW(constructor) new(std::nothrow) constructor +# define DELETE(object) delete object +#endif + + +typedef long number_type; + +enum { + ERROR_OK = 0, + ERROR_NOT_MANGLED, + ERROR_UNSUPPORTED, + ERROR_INVALID, + ERROR_BUFFER_TOO_SMALL, + ERROR_NO_MEMORY, + ERROR_INTERNAL, + ERROR_INVALID_PARAMETER_INDEX +}; + +// object classification +enum object_type { + OBJECT_TYPE_UNKNOWN, + OBJECT_TYPE_DATA, + OBJECT_TYPE_FUNCTION, + OBJECT_TYPE_METHOD_CLASS, + OBJECT_TYPE_METHOD_OBJECT, + OBJECT_TYPE_METHOD_UNKNOWN +}; + +// prefix classification +enum prefix_type { + PREFIX_NONE, + PREFIX_NAMESPACE, + PREFIX_CLASS, + PREFIX_UNKNOWN +}; + +// type classification +enum type_type { + TYPE_ELLIPSIS, + TYPE_VOID, + TYPE_WCHAR_T, + TYPE_BOOL, + TYPE_CHAR, + TYPE_SIGNED_CHAR, + TYPE_UNSIGNED_CHAR, + TYPE_SHORT, + TYPE_UNSIGNED_SHORT, + TYPE_INT, + TYPE_UNSIGNED_INT, + TYPE_LONG, + TYPE_UNSIGNED_LONG, + TYPE_LONG_LONG, + TYPE_UNSIGNED_LONG_LONG, + TYPE_INT128, + TYPE_UNSIGNED_INT128, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_LONG_DOUBLE, + TYPE_FLOAT128, + TYPE_DFLOAT16, + TYPE_DFLOAT32, + TYPE_DFLOAT64, + TYPE_DFLOAT128, + TYPE_CHAR16_T, + TYPE_CHAR32_T, + + TYPE_UNKNOWN, + TYPE_CONST_CHAR_POINTER, + TYPE_POINTER, + TYPE_REFERENCE +}; + +const char* const kTypeNames[] = { + "...", + "void", + "wchar_t", + "bool", + "char", + "signed char", + "unsigned char", + "short", + "unsigned short", + "int", + "unsigned int", + "long", + "unsigned long", + "long long", + "unsigned long long", + "__int128", + "unsigned __int128", + "float", + "double", + "long double", + "__float128", + "__dfloat16", // TODO: Official names for the __dfloat*! + "__dfloat32", + "__dfloat64", + "__dfloat64", + "char16_t", + "char32_t", + + "?", + "char const*", + "void*", + "void&" +}; + + +// CV qualifier flags +enum { + CV_QUALIFIER_RESTRICT = 0x1, + CV_QUALIFIER_VOLATILE = 0x2, + CV_QUALIFIER_CONST = 0x4 +}; + +enum type_modifier { + TYPE_QUALIFIER_POINTER = 0, + TYPE_QUALIFIER_REFERENCE, + TYPE_QUALIFIER_RVALUE_REFERENCE, + TYPE_QUALIFIER_COMPLEX, + TYPE_QUALIFIER_IMAGINARY +}; + +static const char* const kTypeModifierSuffixes[] = { + "*", + "&", + "&&", + " complex", + " imaginary" +}; + +struct operator_info { + const char* mangled_name; + const char* name; + int argument_count; + int flags; +}; + +// operator flags +enum { + OPERATOR_TYPE_PARAM = 0x01, + OPERATOR_IS_MEMBER = 0x02 +}; + + +static const operator_info kOperatorInfos[] = { + { "nw", "new", -1, OPERATOR_IS_MEMBER }, + { "na", "new[]", -1, OPERATOR_IS_MEMBER }, + { "dl", "delete", -1, OPERATOR_IS_MEMBER }, + { "da", "delete[]", -1, OPERATOR_IS_MEMBER }, + { "ps", "+", 1, 0 }, // unary + { "ng", "-", 1, 0 }, // unary + { "ad", "&", 1, 0 }, // unary + { "de", "*", 1, 0 }, // unary + { "co", "~", 1, 0 }, + { "pl", "+", 2, 0 }, + { "mi", "-", 2, 0 }, + { "ml", "*", 2, 0 }, + { "dv", "/", 2, 0 }, + { "rm", "%", 2, 0 }, + { "an", "&", 2, 0 }, + { "or", "|", 2, 0 }, + { "eo", "^", 2, 0 }, + { "aS", "=", 2, 0 }, + { "pL", "+=", 2, 0 }, + { "mI", "-=", 2, 0 }, + { "mL", "*=", 2, 0 }, + { "dV", "/=", 2, 0 }, + { "rM", "%=", 2, 0 }, + { "aN", "&=", 2, 0 }, + { "oR", "|=", 2, 0 }, + { "eO", "^=", 2, 0 }, + { "ls", "<<", 2, 0 }, + { "rs", ">>", 2, 0 }, + { "lS", "<<=", 2, 0 }, + { "rS", ">>=", 2, 0 }, + { "eq", "==", 2, 0 }, + { "ne", "!=", 2, 0 }, + { "lt", "<", 2, 0 }, + { "gt", ">", 2, 0 }, + { "le", "<=", 2, 0 }, + { "ge", ">=", 2, 0 }, + { "nt", "!", 1, 0 }, + { "aa", "&&", 2, 0 }, + { "oo", "||", 2, 0 }, + { "pp", "++", 1, 0 }, + { "mm", "--", 1, 0 }, + { "cm", ",", -1, 0 }, + { "pm", "->*", 2, 0 }, + { "pt", "->", 2, 0 }, + { "cl", "()", -1, 0 }, + { "ix", "[]", -1, 0 }, + { "qu", "?", 3, 0 }, + { "st", "sizeof", 1, OPERATOR_TYPE_PARAM }, // type + { "sz", "sizeof", 1, 0 }, // expression + { "at", "alignof", 1, OPERATOR_TYPE_PARAM }, // type + { "az", "alignof", 1, 0 }, // expression + {} +}; + + +#ifdef TRACE_GCC3_DEMANGLER + +struct DebugScope { + DebugScope(const char* functionName, const char* remainingString = NULL) + : + fParent(sGlobalScope), + fFunctionName(functionName), + fLevel(fParent != NULL ? fParent->fLevel + 1 : 0) + { + sGlobalScope = this; + if (remainingString != NULL) { + PRINT("%*s%s(): \"%s\"\n", fLevel * 2, "", fFunctionName, + remainingString); + } else + PRINT("%*s%s()\n", fLevel * 2, "", fFunctionName); + } + + ~DebugScope() + { + sGlobalScope = fParent; + PRINT("%*s%s() done\n", fLevel * 2, "", fFunctionName); + } + + static void Print(const char* format,...) + { + int level = sGlobalScope != NULL ? sGlobalScope->fLevel : 0; + + va_list args; + va_start(args, format); + PRINT("%*s", (level + 1) * 2, ""); + VPRINT(format, args); + va_end(args); + } + +private: + DebugScope* fParent; + const char* fFunctionName; + int fLevel; + + static DebugScope* sGlobalScope; +}; + +DebugScope* DebugScope::sGlobalScope = NULL; + +#endif // TRACE_GCC3_DEMANGLER + + +class Input { +public: + Input() + : + fString(NULL), + fLength(0) + { + } + + void SetTo(const char* string, size_t length) + { + fString = string; + fLength = length; + } + + const char* String() const + { + return fString; + } + + int CharsRemaining() const + { + return fLength; + } + + void Skip(size_t count) + { + if (count > fLength) { + PRINT("Input::Skip(): fOffset > fLength\n"); + return; + } + + fString += count; + fLength -= count; + } + + bool HasPrefix(char prefix) const + { + return fLength > 0 && fString[0] == prefix; + } + + bool HasPrefix(const char* prefix) const + { + size_t prefixLen = strlen(prefix); + return prefixLen <= fLength + && strncmp(fString, prefix, strlen(prefix)) == 0; + } + + bool SkipPrefix(char prefix) + { + if (!HasPrefix(prefix)) + return false; + + fString++; + fLength--; + return true; + } + + bool SkipPrefix(const char* prefix) + { + size_t prefixLen = strlen(prefix); + if (prefixLen <= fLength && strncmp(fString, prefix, prefixLen) != 0) + return false; + + fString += prefixLen; + fLength -= prefixLen; + return true; + } + + char operator[](size_t index) const + { + if (index >= fLength) { + PRINT("Input::operator[](): fOffset + index >= fLength\n"); + return '\0'; + } + + return fString[index]; + } + +private: + const char* fString; + size_t fLength; +}; + + +class NameBuffer { +public: + NameBuffer(char* buffer, size_t size) + : + fBuffer(buffer), + fSize(size), + fLength(0), + fOverflow(false) + { + } + + bool IsEmpty() const + { + return fLength == 0; + } + + char LastChar() const + { + return fLength > 0 ? fBuffer[fLength - 1] : '\0'; + } + + bool HadOverflow() const + { + return fOverflow; + } + + char* Terminate() + { + fBuffer[fLength] = '\0'; + return fBuffer; + } + + bool Append(const char* string, size_t length) + { + if (fLength + length >= fSize) { + fOverflow = true; + return false; + } + + memcpy(fBuffer + fLength, string, length); + fLength += length; + return true; + } + + bool Append(const char* string) + { + return Append(string, strlen(string)); + } + +private: + char* fBuffer; + size_t fSize; + size_t fLength; + bool fOverflow; +}; + + +struct TypeInfo { + type_type type; + int cvQualifiers; + + TypeInfo() + : + type(TYPE_UNKNOWN), + cvQualifiers(0) + { + } + + TypeInfo(type_type type) + : + type(type), + cvQualifiers(0) + { + } + + TypeInfo(const TypeInfo& other, int cvQualifiers = 0) + : + type(other.type), + cvQualifiers(other.cvQualifiers | cvQualifiers) + { + } + + TypeInfo& operator=(const TypeInfo& other) + { + type = other.type; + cvQualifiers = other.cvQualifiers; + return *this; + } +}; + + +struct DemanglingParameters { + bool objectNameOnly; + + DemanglingParameters(bool objectNameOnly) + : + objectNameOnly(objectNameOnly) + { + } +}; + + +struct DemanglingInfo : DemanglingParameters { + object_type objectType; + + DemanglingInfo(bool objectNameOnly) + : + DemanglingParameters(objectNameOnly), + objectType(OBJECT_TYPE_UNKNOWN) + { + } +}; + + +struct ParameterInfo { + TypeInfo type; + + ParameterInfo() + { + } +}; + + +class Node; + +struct NameDecorationInfo { + const Node* firstDecorator; + const Node* closestCVDecoratorList; + + NameDecorationInfo(const Node* decorator) + : + firstDecorator(decorator), + closestCVDecoratorList(NULL) + { + } +}; + +struct CVQualifierInfo { + const Node* firstCVQualifier; + const Node* firstNonCVQualifier; + + CVQualifierInfo() + : + firstCVQualifier(NULL), + firstNonCVQualifier(NULL) + { + } +}; + + +class Node { +public: + Node() + : + fNextAllocated(NULL), + fParent(NULL), + fNext(NULL), + fNextReferenceable(NULL), + fReferenceable(true) + { + } + + virtual ~Node() + { + } + + Node* NextAllocated() const { return fNextAllocated; } + void SetNextAllocated(Node* node) { fNextAllocated = node; } + + Node* Parent() const { return fParent; } + virtual void SetParent(Node* node) { fParent = node; } + + Node* Next() const { return fNext; } + void SetNext(Node* node) { fNext = node; } + + bool IsReferenceable() const { return fReferenceable; } + void SetReferenceable(bool flag) { fReferenceable = flag; } + + Node* NextReferenceable() const { return fNextReferenceable; } + void SetNextReferenceable(Node* node) { fNextReferenceable = node; } + + virtual bool GetName(NameBuffer& buffer) const = 0; + + virtual bool GetDecoratedName(NameBuffer& buffer, + NameDecorationInfo& decorationInfo) const + { + if (!GetName(buffer)) + return false; + + return decorationInfo.firstDecorator == NULL + || decorationInfo.firstDecorator->AddDecoration(buffer, NULL); + } + + virtual bool AddDecoration(NameBuffer& buffer, + const Node* stopDecorator) const + { + return true; + } + + virtual void GetCVQualifierInfo(CVQualifierInfo& info) const + { + info.firstNonCVQualifier = this; + } + + virtual Node* GetUnqualifiedNode(Node* beforeNode) + { + return this; + } + + virtual bool IsTemplatized() const + { + return false; + } + + virtual Node* TemplateParameterAt(int index) const + { + return NULL; + } + + virtual bool IsNoReturnValueFunction() const + { + return false; + } + + virtual bool IsTypeName(const char* name, size_t length) const + { + return false; + } + + virtual object_type ObjectType() const + { + return OBJECT_TYPE_UNKNOWN; + } + + virtual prefix_type PrefixType() const + { + return PREFIX_NONE; + } + + virtual TypeInfo Type() const + { + return TypeInfo(); + } + +private: + Node* fNextAllocated; + Node* fParent; + Node* fNext; + Node* fNextReferenceable; + bool fReferenceable; +}; + + +class NamedTypeNode : public Node { +public: + NamedTypeNode(Node* name) + : + fName(name) + { + if (fName != NULL) + fName->SetParent(this); + } + + virtual bool GetName(NameBuffer& buffer) const + { + return fName == NULL || fName->GetName(buffer); + } + + virtual bool IsNoReturnValueFunction() const + { + return fName != NULL && fName->IsNoReturnValueFunction(); + } + + virtual TypeInfo Type() const + { + return fName != NULL ? fName->Type() : TypeInfo(); + } + +protected: + Node* fName; +}; + + +class SubstitutionNode : public Node { +public: + SubstitutionNode(Node* node) + : + fNode(node) + { + } + + virtual bool GetName(NameBuffer& buffer) const + { + return fNode->GetName(buffer); + } + + virtual bool GetDecoratedName(NameBuffer& buffer, + NameDecorationInfo& decorationInfo) const + { + return fNode->GetDecoratedName(buffer, decorationInfo); + } + + virtual bool AddDecoration(NameBuffer& buffer, + const Node* stopDecorator) const + { + return fNode->AddDecoration(buffer, stopDecorator); + } + + virtual void GetCVQualifierInfo(CVQualifierInfo& info) const + { + fNode->GetCVQualifierInfo(info); + } + + virtual bool IsTemplatized() const + { + return fNode->IsTemplatized(); + } + + virtual Node* TemplateParameterAt(int index) const + { + return fNode->TemplateParameterAt(index); + } + + virtual bool IsNoReturnValueFunction() const + { + return fNode->IsNoReturnValueFunction(); + } + + virtual bool IsTypeName(const char* name, size_t length) const + { + return fNode->IsTypeName(name, length); + } + + virtual object_type ObjectType() const + { + return fNode->ObjectType(); + } + + virtual prefix_type PrefixType() const + { + return fNode->PrefixType(); + } + + virtual TypeInfo Type() const + { [... truncated: 3248 lines follow ...] From bonefish at mail.berlios.de Thu Jun 4 04:00:48 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Thu, 4 Jun 2009 04:00:48 +0200 Subject: [Haiku-commits] r30955 - in haiku/trunk/src: add-ons/kernel/debugger/demangle system/kernel/arch/x86 Message-ID: <200906040200.n5420lAg006636@sheep.berlios.de> Author: bonefish Date: 2009-06-04 04:00:45 +0200 (Thu, 04 Jun 2009) New Revision: 30955 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30955&view=rev Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp Log: Moved the appending of '*'/'&' for pointer/reference parameters to the gcc 2 demangler, where it belongs. The gcc 4 stack traces look correct now. Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp 2009-06-04 01:47:05 UTC (rev 30954) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc2.cpp 2009-06-04 02:00:45 UTC (rev 30955) @@ -349,8 +349,8 @@ return B_LINK_LIMIT; // it's a repeat case - status_t status = get_next_argument_internal(&index, symbol, name, - nameSize, _type, _argumentLength, true); + status_t status = get_next_argument_internal(&index, symbol, + name, nameSize, _type, _argumentLength, true); if (status == B_OK) (*_cookie)++; return status; @@ -472,6 +472,14 @@ get_next_argument_gcc2(uint32* _cookie, const char* symbol, char* name, size_t nameSize, int32* _type, size_t* _argumentLength) { - return get_next_argument_internal(_cookie, symbol, name, nameSize, _type, - _argumentLength, false); + status_t error = get_next_argument_internal(_cookie, symbol, name, nameSize, + _type, _argumentLength, false); + if (error != B_OK) + return error; + + // append the missing '*'/'&' for pointer/ref types + if (name[0] != '\0' && (*_type == B_POINTER_TYPE || *_type == B_REF_TYPE)) + strlcat(name, *_type == B_POINTER_TYPE ? "*" : "&", nameSize); + + return B_OK; } Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2009-06-04 01:47:05 UTC (rev 30954) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2009-06-04 02:00:45 UTC (rev 30955) @@ -204,10 +204,8 @@ kprintf("\33[34m%s\33[0m", value ? "true" : "false"); break; default: - if (buffer[0]) { - kprintf("%s%s: ", buffer, type == B_POINTER_TYPE ? "*" - : type == B_REF_TYPE ? "&" : ""); - } + if (buffer[0]) + kprintf("%s: ", buffer); if (length == 4) { value = *(uint32*)arg; From axeld at mail.berlios.de Thu Jun 4 11:57:32 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Thu, 4 Jun 2009 11:57:32 +0200 Subject: [Haiku-commits] r30956 - haiku/trunk/src/kits/support Message-ID: <200906040957.n549vW8Y029261@sheep.berlios.de> Author: axeld Date: 2009-06-04 11:57:31 +0200 (Thu, 04 Jun 2009) New Revision: 30956 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30956&view=rev Modified: haiku/trunk/src/kits/support/Url.cpp Log: * Fixed debug build. Modified: haiku/trunk/src/kits/support/Url.cpp =================================================================== --- haiku/trunk/src/kits/support/Url.cpp 2009-06-04 02:00:45 UTC (rev 30955) +++ haiku/trunk/src/kits/support/Url.cpp 2009-06-04 09:57:31 UTC (rev 30956) @@ -9,7 +9,6 @@ /*! Url class for parsing an URL and opening it with its preferred handler. */ -#define DEBUG 0 #include #include @@ -18,6 +17,7 @@ #include + namespace BPrivate { namespace Support { From axeld at mail.berlios.de Thu Jun 4 12:50:12 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Thu, 4 Jun 2009 12:50:12 +0200 Subject: [Haiku-commits] r30957 - haiku/trunk/src/tests/system/kernel/cache Message-ID: <200906041050.n54AoClR015805@sheep.berlios.de> Author: axeld Date: 2009-06-04 12:50:09 +0200 (Thu, 04 Jun 2009) New Revision: 30957 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30957&view=rev Added: haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp Modified: haiku/trunk/src/tests/system/kernel/cache/Jamfile Log: * Started a file_map test app. Modified: haiku/trunk/src/tests/system/kernel/cache/Jamfile =================================================================== --- haiku/trunk/src/tests/system/kernel/cache/Jamfile 2009-06-04 09:57:31 UTC (rev 30956) +++ haiku/trunk/src/tests/system/kernel/cache/Jamfile 2009-06-04 10:50:09 UTC (rev 30957) @@ -21,7 +21,12 @@ block_cache_test.cpp : libkernelland_emu.so ; +SimpleTest file_map_test : + file_map_test.cpp + file_map.cpp + : libkernelland_emu.so ; + SimpleTest pages_io_test : pages_io_test.cpp - ; +; Added: haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp 2009-06-04 09:57:31 UTC (rev 30956) +++ haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp 2009-06-04 10:50:09 UTC (rev 30957) @@ -0,0 +1,318 @@ +/* + * Copyright 2009, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include +#include + +#include + + +#define MAX_VECS 32 + + +class Map { +public: + Map(const char* name, off_t size); + ~Map(); + + void SetTo(const char* name, off_t size); + + Map& Add(off_t offset, off_t length, off_t diskOffset); + Map& Clear(); + Map& SetSize(off_t size); + void Invalidate(off_t start, off_t size); + void SetMode(uint32 mode); + void Test(); + + status_t GetFileMap(off_t offset, off_t length, file_io_vec* vecs, + size_t* _vecCount); + +private: + void _Error(const char* format, ...); + void _Verbose(const char* format, ...); + int32 _IndexFor(off_t offset); + + const char* fName; + uint32 fTest; + void* fMap; + off_t fOffsets[MAX_VECS]; + file_io_vec fVecs[MAX_VECS]; + file_io_vec fTestVecs[MAX_VECS]; + uint32 fCount; + uint32 fTestCount; + off_t fTestOffset; + off_t fTestLength; + off_t fSize; +}; + + +static bool sVerbose; + + +Map::Map(const char* name, off_t size) + : + fName(NULL), + fMap(NULL), + fCount(0), + fSize(0) +{ + SetTo(name, size); +} + + +Map::~Map() +{ + file_map_delete(fMap); +} + + +void +Map::SetTo(const char* name, off_t size) +{ + file_map_delete(fMap); + + fMap = file_map_create((dev_t)this, 0, size); + if (fMap == NULL) + _Error("Creating file map failed."); + + fName = name; + fSize = size; + fCount = 0; + fTest = 0; + + printf("Running %s\n", fName); +} + + +Map& +Map::Add(off_t offset, off_t length, off_t diskOffset) +{ + _Verbose(" Add(): offset %lld, length %lld, diskOffset %lld", offset, + length, diskOffset); + + if (fCount < MAX_VECS) { + fOffsets[fCount] = offset; + fVecs[fCount].offset = diskOffset; + fVecs[fCount].length = length; + fCount++; + } + + return *this; +} + + +Map& +Map::Clear() +{ + _Verbose(" Clear()"); + fCount = 0; + return *this; +} + + +Map& +Map::SetSize(off_t size) +{ + _Verbose(" SetSize(): size %lld", size); + file_map_set_size(fMap, size); + fSize = size; + return *this; +} + + +void +Map::Invalidate(off_t start, off_t size) +{ + _Verbose(" Invalidate(): start %lld, size %lld", start, size); + file_map_invalidate(fMap, start, size); +} + + +void +Map::SetMode(uint32 mode) +{ + file_map_set_mode(fMap, mode); +} + + +void +Map::Test() +{ + printf(" Test %lu\n", ++fTest); + + for (off_t offset = 0; offset < fSize; offset += 256) { + fTestOffset = offset; + fTestLength = 256; + fTestCount = MAX_VECS; + status_t status = file_map_translate(fMap, offset, fTestLength, + fTestVecs, &fTestCount, 0); + if (status != B_OK) { + _Error("file_map_translate(offset %lld) failed: %s", offset, + strerror(status)); + } + + int32 index = _IndexFor(offset); + if (index < 0) + _Error("index for offset %lld not found!", offset); + + off_t diff = offset - fOffsets[index]; + + if (fTestVecs[0].length > fSize - diff) { + _Error("size too large: got %lld, size is %lld", + fTestVecs[0].length, fSize); + } + if (fTestVecs[0].offset != fVecs[index].offset + diff) { + _Error("offset mismatch: got %lld, should be %lld", + fTestVecs[0].offset, fVecs[index].offset + diff); + } + } + + fTestCount = 0; +} + + +status_t +Map::GetFileMap(off_t offset, off_t length, file_io_vec* vecs, + size_t* _vecCount) +{ + int32 index = _IndexFor(offset); + if (index < 0) + _Error("No vec for offset %lld\n", offset); + + _Verbose(" GetFileMap(): offset: %lld, length: %lld, index %ld", offset, + length, index); + + uint32 count = 0; + + while (length > 0) { + if (count >= *_vecCount) + return B_BUFFER_OVERFLOW; + if ((uint32)index >= fCount) + return B_OK; + + off_t diff = offset - fOffsets[index]; + vecs[count].offset = fVecs[index].offset + diff; + vecs[count].length = fVecs[index].length - diff; + _Verbose(" [%lu] offset %lld, length %lld", count, + vecs[count].offset, vecs[count].length); + + length -= vecs[count].length; + offset += vecs[count].length; + index++; + count++; + } + + return B_OK; +} + + +void +Map::_Error(const char* format, ...) +{ + va_list args; + va_start(args, format); + + fprintf(stderr, "ERROR %s: ", fName); + vfprintf(stderr, format, args); + fputc('\n', stderr); + + va_end(args); + + fprintf(stderr, " size %lld\n", fSize); + + for (uint32 i = 0; i < fCount; i++) { + fprintf(stderr, " [%lu] offset %lld, length %lld, disk offset %lld\n", + i, fOffsets[i], fVecs[i].length, fVecs[i].offset); + } + + if (fTestCount > 0) { + fprintf(stderr, "got for offset %lld, length %lld:\n", + fTestOffset, fTestLength); + } + + for (uint32 i = 0; i < fTestCount; i++) { + fprintf(stderr, " [%lu] offset %lld, length %lld\n", + i, fTestVecs[i].offset, fTestVecs[i].length); + } + + fflush(stderr); + + debugger("file map error"); + exit(1); +} + + +void +Map::_Verbose(const char* format, ...) +{ + if (!sVerbose) + return; + + va_list args; + va_start(args, format); + + vprintf(format, args); + putchar('\n'); + + va_end(args); + fflush(stdout); +} + + +int32 +Map::_IndexFor(off_t offset) +{ + for (uint32 i = 0; i < fCount; i++) { + if (offset >= fOffsets[i] && offset < fOffsets[i] + fVecs[i].length) + return i; + } + + return -1; +} + + +// #pragma mark - VFS support functions + + +extern "C" status_t +vfs_get_file_map(struct vnode* vnode, off_t offset, uint32 length, + file_io_vec* vecs, size_t* _vecCount) +{ + Map* map = (Map*)vnode; + return map->GetFileMap(offset, length, vecs, _vecCount); +} + + +extern "C" status_t +vfs_lookup_vnode(dev_t mountID, ino_t vnodeID, struct vnode** _vnode) +{ + *_vnode = (struct vnode*)mountID; + return B_OK; +} + + +// #pragma mark - + + +int +main(int argc, char** argv) +{ + file_map_init(); + sVerbose = true; + + Map map("shrink1", 4096); + map.Add(0, 1024, 4096).Add(1024, 3072, 8192); + map.Test(); + map.SetSize(0).Clear(); + map.Test(); + map.Add(0, 8192, 1000).SetSize(7777); + map.Test(); + + return 0; +} From axeld at mail.berlios.de Thu Jun 4 14:11:38 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Thu, 4 Jun 2009 14:11:38 +0200 Subject: [Haiku-commits] r30958 - haiku/trunk/src/tests/system/kernel/cache Message-ID: <200906041211.n54CBcuG017012@sheep.berlios.de> Author: axeld Date: 2009-06-04 14:11:37 +0200 (Thu, 04 Jun 2009) New Revision: 30958 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30958&view=rev Modified: haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp Log: * Fixed Map::GetFileMap(), added some more tests. Modified: haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp 2009-06-04 10:50:09 UTC (rev 30957) +++ haiku/trunk/src/tests/system/kernel/cache/file_map_test.cpp 2009-06-04 12:11:37 UTC (rev 30958) @@ -194,7 +194,7 @@ if (count >= *_vecCount) return B_BUFFER_OVERFLOW; if ((uint32)index >= fCount) - return B_OK; + break; off_t diff = offset - fOffsets[index]; vecs[count].offset = fVecs[index].offset + diff; @@ -208,6 +208,7 @@ count++; } + *_vecCount = count; return B_OK; } @@ -314,5 +315,22 @@ map.Add(0, 8192, 1000).SetSize(7777); map.Test(); + map.SetTo("shrink2", 8888); + map.Add(0, 10000, 3330000); + map.Test(); + map.SetSize(0); + map.SetSize(4444); + map.Clear(); + map.Add(0, 5000, 2220000); + map.Test(); + + map.SetTo("shrink3", 256000); + map.Add(0, 98304, 188074464); + map.Add(98304, 38912, 189057024); + map.Add(137216, 118784, 189177856); + map.Test(); + map.SetSize(0); + map.Test(); + return 0; } From axeld at mail.berlios.de Thu Jun 4 14:27:09 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 4 Jun 2009 14:27:09 +0200 Subject: [Haiku-commits] r30959 - haiku/trunk/src/bin/desklink Message-ID: <200906041227.n54CR95Z018414@sheep.berlios.de> Author: axeld Date: 2009-06-04 14:27:09 +0200 (Thu, 04 Jun 2009) New Revision: 30959 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30959&view=rev Modified: haiku/trunk/src/bin/desklink/VolumeControl.cpp Log: * Simplified computation as suggested by Ingo. Modified: haiku/trunk/src/bin/desklink/VolumeControl.cpp =================================================================== --- haiku/trunk/src/bin/desklink/VolumeControl.cpp 2009-06-04 12:11:37 UTC (rev 30958) +++ haiku/trunk/src/bin/desklink/VolumeControl.cpp 2009-06-04 12:27:09 UTC (rev 30959) @@ -301,7 +301,7 @@ int32 min, max; GetLimits(&min, &max); - float position = 1.0f * (max - min - max) / (max - min); + float position = (float)min / (min - max); be_control_look->DrawSliderBar(view, frame, frame, base, leftFillColor, rightFillColor, position, flags, Orientation()); From axeld at mail.berlios.de Thu Jun 4 14:29:16 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 4 Jun 2009 14:29:16 +0200 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache Message-ID: <200906041229.n54CTGFd018590@sheep.berlios.de> Author: axeld Date: 2009-06-04 14:29:15 +0200 (Thu, 04 Jun 2009) New Revision: 30960 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30960&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp Log: * Fixed a bug that let _InvalidateAfter() access already freed memory, and would also mess up the file map, causing all sorts of file corruption. * This fixes bug #3991 (and eventually some others). Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_map.cpp 2009-06-04 12:27:09 UTC (rev 30959) +++ haiku/trunk/src/system/kernel/cache/file_map.cpp 2009-06-04 12:29:15 UTC (rev 30960) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2004-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -280,13 +280,15 @@ uint32 index; file_extent* extent = _FindExtent(offset, &index); if (extent != NULL) { - _MakeSpace(index + 1); + uint32 resizeTo = index + 1; if (extent->offset + extent->disk.length > offset) { extent->disk.length = offset - extent->offset; if (extent->disk.length == 0) - _MakeSpace(index); + resizeTo = index; } + + _MakeSpace(resizeTo); } } From anevilyak at gmail.com Thu Jun 4 16:55:03 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 4 Jun 2009 09:55:03 -0500 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <200906041229.n54CTGFd018590@sheep.berlios.de> References: <200906041229.n54CTGFd018590@sheep.berlios.de> Message-ID: On Thu, Jun 4, 2009 at 7:29 AM, axeld at BerliOS wrote: > Author: axeld > Date: 2009-06-04 14:29:15 +0200 (Thu, 04 Jun 2009) > New Revision: 30960 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30960&view=rev > > Modified: > ? haiku/trunk/src/system/kernel/cache/file_map.cpp > Log: > * Fixed a bug that let _InvalidateAfter() access already freed memory, and would > ?also mess up the file map, causing all sorts of file corruption. > * This fixes bug #3991 (and eventually some others). > Nice catch! I'm assuming this one would only have corrupted the contents of the files themselves, but not things like the BFS B+ trees? Regards, Rene From axeld at pinc-software.de Thu Jun 4 20:03:27 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 04 Jun 2009 20:03:27 +0200 CEST Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: Message-ID: <39244399752-BeMail@zon> Rene Gollent wrote: > On Thu, Jun 4, 2009 at 7:29 AM, axeld at BerliOS < > axeld at mail.berlios.de> wrote: > > Modified: > > ? haiku/trunk/src/system/kernel/cache/file_map.cpp > > Log: > > * Fixed a bug that let _InvalidateAfter() access already freed > > memory, and would > > ?also mess up the file map, causing all sorts of file corruption. > > * This fixes bug #3991 (and eventually some others). > Nice catch! I'm assuming this one would only have corrupted the > contents of the files themselves, but not things like the BFS B+ > trees? It could overwrite all data, including B+trees and inodes - everything that used to be part of the file. But only in the case that a file was truncated, and then reallocated at a different position (ie. if the file had been moved, or something else managed to claim the space that was freed on truncation). I don't think this will solve all symptoms, but at least it might fix some of them -- the reported failures on SVN conflicts are a good candidate for this, for example. Bye, Axel. From axeld at pinc-software.de Thu Jun 4 22:48:54 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 04 Jun 2009 22:48:54 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30946_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/graphics/nvidia_src/add-ons/accelerants/nvidia/engine?= In-Reply-To: Message-ID: <49171207270-BeMail@zon> Hi Rudolf, Rudolf Cornelissen wrote: > actually I am using it. Just not where I want something else than > this code > provides, like dumping stuff in my own logfile instead of syslog. > Were you > thinking of something specific? Yes, you are not using the I2C code there is, and you seem to have copied the EDID dumping code for some reason. I guess this could explained with the logfile stuff? I think the syslog is just fine for most purposes. Bye, Axel. From axeld at mail.berlios.de Thu Jun 4 23:06:07 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 4 Jun 2009 23:06:07 +0200 Subject: [Haiku-commits] r30961 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200906042106.n54L672q020269@sheep.berlios.de> Author: axeld Date: 2009-06-04 23:06:06 +0200 (Thu, 04 Jun 2009) New Revision: 30961 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30961&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp Log: * Only call Removed() on the device if the device actually got removed, not if only one of its partitions went away. This should fix #3983. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2009-06-04 12:29:15 UTC (rev 30960) +++ haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2009-06-04 21:06:06 UTC (rev 30961) @@ -252,15 +252,14 @@ hash_remove(fs->vnode_hash, vnode); if (S_ISCHR(vnode->stream.type)) { - // pass the call through to the underlying device - vnode->stream.u.dev.device->Removed(); - - // for partitions, we have to release the raw device but must - // not free the device info as it was inherited from the raw - // device and is still in use there - if (vnode->stream.u.dev.partition) { - put_vnode(fs->volume, - vnode->stream.u.dev.partition->raw_device->id); + if (vnode->stream.u.dev.partition == NULL) { + // pass the call through to the underlying device + vnode->stream.u.dev.device->Removed(); + } else { + // for partitions, we have to release the raw device but must + // not free the device info as it was inherited from the raw + // device and is still in use there + put_vnode(fs->volume, vnode->stream.u.dev.partition->raw_device->id); } } @@ -385,7 +384,7 @@ return B_BAD_VALUE; // we don't support nested partitions - if (device->stream.u.dev.partition) + if (device->stream.u.dev.partition != NULL) return B_BAD_VALUE; // reduce checks to a minimum - things like negative offsets could be useful @@ -1225,11 +1224,11 @@ if (pos < 0) return B_BAD_VALUE; - if (vnode->stream.u.dev.partition) { + if (vnode->stream.u.dev.partition != NULL) { if (pos >= vnode->stream.u.dev.partition->info.size) return B_BAD_VALUE; - translate_partition_access(vnode->stream.u.dev.partition, pos, - *_length); + + translate_partition_access(vnode->stream.u.dev.partition, pos, *_length); } if (*_length == 0) @@ -1257,11 +1256,11 @@ if (pos < 0) return B_BAD_VALUE; - if (vnode->stream.u.dev.partition) { + if (vnode->stream.u.dev.partition != NULL) { if (pos >= vnode->stream.u.dev.partition->info.size) return B_BAD_VALUE; - translate_partition_access(vnode->stream.u.dev.partition, pos, - *_length); + + translate_partition_access(vnode->stream.u.dev.partition, pos, *_length); } if (*_length == 0) @@ -1458,7 +1457,7 @@ switch (op) { case B_GET_GEOMETRY: { - struct devfs_partition *partition + struct devfs_partition* partition = vnode->stream.u.dev.partition; if (partition == NULL) break; @@ -1498,7 +1497,7 @@ case B_GET_PARTITION_INFO: { - struct devfs_partition *partition + struct devfs_partition* partition = vnode->stream.u.dev.partition; if (!S_ISCHR(vnode->stream.type) || partition == NULL @@ -1638,9 +1637,10 @@ if (pos < 0) return B_BAD_VALUE; - if (vnode->stream.u.dev.partition) { + if (vnode->stream.u.dev.partition != NULL) { if (pos >= vnode->stream.u.dev.partition->info.size) return B_BAD_VALUE; + translate_partition_access(vnode->stream.u.dev.partition, pos, *_numBytes); } @@ -1696,9 +1696,10 @@ if (pos < 0) return B_BAD_VALUE; - if (vnode->stream.u.dev.partition) { + if (vnode->stream.u.dev.partition != NULL) { if (pos >= vnode->stream.u.dev.partition->info.size) return B_BAD_VALUE; + translate_partition_access(vnode->stream.u.dev.partition, pos, *_numBytes); } @@ -1755,7 +1756,7 @@ return B_NOT_ALLOWED; } - if (vnode->stream.u.dev.partition) { + if (vnode->stream.u.dev.partition != NULL) { if (request->Offset() + request->Length() >= vnode->stream.u.dev.partition->info.size) { return B_BAD_VALUE; From anevilyak at mail.berlios.de Fri Jun 5 04:50:32 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Fri, 5 Jun 2009 04:50:32 +0200 Subject: [Haiku-commits] r30962 - in haiku/trunk: build/jam src/add-ons/accelerants src/add-ons/accelerants/ati src/add-ons/kernel/drivers/graphics src/add-ons/kernel/drivers/graphics/ati Message-ID: <200906050250.n552oWOq031486@sheep.berlios.de> Author: anevilyak Date: 2009-06-05 04:50:25 +0200 (Fri, 05 Jun 2009) New Revision: 30962 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30962&view=rev Added: haiku/trunk/src/add-ons/accelerants/ati/ haiku/trunk/src/add-ons/accelerants/ati/Jamfile haiku/trunk/src/add-ons/accelerants/ati/accelerant.cpp haiku/trunk/src/add-ons/accelerants/ati/accelerant.h haiku/trunk/src/add-ons/accelerants/ati/cursor.cpp haiku/trunk/src/add-ons/accelerants/ati/engine.cpp haiku/trunk/src/add-ons/accelerants/ati/hooks.cpp haiku/trunk/src/add-ons/accelerants/ati/mach64.h haiku/trunk/src/add-ons/accelerants/ati/mach64_cursor.cpp haiku/trunk/src/add-ons/accelerants/ati/mach64_dpms.cpp haiku/trunk/src/add-ons/accelerants/ati/mach64_draw.cpp haiku/trunk/src/add-ons/accelerants/ati/mach64_init.cpp haiku/trunk/src/add-ons/accelerants/ati/mach64_mode.cpp haiku/trunk/src/add-ons/accelerants/ati/mach64_util.cpp haiku/trunk/src/add-ons/accelerants/ati/mode.cpp haiku/trunk/src/add-ons/accelerants/ati/rage128.h haiku/trunk/src/add-ons/accelerants/ati/rage128_cursor.cpp haiku/trunk/src/add-ons/accelerants/ati/rage128_dpms.cpp haiku/trunk/src/add-ons/accelerants/ati/rage128_draw.cpp haiku/trunk/src/add-ons/accelerants/ati/rage128_init.cpp haiku/trunk/src/add-ons/accelerants/ati/rage128_mode.cpp haiku/trunk/src/add-ons/kernel/drivers/graphics/ati/ haiku/trunk/src/add-ons/kernel/drivers/graphics/ati/Jamfile haiku/trunk/src/add-ons/kernel/drivers/graphics/ati/driver.cpp Removed: haiku/trunk/src/add-ons/accelerants/atimach64/ haiku/trunk/src/add-ons/kernel/drivers/graphics/atimach64/ Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/add-ons/accelerants/Jamfile haiku/trunk/src/add-ons/kernel/drivers/graphics/Jamfile Log: Imported Gerald Zajac's ATI Mach64 / Rage driver and removed the old GPL-only mach64 driver that wasn't even part of the image anyways. Thanks! Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/build/jam/HaikuImage 2009-06-05 02:50:25 UTC (rev 30962) @@ -100,6 +100,7 @@ $(X86_ONLY)nvidia.accelerant $(X86_ONLY)matrox.accelerant $(X86_ONLY)neomagic.accelerant $(X86_ONLY)intel_extreme.accelerant $(X86_ONLY)s3.accelerant $(X86_ONLY)vesa.accelerant + $(X86_ONLY)ati.accelerant #$(X86_ONLY)via.accelerant #$(X86_ONLY)vmware.accelerant ; @@ -142,6 +143,7 @@ SYSTEM_ADD_ONS_DRIVERS_GRAPHICS = $(X86_ONLY)radeon $(X86_ONLY)nvidia $(X86_ONLY)neomagic $(X86_ONLY)matrox $(X86_ONLY)intel_extreme $(X86_ONLY)s3 $(X86_ONLY)vesa #$(X86_ONLY)via #$(X86_ONLY)vmware + $(X86_ONLY)ati ; SYSTEM_ADD_ONS_DRIVERS_MIDI = emuxki ; SYSTEM_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com $(X86_ONLY)broadcom440x Modified: haiku/trunk/src/add-ons/accelerants/Jamfile =================================================================== --- haiku/trunk/src/add-ons/accelerants/Jamfile 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/Jamfile 2009-06-05 02:50:25 UTC (rev 30962) @@ -1,5 +1,6 @@ SubDir HAIKU_TOP src add-ons accelerants ; +SubInclude HAIKU_TOP src add-ons accelerants ati ; SubInclude HAIKU_TOP src add-ons accelerants common ; SubInclude HAIKU_TOP src add-ons accelerants et6x00 ; SubInclude HAIKU_TOP src add-ons accelerants intel_extreme ; @@ -13,5 +14,3 @@ SubInclude HAIKU_TOP src add-ons accelerants vesa ; SubInclude HAIKU_TOP src add-ons accelerants via ; SubInclude HAIKU_TOP src add-ons accelerants vmware ; - -SubIncludeGPL HAIKU_TOP src add-ons accelerants atimach64 ; Added: haiku/trunk/src/add-ons/accelerants/ati/Jamfile =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/Jamfile 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/Jamfile 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,28 @@ +SubDir HAIKU_TOP src add-ons accelerants ati ; + +UsePrivateHeaders graphics ; +UsePrivateHeaders [ FDirName graphics ati ] ; +UsePrivateHeaders [ FDirName graphics common ] ; + +Addon ati.accelerant : + accelerant.cpp + cursor.cpp + engine.cpp + hooks.cpp + mode.cpp + + mach64_cursor.cpp + mach64_dpms.cpp + mach64_draw.cpp + mach64_init.cpp + mach64_mode.cpp + mach64_util.cpp + + rage128_cursor.cpp + rage128_dpms.cpp + rage128_draw.cpp + rage128_init.cpp + rage128_mode.cpp + + : be libaccelerantscommon.a +; Added: haiku/trunk/src/add-ons/accelerants/ati/accelerant.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/accelerant.cpp 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/accelerant.cpp 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,222 @@ +/* + Copyright 2007-2009 Haiku, Inc. All rights reserved. + Distributed under the terms of the MIT license. + + Authors: + Gerald Zajac 2007-2009 +*/ + +#include "accelerant.h" + +#include +#include +#include + + + +AccelerantInfo gInfo; // global data used by various source files of accelerant. + + + +static status_t +InitCommon(int fileDesc) +{ + // Initialization function used by primary and cloned accelerants. + + gInfo.deviceFileDesc = fileDesc; + + // Get area ID of shared data from driver. + + area_id sharedArea; + status_t result = ioctl(gInfo.deviceFileDesc, ATI_GET_SHARED_DATA, + &sharedArea, sizeof(sharedArea)); + if (result != B_OK) + return result; + + gInfo.sharedInfoArea = clone_area("ATI shared info", (void**)&(gInfo.sharedInfo), + B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, sharedArea); + if (gInfo.sharedInfoArea < 0) + return gInfo.sharedInfoArea; // sharedInfoArea has error code + + gInfo.regsArea = clone_area("ATI regs area", (void**)&(gInfo.regs), + B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, gInfo.sharedInfo->regsArea); + if (gInfo.regsArea < 0) { + delete_area(gInfo.sharedInfoArea); + return gInfo.regsArea; // regsArea has error code + } + + // Set pointers to various device specific functions. + + if (RAGE128_FAMILY(gInfo.sharedInfo->chipType)) + Rage128_SetFunctionPointers(); + else if (MACH64_FAMILY(gInfo.sharedInfo->chipType)) + Mach64_SetFunctionPointers(); + else + return B_ERROR; // undefined chip type code + + return B_OK; +} + + +static void +UninitCommon(void) +{ + // This function is used by both primary and cloned accelerants. + + delete_area(gInfo.regsArea); + gInfo.regs = 0; + + delete_area(gInfo.sharedInfoArea); + gInfo.sharedInfo = 0; +} + + +status_t +InitAccelerant(int fileDesc) +{ + // Initialize the accelerant. fileDesc is the file handle of the device + // (in /dev/graphics) that has been opened by the app_server. + + TRACE("Enter InitAccelerant()\n"); + + gInfo.bAccelerantIsClone = false; // indicate this is primary accelerant + + status_t result = InitCommon(fileDesc); + if (result == B_OK) { + SharedInfo& si = *gInfo.sharedInfo; + + TRACE("Vendor ID: 0x%X, Device ID: 0x%X\n", si.vendorID, si.deviceID); + + // Ensure that InitAccelerant is executed just once (copies should be clones) + + if (si.bAccelerantInUse) { + result = B_NOT_ALLOWED; + } else { + result = gInfo.ChipInit(); // perform init related to current chip + if (result == B_OK) { + result = si.engineLock.Init("ATI engine lock"); + if (result == B_OK) { + if (gInfo.ShowCursor != NULL) + gInfo.ShowCursor(false); + + // ensure that this function won't be executed again + // (copies should be clones) + si.bAccelerantInUse = true; + } + } + } + + if (result != B_OK) + UninitCommon(); + } + + TRACE("Leave InitAccelerant(), result: 0x%X\n", result); + return result; +} + + +ssize_t +AccelerantCloneInfoSize(void) +{ + // Return the number of bytes required to hold the information required + // to clone the device. The information is merely the name of the device; + // thus, return the size of the name buffer. + + return B_OS_NAME_LENGTH; +} + + +void +GetAccelerantCloneInfo(void* data) +{ + // Return the info required to clone the device. Argument data points to + // a buffer which is the size returned by AccelerantCloneInfoSize(). + + ioctl(gInfo.deviceFileDesc, ATI_DEVICE_NAME, data, B_OS_NAME_LENGTH); +} + + +status_t +CloneAccelerant(void* data) +{ + // Initialize a copy of the accelerant as a clone. Argument data points to + // a copy of the data which was returned by GetAccelerantCloneInfo(). + + TRACE("Enter CloneAccelerant()\n"); + + char path[MAXPATHLEN] = "/dev/"; + strcat(path, (const char*)data); + + gInfo.deviceFileDesc = open(path, B_READ_WRITE); // open the device + if (gInfo.deviceFileDesc < 0) + return errno; + + gInfo.bAccelerantIsClone = true; + + status_t result = InitCommon(gInfo.deviceFileDesc); + if (result != B_OK) { + close(gInfo.deviceFileDesc); + return result; + } + + result = gInfo.modeListArea = clone_area("ATI cloned display_modes", + (void**) &gInfo.modeList, B_ANY_ADDRESS, B_READ_AREA, + gInfo.sharedInfo->modeArea); + if (result < 0) { + UninitCommon(); + close(gInfo.deviceFileDesc); + return result; + } + + TRACE("Leave CloneAccelerant()\n"); + return B_OK; +} + + +void +UninitAccelerant(void) +{ + delete_area(gInfo.modeListArea); + gInfo.modeList = NULL; + + UninitCommon(); + + if (gInfo.bAccelerantIsClone) + close(gInfo.deviceFileDesc); +} + + +sem_id +AccelerantRetraceSemaphore(void) +{ + // Return the semaphore id that will be used to signal that a vertical + // retrace occured. + + return B_ERROR; +} + + +status_t +GetAccelerantDeviceInfo(accelerant_device_info* adi) +{ + // Get info about the device. + + SharedInfo& si = *gInfo.sharedInfo; + + adi->version = 1; + strcpy(adi->name, "ATI chipset"); + strcpy(adi->serial_no, "unknown"); + adi->memory = si.maxFrameBufferSize; + adi->dac_speed = 270; + + // If laptop LCD display or flat panel display (ie, DVI interface), set chip + // set name to "VESA" so that Screen Preferences will not show a refresh rate + // since we will be using VESA code to set the video mode. + + if (si.displayType == MT_VGA) + strcpy(adi->chipset, si.chipName); + else + strcpy(adi->chipset, "VESA"); + + return B_OK; +} Added: haiku/trunk/src/add-ons/accelerants/ati/accelerant.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/accelerant.h 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/accelerant.h 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,208 @@ +/* + Copyright 2007-2009 Haiku, Inc. All rights reserved. + Distributed under the terms of the MIT license. + + Authors: + Gerald Zajac 2007-2009 +*/ + +#ifndef _ACCELERANT_H +#define _ACCELERANT_H + +#include "DriverInterface.h" + + + +#undef TRACE + +#ifdef ENABLE_DEBUG_TRACE +extern "C" void _sPrintf(const char* format, ...); +# define TRACE(x...) _sPrintf("ati: " x) +#else +# define TRACE(x...) ; +#endif + + +// Global data used by various source files of the accelerant. + +struct AccelerantInfo { + int deviceFileDesc; // file descriptor of kernel driver + + SharedInfo* sharedInfo; // address of info shared between accelerants & driver + area_id sharedInfoArea; // shared info area ID + + uint8* regs; // base address of MMIO register area + area_id regsArea; // MMIO register area ID + + display_mode* modeList; // list of standard display modes + area_id modeListArea; // mode list area ID + + bool bAccelerantIsClone; // true if this is a cloned accelerant + + // Pointers to various global accelerant functions. + //------------------------------------------------- + + // Pointers to wait handlers. + void (*WaitForFifo)(uint32); + void (*WaitForIdle)(); + + // Pointers to DPMS functions. + uint32 (*DPMSCapabilities)(void); + uint32 (*GetDPMSMode)(void); + status_t (*SetDPMSMode)(uint32 dpms_flags); + + // Pointers to cursor functions. + bool (*LoadCursorImage)(int width, int height, uint8* and_mask, uint8* xor_mask); + void (*SetCursorPosition)(int x, int y); + void (*ShowCursor)(bool bShow); + + // Pointers to 2D acceleration functions. + void (*FillRectangle)(engine_token*, uint32 color, fill_rect_params*, uint32 count); + void (*FillSpan)(engine_token*, uint32 color, uint16* list, uint32 count); + void (*InvertRectangle)(engine_token*, fill_rect_params*, uint32 count); + void (*ScreenToScreenBlit)(engine_token*, blit_params*, uint32 count); + + // Pointers to other functions. + void (*AdjustFrame)(const DisplayModeEx& mode); + status_t (*ChipInit)(void); + bool (*GetColorSpaceParams)(int colorSpace, uint8& bpp, uint32& maxPixelClk); + status_t (*SetDisplayMode)(const DisplayModeEx& mode); + void (*SetIndexedColors)(uint count, uint8 first, uint8* color_data, uint32 flags); +}; + +extern AccelerantInfo gInfo; + + +// Prototypes of the interface functions called by the app_server. Note that +// the functions that are unique to a particular chip family, will be prefixed +// with the name of the family, and the functions that are applicable to all +// chips will have no prefix. +//================================================================ + +#if defined(__cplusplus) +extern "C" { +#endif + +// General +status_t InitAccelerant(int fd); +ssize_t AccelerantCloneInfoSize(void); +void GetAccelerantCloneInfo(void* data); +status_t CloneAccelerant(void* data); +void UninitAccelerant(void); +status_t GetAccelerantDeviceInfo(accelerant_device_info* adi); +sem_id AccelerantRetraceSemaphore(void); + +// Mode Configuration +uint32 AccelerantModeCount(void); +status_t GetModeList(display_mode* dm); +status_t ProposeDisplayMode(display_mode* target, const display_mode* low, const display_mode* high); +status_t SetDisplayMode(display_mode* mode_to_set); +status_t GetDisplayMode(display_mode* current_mode); +status_t GetFrameBufferConfig(frame_buffer_config* a_frame_buffer); +status_t GetPixelClockLimits(display_mode* dm, uint32* low, uint32* high); +status_t MoveDisplay(uint16 h_display_start, uint16 v_display_start); +status_t GetTimingConstraints(display_timing_constraints* dtc); +void Mach64_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); +void Rage128_SetIndexedColors(uint count, uint8 first, uint8* color_data, uint32 flags); +status_t GetPreferredDisplayMode(display_mode* preferredMode); +status_t GetEdidInfo(void* info, size_t size, uint32* _version); + +// DPMS +uint32 Mach64_DPMSCapabilities(void); +uint32 Mach64_GetDPMSMode(void); +status_t Mach64_SetDPMSMode(uint32 dpms_flags); + +uint32 Rage128_DPMSCapabilities(void); +uint32 Rage128_GetDPMSMode(void); +status_t Rage128_SetDPMSMode(uint32 dpms_flags); + +// Cursor +status_t SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, + uint8* andMask, uint8* xorMask); +void MoveCursor(uint16 x, uint16 y); + +// Engine Management +uint32 AccelerantEngineCount(void); +status_t AcquireEngine(uint32 capabilities, uint32 max_wait, sync_token* st, engine_token** et); +status_t ReleaseEngine(engine_token* et, sync_token* st); +void WaitEngineIdle(void); +status_t GetSyncToken(engine_token* et, sync_token* st); +status_t SyncToToken(sync_token* st); + +// 2D acceleration +void Mach64_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); +void Mach64_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); +void Mach64_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); +void Mach64_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); + +void Rage128_FillRectangle(engine_token* et, uint32 color, fill_rect_params* list, uint32 count); +void Rage128_FillSpan(engine_token* et, uint32 color, uint16* list, uint32 count); +void Rage128_InvertRectangle(engine_token* et, fill_rect_params* list, uint32 count); +void Rage128_ScreenToScreenBlit(engine_token* et, blit_params* list, uint32 count); + +#if defined(__cplusplus) +} +#endif + + + +// Prototypes for other functions that are called from source files other than +// where they are defined. +//============================================================================ + +status_t CreateModeList(bool (*checkMode)(const display_mode* mode)); +uint16 GetVesaModeNumber(const display_mode& mode, uint8 bitsPerPixel); +bool IsModeUsable(const display_mode* mode); + +// Mach64 functions. + +void Mach64_EngineReset(void); +void Mach64_EngineInit(const DisplayModeEx& mode); + +bool Mach64_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); +void Mach64_SetCursorPosition(int x, int y); +void Mach64_ShowCursor(bool bShow); + +void Mach64_AdjustFrame(const DisplayModeEx& mode); +status_t Mach64_SetDisplayMode(const DisplayModeEx& mode); +void Mach64_SetFunctionPointers(void); + +int Mach64_Divide(int numerator, int denom, int shift, const int roundingKind); +void Mach64_ReduceRatio(int *numerator, int *denominator); + + +// Rage128 functions. + +void Rage128_EngineFlush(void); +void Rage128_EngineReset(void); +void Rage128_EngineInit(const DisplayModeEx& mode); + +bool Rage128_GetEdidInfo(void); + +bool Rage128_LoadCursorImage(int width, int height, uint8* and_mask, uint8* xor_mask); +void Rage128_SetCursorPosition(int x, int y); +void Rage128_ShowCursor(bool bShow); + +void Rage128_AdjustFrame(const DisplayModeEx& mode); +status_t Rage128_SetDisplayMode(const DisplayModeEx& mode); +void Rage128_SetFunctionPointers(void); + + +// Macros for memory mapped I/O for both Mach64 and Rage128 chips. +//================================================================ + +#define INREG8(addr) *((vuint8*)(gInfo.regs + addr)) +#define INREG16(addr) *((vuint16*)(gInfo.regs + addr)) +#define INREG(addr) *((vuint32*)(gInfo.regs + addr)) + +#define OUTREG8(addr, val) *((vuint8*)(gInfo.regs + addr)) = val +#define OUTREG16(addr, val) *((vuint16*)(gInfo.regs + addr)) = val +#define OUTREG(addr, val) *((vuint32*)(gInfo.regs + addr)) = val + +// Write a value to an 32-bit reg using a mask. The mask selects the +// bits to be modified. +#define OUTREGM(addr, value, mask) \ + (OUTREG(addr, (INREG(addr) & ~mask) | (value & mask))) + + +#endif // _ACCELERANT_H Added: haiku/trunk/src/add-ons/accelerants/ati/cursor.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/cursor.cpp 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/cursor.cpp 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,81 @@ +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. + + Other authors: + Gerald Zajac 2007-2008 +*/ + +#include "accelerant.h" + + +status_t +SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, + uint8* andMask, uint8* xorMask) +{ + // NOTE: Currently, for BeOS, cursor width and height must be equal to 16. + + if ((width != 16) || (height != 16)) { + return B_ERROR; + } else if ((hot_x >= width) || (hot_y >= height)) { + return B_ERROR; + } else { + // Update cursor variables appropriately. + + SharedInfo& si = *gInfo.sharedInfo; + si.cursorHotX = hot_x; + si.cursorHotY = hot_y; + + if ( ! gInfo.LoadCursorImage(width, height, andMask, xorMask)) + return B_ERROR; + } + + return B_OK; +} + + +void +MoveCursor(uint16 xPos, uint16 yPos) +{ + // Move the cursor to the specified position on the desktop. If we're + // using some kind of virtual desktop, adjust the display start position + // accordingly and position the cursor in the proper "virtual" location. + + int x = xPos; // use signed int's since chip specific functions + int y = yPos; // need signed int to determine if cursor off screen + + SharedInfo& si = *gInfo.sharedInfo; + DisplayModeEx& dm = si.displayMode; + + uint16 hds = dm.h_display_start; // current horizontal starting pixel + uint16 vds = dm.v_display_start; // current vertical starting line + + // Clamp cursor to virtual display. + if (x >= dm.virtual_width) + x = dm.virtual_width - 1; + if (y >= dm.virtual_height) + y = dm.virtual_height - 1; + + // Adjust h/v display start to move cursor onto screen. + if (x >= (dm.timing.h_display + hds)) + hds = x - dm.timing.h_display + 1; + else if (x < hds) + hds = x; + + if (y >= (dm.timing.v_display + vds)) + vds = y - dm.timing.v_display + 1; + else if (y < vds) + vds = y; + + // Reposition the desktop on the display if required. + if (hds != dm.h_display_start || vds != dm.v_display_start) + MoveDisplay(hds, vds); + + // Put cursor in correct physical position. + x -= (hds + si.cursorHotX); + y -= (vds + si.cursorHotY); + + // Position the cursor on the display. + gInfo.SetCursorPosition(x, y); +} + Added: haiku/trunk/src/add-ons/accelerants/ati/engine.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/engine.cpp 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/engine.cpp 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,78 @@ +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. + + Other authors: + Gerald Zajac 2007-2008 +*/ + +#include "accelerant.h" + + +static engine_token engineToken = { 1, B_2D_ACCELERATION, NULL }; + + +uint32 +AccelerantEngineCount(void) +{ + return 1; +} + + +status_t +AcquireEngine(uint32 capabilities, uint32 max_wait, + sync_token* st, engine_token** et) +{ + (void)capabilities; // avoid compiler warning for unused arg + (void)max_wait; // avoid compiler warning for unused arg + + if (gInfo.sharedInfo->engineLock.Acquire() != B_OK) + return B_ERROR; + + // Sync if required. + if (st) + SyncToToken(st); + + // Return an engine token. + *et = &engineToken; + return B_OK; +} + + +status_t +ReleaseEngine(engine_token* et, sync_token* st) +{ + // Update the sync token, if any. + if (st) + GetSyncToken(et, st); + + gInfo.sharedInfo->engineLock.Release(); + return B_OK; +} + + +void +WaitEngineIdle(void) +{ + gInfo.WaitForIdle(); // wait until engine is completely idle +} + + +status_t +GetSyncToken(engine_token* et, sync_token* st) +{ + st->engine_id = et->engine_id; + st->counter = 0; + return B_OK; +} + + +status_t +SyncToToken(sync_token* st) +{ + (void)st; // avoid compiler warning for unused arg + + WaitEngineIdle(); + return B_OK; +} + Added: haiku/trunk/src/add-ons/accelerants/ati/hooks.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/hooks.cpp 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/hooks.cpp 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,67 @@ +/* + Copyright 2008 Haiku, Inc. All rights reserved. + Distributed under the terms of the MIT license. + + Authors: + Gerald Zajac 2008 +*/ + +#include "accelerant.h" + + +extern "C" void* +get_accelerant_hook(uint32 feature, void* data) +{ + (void)data; // avoid compiler warning for unused arg + + switch (feature) { + // General + case B_INIT_ACCELERANT: return (void*)InitAccelerant; + case B_UNINIT_ACCELERANT: return (void*)UninitAccelerant; + case B_CLONE_ACCELERANT: return (void*)CloneAccelerant; + case B_ACCELERANT_CLONE_INFO_SIZE: return (void*)AccelerantCloneInfoSize; + case B_GET_ACCELERANT_CLONE_INFO: return (void*)GetAccelerantCloneInfo; + case B_GET_ACCELERANT_DEVICE_INFO: return (void*)GetAccelerantDeviceInfo; + case B_ACCELERANT_RETRACE_SEMAPHORE: return (void*)AccelerantRetraceSemaphore; + + // Mode Configuration + case B_ACCELERANT_MODE_COUNT: return (void*)AccelerantModeCount; + case B_GET_MODE_LIST: return (void*)GetModeList; + case B_PROPOSE_DISPLAY_MODE: return (void*)ProposeDisplayMode; + case B_SET_DISPLAY_MODE: return (void*)SetDisplayMode; + case B_GET_DISPLAY_MODE: return (void*)GetDisplayMode; + case B_GET_PREFERRED_DISPLAY_MODE: return (void*)GetPreferredDisplayMode; + case B_GET_EDID_INFO: return (void*)GetEdidInfo; + case B_GET_FRAME_BUFFER_CONFIG: return (void*)GetFrameBufferConfig; + case B_GET_PIXEL_CLOCK_LIMITS: return (void*)GetPixelClockLimits; + case B_MOVE_DISPLAY: return (void*)MoveDisplay; + case B_SET_INDEXED_COLORS: return (void*)(gInfo.SetIndexedColors); + case B_GET_TIMING_CONSTRAINTS: return (void*)GetTimingConstraints; + + // DPMS + case B_DPMS_CAPABILITIES: return (void*)(gInfo.DPMSCapabilities); + case B_DPMS_MODE: return (void*)(gInfo.GetDPMSMode); + case B_SET_DPMS_MODE: return (void*)(gInfo.SetDPMSMode); + + // Cursor + case B_SET_CURSOR_SHAPE: return (void*)SetCursorShape; + case B_MOVE_CURSOR: return (void*)MoveCursor; + case B_SHOW_CURSOR: return (void*)(gInfo.ShowCursor); + + // Engine Management + case B_ACCELERANT_ENGINE_COUNT: return (void*)AccelerantEngineCount; + case B_ACQUIRE_ENGINE: return (void*)AcquireEngine; + case B_RELEASE_ENGINE: return (void*)ReleaseEngine; + case B_WAIT_ENGINE_IDLE: return (void*)WaitEngineIdle; + case B_GET_SYNC_TOKEN: return (void*)GetSyncToken; + case B_SYNC_TO_TOKEN: return (void*)SyncToToken; + + // 2D acceleration + case B_SCREEN_TO_SCREEN_BLIT: return (void*)(gInfo.ScreenToScreenBlit); + case B_FILL_RECTANGLE: return (void*)(gInfo.FillRectangle); + case B_INVERT_RECTANGLE: return (void*)(gInfo.InvertRectangle); + case B_FILL_SPAN: return (void*)(gInfo.FillSpan); + } + + return NULL; // Return null pointer for any feature not handled above +} Added: haiku/trunk/src/add-ons/accelerants/ati/mach64.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/mach64.h 2009-06-04 21:06:06 UTC (rev 30961) +++ haiku/trunk/src/add-ons/accelerants/ati/mach64.h 2009-06-05 02:50:25 UTC (rev 30962) @@ -0,0 +1,476 @@ +/* + Haiku ATI video driver adapted from the X.org ATI driver. + + Copyright 1992,1993,1994,1995,1996,1997 by Kevin E. Martin, Chapel Hill, North Carolina. + + Copyright 2009 Haiku, Inc. All rights reserved. + Distributed under the terms of the MIT license. + + Authors: + Gerald Zajac 2009 +*/ + +#ifndef __MACH64_H__ +#define __MACH64_H__ + + +#define CURSOR_BYTES 1024 // bytes used for cursor image in video memory + +// Memory types for Mach64 chips. + +enum Mach64_MemoryType +{ + MEM_NONE, + MEM_DRAM, + MEM_EDO, + MEM_PSEUDO_EDO, + MEM_SDRAM, + MEM_SGRAM, + MEM_SGRAM32, + MEM_TYPE_7 +}; + + +// Macros to get/set a contiguous bit field. Arguments should not be +// self-modifying. + +#define UnitOf(___Value) (((((___Value) ^ ((___Value) - 1)) + 1) >> 1) \ + | ((((___Value) ^ ((___Value) - 1)) >> 1) + 1)) + +#define GetBits(__Value, _Mask) (((__Value) & (_Mask)) / UnitOf(_Mask)) +#define SetBits(__Value, _Mask) (((__Value) * UnitOf(_Mask)) & (_Mask)) + + +// Register MMIO addresses - expressed in BYTE offsets. +//----------------------------------------------------- + +#define CRTC_H_TOTAL_DISP (0x0c00 + 0x0000) // Dword offset 00 +#define CRTC_H_SYNC_STRT_WID (0x0c00 + 0x0004) // Dword offset 01 +#define CRTC_V_TOTAL_DISP (0x0c00 + 0x0008) // Dword offset 02 +#define CRTC_V_SYNC_STRT_WID (0x0c00 + 0x000C) // Dword offset 03 +#define CRTC_VLINE_CRNT_VLINE (0x0c00 + 0x0010) // Dword offset 04 +#define CRTC_OFF_PITCH (0x0c00 + 0x0014) // Dword offset 05 +#define CRTC_INT_CNTL (0x0c00 + 0x0018) // Dword offset 06 +#define CRTC_GEN_CNTL (0x0c00 + 0x001C) // Dword offset 07 + +#define DSP_CONFIG (0x0c00 + 0x0020) // Dword offset 08 +#define DSP_ON_OFF (0x0c00 + 0x0024) // Dword offset 09 + +#define SHARED_CNTL (0x0c00 + 0x0038) // Dword offset 0E + +#define OVR_CLR (0x0c00 + 0x0040) // Dword offset 10 +#define OVR_WID_LEFT_RIGHT (0x0c00 + 0x0044) // Dword offset 11 +#define OVR_WID_TOP_BOTTOM (0x0c00 + 0x0048) // Dword offset 12 + +#define CUR_CLR0 (0x0c00 + 0x0060) // Dword offset 18 +#define CUR_CLR1 (0x0c00 + 0x0064) // Dword offset 19 +#define CUR_OFFSET (0x0c00 + 0x0068) // Dword offset 1A +#define CUR_HORZ_VERT_POSN (0x0c00 + 0x006C) // Dword offset 1B +#define CUR_HORZ_VERT_OFF (0x0c00 + 0x0070) // Dword offset 1C + +#define HW_DEBUG (0x0c00 + 0x007C) // Dword offset 1F + +#define SCRATCH_REG0 (0x0c00 + 0x0080) // Dword offset 20 +#define SCRATCH_REG1 (0x0c00 + 0x0084) // Dword offset 21 + +#define CLOCK_CNTL (0x0c00 + 0x0090) // Dword offset 24 + +#define BUS_CNTL (0x0c00 + 0x00A0) // Dword offset 28 + +#define LCD_INDEX (0x0c00 + 0x00A4) // Dword offset 29 +#define LCD_DATA (0x0c00 + 0x00A8) // Dword offset 2A + +#define MEM_CNTL (0x0c00 + 0x00B0) // Dword offset 2C + +#define MEM_VGA_WP_SEL (0x0c00 + 0x00B4) // Dword offset 2D +#define MEM_VGA_RP_SEL (0x0c00 + 0x00B8) // Dword offset 2E + +#define DAC_REGS (0x0c00 + 0x00C0) // Dword offset 30 +#define DAC_W_INDEX (DAC_REGS + 0) +#define DAC_DATA (DAC_REGS + 1) +#define DAC_MASK (DAC_REGS + 2) +#define DAC_R_INDEX (DAC_REGS + 3) +#define DAC_CNTL (0x0c00 + 0x00C4) // Dword offset 31 + +#define GEN_TEST_CNTL (0x0c00 + 0x00D0) // Dword offset 34 + +#define CONFIG_CNTL (0x0c00 + 0x00DC // Dword offset 37 (CT, ET, VT) +#define CONFIG_CHIP_ID (0x0c00 + 0x00E0) // Dword offset 38 +#define CONFIG_STAT0 (0x0c00 + 0x00E4) // Dword offset 39 +#define CONFIG_STAT1 (0x0c00 + 0x00E8) // Dword offset 3A + +#define DST_OFF_PITCH (0x0c00 + 0x0100) // Dword offset 40 +#define DST_X (0x0c00 + 0x0104) // Dword offset 41 +#define DST_Y (0x0c00 + 0x0108) // Dword offset 42 +#define DST_Y_X (0x0c00 + 0x010C) // Dword offset 43 +#define DST_WIDTH (0x0c00 + 0x0110) // Dword offset 44 +#define DST_HEIGHT (0x0c00 + 0x0114) // Dword offset 45 +#define DST_HEIGHT_WIDTH (0x0c00 + 0x0118) // Dword offset 46 +#define DST_X_WIDTH (0x0c00 + 0x011C) // Dword offset 47 +#define DST_BRES_LNTH (0x0c00 + 0x0120) // Dword offset 48 +#define DST_BRES_ERR (0x0c00 + 0x0124) // Dword offset 49 +#define DST_BRES_INC (0x0c00 + 0x0128) // Dword offset 4A +#define DST_BRES_DEC (0x0c00 + 0x012C) // Dword offset 4B +#define DST_CNTL (0x0c00 + 0x0130) // Dword offset 4C + +#define SRC_OFF_PITCH (0x0c00 + 0x0180) // Dword offset 60 +#define SRC_X (0x0c00 + 0x0184) // Dword offset 61 +#define SRC_Y (0x0c00 + 0x0188) // Dword offset 62 +#define SRC_Y_X (0x0c00 + 0x018C) // Dword offset 63 +#define SRC_WIDTH1 (0x0c00 + 0x0190) // Dword offset 64 +#define SRC_HEIGHT1 (0x0c00 + 0x0194) // Dword offset 65 +#define SRC_HEIGHT1_WIDTH1 (0x0c00 + 0x0198) // Dword offset 66 +#define SRC_X_START (0x0c00 + 0x019C) // Dword offset 67 +#define SRC_Y_START (0x0c00 + 0x01A0) // Dword offset 68 +#define SRC_Y_X_START (0x0c00 + 0x01A4) // Dword offset 69 +#define SRC_WIDTH2 (0x0c00 + 0x01A8) // Dword offset 6A +#define SRC_HEIGHT2 (0x0c00 + 0x01AC) // Dword offset 6B +#define SRC_HEIGHT2_WIDTH2 (0x0c00 + 0x01B0) // Dword offset 6C +#define SRC_CNTL (0x0c00 + 0x01B4) // Dword offset 6D + +#define HOST_DATA0 (0x0c00 + 0x0200) // Dword offset 80 +#define HOST_DATA1 (0x0c00 + 0x0204) // Dword offset 81 +#define HOST_DATA2 (0x0c00 + 0x0208) // Dword offset 82 +#define HOST_DATA3 (0x0c00 + 0x020C) // Dword offset 83 +#define HOST_DATA4 (0x0c00 + 0x0210) // Dword offset 84 +#define HOST_DATA5 (0x0c00 + 0x0214) // Dword offset 85 +#define HOST_DATA6 (0x0c00 + 0x0218) // Dword offset 86 +#define HOST_DATA7 (0x0c00 + 0x021C) // Dword offset 87 +#define HOST_DATA8 (0x0c00 + 0x0220) // Dword offset 88 +#define HOST_DATA9 (0x0c00 + 0x0224) // Dword offset 89 +#define HOST_DATAA (0x0c00 + 0x0228) // Dword offset 8A +#define HOST_DATAB (0x0c00 + 0x022C) // Dword offset 8B +#define HOST_DATAC (0x0c00 + 0x0230) // Dword offset 8C +#define HOST_DATAD (0x0c00 + 0x0234) // Dword offset 8D +#define HOST_DATAE (0x0c00 + 0x0238) // Dword offset 8E +#define HOST_DATAF (0x0c00 + 0x023C) // Dword offset 8F +#define HOST_CNTL (0x0c00 + 0x0240) // Dword offset 90 + +#define PAT_REG0 (0x0c00 + 0x0280) // Dword offset A0 +#define PAT_REG1 (0x0c00 + 0x0284) // Dword offset A1 +#define PAT_CNTL (0x0c00 + 0x0288) // Dword offset A2 + +#define SC_LEFT (0x0c00 + 0x02A0) // Dword offset A8 +#define SC_RIGHT (0x0c00 + 0x02A4) // Dword offset A9 +#define SC_LEFT_RIGHT (0x0c00 + 0x02A8) // Dword offset AA +#define SC_TOP (0x0c00 + 0x02AC) // Dword offset AB +#define SC_BOTTOM (0x0c00 + 0x02B0) // Dword offset AC +#define SC_TOP_BOTTOM (0x0c00 + 0x02B4) // Dword offset AD + +#define DP_BKGD_CLR (0x0c00 + 0x02C0) // Dword offset B0 +#define DP_FRGD_CLR (0x0c00 + 0x02C4) // Dword offset B1 +#define DP_WRITE_MASK (0x0c00 + 0x02C8) // Dword offset B2 +#define DP_CHAIN_MASK (0x0c00 + 0x02CC) // Dword offset B3 +#define DP_PIX_WIDTH (0x0c00 + 0x02D0) // Dword offset B4 +#define DP_MIX (0x0c00 + 0x02D4) // Dword offset B5 +#define DP_SRC (0x0c00 + 0x02D8) // Dword offset B6 + +#define CLR_CMP_CLR (0x0c00 + 0x0300) // Dword offset C0 +#define CLR_CMP_MASK (0x0c00 + 0x0304) // Dword offset C1 +#define CLR_CMP_CNTL (0x0c00 + 0x0308) // Dword offset C2 + +#define FIFO_STAT (0x0c00 + 0x0310) // Dword offset C4 + +#define CONTEXT_MASK (0x0c00 + 0x0320) // Dword offset C8 +#define CONTEXT_LOAD_CNTL (0x0c00 + 0x032C) // Dword offset CB + +#define GUI_TRAJ_CNTL (0x0c00 + 0x0330) // Dword offset CC +#define GUI_STAT (0x0c00 + 0x0338) // Dword offset CE + + +// CRTC control values. + +#define CRTC_H_SYNC_NEG 0x00200000 +#define CRTC_V_SYNC_NEG 0x00200000 + +#define CRTC_DBL_SCAN_EN 0x00000001 +#define CRTC_INTERLACE_EN 0x00000002 +#define CRTC_HSYNC_DIS 0x00000004 +#define CRTC_VSYNC_DIS 0x00000008 +#define CRTC_CSYNC_EN 0x00000010 +#define CRTC_PIX_BY_2_EN 0x00000020 +#define CRTC_DISPLAY_DIS 0x00000040 +#define CRTC_VGA_XOVERSCAN 0x00000080 + +#define CRTC_PIX_WIDTH 0x00000700 +#define CRTC_PIX_WIDTH_4BPP 0x00000100 +#define CRTC_PIX_WIDTH_8BPP 0x00000200 +#define CRTC_PIX_WIDTH_15BPP 0x00000300 +#define CRTC_PIX_WIDTH_16BPP 0x00000400 +#define CRTC_PIX_WIDTH_24BPP 0x00000500 +#define CRTC_PIX_WIDTH_32BPP 0x00000600 + +#define CRTC_BYTE_PIX_ORDER 0x00000800 +#define CRTC_PIX_ORDER_MSN_LSN 0x00000000 +#define CRTC_PIX_ORDER_LSN_MSN 0x00000800 + +#define CRTC_FIFO_LWM 0x000f0000 +#define CRTC2_PIX_WIDTH 0x000e0000 +#define CRTC_VGA_128KAP_PAGING 0x00100000 +#define CRTC_VFC_SYNC_TRISTATE 0x00200000 +#define CRTC2_EN 0x00200000 +#define CRTC_LOCK_REGS 0x00400000 +#define CRTC_SYNC_TRISTATE 0x00800000 +#define CRTC_EXT_DISP_EN 0x01000000 +#define CRTC_EN 0x02000000 +#define CRTC_DISP_REQ_EN 0x04000000 +#define CRTC_VGA_LINEAR 0x08000000 +#define CRTC_VGA_TEXT_132 0x20000000 +#define CRTC_CNT_EN 0x40000000 +#define CRTC_CUR_B_TEST 0x80000000 + +#define CRTC_CRNT_VLINE 0x07f00000 +#define CRTC_VBLANK 0x00000001 + +#define CRTC_PITCH 0xffc00000 + +// DAC control values. + +#define DAC_8BIT_EN 0x00000100 + +// Mix control values. + +#define MIX_NOT_DST 0x0000 +#define MIX_0 0x0001 +#define MIX_1 0x0002 +#define MIX_DST 0x0003 [... truncated: 4631 lines follow ...] From umccullough at gmail.com Fri Jun 5 05:36:38 2009 From: umccullough at gmail.com (Urias McCullough) Date: Thu, 4 Jun 2009 20:36:38 -0700 Subject: [Haiku-commits] r30962 - in haiku/trunk: build/jam src/add-ons/accelerants src/add-ons/accelerants/ati src/add-ons/kernel/drivers/graphics src/add-ons/kernel/drivers/graphics/ati In-Reply-To: <200906050250.n552oWOq031486@sheep.berlios.de> References: <200906050250.n552oWOq031486@sheep.berlios.de> Message-ID: <1e80d8750906042036t4c6e89e4x8f6795ff451c490d@mail.gmail.com> On Thu, Jun 4, 2009 at 7:50 PM, anevilyak at BerliOS wrote: > Author: anevilyak > Date: 2009-06-05 04:50:25 +0200 (Fri, 05 Jun 2009) > New Revision: 30962 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30962&view=rev > > Added: > ? haiku/trunk/src/add-ons/accelerants/ati/ > ? haiku/trunk/src/add-ons/accelerants/ati/Jamfile > ? haiku/trunk/src/add-ons/accelerants/ati/accelerant.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/accelerant.h > ? haiku/trunk/src/add-ons/accelerants/ati/cursor.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/engine.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/hooks.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mach64.h > ? haiku/trunk/src/add-ons/accelerants/ati/mach64_cursor.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mach64_dpms.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mach64_draw.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mach64_init.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mach64_mode.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mach64_util.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/mode.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/rage128.h > ? haiku/trunk/src/add-ons/accelerants/ati/rage128_cursor.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/rage128_dpms.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/rage128_draw.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/rage128_init.cpp > ? haiku/trunk/src/add-ons/accelerants/ati/rage128_mode.cpp > ? haiku/trunk/src/add-ons/kernel/drivers/graphics/ati/ > ? haiku/trunk/src/add-ons/kernel/drivers/graphics/ati/Jamfile > ? haiku/trunk/src/add-ons/kernel/drivers/graphics/ati/driver.cpp > Removed: > ? haiku/trunk/src/add-ons/accelerants/atimach64/ > ? haiku/trunk/src/add-ons/kernel/drivers/graphics/atimach64/ > Modified: > ? haiku/trunk/build/jam/HaikuImage > ? haiku/trunk/src/add-ons/accelerants/Jamfile > ? haiku/trunk/src/add-ons/kernel/drivers/graphics/Jamfile > Log: > Imported Gerald Zajac's ATI Mach64 / Rage driver and removed the old GPL-only mach64 driver that wasn't even part of the image anyways. Thanks! You missed the DriverInterface.h header in headers/.... build fails for me without it. From anevilyak at mail.berlios.de Fri Jun 5 05:50:23 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Fri, 5 Jun 2009 05:50:23 +0200 Subject: [Haiku-commits] r30963 - in haiku/trunk/headers/private/graphics: . ati Message-ID: <200906050350.n553oN4Q005236@sheep.berlios.de> Author: anevilyak Date: 2009-06-05 05:50:21 +0200 (Fri, 05 Jun 2009) New Revision: 30963 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30963&view=rev Added: haiku/trunk/headers/private/graphics/ati/ haiku/trunk/headers/private/graphics/ati/DriverInterface.h Log: Added files missed in previous commit. Thanks Urias. Added: haiku/trunk/headers/private/graphics/ati/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/ati/DriverInterface.h 2009-06-05 02:50:25 UTC (rev 30962) +++ haiku/trunk/headers/private/graphics/ati/DriverInterface.h 2009-06-05 03:50:21 UTC (rev 30963) @@ -0,0 +1,234 @@ +/* + Copyright 2007-2009 Haiku, Inc. All rights reserved. + Distributed under the terms of the MIT license. + + Authors: + Gerald Zajac 2007-2009 +*/ + +#ifndef DRIVERINTERFACE_H +#define DRIVERINTERFACE_H + + +#include +#include +#include +#include + + +// This file contains info that is shared between the kernel driver and the +// accelerant, and info that is shared among the source files of the accelerant. + + +#define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog + + +#define ARRAY_SIZE(a) (int(sizeof(a) / sizeof(a[0]))) // get number of elements in an array + +struct Benaphore { + sem_id sem; + int32 count; + + status_t Init(const char* name) + { + count = 0; + sem = create_sem(0, name); + return sem < 0 ? sem : B_OK; + } + + status_t Acquire() + { + if (atomic_add(&count, 1) > 0) + return acquire_sem(sem); + return B_OK; + } + + status_t Release() + { + if (atomic_add(&count, -1) > 1) + return release_sem(sem); + return B_OK; + } + + void Delete() { delete_sem(sem); } +}; + + +enum { + ATI_GET_SHARED_DATA = B_DEVICE_OP_CODES_END + 123, + ATI_DEVICE_NAME, + ATI_GET_EDID, + ATI_RUN_INTERRUPTS, + ATI_SET_VESA_DISPLAY_MODE +}; + + +// Chip type numbers. These are used to group the chips into related +// groups. See table chipTable in driver.c +// Note that the order of the Mach64 chip types must not be changed because +// < or > comparisons of the chip types are made. They should be in the order +// of the evolution of the chips. + +enum ChipType { + ATI_NONE = 0, + + MACH64_264VT, + MACH64_264GT, + MACH64_264VTB, + MACH64_264GTB, + MACH64_264VT3, + MACH64_264GTDVD, + MACH64_264LT, + MACH64_264VT4, + MACH64_264GT2C, + MACH64_264GTPRO, + MACH64_264LTPRO, + MACH64_264XL, + MACH64_MOBILITY, + Mach64_ChipsEnd, // marks end of Mach64's + RAGE128_GL, + RAGE128_MOBILITY, + RAGE128_PRO_GL, + RAGE128_PRO_VR, + RAGE128_PRO_ULTRA, + RAGE128_VR, +}; + + +#define MACH64_FAMILY(chipType) (chipType < Mach64_ChipsEnd) +#define RAGE128_FAMILY(chipType) (chipType > Mach64_ChipsEnd) + + + +enum MonitorType { + MT_VGA, // monitor with analog VGA interface + MT_DVI, // monitor with DVI interface + MT_LAPTOP // laptop video display +}; + + +// Mach64 parameters for computing register vaules and other parameters. + +struct M64_Params { + // Clock parameters + uint8 clockNumberToProgram; // obtained from video BIOS + uint32 maxPixelClock; // obtained from video BIOS + int refFreq; // obtained from video BIOS + int refDivider; // obtained from video BIOS + uint8 xClkPostDivider; + uint8 xClkRefDivider; + uint16 xClkPageFaultDelay; + uint16 xClkMaxRASDelay; + uint16 displayFIFODepth; + uint16 displayLoopLatency; + uint8 vClkPostDivider; + uint8 vClkFeedbackDivider; +}; + + +struct R128_PLLParams { + uint16 reference_freq; + uint16 reference_div; + uint32 min_pll_freq; + uint32 max_pll_freq; + uint16 xclk; +}; + + +struct R128_RAMSpec { // All values in XCLKS + int memReadLatency; // Memory Read Latency + int memBurstLen; // Memory Burst Length + int rasToCasDelay; // RAS to CAS delay + int rasPercentage; // RAS percentage + int writeRecovery; // Write Recovery + int casLatency; // CAS Latency + int readToWriteDelay; // Read to Write Delay + int loopLatency; // Loop Latency + int loopFudgeFactor; // Add to memReadLatency to get loopLatency + char *name; +}; + + +struct VesaMode { + uint16 mode; // VESA mode number + uint16 width; + uint16 height; + uint8 bitsPerPixel; +}; + + +struct DisplayModeEx : display_mode { + uint8 bitsPerPixel; + uint16 bytesPerRow; // number of bytes in one line/row +}; + + +struct SharedInfo { + // Device ID info. + uint16 vendorID; // PCI vendor ID, from pci_info + uint16 deviceID; // PCI device ID, from pci_info + uint8 revision; // PCI device revsion, from pci_info + ChipType chipType; // indicates group in which chip belongs (a group has similar functionality) + char chipName[32]; // user recognizable name of chip + + bool bAccelerantInUse; // true = accelerant has been initialized + bool bInterruptAssigned; // card has a useable interrupt assigned to it + + sem_id vertBlankSem; // vertical blank semaphore; if < 0, there is no semaphore + + // Memory mappings. + area_id regsArea; // area_id for the memory mapped registers. It will + // be cloned into accelerant's address space. + area_id videoMemArea; // video memory area_id. The addresses are shared with all teams. + void* videoMemAddr; // video memory addr as viewed from virtual memory + void* videoMemPCI; // video memory addr as viewed from the PCI bus (for DMA) + uint32 videoMemSize; // video memory size in bytes. + + uint32 cursorOffset; // offset of cursor in video memory + uint32 frameBufferOffset; // offset of frame buffer in video memory + uint32 maxFrameBufferSize; // max available video memory for frame buffer + + // Color spaces supported by current video chip/driver. + color_space colorSpaces[6]; + uint32 colorSpaceCount; // number of color spaces in array colorSpaces + + // List of screen modes. + area_id modeArea; // area containing list of display modes the driver supports + uint32 modeCount; // number of display modes in the list + + DisplayModeEx displayMode; // current display mode configuration + + // List of VESA modes supported by current chip. + uint32 vesaModeTableOffset; // offset of table in shared info + uint32 vesaModeCount; + + uint16 cursorHotX; // Cursor hot spot. Top left corner of the cursor + uint16 cursorHotY; // is 0,0 + + edid1_info edidInfo; + bool bHaveEDID; // true = EDID info from device is in edidInfo + + Benaphore engineLock; // for serializing access to the acceleration engine + + MonitorType displayType; + + uint16 panelX; // laptop LCD width + uint16 panelY; // laptop LCD height + uint16 panelPowerDelay; + + // Data members for Mach64 chips. + //------------------------------- + + M64_Params m64Params; // parameters for Mach64 chips + + // Data members for Rage128 chips. + //-------------------------------- + + R128_RAMSpec r128MemSpec; // Rage128 memory timing spec's + R128_PLLParams r128PLLParams; // Rage128 PLL parameters from video BIOS ROM + + uint32 r128_dpGuiMasterCntl; // flags for accelerated drawing +}; + + +#endif // DRIVERINTERFACE_H From axeld at mail.berlios.de Fri Jun 5 09:37:25 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 5 Jun 2009 09:37:25 +0200 Subject: [Haiku-commits] r30964 - haiku/trunk/src/kits/network/dns/irs Message-ID: <200906050737.n557bP85025081@sheep.berlios.de> Author: axeld Date: 2009-06-05 09:37:24 +0200 (Fri, 05 Jun 2009) New Revision: 30964 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30964&view=rev Modified: haiku/trunk/src/kits/network/dns/irs/lcl_ho.c Log: * Fixed wrong localhost. This fixes bug #3990. * Automatic whitespace cleanup. Modified: haiku/trunk/src/kits/network/dns/irs/lcl_ho.c =================================================================== --- haiku/trunk/src/kits/network/dns/irs/lcl_ho.c 2009-06-05 03:50:21 UTC (rev 30963) +++ haiku/trunk/src/kits/network/dns/irs/lcl_ho.c 2009-06-05 07:37:24 UTC (rev 30964) @@ -6,7 +6,7 @@ /* * Copyright (c) 1985, 1988, 1993 * The Regents of the University of California. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,7 +22,7 @@ * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -226,7 +226,7 @@ struct hostent *hp; char **hap; size_t n; - + if (init(this) == -1) return (NULL); @@ -261,7 +261,7 @@ const u_char *uaddr = addr; struct hostent *hp; int size; - + if (init(this) == -1) return (NULL); @@ -350,7 +350,7 @@ pvt->host.h_addrtype = AF_INET; pvt->host.h_aliases = pvt->host_aliases; pvt->host.h_name = pvt->hostbuf; - ((struct in_addr *)pvt->host_addr)->s_addr = INADDR_LOOPBACK; + ((struct in_addr *)pvt->host_addr)->s_addr = htonl(INADDR_LOOPBACK); pvt->index++; RES_SET_H_ERRNO(pvt->res, NETDB_SUCCESS); @@ -474,7 +474,7 @@ } if (pvt->res) res_nclose(pvt->res); -} +} static struct __res_state * ho_res_get(struct irs_ho *this) { @@ -589,7 +589,7 @@ static int init(struct irs_ho *this) { struct pvt *pvt = (struct pvt *)this->private; - + if (!pvt->res && !ho_res_get(this)) return (-1); if (((pvt->res->options & RES_INIT) == 0U) && From axeld at mail.berlios.de Fri Jun 5 09:47:09 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 5 Jun 2009 09:47:09 +0200 Subject: [Haiku-commits] r30965 - in haiku/trunk: build/jam src/preferences Message-ID: <200906050747.n557l9XZ031545@sheep.berlios.de> Author: axeld Date: 2009-06-05 09:47:08 +0200 (Fri, 05 Jun 2009) New Revision: 30965 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30965&view=rev Removed: haiku/trunk/src/preferences/menu/ Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/preferences/Jamfile Log: * Removed Menu preferences. This closes ticket #3976. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-05 07:37:24 UTC (rev 30964) +++ haiku/trunk/build/jam/HaikuImage 2009-06-05 07:47:08 UTC (rev 30965) @@ -71,7 +71,7 @@ StyledEdit Terminal TextSearch TV Workspaces ; SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations E-mail - FileTypes Fonts Keyboard Keymap Locale Media Menu Mouse Network Printers + FileTypes Fonts Keyboard Keymap Locale Media Mouse Network Printers Screen ScreenSaver Sounds Time Touchpad Tracker VirtualMemory ; SYSTEM_DEMOS = BSnow Chart Clock Cortex FontDemo Modified: haiku/trunk/src/preferences/Jamfile =================================================================== --- haiku/trunk/src/preferences/Jamfile 2009-06-05 07:37:24 UTC (rev 30964) +++ haiku/trunk/src/preferences/Jamfile 2009-06-05 07:47:08 UTC (rev 30965) @@ -15,7 +15,6 @@ SubInclude HAIKU_TOP src preferences locale ; SubInclude HAIKU_TOP src preferences mail ; SubInclude HAIKU_TOP src preferences media ; -SubInclude HAIKU_TOP src preferences menu ; SubInclude HAIKU_TOP src preferences mouse ; SubInclude HAIKU_TOP src preferences network ; SubInclude HAIKU_TOP src preferences print ; From stefano.ceccherini at gmail.com Fri Jun 5 09:49:42 2009 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Fri, 5 Jun 2009 09:49:42 +0200 Subject: [Haiku-commits] r30965 - in haiku/trunk: build/jam src/preferences In-Reply-To: <200906050747.n557l9XZ031545@sheep.berlios.de> References: <200906050747.n557l9XZ031545@sheep.berlios.de> Message-ID: <894b9700906050049p7ca4d1cuca4a691a8e0be80c@mail.gmail.com> 2009/6/5 axeld at BerliOS : > Author: axeld > Date: 2009-06-05 09:47:08 +0200 (Fri, 05 Jun 2009) > New Revision: 30965 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30965&view=rev > > Removed: > ? haiku/trunk/src/preferences/menu/ > Modified: > ? haiku/trunk/build/jam/HaikuImage > ? haiku/trunk/src/preferences/Jamfile > Log: > * Removed Menu preferences. This closes ticket #3976. What about the "Always show triggers" option ? What do we want to do with it ? From axeld at mail.berlios.de Fri Jun 5 10:14:34 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Fri, 5 Jun 2009 10:14:34 +0200 Subject: [Haiku-commits] r30966 - haiku/trunk/src/tests/add-ons/kernel/kernelland_emu Message-ID: <200906050814.n558EY8q010732@sheep.berlios.de> Author: axeld Date: 2009-06-05 10:14:31 +0200 (Fri, 05 Jun 2009) New Revision: 30966 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30966&view=rev Modified: haiku/trunk/src/tests/add-ons/kernel/kernelland_emu/debug.cpp Log: * Added dprintf_no_syslog() to our kernel emulation layer. Modified: haiku/trunk/src/tests/add-ons/kernel/kernelland_emu/debug.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/kernelland_emu/debug.cpp 2009-06-05 07:47:08 UTC (rev 30965) +++ haiku/trunk/src/tests/add-ons/kernel/kernelland_emu/debug.cpp 2009-06-05 08:14:31 UTC (rev 30966) @@ -106,6 +106,22 @@ extern "C" void +dprintf_no_syslog(const char *format,...) +{ + if (!gDebugOutputEnabled) + return; + + va_list args; + va_start(args, format); + printf("\33[34m"); + vprintf(format, args); + printf("\33[0m"); + fflush(stdout); + va_end(args); +} + + +extern "C" void kprintf(const char *format,...) { va_list args; From axeld at mail.berlios.de Fri Jun 5 10:20:49 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Fri, 5 Jun 2009 10:20:49 +0200 Subject: [Haiku-commits] r30967 - haiku/trunk/src/apps/activitymonitor Message-ID: <200906050820.n558Kn4O011718@sheep.berlios.de> Author: axeld Date: 2009-06-05 10:20:43 +0200 (Fri, 05 Jun 2009) New Revision: 30967 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30967&view=rev Modified: haiku/trunk/src/apps/activitymonitor/ActivityView.cpp haiku/trunk/src/apps/activitymonitor/CircularBuffer.h Log: * CircularBuffer is now save to use even if the buffer allocation failed. This fixes bug #3985. * This happened as ViewHistory::Update() can obviously be called before the view is really layouted. Therefore it now restricts the view size to 16384. * Since the Update() happens in Draw(), it looks like this is actually a problem of our layout engine (as the size is computed via BView::Frame()). Modified: haiku/trunk/src/apps/activitymonitor/ActivityView.cpp =================================================================== --- haiku/trunk/src/apps/activitymonitor/ActivityView.cpp 2009-06-05 08:14:31 UTC (rev 30966) +++ haiku/trunk/src/apps/activitymonitor/ActivityView.cpp 2009-06-05 08:20:43 UTC (rev 30967) @@ -225,6 +225,11 @@ ViewHistory::Update(DataHistory* history, int32 width, int32 resolution, bigtime_t toTime, bigtime_t step, bigtime_t refresh) { + if (width > 16384) { + // ignore this - it seems the view hasn't been layouted yet + return; + } + // Check if we need to invalidate the existing values if ((int32)fValues.Size() != width || fResolution != resolution Modified: haiku/trunk/src/apps/activitymonitor/CircularBuffer.h =================================================================== --- haiku/trunk/src/apps/activitymonitor/CircularBuffer.h 2009-06-05 08:14:31 UTC (rev 30966) +++ haiku/trunk/src/apps/activitymonitor/CircularBuffer.h 2009-06-05 08:20:43 UTC (rev 30967) @@ -1,5 +1,5 @@ /* - * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2008-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef CIRCULAR_BUFFER_H @@ -40,7 +40,12 @@ fSize = size; fBuffer = (Type*)malloc(fSize * sizeof(Type)); - return fBuffer != NULL ? B_OK : B_NO_MEMORY; + if (fBuffer == NULL) { + fSize = 0; + return B_NO_MEMORY; + } + + return B_OK; } void MakeEmpty() @@ -61,7 +66,7 @@ Type* ItemAt(int32 index) const { - if (index >= (int32)fIn || index < 0) + if (index >= (int32)fIn || index < 0 || fBuffer == NULL) return NULL; return &fBuffer[(fFirst + index) % fSize]; @@ -75,7 +80,8 @@ else index = fFirst++; - fBuffer[index % fSize] = item; + if (fBuffer != NULL) + fBuffer[index % fSize] = item; } size_t Size() const From stippi at mail.berlios.de Fri Jun 5 10:22:10 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Fri, 5 Jun 2009 10:22:10 +0200 Subject: [Haiku-commits] r30968 - haiku/trunk/src/data/etc/keymaps Message-ID: <200906050822.n558MAGq012040@sheep.berlios.de> Author: stippi Date: 2009-06-05 10:22:09 +0200 (Fri, 05 Jun 2009) New Revision: 30968 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30968&view=rev Modified: haiku/trunk/src/data/etc/keymaps/Colemak.keymap Log: Patch by Geert Hendrickx: * Fixed remapping the Control keys. * Adjusted the caps-lock shifted keys, in case someone decides to exchange the left backspace key for the caps-lock key again. Thanks a lot! Modified: haiku/trunk/src/data/etc/keymaps/Colemak.keymap =================================================================== --- haiku/trunk/src/data/etc/keymaps/Colemak.keymap 2009-06-05 08:20:43 UTC (rev 30967) +++ haiku/trunk/src/data/etc/keymaps/Colemak.keymap 2009-06-05 08:22:09 UTC (rev 30968) @@ -76,19 +76,19 @@ Key 0x0e = 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 Key 0x0f = 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 Key 0x10 = 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0x10 -Key 0x11 = '`' '~' '' '~' '' '`' '~' ' ' '' -Key 0x12 = '1' '!' '' 0xc2a1 0xc2b9 '1' '!' ' ' '' -Key 0x13 = '2' '@' 0x00 0xc2ba 0xc2b2 '2' '@' ' ' '' -Key 0x14 = '3' '#' '' 0xc2aa 0xc2b3 '3' '#' ' ' '' -Key 0x15 = '4' '$' '' 0xc2a2 0xc2a3 '4' '$' ' ' '' -Key 0x16 = '5' '%' '' 0xe282ac 0xc2a5 '5' '%' ' ' '' -Key 0x17 = '6' '^' 0x1e 0xc4a7 0xc4a6 '6' '^' ' ' '' -Key 0x18 = '7' '&' '' 0xc3b0 0xc390 '7' '&' ' ' '' -Key 0x19 = '8' '*' '' 0xc3be 0xc39e '8' '*' ' ' '' -Key 0x1a = '9' '(' '' 0xe28098 0xe2809c '9' '(' ' ' '' -Key 0x1b = '0' ')' '' 0xe28099 0xe2809d '0' ')' ' ' '' -Key 0x1c = '-' '_' 0x1f 0xe28093 0xe28094 '-' '_' ' ' '' -Key 0x1d = '=' '+' '' 0xc397 0xc3b7 '=' '+' ' ' '' +Key 0x11 = '`' '~' '' '~' '' '`' '~' '~' '' +Key 0x12 = '1' '!' '' 0xc2a1 0xc2b9 '1' '!' 0xc2a1 0xc2b9 +Key 0x13 = '2' '@' 0x00 0xc2ba 0xc2b2 '2' '@' 0xc2ba 0xc2b2 +Key 0x14 = '3' '#' '' 0xc2aa 0xc2b3 '3' '#' 0xc2aa 0xc2b3 +Key 0x15 = '4' '$' '' 0xc2a2 0xc2a3 '4' '$' 0xc2a2 0xc2a3 +Key 0x16 = '5' '%' '' 0xe282ac 0xc2a5 '5' '%' 0xe282ac 0xc2a5 +Key 0x17 = '6' '^' 0x1e 0xc4a7 0xc4a6 '6' '^' 0xc4a6 0xc4a7 +Key 0x18 = '7' '&' '' 0xc3b0 0xc390 '7' '&' 0xc390 0xc3b0 +Key 0x19 = '8' '*' '' 0xc3be 0xc39e '8' '*' 0xc39e 0xc3be +Key 0x1a = '9' '(' '' 0xe28098 0xe2809c '9' '(' 0xe28098 0xe2809c +Key 0x1b = '0' ')' '' 0xe28099 0xe2809d '0' ')' 0xe28099 0xe2809d +Key 0x1c = '-' '_' 0x1f 0xe28093 0xe28094 '-' '_' 0xe28093 0xe28094 +Key 0x1d = '=' '+' '' 0xc397 0xc3b7 '=' '+' 0xc397 0xc3b7 Key 0x1e = 0x08 0x08 0x7f 0x08 0x08 0x08 0x08 0x08 0x08 Key 0x1f = 0x05 0x05 0x05 0x05 0x05 0x05 0x05 0x05 0x05 Key 0x20 = 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 @@ -98,18 +98,18 @@ Key 0x24 = '*' '*' '*' '*' '*' '*' '*' '*' '*' Key 0x25 = '-' '-' '-' '-' '-' '-' '-' '-' '-' Key 0x26 = 0x09 0x09 0x09 0x09 0x09 0x09 0x09 0x09 0x09 -Key 0x27 = 'q' 'Q' 0x11 0xc3a4 0xc384 'Q' 'q' ' ' '' -Key 0x28 = 'w' 'W' 0x17 0xc3a5 0xc385 'W' 'w' ' ' '' -Key 0x29 = 'f' 'F' 0x05 0xc3a3 0xc383 'E' 'e' ' ' '' -Key 0x2a = 'p' 'P' 0x12 0xc3b8 0xc398 'R' 'r' ' ' '' -Key 0x2b = 'g' 'G' 0x14 ' ' '' 'T' 't' ' ' '' -Key 0x2c = 'j' 'J' 0x19 0xc491 0xc490 'Y' 'y' ' ' '' -Key 0x2d = 'l' 'L' 0x15 0xc582 0xc581 'U' 'u' ' ' '' -Key 0x2e = 'u' 'U' 0x09 0xc3ba 0xc39a 'I' 'i' ' ' '' -Key 0x2f = 'y' 'Y' 0x0f 0xc3bc 0xc39c 'O' 'o' ' ' '' -Key 0x30 = ';' ':' 0x10 0xc3b6 0xc396 'P' 'p' ' ' '' -Key 0x31 = '[' '{' 0x1b 0xc2ab 0xe280b9 '[' '{' ' ' '' -Key 0x32 = ']' '}' 0x1d 0xc2bb 0xe280ba ']' '}' ' ' '' +Key 0x27 = 'q' 'Q' 0x11 0xc3a4 0xc384 'Q' 'q' 0xc384 0xc3a4 +Key 0x28 = 'w' 'W' 0x17 0xc3a5 0xc385 'W' 'w' 0xc385 0xc3a5 +Key 0x29 = 'f' 'F' 0x06 0xc3a3 0xc383 'F' 'f' 0xc383 0xc3a3 +Key 0x2a = 'p' 'P' 0x10 0xc3b8 0xc398 'P' 'p' 0xc398 0xc3b8 +Key 0x2b = 'g' 'G' 0x07 ' ' '' 'G' 'g' ' ' '' +Key 0x2c = 'j' 'J' 0x0a 0xc491 0xc490 'J' 'j' 0xc490 0xc491 +Key 0x2d = 'l' 'L' 0x0c 0xc582 0xc581 'L' 'l' 0xc581 0xc582 +Key 0x2e = 'u' 'U' 0x15 0xc3ba 0xc39a 'U' 'u' 0xc39a 0xc3ba +Key 0x2f = 'y' 'Y' 0x19 0xc3bc 0xc39c 'Y' 'y' 0xc39c 0xc3bc +Key 0x30 = ';' ':' '' 0xc3b6 0xc396 ';' ':' 0xc396 0xc3b6 +Key 0x31 = '[' '{' 0x1b 0xc2ab 0xe280b9 '[' '{' 0xc2ab 0xe280b9 +Key 0x32 = ']' '}' 0x1d 0xc2bb 0xe280ba ']' '}' 0xc2bb 0xe280ba Key 0x33 = '\\' '|' 0x1c ' ' '' '\\' '|' ' ' '' Key 0x34 = 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f Key 0x35 = 0x04 0x04 0x04 0x04 0x04 0x04 0x04 0x04 0x04 @@ -119,32 +119,32 @@ Key 0x39 = 0x0b '9' 0x0b 0x0b '9' 0x0b '9' 0x0b '9' Key 0x3a = '+' '+' '+' '+' '+' '+' '+' '+' '+' Key 0x3b = 0x08 0x08 0x7f 0x08 0x08 0x08 0x08 0x08 0x08 -Key 0x3c = 'a' 'A' 0x01 0xc3a1 0xc381 'A' 'a' ' ' '' -Key 0x3d = 'r' 'R' 0x13 '`' '' 'S' 's' ' ' '' -Key 0x3e = 's' 'S' 0x04 0xc39f '' 'D' 'd' ' ' '' -Key 0x3f = 't' 'T' 0x06 '\'' '' 'F' 'f' ' ' '' -Key 0x40 = 'd' 'D' 0x07 '"' '' 'G' 'g' ' ' '' +Key 0x3c = 'a' 'A' 0x01 0xc3a1 0xc381 'A' 'a' 0xc381 0xc3a1 +Key 0x3d = 'r' 'R' 0x12 '`' '' 'R' 'r' '`' '' +Key 0x3e = 's' 'S' 0x13 0xc39f '' 'S' 's' 0xc39f '' +Key 0x3f = 't' 'T' 0x14 '\'' '' 'T' 't' '\'' '' +Key 0x40 = 'd' 'D' 0x04 '"' '' 'D' 'd' '"' '' Key 0x41 = 'h' 'H' 0x08 ' ' '' 'H' 'h' ' ' '' -Key 0x42 = 'n' 'N' 0x0a 0xc3b1 0xc391 'J' 'j' ' ' '' -Key 0x43 = 'e' 'E' 0x0b 0xc3a9 0xc389 'K' 'k' ' ' '' -Key 0x44 = 'i' 'I' 0x0c 0xc3ad 0xc38d 'L' 'l' ' ' '' -Key 0x45 = 'o' 'O' '' 0xc3b3 0xc393 ';' ':' ' ' '' +Key 0x42 = 'n' 'N' 0x0e 0xc3b1 0xc391 'N' 'n' 0xc391 0xc3b1 +Key 0x43 = 'e' 'E' 0x05 0xc3a9 0xc389 'E' 'e' 0xc389 0xc3a9 +Key 0x44 = 'i' 'I' 0x09 0xc3ad 0xc38d 'I' 'i' 0xc38d 0xc3ad +Key 0x45 = 'o' 'O' 0x0f 0xc3b3 0xc393 'O' 'o' 0xc393 0xc3b3 Key 0x46 = '\'' '"' '' ' ' '' '\'' '"' ' ' '' Key 0x47 = 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a Key 0x48 = 0x1c '4' 0x1c 0x1c '4' 0x1c '4' 0x1c '4' Key 0x49 = '' '5' '' '' '5' '' '5' '' '5' Key 0x4a = 0x1d '6' 0x1d 0x1d '6' 0x1d '6' 0x1d '6' Key 0x4b = '' '' '' '' '' '' '' '' '' -Key 0x4c = 'z' 'Z' 0x1a 0xc3a6 0xc386 'Z' 'z' ' ' '' -Key 0x4d = 'x' 'X' 0x18 '^' '' 'X' 'x' ' ' '' -Key 0x4e = 'c' 'C' 0x03 0xc3a7 0xc387 'C' 'c' ' ' '' -Key 0x4f = 'v' 'V' 0x16 0xc593 0xc592 'V' 'v' ' ' '' +Key 0x4c = 'z' 'Z' 0x1a 0xc3a6 0xc386 'Z' 'z' 0xc386 0xc3a6 +Key 0x4d = 'x' 'X' 0x18 '^' '' 'X' 'x' '^' '' +Key 0x4e = 'c' 'C' 0x03 0xc3a7 0xc387 'C' 'c' 0xc387 0xc3a7 +Key 0x4f = 'v' 'V' 0x16 0xc593 0xc592 'V' 'v' 0xc592 0xc593 Key 0x50 = 'b' 'B' 0x02 ' ' '' 'B' 'b' ' ' '' -Key 0x51 = 'k' 'K' 0x0e ' ' '' 'N' 'n' ' ' '' +Key 0x51 = 'k' 'K' 0x0b ' ' '' 'K' 'k' ' ' '' Key 0x52 = 'm' 'M' 0x0d ' ' '' 'M' 'm' ' ' '' Key 0x53 = ',' '<' '' ' ' '' ',' '<' ' ' '' Key 0x54 = '.' '>' '' ' ' '' '.' '>' ' ' '' -Key 0x55 = '/' '?' '' 0xc2bf '' '/' '?' ' ' '' +Key 0x55 = '/' '?' '' 0xc2bf '' '/' '?' 0xc2bf '' Key 0x56 = '' '' '' '' '' '' '' '' '' Key 0x57 = 0x1e 0x1e 0x1e 0x1e 0x1e 0x1e 0x1e 0x1e 0x1e Key 0x58 = 0x04 '1' 0x04 0x04 '1' 0x04 '1' 0x04 '1' @@ -153,7 +153,7 @@ Key 0x5b = 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a 0x0a Key 0x5c = '' '' '' '' '' '' '' '' '' Key 0x5d = '' '' '' '' '' '' '' '' '' -Key 0x5e = ' ' ' ' 0x00 ' ' 0xc2a0 ' ' ' ' ' ' ' ' +Key 0x5e = ' ' ' ' 0x00 ' ' 0xc2a0 ' ' ' ' ' ' 0xc2a0 Key 0x5f = '' '' '' '' '' '' '' '' '' Key 0x60 = '' '' '' '' '' '' '' '' '' Key 0x61 = 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c @@ -164,7 +164,7 @@ Key 0x66 = '' '' '' '' '' '' '' '' '' Key 0x67 = '' '' '' '' '' '' '' '' '' Key 0x68 = '' '' '' '' '' '' '' '' '' -Key 0x69 = '-' '_' 0x1f 0xe28093 0xe28094 '-' '_' ' ' '' +Key 0x69 = '-' '_' 0x1f 0xe28093 0xe28094 '-' '_' 0xe28093 0xe28094 Key 0x6a = '' '' '' '' '' '' '' '' '' Key 0x6b = '' '' '' '' '' '' '' '' '' Key 0x6c = '' '' '' '' '' '' '' '' '' From axeld at pinc-software.de Fri Jun 5 10:23:23 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 05 Jun 2009 10:23:23 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30965_-_in_haiku/trunk=3A_build/jam_sr?= =?utf-8?q?c/preferences?= In-Reply-To: <894b9700906050049p7ca4d1cuca4a691a8e0be80c@mail.gmail.com> Message-ID: <5134131338-BeMail@zon> Stefano Ceccherini wrote: > What about the "Always show triggers" option ? What do we want to do > with it ? I don't know yet - it didn't work before, though, so it's no great loss :-) I don't think there is a need to make this settable, though. Bye, Axel. From axeld at pinc-software.de Fri Jun 5 10:29:04 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 05 Jun 2009 10:29:04 +0200 CEST Subject: [Haiku-commits] r30894 - haiku/trunk/src/kits/tracker In-Reply-To: Message-ID: <5476003700-BeMail@zon> Philippe Saint-Pierre wrote: > 2009/5/28 Axel D?rfler > > > This implement the suggestion in ticket #2868. > > Not sure this is a good idea - this can get pretty expensive, and > > also > > slow, since each change is followed by a complete rescan. I don't > > think > > we should keep it that way. > Are you against the whole idea or against my implementation? > (against might > be a bit hard..) > > If it's the former, I will revert the change completely, > > if it's the later, I have a few optimisations in mind, like actually > using > the information returned by the monitoring, rather than scanning the > whole > thing again. There are a few things I don't like, most importantly, it's the delay until the window opens. This even happens when the size is not actually computed, btw (like for the "Home" link on your desktop). Since it currently costs that many resources with large folders (like, usually, your home folder), I'm not sure this is a good feature to have in general. The complete rescan on changes is just the tip of the iceberg. Bye, Axel. From stippi at mail.berlios.de Fri Jun 5 10:43:43 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Fri, 5 Jun 2009 10:43:43 +0200 Subject: [Haiku-commits] r30969 - haiku/trunk/src/servers/app Message-ID: <200906050843.n558hhbB015254@sheep.berlios.de> Author: stippi Date: 2009-06-05 10:43:41 +0200 (Fri, 05 Jun 2009) New Revision: 30969 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30969&view=rev Modified: haiku/trunk/src/servers/app/app_server.rdef Log: Added lightbulb icon made by zuMi (idea alerts). Great work, thanks a lot! Fixes alert part of ticket #1429. Modified: haiku/trunk/src/servers/app/app_server.rdef =================================================================== --- haiku/trunk/src/servers/app/app_server.rdef 2009-06-05 08:22:09 UTC (rev 30968) +++ haiku/trunk/src/servers/app/app_server.rdef 2009-06-05 08:43:41 UTC (rev 30969) @@ -94,6 +94,23 @@ $"07000A050108000A040109000A00010A1001178400040A07010A000A08010B00" }; +resource(1, "idea") #'VICN' array { + $"6E63696605020102023DC0000000000000003D80004A00004A40007D01000044" + $"FF0100000003010000020116043B73F1366FD3B526223A3B22497CE64B43AE70" + $"F2A38ED4E1FF59020106033DC0000000000000003DC00049000048000031FFFF" + $"FFD5FFE500FFFFC800020106033DC0000000000000003DC00049000048000000" + $"FFE6A5FFFFBF00E2FFBB03070204402052202E202040202E205240602E605260" + $"60406052602E0405FE0148534858485848CAB0405EC18E5EBDF15E385838CAB0" + $"3858530405FE014B4B4B4D4B4D4BC6D24056C22956BD5656354D35C6D2354D4B" + $"0005444D444DC56BC42F563856C0D4C883B7C14022C49622BAE9222A382AB7C1" + $"2AC0D43C4DBA14C42F3C4D08024050404202043C3C3CBF713CBCDE4036BED836" + $"C0A736443C44BCDE44BF714042C0A742BED8420203344A344ABBEAC4533C4DBD" + $"00C4B83C4D344B374D344B0B0A000100023EE0000000000000003C8000484000" + $"4AC0000A0101011001178400040A020101000A010202031001178400040A0301" + $"02000A030103000A0400000A0401041001178422040A0401051001178422040A" + $"010106000A01010602C000000000000000004000004C0000000000" +}; + resource(2, "warn") #'VICN' array { $"6E636966060500020006023B5F8C3892CABB1F6A3E0BF0492A4E47706700FFF4" $"9EFFFFBD30020006023B3049396B0ABA90833C646E4A101543299500FFFFFFFF" @@ -160,6 +177,41 @@ $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000E0E0E0E0EFFFFFFFFFFFFFFFFFFFF" }; +resource(1, "idea") #'ICON' array { + $"FFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0000FAFAFAFAFAFAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF00FBFAFCFCFCFCFBFCFCFAFA00FFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFF00FAFCFCFDFDFDFDFDFDFCFBFAFA00FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF00FAFDFDFDFEFEFEFEFEFEFDFCFBFAFA00FFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFF00FAFDFCFE3F3F3F3F3FFEFEFDFDFCFBFAF900FFFFFFFFFFFFFFFFFFFF" + $"FFFFFF00FAFCFE3F3F3F3F3F3F3FFEFDFDFCFBFBF900FFFFFFFFFFFFFFFFFFFF" + $"FFFF00FAFCFDFE3F3F3F3F3F3F3F3FFEFDFDFDFBFAF900FFFFFFFFFFFFFFFFFF" + $"FFFF00FAFCFDFE3F3F3F3F3F3F3F3FFEFDFDFCFBFAF900FFFFFFFFFFFFFFFFFF" + $"FFFF00FAFCFDFE3F3F3F3F3FF93FFEFEFEFDFCFBFBF900FFFFFFFFFFFFFFFFFF" + $"FFFF00FAFCFDFE3F3F3F3F5D3F5D3FFEFEFDFCFBFAF900FFFFFFFFFFFFFFFFFF" + $"FFFF00FAFCFDFDFE3F3F3F5D3FF9FEFEFEFDFCFBFAF900FFFFFFFFFFFFFFFFFF" + $"FFFF00FAFCFBFDFEFE3F3F5D3FF9FEFDFDFCFCFBFAF900FFFFFFFFFFFFFFFFFF" + $"FFFF00FAFAFCFCFDFEFEFEFE5DF9FDFDFDFDFBFBF9F900FFFFFFFFFFFFFFFFFF" + $"FFFFFF00FAFBFDFDFDFEFEFDF9FDFDFCFCFBFBFAF900FFFFFFFFFFFFFFFFFFFF" + $"FFFFFF00FAFAFBFCFDFDFDFDF9FDFCFCFCFBFBF9F900FFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF00FAFAFBFCFCFDFCF9FCFCFCFBFBF9F900FFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFF00FAFAFBFBFCFCF9FBFBFBFBF9F900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF00F9FAFBFBFBF9FBFBFAF9F900FFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF00F9F9FAFA5DFAF9F95D00FFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF005DF9FD5DF95D5D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF005DF9FD5DF95D5D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF005DF9FD5DF95D5D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF0000F9FD5DF95D0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF001500000000000A00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF00001B193F0A0A0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF001500000000000A00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF00001B193F0A0A0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFF001500000000000A00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFF001B193F0A0A000E0E0E0E0E0E0E0E0E0E0E0E0EFFFFFF" + $"FFFFFFFFFFFFFFFFFFFF00000000000E0E0E0E0E0E0E0E0E0E0E0E0E1BFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFF0000000E0E0E0E0E0E0E0E0E0E0E0E0E1B1BFFFFFF" +}; + resource(2, "warn") #'ICON' array { $"FFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFF00FAFAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" @@ -231,39 +283,3 @@ }; #endif // HAIKU_TARGET_PLATFORM_HAIKU - -resource(1, "idea") #'ICON' array { - $"FFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFF0000FAFAFAFAFAFAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFF00FBFAFCFCFCFCFBFCFCFAFA00FFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFF00FAFCFCFDFDFDFDFDFDFCFBFAFA00FFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFF00FAFDFDFDFEFEFEFEFEFEFDFCFBFAFA00FFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFF00FAFDFCFE3F3F3F3F3FFEFEFDFDFCFBFAF900FFFFFFFFFFFFFFFFFFFF" - $"FFFFFF00FAFCFE3F3F3F3F3F3F3FFEFDFDFCFBFBF900FFFFFFFFFFFFFFFFFFFF" - $"FFFF00FAFCFDFE3F3F3F3F3F3F3F3FFEFDFDFDFBFAF900FFFFFFFFFFFFFFFFFF" - $"FFFF00FAFCFDFE3F3F3F3F3F3F3F3FFEFDFDFCFBFAF900FFFFFFFFFFFFFFFFFF" - $"FFFF00FAFCFDFE3F3F3F3F3FF93FFEFEFEFDFCFBFBF900FFFFFFFFFFFFFFFFFF" - $"FFFF00FAFCFDFE3F3F3F3F5D3F5D3FFEFEFDFCFBFAF900FFFFFFFFFFFFFFFFFF" - $"FFFF00FAFCFDFDFE3F3F3F5D3FF9FEFEFEFDFCFBFAF900FFFFFFFFFFFFFFFFFF" - $"FFFF00FAFCFBFDFEFE3F3F5D3FF9FEFDFDFCFCFBFAF900FFFFFFFFFFFFFFFFFF" - $"FFFF00FAFAFCFCFDFEFEFEFE5DF9FDFDFDFDFBFBF9F900FFFFFFFFFFFFFFFFFF" - $"FFFFFF00FAFBFDFDFDFEFEFDF9FDFDFCFCFBFBFAF900FFFFFFFFFFFFFFFFFFFF" - $"FFFFFF00FAFAFBFCFDFDFDFDF9FDFCFCFCFBFBF9F900FFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFF00FAFAFBFCFCFDFCF9FCFCFCFBFBF9F900FFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFF00FAFAFBFBFCFCF9FBFBFBFBF9F900FFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFF00F9FAFBFBFBF9FBFBFAF9F900FFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFF00F9F9FAFA5DFAF9F95D00FFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF005DF9FD5DF95D5D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF005DF9FD5DF95D5D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF005DF9FD5DF95D5D00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF0000F9FD5DF95D0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF001500000000000A00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF00001B193F0A0A0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF001500000000000A00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF00001B193F0A0A0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFF001500000000000A00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - $"FFFFFFFFFFFFFFFFFF001B193F0A0A000E0E0E0E0E0E0E0E0E0E0E0E0EFFFFFF" - $"FFFFFFFFFFFFFFFFFFFF00000000000E0E0E0E0E0E0E0E0E0E0E0E0E1BFFFFFF" - $"FFFFFFFFFFFFFFFFFFFFFF0000000E0E0E0E0E0E0E0E0E0E0E0E0E1B1BFFFFFF" -}; - From axeld at mail.berlios.de Fri Jun 5 11:06:13 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Fri, 5 Jun 2009 11:06:13 +0200 Subject: [Haiku-commits] r30970 - haiku/trunk/src/bin/mkfs Message-ID: <200906050906.n5596DXZ018938@sheep.berlios.de> Author: axeld Date: 2009-06-05 11:06:11 +0200 (Fri, 05 Jun 2009) New Revision: 30970 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30970&view=rev Modified: haiku/trunk/src/bin/mkfs/FsCreator.cpp Log: * Fixed wrong partition name in mkfs, closing ticket #3954. Modified: haiku/trunk/src/bin/mkfs/FsCreator.cpp =================================================================== --- haiku/trunk/src/bin/mkfs/FsCreator.cpp 2009-06-05 08:43:41 UTC (rev 30969) +++ haiku/trunk/src/bin/mkfs/FsCreator.cpp 2009-06-05 09:06:11 UTC (rev 30970) @@ -1,5 +1,5 @@ /* - * Copyright 2008 Haiku Inc. All rights reserved. + * Copyright 2008-2009 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -172,15 +172,18 @@ return true; } + BString contentName = partition->ContentName(); + // CommitModifications() will invalidate our partition object + status = device.CommitModifications(); if (status == B_OK) { if (fVerbose) { - std::cout << "Volume " << partition->ContentName() - << " has been initialized successfully!\n"; + std::cout << "Volume \"" << contentName.String() + << "\" has been initialized successfully!" << std::endl; } } else { - std::cout << kProgramName << ": Initialization of " - << partition->ContentName() << " failed: " << strerror(status) + std::cout << kProgramName << ": Initialization of \"" + << contentName.String() << "\" failed: " << strerror(status) << std::endl; return false; } From rudolfc at mail.berlios.de Fri Jun 5 11:10:40 2009 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Fri, 5 Jun 2009 11:10:40 +0200 Subject: [Haiku-commits] r30971 - haiku/trunk/src/add-ons/accelerants/nvidia/engine Message-ID: <200906050910.n559Aecv019561@sheep.berlios.de> Author: rudolfc Date: 2009-06-05 11:10:40 +0200 (Fri, 05 Jun 2009) New Revision: 30971 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30971&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c Log: comments update only: newly discovered PLL info/trouble. needs to be investigated more. Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c 2009-06-05 09:06:11 UTC (rev 30970) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c 2009-06-05 09:10:40 UTC (rev 30971) @@ -2971,6 +2971,14 @@ si->ps.std_memory_clock = 200; } +/* notes on PLL's: + on NV34, GeForce FX 5200, id 0x0322 DAC1 PLL observed behaviour: + - Fcomp may be as high as 27Mhz (BIOS), and current set range seems ok as well; + - Fvco may not be as low as 216Mhz (DVI pixelclock intermittant locking error, + visible as horizontal shifting picture and black screen (out of range): both intermittant); + - Fvco may be as high as 432Mhz (BIOS); + - This is not an extended PLL: the second divisor register does not do anything. +*/ static void pinsnv30_arch_fake(void) { /* determine PLL type */ From axeld at mail.berlios.de Fri Jun 5 11:49:45 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Fri, 5 Jun 2009 11:49:45 +0200 Subject: [Haiku-commits] r30972 - haiku/trunk/src/bin Message-ID: <200906050949.n559nj5o024348@sheep.berlios.de> Author: axeld Date: 2009-06-05 11:49:43 +0200 (Fri, 05 Jun 2009) New Revision: 30972 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30972&view=rev Modified: haiku/trunk/src/bin/mountvolume.cpp Log: * Unmounting a volume now actually works, this fixes bug #3671. * Added -u as an alias for -unmount. Added -readonly as an alias for -ro. * Made the volume/fs column width depending on the terminal size. * Now lists the volumes (-l) when invoked without any arguments instead of showing the help text. * Improved output of not mounted volumes. * Minor cleanup. Modified: haiku/trunk/src/bin/mountvolume.cpp =================================================================== --- haiku/trunk/src/bin/mountvolume.cpp 2009-06-05 09:10:40 UTC (rev 30971) +++ haiku/trunk/src/bin/mountvolume.cpp 2009-06-05 09:49:43 UTC (rev 30972) @@ -1,15 +1,22 @@ /* * Copyright 2005-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. + * * Distributed under the terms of the MIT License. */ +#include +#include + #include #include #include +#include -#include -#include +#include +#include +#include #include #include @@ -18,20 +25,17 @@ #include #include -#include -#include - using std::set; using std::string; -extern const char *__progname; +extern const char* __progname; typedef set StringSet; // usage -static const char *kUsage = - "%s [ ... ]\n" +static const char* kUsage = + "Usage: %s [ ... ]\n\n" "Mounts the volume with name , if given. Lists info about\n" "mounted and mountable volumes and mounts/unmounts volumes.\n" "\n" @@ -40,51 +44,53 @@ "\n" "Options:\n" "[general]\n" - " -s - silent; don't print info about (un)mounting\n" - " -h, --help - print this info text\n" + " -s - silent; don't print info about (un)mounting\n" + " -h, --help - print this info text\n" "\n" "[mounting]\n" - " -all - mount all mountable volumes\n" - " -allbfs - mount all mountable BFS volumes\n" - " -allhfs - mount all mountable HFS volumes\n" - " -alldos - mount all mountable DOS volumes\n" - " -ro - mount volumes read-only\n" - " -unmount - unmount the volume with the name \n" + " -all - mount all mountable volumes\n" + " -allbfs - mount all mountable BFS volumes\n" + " -allhfs - mount all mountable HFS volumes\n" + " -alldos - mount all mountable DOS volumes\n" + " -ro, -readonly - mount volumes read-only\n" + " -u, -unmount - unmount the volume with the name \n" "\n" "[info]\n" - " -p, -l - list all mounted and mountable volumes\n" - " -lh - list all existing volumes (incl. not-mountable ones)\n" - " -dd - list all disk existing devices\n" + " -p, -l - list all mounted and mountable volumes\n" + " -lh - list all existing volumes (incl. not-mountable " + "ones)\n" + " -dd - list all disk existing devices\n" "\n" "[obsolete]\n" - " -r - ignored\n" - " -publishall - ignored\n" - " -publishbfs - ignored\n" - " -publishhfs - ignored\n" - " -publishdos - ignored\n"; + " -r - ignored\n" + " -publishall - ignored\n" + " -publishbfs - ignored\n" + " -publishhfs - ignored\n" + " -publishdos - ignored\n"; -// application name -const char *kAppName = __progname; +const char* kAppName = __progname; -// print_usage -static -void +static int sVolumeNameWidth = B_OS_NAME_LENGTH; +static int sFSNameWidth = 25; + + +static void print_usage(bool error) { fprintf(error ? stderr : stdout, kUsage, kAppName); } -// print_usage_and_exit -static -void + +static void print_usage_and_exit(bool error) { print_usage(error); exit(error ? 0 : 1); } -static const char * + +static const char* size_string(int64 size) { double blocks = size; @@ -93,7 +99,7 @@ if (size < 1024) sprintf(string, "%Ld", size); else { - char *units[] = {"K", "M", "G", NULL}; + char* units[] = {"K", "M", "G", NULL}; int32 i = -1; do { @@ -113,27 +119,28 @@ struct MountVisitor : public BDiskDeviceVisitor { MountVisitor() - : silent(false), - mountAll(false), - mountBFS(false), - mountHFS(false), - mountDOS(false), - readOnly(false) + : + silent(false), + mountAll(false), + mountBFS(false), + mountHFS(false), + mountDOS(false), + readOnly(false) { } - virtual bool Visit(BDiskDevice *device) + virtual bool Visit(BDiskDevice* device) { return Visit(device, 0); } - virtual bool Visit(BPartition *partition, int32 level) + virtual bool Visit(BPartition* partition, int32 level) { // get name and type - const char *name = partition->ContentName(); + const char* name = partition->ContentName(); if (!name) name = partition->Name(); - const char *type = partition->ContentType(); + const char* type = partition->ContentType(); // check whether to mount bool mount = false; @@ -165,7 +172,7 @@ bool unmount = false; if (name && toUnmount.find(name) != toUnmount.end()) { toUnmount.erase(name); - if (!partition->IsMounted()) { + if (partition->IsMounted()) { unmount = true; mount = false; } else if (!silent) @@ -180,7 +187,8 @@ if (error >= B_OK) { BPath mountPoint; partition->GetMountPoint(&mountPoint); - printf("Volume `%s' mounted successfully at '%s'.\n", name, mountPoint.Path()); + printf("Volume `%s' mounted successfully at '%s'.\n", name, + mountPoint.Path()); } else { fprintf(stderr, "Failed to mount volume `%s': %s\n", name, strerror(error)); @@ -224,15 +232,15 @@ return listMountablePartitions || listAllPartitions; } - virtual bool Visit(BDiskDevice *device) + virtual bool Visit(BDiskDevice* device) { return Visit(device, 0); } - virtual bool Visit(BPartition *partition, int32 level) + virtual bool Visit(BPartition* partition, int32 level) { // get name and type - const char *name = partition->ContentName(); + const char* name = partition->ContentName(); if (name == NULL || name[0] == '\0') { name = partition->Name(); if (name == NULL || name[0] == '\0') { @@ -242,7 +250,7 @@ name = ""; } } - const char *type = partition->ContentType(); + const char* type = partition->ContentType(); if (type == NULL) type = ""; @@ -264,9 +272,10 @@ if (partition->IsMounted()) partition->GetMountPoint(&mountPoint); - printf("%-14s %-20s %8s %s (%s)\n", - name, type, size_string(partition->Size()), + printf("%-*s %-*s %8s %s%s(%s)\n", sVolumeNameWidth, name, + sFSNameWidth, type, size_string(partition->Size()), partition->IsMounted() ? mountPoint.Path() : "", + partition->IsMounted() ? " " : "", path.Path() + skip); return false; } @@ -280,19 +289,19 @@ int -main(int argc, char **argv) +main(int argc, char** argv) { - if (argc < 2) - print_usage_and_exit(true); - MountVisitor mountVisitor; PrintPartitionsVisitor printPartitionsVisitor; bool listAllDevices = false; + if (argc < 2) + printPartitionsVisitor.listMountablePartitions = true; + // parse arguments for (int argi = 1; argi < argc; argi++) { - const char *arg = argv[argi]; + const char* arg = argv[argi]; if (arg[0] != '\0' && arg[0] != '-') { mountVisitor.toMount.insert(arg); @@ -308,9 +317,9 @@ mountVisitor.mountHFS = true; } else if (strcmp(arg, "-alldos") == 0) { mountVisitor.mountDOS = true; - } else if (strcmp(arg, "-ro") == 0) { + } else if (strcmp(arg, "-ro") == 0 || strcmp(arg, "-readonly") == 0) { mountVisitor.readOnly = true; - } else if (strcmp(arg, "-unmount") == 0) { + } else if (strcmp(arg, "-u") == 0 || strcmp(arg, "-unmount") == 0) { argi++; if (argi >= argc) print_usage_and_exit(true); @@ -399,8 +408,8 @@ } for (StringSet::iterator it = mountVisitor.toUnmount.begin(); it != mountVisitor.toUnmount.end(); it++) { - fprintf(stderr, "Failed to unmount volume `%s': Volume not found.\n", - (*it).c_str()); + fprintf(stderr, "Failed to unmount volume `%s': Volume not " + "found.\n", (*it).c_str()); } } @@ -418,9 +427,23 @@ // TODO } + // determine width of the terminal in order to shrink the columns if needed + if (isatty(STDOUT_FILENO)) { + winsize size; + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size, sizeof(winsize)) == 0) { + if (size.ws_col < 95) { + sVolumeNameWidth -= (95 - size.ws_col) / 2; + sFSNameWidth -= (95 - size.ws_col) / 2; + } + } + } + if (printPartitionsVisitor.IsUsed()) { - puts("Volume File System Size Mounted At (Device)"); - puts("---------------------------------------------------------------------"); + printf("%-*s %-*s Size Mounted At (Device)\n", + sVolumeNameWidth, "Volume", sFSNameWidth, "File System"); + BString separator; + separator.SetTo('-', sVolumeNameWidth + sFSNameWidth + 35); + puts(separator.String()); if (printPartitionsVisitor.listAllPartitions) deviceList.VisitEachPartition(&printPartitionsVisitor); From superstippi at gmx.de Fri Jun 5 12:04:05 2009 From: superstippi at gmx.de (=?UTF-8?B?U3RlcGhhbiBBw59tdXM=?=) Date: Fri, 05 Jun 2009 12:04:05 +0200 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <39244399752-BeMail@zon> References: <39244399752-BeMail@zon> Message-ID: <4A28ED95.3090806@gmx.de> Axel D?rfler schrieb: > Rene Gollent wrote: >> On Thu, Jun 4, 2009 at 7:29 AM, axeld at BerliOS < >> axeld at mail.berlios.de> wrote: >>> Modified: >>> haiku/trunk/src/system/kernel/cache/file_map.cpp >>> Log: >>> * Fixed a bug that let _InvalidateAfter() access already freed >>> memory, and would >>> also mess up the file map, causing all sorts of file corruption. >>> * This fixes bug #3991 (and eventually some others). >> Nice catch! I'm assuming this one would only have corrupted the >> contents of the files themselves, but not things like the BFS B+ >> trees? > > It could overwrite all data, including B+trees and inodes - everything > that used to be part of the file. > But only in the case that a file was truncated, and then reallocated at > a different position (ie. if the file had been moved, or something else > managed to claim the space that was freed on truncation). > I don't think this will solve all symptoms, but at least it might fix > some of them -- the reported failures on SVN conflicts are a good > candidate for this, for example. I don't understand if this means the bug could have caused problems on directories themselves, or only on file content. Can you clarify? Thanks a lot for fixing it, anyway! Great work! Best regards, -Stephan From axeld at pinc-software.de Fri Jun 5 13:11:56 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 05 Jun 2009 13:11:56 +0200 CEST Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <4A28ED95.3090806@gmx.de> Message-ID: <542771326-BeMail@zon> Stephan A?mus wrote: > > It could overwrite all data, including B+trees and inodes - > > everything > > that used to be part of the file. [...] > I don't understand if this means the bug could have caused problems > on > directories themselves, or only on file content. Can you clarify? It probably would have been clear if the end of the sentence above ended in: everything that was once covered by that file. Ie. it could have overwritten anything that was at the same place as a file that triggered the problem. Bye, Axel. From superstippi at gmx.de Fri Jun 5 14:03:26 2009 From: superstippi at gmx.de (=?UTF-8?B?U3RlcGhhbiBBw59tdXM=?=) Date: Fri, 05 Jun 2009 14:03:26 +0200 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <542771326-BeMail@zon> References: <542771326-BeMail@zon> Message-ID: <4A29098E.3010501@gmx.de> Axel D?rfler schrieb: > Stephan A?mus wrote: >>> It could overwrite all data, including B+trees and inodes - >>> everything >>> that used to be part of the file. > [...] >> I don't understand if this means the bug could have caused problems >> on >> directories themselves, or only on file content. Can you clarify? > > It probably would have been clear if the end of the sentence above > ended in: everything that was once covered by that file. > Ie. it could have overwritten anything that was at the same place as a > file that triggered the problem. So when I just move mails from one mail folder into the Trash, could that cause that folder to be "truncated" so that it could mess up data from another folder? Other than that, I don't see a "truncation" operation being involved at all in what I do to trigger the bug that mails disappear from one of my mail folders, so it's probably unrelated, correct? Best regards, -Stephan From anevilyak at mail.berlios.de Fri Jun 5 14:33:23 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Fri, 5 Jun 2009 14:33:23 +0200 Subject: [Haiku-commits] r30973 - haiku/trunk/src/add-ons/accelerants/ati Message-ID: <200906051233.n55CXNmj022587@sheep.berlios.de> Author: anevilyak Date: 2009-06-05 14:33:22 +0200 (Fri, 05 Jun 2009) New Revision: 30973 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30973&view=rev Modified: haiku/trunk/src/add-ons/accelerants/ati/mode.cpp Log: Fix gcc4 build. Closes ticket #3996. Modified: haiku/trunk/src/add-ons/accelerants/ati/mode.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/ati/mode.cpp 2009-06-05 09:49:43 UTC (rev 30972) +++ haiku/trunk/src/add-ons/accelerants/ati/mode.cpp 2009-06-05 12:33:22 UTC (rev 30973) @@ -8,9 +8,10 @@ #include "accelerant.h" -#include // common accelerant header file +#include #include +#include // common accelerant header file static display_mode* From anevilyak at gmail.com Fri Jun 5 14:42:43 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 5 Jun 2009 07:42:43 -0500 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <4A29098E.3010501@gmx.de> References: <542771326-BeMail@zon> <4A29098E.3010501@gmx.de> Message-ID: On Fri, Jun 5, 2009 at 7:03 AM, Stephan A?mus wrote: > So when I just move mails from one mail folder into the Trash, could > that cause that folder to be "truncated" so that it could mess up data > from another folder? Other than that, I don't see a "truncation" > operation being involved at all in what I do to trigger the bug that > mails disappear from one of my mail folders, so it's probably unrelated, > correct? Most likely unrelated. This particular bug as I understand it would essentially be triggered as follows: Some file gets truncated to 0 bytes, and its storage is thus freed. Something else then winds up getting allocated on the disk in the same spot where those file blocks used to be, say, a B+ tree. Then due to the bug, the same blocks where that directory was just written to get overwritten with some other blocks. Presto, corrupted B+ tree. Requires a pretty specific set of circumstances to trigger though, which sound completely different from your disappearing email. Correct me if I'm wrong Axel :) HTH, Rene From superstippi at gmx.de Fri Jun 5 14:51:28 2009 From: superstippi at gmx.de (=?UTF-8?B?U3RlcGhhbiBBw59tdXM=?=) Date: Fri, 05 Jun 2009 14:51:28 +0200 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: References: <542771326-BeMail@zon> <4A29098E.3010501@gmx.de> Message-ID: <4A2914D0.8030607@gmx.de> Rene Gollent schrieb: > On Fri, Jun 5, 2009 at 7:03 AM, Stephan A?mus wrote: >> So when I just move mails from one mail folder into the Trash, could >> that cause that folder to be "truncated" so that it could mess up data >> from another folder? Other than that, I don't see a "truncation" >> operation being involved at all in what I do to trigger the bug that >> mails disappear from one of my mail folders, so it's probably unrelated, >> correct? > > Most likely unrelated. This particular bug as I understand it would > essentially be triggered as follows: Some file gets truncated to 0 > bytes, and its storage is thus freed. Something else then winds up > getting allocated on the disk in the same spot where those file blocks > used to be, say, a B+ tree. Then due to the bug, the same blocks where > that directory was just written to get overwritten with some other > blocks. Presto, corrupted B+ tree. Requires a pretty specific set of > circumstances to trigger though, which sound completely different from > your disappearing email. Correct me if I'm wrong Axel :) So what happened if a program overwrites some file's contents, even if they end up being the same size or larger than before? Wouldn't that too start with a truncate operation depending on how you do it? What about attributes, were those affected in the same way? I don't really know if anything that Beam does could fit the situation. I guess I will simply find out when I use Beam more frequently on that machine again... :-) Best regards, -Stephan From axeld at mail.berlios.de Fri Jun 5 15:03:06 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 5 Jun 2009 15:03:06 +0200 Subject: [Haiku-commits] r30974 - in haiku/trunk: headers/private/graphics/vesa src/add-ons/accelerants/vesa src/add-ons/kernel/drivers/graphics/vesa Message-ID: <200906051303.n55D36ik027602@sheep.berlios.de> Author: axeld Date: 2009-06-05 15:03:05 +0200 (Fri, 05 Jun 2009) New Revision: 30974 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30974&view=rev Modified: haiku/trunk/headers/private/graphics/vesa/vesa.h haiku/trunk/headers/private/graphics/vesa/vesa_info.h haiku/trunk/src/add-ons/accelerants/vesa/dpms.cpp haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/device.cpp haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h Log: * Added DPMS support to the VESA driver, in case the hardware/BIOS supports it. * Minor cleanup. Modified: haiku/trunk/headers/private/graphics/vesa/vesa.h =================================================================== --- haiku/trunk/headers/private/graphics/vesa/vesa.h 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/headers/private/graphics/vesa/vesa.h 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2004-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef VESA_H @@ -141,6 +141,15 @@ #define CRTC_NEGATIVE_VSYNC 0x08 +/* Power Management */ + +#define DPMS_ON 0x00 +#define DPMS_STANDBY 0x01 +#define DPMS_SUSPEND 0x02 +#define DPMS_OFF 0x04 +#define DPMS_REDUCED_ON 0x08 + + /* VBE 3.0 protected mode interface * The BIOS area can be scanned for the protected mode * signature that identifies the structure below. Modified: haiku/trunk/headers/private/graphics/vesa/vesa_info.h =================================================================== --- haiku/trunk/headers/private/graphics/vesa/vesa_info.h 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/headers/private/graphics/vesa/vesa_info.h 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef VESA_INFO_H @@ -40,6 +40,7 @@ edid1_info edid_info; bool has_edid; + uint32 dpms_capabilities; }; //----------------- ioctl() interface ---------------- @@ -49,6 +50,8 @@ VESA_GET_PRIVATE_DATA = B_DEVICE_OP_CODES_END + 1, VESA_GET_DEVICE_NAME, VESA_SET_DISPLAY_MODE, + VESA_GET_DPMS_MODE, + VESA_SET_DPMS_MODE, VGA_SET_INDEXED_COLORS, VGA_PLANAR_BLIT, Modified: haiku/trunk/src/add-ons/accelerants/vesa/dpms.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/vesa/dpms.cpp 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/src/add-ons/accelerants/vesa/dpms.cpp 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,9 +1,11 @@ /* - * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ +#include + #include "accelerant_protos.h" #include "accelerant.h" @@ -11,20 +13,27 @@ uint32 vesa_dpms_capabilities(void) { - return B_DPMS_ON; + return gInfo->shared_info->dpms_capabilities; } uint32 vesa_dpms_mode(void) { - return B_DPMS_ON; + uint32 mode; + if (ioctl(gInfo->device, VESA_GET_DPMS_MODE, &mode, sizeof(mode)) != 0) + return B_DPMS_ON; + + return mode; } status_t -vesa_set_dpms_mode(uint32 dpms_flags) +vesa_set_dpms_mode(uint32 mode) { - return B_ERROR; + if (ioctl(gInfo->device, VESA_SET_DPMS_MODE, &mode, sizeof(mode)) != 0) + return errno; + + return B_OK; } Modified: haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/src/add-ons/accelerants/vesa/mode.cpp 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,8 +1,9 @@ /* - * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ + #include #include @@ -14,7 +15,7 @@ //#define TRACE_MODE #ifdef TRACE_MODE -extern "C" void _sPrintf(const char *format, ...); +extern "C" void _sPrintf(const char* format, ...); # define TRACE(x) _sPrintf x #else # define TRACE(x) ; @@ -46,9 +47,9 @@ /*! Checks if the specified \a mode can be set using VESA. */ static bool -is_mode_supported(display_mode *mode) +is_mode_supported(display_mode* mode) { - vesa_mode *modes = gInfo->vesa_modes; + vesa_mode* modes = gInfo->vesa_modes; for (uint32 i = gInfo->shared_info->vesa_mode_count; i-- > 0;) { // search mode in VESA mode list @@ -96,7 +97,7 @@ status_t -vesa_get_mode_list(display_mode *modeList) +vesa_get_mode_list(display_mode* modeList) { TRACE(("vesa_get_mode_info()\n")); memcpy(modeList, gInfo->mode_list, @@ -106,15 +107,15 @@ status_t -vesa_propose_display_mode(display_mode *target, const display_mode *low, - const display_mode *high) +vesa_propose_display_mode(display_mode* target, const display_mode* low, + const display_mode* high) { TRACE(("vesa_propose_display_mode()\n")); // just search for the specified mode in the list for (uint32 i = 0; i < gInfo->shared_info->mode_count; i++) { - display_mode *current = &gInfo->mode_list[i]; + display_mode* current = &gInfo->mode_list[i]; if (target->virtual_width != current->virtual_width || target->virtual_height != current->virtual_height @@ -129,7 +130,7 @@ status_t -vesa_set_display_mode(display_mode *_mode) +vesa_set_display_mode(display_mode* _mode) { TRACE(("vesa_set_display_mode()\n")); @@ -137,8 +138,8 @@ if (vesa_propose_display_mode(&mode, &mode, &mode) != B_OK) return B_BAD_VALUE; - vesa_mode *modes = gInfo->vesa_modes; - for (unsigned int i = gInfo->shared_info->vesa_mode_count; i-- > 0;) { + vesa_mode* modes = gInfo->vesa_modes; + for (uint32 i = gInfo->shared_info->vesa_mode_count; i-- > 0;) { // search mode in VESA mode list // TODO: list is ordered, we could use binary search if (modes[i].width == mode.virtual_width @@ -153,7 +154,7 @@ status_t -vesa_get_display_mode(display_mode *_currentMode) +vesa_get_display_mode(display_mode* _currentMode) { TRACE(("vesa_get_display_mode()\n")); *_currentMode = gInfo->shared_info->current_mode; @@ -162,7 +163,7 @@ status_t -vesa_get_edid_info(void *info, size_t size, uint32 *_version) +vesa_get_edid_info(void* info, size_t size, uint32* _version) { TRACE(("intel_get_edid_info()\n")); @@ -178,7 +179,7 @@ status_t -vesa_get_frame_buffer_config(frame_buffer_config *config) +vesa_get_frame_buffer_config(frame_buffer_config* config) { TRACE(("vesa_get_frame_buffer_config()\n")); @@ -191,20 +192,21 @@ status_t -vesa_get_pixel_clock_limits(display_mode *mode, uint32 *low, uint32 *high) +vesa_get_pixel_clock_limits(display_mode* mode, uint32* low, uint32* high) { TRACE(("vesa_get_pixel_clock_limits()\n")); - // ToDo: do some real stuff here (taken from radeon driver) - uint32 total_pix = (uint32)mode->timing.h_total * (uint32)mode->timing.v_total; - uint32 clock_limit = 2000000; + // TODO: do some real stuff here (taken from radeon driver) + uint32 totalPixel = (uint32)mode->timing.h_total + * (uint32)mode->timing.v_total; + uint32 clockLimit = 2000000; - /* lower limit of about 48Hz vertical refresh */ - *low = (total_pix * 48L) / 1000L; - if (*low > clock_limit) + // lower limit of about 48Hz vertical refresh + *low = totalPixel * 48L / 1000L; + if (*low > clockLimit) return B_ERROR; - *high = clock_limit; + *high = clockLimit; return B_OK; } @@ -218,7 +220,7 @@ status_t -vesa_get_timing_constraints(display_timing_constraints *dtc) +vesa_get_timing_constraints(display_timing_constraints* constraints) { TRACE(("vesa_get_timing_constraints()\n")); return B_ERROR; @@ -226,7 +228,7 @@ void -vesa_set_indexed_colors(uint count, uint8 first, uint8 *colors, uint32 flags) +vesa_set_indexed_colors(uint count, uint8 first, uint8* colors, uint32 flags) { TRACE(("vesa_set_indexed_colors()\n")); vga_set_indexed_colors_args args; Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/device.cpp 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/device.cpp 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -32,53 +32,23 @@ #endif -/* device hooks prototypes */ - -static status_t device_open(const char *, uint32, void **); -static status_t device_close(void *); -static status_t device_free(void *); -static status_t device_ioctl(void *, uint32, void *, size_t); -static status_t device_read(void *, off_t, void *, size_t *); -static status_t device_write(void *, off_t, const void *, size_t *); - - -device_hooks gDeviceHooks = { - device_open, - device_close, - device_free, - device_ioctl, - device_read, - device_write, - NULL, - NULL, - NULL, - NULL -}; - - -// #pragma mark - -// the device will be accessed through the following functions (a.k.a. device hooks) - - static status_t -device_open(const char *name, uint32 flags, void **_cookie) +device_open(const char* name, uint32 flags, void** _cookie) { int id; // find accessed device - { - char *thisName; + char* thisName; - // search for device name - for (id = 0; (thisName = gDeviceNames[id]) != NULL; id++) { - if (!strcmp(name, thisName)) - break; - } - if (!thisName) - return EINVAL; + // search for device name + for (id = 0; (thisName = gDeviceNames[id]) != NULL; id++) { + if (!strcmp(name, thisName)) + break; } + if (thisName == NULL) + return B_BAD_VALUE; - vesa_info *info = gDeviceInfo[id]; + vesa_info* info = gDeviceInfo[id]; *_cookie = info; acquire_lock(&gLock); @@ -100,16 +70,16 @@ static status_t -device_close(void *cookie) +device_close(void* cookie) { return B_OK; } static status_t -device_free(void *cookie) +device_free(void* cookie) { - struct vesa_info *info = (vesa_info *)cookie; + struct vesa_info* info = (vesa_info*)cookie; acquire_lock(&gLock); @@ -124,26 +94,26 @@ static status_t -device_ioctl(void *cookie, uint32 msg, void *buffer, size_t bufferLength) +device_ioctl(void* cookie, uint32 msg, void* buffer, size_t bufferLength) { - struct vesa_info *info = (vesa_info *)cookie; + struct vesa_info* info = (vesa_info*)cookie; switch (msg) { case B_GET_ACCELERANT_SIGNATURE: dprintf(DEVICE_NAME ": acc: %s\n", VESA_ACCELERANT_NAME); - if (user_strlcpy((char *)buffer, VESA_ACCELERANT_NAME, + if (user_strlcpy((char*)buffer, VESA_ACCELERANT_NAME, B_FILE_NAME_LENGTH) < B_OK) return B_BAD_ADDRESS; return B_OK; - // needed to share data between kernel and accelerant + // needed to share data between kernel and accelerant case VESA_GET_PRIVATE_DATA: return user_memcpy(buffer, &info->shared_area, sizeof(area_id)); // needed for cloning case VESA_GET_DEVICE_NAME: - if (user_strlcpy((char *)buffer, gDeviceNames[info->id], + if (user_strlcpy((char*)buffer, gDeviceNames[info->id], B_PATH_NAME_LENGTH) < B_OK) return B_BAD_ADDRESS; @@ -151,15 +121,41 @@ case VESA_SET_DISPLAY_MODE: { - unsigned int mode; + if (bufferLength != sizeof(uint32)) + return B_BAD_VALUE; - if (bufferLength != sizeof(mode) - || user_memcpy(&mode, buffer, sizeof(mode)) < B_OK) + uint32 mode; + if (user_memcpy(&mode, buffer, sizeof(uint32)) < B_OK) return B_BAD_ADDRESS; return vesa_set_display_mode(*info, mode); } + case VESA_GET_DPMS_MODE: + { + if (bufferLength != sizeof(uint32)) + return B_BAD_VALUE; + + uint32 mode; + status_t status = vesa_get_dpms_mode(*info, mode); + if (status != B_OK) + return status; + + return user_memcpy(buffer, &mode, sizeof(mode)); + } + + case VESA_SET_DPMS_MODE: + { + if (bufferLength != sizeof(uint32)) + return B_BAD_VALUE; + + uint32 mode; + if (user_memcpy(&mode, buffer, sizeof(uint32)) < B_OK) + return B_BAD_ADDRESS; + + return vesa_set_dpms_mode(*info, mode); + } + case VGA_SET_INDEXED_COLORS: { vga_set_indexed_colors_args args; @@ -181,7 +177,9 @@ } default: - TRACE((DEVICE_NAME ": ioctl() unknown message %ld (length = %lu)\n", msg, bufferLength)); + TRACE((DEVICE_NAME ": ioctl() unknown message %ld (length = %lu)\n", + msg, bufferLength)); + break; } return B_DEV_INVALID_IOCTL; @@ -189,17 +187,31 @@ static status_t -device_read(void */*cookie*/, off_t /*pos*/, void */*buffer*/, size_t *_length) +device_read(void* /*cookie*/, off_t /*pos*/, void* /*buffer*/, size_t* _length) { - *_length = 0; + *_length = 0; return B_NOT_ALLOWED; } static status_t -device_write(void */*cookie*/, off_t /*pos*/, const void */*buffer*/, size_t *_length) +device_write(void* /*cookie*/, off_t /*pos*/, const void* /*buffer*/, + size_t* _length) { - *_length = 0; + *_length = 0; return B_NOT_ALLOWED; } + +device_hooks gDeviceHooks = { + device_open, + device_close, + device_free, + device_ioctl, + device_read, + device_write, + NULL, + NULL, + NULL, + NULL +}; Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -44,26 +44,26 @@ static status_t -vbe_get_mode_info(struct vm86_state *vmState, uint16 mode, - struct vbe_mode_info *modeInfo) +vbe_get_mode_info(struct vm86_state& vmState, uint16 mode, + struct vbe_mode_info* modeInfo) { - struct vbe_mode_info *vbeModeInfo = (struct vbe_mode_info *)0x1000; + struct vbe_mode_info* vbeModeInfo = (struct vbe_mode_info*)0x1000; memset(vbeModeInfo, 0, sizeof(vbe_mode_info)); - vmState->regs.eax = 0x4f01; - vmState->regs.ecx = mode; - vmState->regs.es = 0x1000 >> 4; - vmState->regs.edi = 0x0000; + vmState.regs.eax = 0x4f01; + vmState.regs.ecx = mode; + vmState.regs.es = 0x1000 >> 4; + vmState.regs.edi = 0x0000; - status_t status = vm86_do_int(vmState, 0x10); + status_t status = vm86_do_int(&vmState, 0x10); if (status != B_OK) { dprintf(DEVICE_NAME ": vbe_get_mode_info(%u): vm86 failed\n", mode); return status; } - if ((vmState->regs.eax & 0xffff) != 0x4f) { + if ((vmState.regs.eax & 0xffff) != 0x4f) { dprintf(DEVICE_NAME ": vbe_get_mode_info(): BIOS returned 0x%04lx\n", - vmState->regs.eax & 0xffff); + vmState.regs.eax & 0xffff); return B_ENTRY_NOT_FOUND; } @@ -73,20 +73,20 @@ static status_t -vbe_set_mode(struct vm86_state *vmState, uint16 mode) +vbe_set_mode(struct vm86_state& vmState, uint16 mode) { - vmState->regs.eax = 0x4f02; - vmState->regs.ebx = (mode & SET_MODE_MASK) | SET_MODE_LINEAR_BUFFER; + vmState.regs.eax = 0x4f02; + vmState.regs.ebx = (mode & SET_MODE_MASK) | SET_MODE_LINEAR_BUFFER; - status_t status = vm86_do_int(vmState, 0x10); + status_t status = vm86_do_int(&vmState, 0x10); if (status != B_OK) { dprintf(DEVICE_NAME ": vbe_set_mode(%u): vm86 failed\n", mode); return status; } - if ((vmState->regs.eax & 0xffff) != 0x4f) { + if ((vmState.regs.eax & 0xffff) != 0x4f) { dprintf(DEVICE_NAME ": vbe_set_mode(): BIOS returned 0x%04lx\n", - vmState->regs.eax & 0xffff); + vmState.regs.eax & 0xffff); return B_ERROR; } @@ -94,26 +94,84 @@ } +static uint32 +vbe_to_system_dpms(uint8 vbeMode) +{ + uint32 mode = 0; + if ((vbeMode & (DPMS_OFF | DPMS_REDUCED_ON)) != 0) + mode |= B_DPMS_OFF; + if ((vbeMode & DPMS_STANDBY) != 0) + mode |= B_DPMS_STAND_BY; + if ((vbeMode & DPMS_SUSPEND) != 0) + mode |= B_DPMS_SUSPEND; + + return mode; +} + + +static status_t +vbe_get_dpms_capabilities(uint32& vbeMode, uint32& mode) +{ + // we always return a valid mode + vbeMode = 0; + mode = B_DPMS_ON; + + // Prepare vm86 mode environment + struct vm86_state vmState; + status_t status = vm86_prepare(&vmState, 0x20000); + if (status != B_OK) { + dprintf(DEVICE_NAME": vbe_get_dpms_capabilities(): vm86_prepare " + "failed: %s\n", strerror(status)); + return status; + } + + vmState.regs.eax = 0x4f10; + vmState.regs.ebx = 0; + vmState.regs.esi = 0; + vmState.regs.edi = 0; + + status = vm86_do_int(&vmState, 0x10); + if (status != B_OK) { + dprintf(DEVICE_NAME ": vbe_get_dpms_capabilities(): vm86 failed\n"); + goto out; + } + + if ((vmState.regs.eax & 0xffff) != 0x4f) { + dprintf(DEVICE_NAME ": vbe_get_dpms_capabilities(): BIOS returned " + "0x%04lx\n", vmState.regs.eax & 0xffff); + status = B_ERROR; + goto out; + } + + vbeMode = vmState.regs.ebx >> 8; + mode = vbe_to_system_dpms(vbeMode); + +out: + vm86_cleanup(&vmState); + return status; +} + + // #pragma mark - status_t -vesa_init(vesa_info &info) +vesa_init(vesa_info& info) { - frame_buffer_boot_info *bufferInfo - = (frame_buffer_boot_info *)get_boot_item(FRAME_BUFFER_BOOT_INFO, NULL); + frame_buffer_boot_info* bufferInfo + = (frame_buffer_boot_info*)get_boot_item(FRAME_BUFFER_BOOT_INFO, NULL); if (bufferInfo == NULL) return B_ERROR; size_t modesSize = 0; - vesa_mode *modes = (vesa_mode *)get_boot_item(VESA_MODES_BOOT_INFO, + vesa_mode* modes = (vesa_mode*)get_boot_item(VESA_MODES_BOOT_INFO, &modesSize); info.modes = modes; size_t sharedSize = (sizeof(vesa_shared_info) + 7) & ~7; info.shared_area = create_area("vesa shared info", - (void **)&info.shared_info, B_ANY_KERNEL_ADDRESS, + (void**)&info.shared_info, B_ANY_KERNEL_ADDRESS, ROUND_TO_PAGE_SIZE(sharedSize + modesSize), B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_USER_CLONEABLE_AREA); if (info.shared_area < B_OK) @@ -131,7 +189,7 @@ } sharedInfo.frame_buffer_area = bufferInfo->area; - sharedInfo.frame_buffer = (uint8 *)bufferInfo->frame_buffer; + sharedInfo.frame_buffer = (uint8*)bufferInfo->frame_buffer; sharedInfo.current_mode.virtual_width = bufferInfo->width; sharedInfo.current_mode.virtual_height = bufferInfo->height; @@ -140,17 +198,19 @@ sharedInfo.bytes_per_row = bufferInfo->bytes_per_row; // TODO: we might want to do this via vm86 instead - edid1_info *edidInfo = (edid1_info *)get_boot_item(VESA_EDID_BOOT_INFO, + edid1_info* edidInfo = (edid1_info*)get_boot_item(VESA_EDID_BOOT_INFO, NULL); if (edidInfo != NULL) { sharedInfo.has_edid = true; memcpy(&sharedInfo.edid_info, edidInfo, sizeof(edid1_info)); } + vbe_get_dpms_capabilities(info.vbe_dpms_capabilities, + sharedInfo.dpms_capabilities); + physical_entry mapping; - get_memory_map((void *)sharedInfo.frame_buffer, B_PAGE_SIZE, - &mapping, 1); - sharedInfo.physical_frame_buffer = (uint8 *)mapping.address; + get_memory_map((void*)sharedInfo.frame_buffer, B_PAGE_SIZE, &mapping, 1); + sharedInfo.physical_frame_buffer = (uint8*)mapping.address; dprintf(DEVICE_NAME ": vesa_init() completed successfully!\n"); return B_OK; @@ -158,7 +218,7 @@ void -vesa_uninit(vesa_info &info) +vesa_uninit(vesa_info& info) { dprintf(DEVICE_NAME": vesa_uninit()\n"); @@ -168,7 +228,7 @@ status_t -vesa_set_display_mode(vesa_info &info, unsigned int mode) +vesa_set_display_mode(vesa_info& info, uint32 mode) { if (mode >= info.shared_info->vesa_mode_count) return B_ENTRY_NOT_FOUND; @@ -181,43 +241,42 @@ return status; } - area_id newFBArea; - frame_buffer_boot_info *bufferInfo; + area_id frameBufferArea; + frame_buffer_boot_info* bufferInfo; struct vbe_mode_info modeInfo; // Get mode information - status = vbe_get_mode_info(&vmState, info.modes[mode].mode, &modeInfo); + status = vbe_get_mode_info(vmState, info.modes[mode].mode, &modeInfo); if (status != B_OK) { dprintf(DEVICE_NAME": vesa_set_display_mode(): cannot get mode info\n"); - goto error; + goto out; } // Set mode - status = vbe_set_mode(&vmState, info.modes[mode].mode); + status = vbe_set_mode(vmState, info.modes[mode].mode); if (status != B_OK) { dprintf(DEVICE_NAME": vesa_set_display_mode(): cannot set mode\n"); - goto error; + goto out; } // Map new frame buffer - void *frameBuffer; - newFBArea = map_physical_memory("vesa_fb", - (void *)modeInfo.physical_base, - modeInfo.bytes_per_row * modeInfo.height, B_ANY_KERNEL_ADDRESS, - B_READ_AREA | B_WRITE_AREA, &frameBuffer); - if (newFBArea < B_OK) { - status = (status_t)newFBArea; - goto error; + void* frameBuffer; + frameBufferArea = map_physical_memory("vesa_fb", + (void*)modeInfo.physical_base, modeInfo.bytes_per_row * modeInfo.height, + B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA, &frameBuffer); + if (frameBufferArea < B_OK) { + status = (status_t)frameBufferArea; + goto out; } delete_area(info.shared_info->frame_buffer_area); // Turn on write combining for the area - vm_set_area_memory_type(newFBArea, modeInfo.physical_base, B_MTR_WC); + vm_set_area_memory_type(frameBufferArea, modeInfo.physical_base, B_MTR_WC); // Update shared frame buffer information - info.shared_info->frame_buffer_area = newFBArea; - info.shared_info->frame_buffer = (uint8 *)frameBuffer; - info.shared_info->physical_frame_buffer = (uint8 *)modeInfo.physical_base; + info.shared_info->frame_buffer_area = frameBufferArea; + info.shared_info->frame_buffer = (uint8*)frameBuffer; + info.shared_info->physical_frame_buffer = (uint8*)modeInfo.physical_base; info.shared_info->bytes_per_row = modeInfo.bytes_per_row; info.shared_info->current_mode.virtual_width = modeInfo.width; info.shared_info->current_mode.virtual_height = modeInfo.height; @@ -226,16 +285,107 @@ // Update boot item as it's used in vesa_init() bufferInfo - = (frame_buffer_boot_info *)get_boot_item(FRAME_BUFFER_BOOT_INFO, NULL); - bufferInfo->area = newFBArea; + = (frame_buffer_boot_info*)get_boot_item(FRAME_BUFFER_BOOT_INFO, NULL); + bufferInfo->area = frameBufferArea; bufferInfo->frame_buffer = (addr_t)frameBuffer; bufferInfo->width = modeInfo.width; bufferInfo->height = modeInfo.height; bufferInfo->depth = modeInfo.bits_per_pixel; bufferInfo->bytes_per_row = modeInfo.bytes_per_row; -error: +out: vm86_cleanup(&vmState); return status; } + +status_t +vesa_get_dpms_mode(vesa_info& info, uint32& mode) +{ + mode = B_DPMS_ON; + // we always return a valid mode + + // Prepare vm86 mode environment + struct vm86_state vmState; + status_t status = vm86_prepare(&vmState, 0x20000); + if (status != B_OK) { + dprintf(DEVICE_NAME": vesa_get_dpms_mode(): vm86_prepare failed: %s\n", + strerror(status)); + return status; + } + + vmState.regs.eax = 0x4f10; + vmState.regs.ebx = 2; + vmState.regs.esi = 0; + vmState.regs.edi = 0; + + status = vm86_do_int(&vmState, 0x10); + if (status != B_OK) { + dprintf(DEVICE_NAME ": vesa_get_dpms_mode(): vm86 failed: %s\n", + strerror(status)); + goto out; + } + + if ((vmState.regs.eax & 0xffff) != 0x4f) { + dprintf(DEVICE_NAME ": vesa_get_dpms_mode(): BIOS returned 0x%04lx\n", + vmState.regs.eax & 0xffff); + status = B_ERROR; + goto out; + } + + mode = vbe_to_system_dpms(vmState.regs.ebx >> 8); + +out: + vm86_cleanup(&vmState); + return status; +} + + +status_t +vesa_set_dpms_mode(vesa_info& info, uint32 mode) +{ + // Only let supported modes through + mode &= info.shared_info->dpms_capabilities; + + uint8 vbeMode = 0; + if ((mode & B_DPMS_OFF) != 0) + vbeMode |= DPMS_OFF | DPMS_REDUCED_ON; + if ((mode & B_DPMS_STAND_BY) != 0) + vbeMode |= DPMS_STANDBY; + if ((mode & B_DPMS_SUSPEND) != 0) + vbeMode |= DPMS_SUSPEND; + + vbeMode &= info.vbe_dpms_capabilities; + + // Prepare vm86 mode environment + struct vm86_state vmState; + status_t status = vm86_prepare(&vmState, 0x20000); + if (status != B_OK) { + dprintf(DEVICE_NAME": vesa_set_dpms_mode(): vm86_prepare failed: %s\n", + strerror(status)); + return status; + } + + vmState.regs.eax = 0x4f10; + vmState.regs.ebx = (vbeMode << 8) | 1; + vmState.regs.esi = 0; + vmState.regs.edi = 0; + + status = vm86_do_int(&vmState, 0x10); + if (status != B_OK) { + dprintf(DEVICE_NAME ": vesa_set_dpms_mode(): vm86 failed: %s\n", + strerror(status)); + goto out; + } + + if ((vmState.regs.eax & 0xffff) != 0x4f) { + dprintf(DEVICE_NAME ": vesa_set_dpms_mode(): BIOS returned 0x%04lx\n", + vmState.regs.eax & 0xffff); + status = B_ERROR; + goto out; + } + +out: + vm86_cleanup(&vmState); + return status; +} Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h 2009-06-05 12:33:22 UTC (rev 30973) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h 2009-06-05 13:03:05 UTC (rev 30974) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef VESA_PRIVATE_H @@ -22,14 +22,17 @@ uint32 cookie_magic; int32 open_count; int32 id; - pci_info *pci; - struct vesa_shared_info *shared_info; + pci_info* pci; + struct vesa_shared_info* shared_info; area_id shared_area; - vesa_mode *modes; + vesa_mode* modes; + uint32 vbe_dpms_capabilities; }; -extern status_t vesa_init(vesa_info &info); -extern void vesa_uninit(vesa_info &info); -extern status_t vesa_set_display_mode(vesa_info &info, unsigned int mode); +extern status_t vesa_init(vesa_info& info); +extern void vesa_uninit(vesa_info& info); +extern status_t vesa_set_display_mode(vesa_info& info, uint32 mode); +extern status_t vesa_get_dpms_mode(vesa_info& info, uint32& mode); +extern status_t vesa_set_dpms_mode(vesa_info& info, uint32 mode); #endif /* VESA_PRIVATE_H */ From ingo_weinhold at gmx.de Fri Jun 5 16:24:07 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 05 Jun 2009 16:24:07 +0200 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <4A2914D0.8030607@gmx.de> References: <542771326-BeMail@zon> <4A29098E.3010501@gmx.de> <4A2914D0.8030607@gmx.de> Message-ID: <20090605162407.907.4@knochen-vm.localdomain> On 2009-06-05 at 14:51:28 [+0200], Stephan A?mus wrote: > Rene Gollent schrieb: > > On Fri, Jun 5, 2009 at 7:03 AM, Stephan A?mus wrote: > >> So when I just move mails from one mail folder into the Trash, could > >> that cause that folder to be "truncated" so that it could mess up data > >> from another folder? Other than that, I don't see a "truncation" > >> operation being involved at all in what I do to trigger the bug that > >> mails disappear from one of my mail folders, so it's probably unrelated, > >> correct? > > > > Most likely unrelated. This particular bug as I understand it would > > essentially be triggered as follows: Some file gets truncated to 0 > > bytes, and its storage is thus freed. Something else then winds up > > getting allocated on the disk in the same spot where those file blocks > > used to be, say, a B+ tree. Then due to the bug, the same blocks where > > that directory was just written to get overwritten with some other > > blocks. Presto, corrupted B+ tree. Requires a pretty specific set of > > circumstances to trigger though, which sound completely different from > > your disappearing email. Correct me if I'm wrong Axel :) > > So what happened if a program overwrites some file's contents, even if > they end up being the same size or larger than before? If opened with O_TRUNC -- which should be the case when overwriting -- it would at least be truncated. Whether it uses the same space on disk supposedly depends on BFS's allocation strategy. Axel certainly knows. > Wouldn't that too > start with a truncate operation depending on how you do it? What about > attributes, were those affected in the same way? I don't really know if > anything that Beam does could fit the situation. Don't forget that Beam writes cache files for the folders. And those should indeed shrink, when you move mails to the trash. Oliver will know how those files are written (overwritten?). CU, Ingo From zooey at hirschkaefer.de Fri Jun 5 17:44:02 2009 From: zooey at hirschkaefer.de (Oliver Tappe) Date: Fri, 05 Jun 2009 17:44:02 +0200 Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20090605162407.907.4@knochen-vm.localdomain> References: <542771326-BeMail@zon> <4A29098E.3010501@gmx.de> <4A2914D0.8030607@gmx.de> <20090605162407.907.4@knochen-vm.localdomain> Message-ID: <20090605174402.3884.4@bepc.1244207272.fake> On 2009-06-05 at 16:24:07 [+0200], Ingo Weinhold wrote: > > On 2009-06-05 at 14:51:28 [+0200], Stephan A?mus wrote: [ ... ] > > Wouldn't that too > > start with a truncate operation depending on how you do it? What about > > attributes, were those affected in the same way? I don't really know if > > anything that Beam does could fit the situation. > > Don't forget that Beam writes cache files for the folders. And those should > indeed shrink, when you move mails to the trash. Oliver will know how those > files are written (overwritten?). Yes, Beam truncates files all over the place, most notably the mentions cache files, which are truncated not only when mails get deleted but also whenever appended actions get integrated into the cache. So I suppose it does depend on how BFS reallocates any blocks freed by those files. cheers, Oliver From axeld at mail.berlios.de Fri Jun 5 17:52:59 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 5 Jun 2009 17:52:59 +0200 Subject: [Haiku-commits] r30975 - in haiku/trunk: headers/private/kernel src/system/kernel/fs src/system/kernel/vm Message-ID: <200906051552.n55FqxBH016759@sheep.berlios.de> Author: axeld Date: 2009-06-05 17:52:58 +0200 (Fri, 05 Jun 2009) New Revision: 30975 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30975&view=rev Modified: haiku/trunk/headers/private/kernel/boot_device.h haiku/trunk/src/system/kernel/fs/vfs_boot.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp Log: * vfs_boot.cpp now also exports gReadOnlyBootDevice which is true when the boot device is actually read-only (even if it's using the write overlay). * Do not create a swap file on a read-only device - this would really be a stupid use of the write overlay (just saw this happening on an older machine). * Made swap_file_{add|delete}() take a const char* path - there was no reason this was writable, and this also avoids casting away the const when adding the default swap file. * Minor cleanup. Modified: haiku/trunk/headers/private/kernel/boot_device.h =================================================================== --- haiku/trunk/headers/private/kernel/boot_device.h 2009-06-05 13:03:05 UTC (rev 30974) +++ haiku/trunk/headers/private/kernel/boot_device.h 2009-06-05 15:52:58 UTC (rev 30975) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_BOOT_DEVICE_H @@ -10,6 +10,7 @@ extern dev_t gBootDevice; +extern bool gReadOnlyBootDevice; // defined in fs/vfs_boot.cpp #endif /* _KERNEL_BOOT_DEVICE_H */ Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2009-06-05 13:03:05 UTC (rev 30974) +++ haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2009-06-05 15:52:58 UTC (rev 30975) @@ -55,15 +55,16 @@ // This can be used by other code to see if there is a boot file system already dev_t gBootDevice = -1; +bool gReadOnlyBootDevice = false; /*! No image was chosen - prefer disks with names like "Haiku", or "System" */ int -compare_image_boot(const void *_a, const void *_b) +compare_image_boot(const void* _a, const void* _b) { - KPartition *a = *(KPartition **)_a; - KPartition *b = *(KPartition **)_b; + KPartition* a = *(KPartition**)_a; + KPartition* b = *(KPartition**)_b; if (a->ContentName() != NULL) { if (b->ContentName() == NULL) @@ -95,13 +96,15 @@ compare_image_boot(). */ static int -compare_cd_boot(const void *_a, const void *_b) +compare_cd_boot(const void* _a, const void* _b) { - KPartition *a = *(KPartition **)_a; - KPartition *b = *(KPartition **)_b; + KPartition* a = *(KPartition**)_a; + KPartition* b = *(KPartition**)_b; - bool aIsCD = a->Type() != NULL && !strcmp(a->Type(), kPartitionTypeDataSession); - bool bIsCD = b->Type() != NULL && !strcmp(b->Type(), kPartitionTypeDataSession); + bool aIsCD = a->Type() != NULL + && !strcmp(a->Type(), kPartitionTypeDataSession); + bool bIsCD = b->Type() != NULL + && !strcmp(b->Type(), kPartitionTypeDataSession); int compare = (int)aIsCD - (int)bIsCD; if (compare != 0) @@ -118,7 +121,7 @@ boot/platform/bios_ia32/devices.cpp (or similar solutions). */ static uint32 -compute_check_sum(KDiskDevice *device, off_t offset) +compute_check_sum(KDiskDevice* device, off_t offset) { char buffer[512]; ssize_t bytesRead = read_pos(device->FD(), offset, buffer, sizeof(buffer)); @@ -128,10 +131,11 @@ if (bytesRead < (ssize_t)sizeof(buffer)) memset(buffer + bytesRead, 0, sizeof(buffer) - bytesRead); - uint32 *array = (uint32 *)buffer; + uint32* array = (uint32*)buffer; uint32 sum = 0; - for (uint32 i = 0; i < (bytesRead + sizeof(uint32) - 1) / sizeof(uint32); i++) { + for (uint32 i = 0; + i < (bytesRead + sizeof(uint32) - 1) / sizeof(uint32); i++) { sum += array[i]; } @@ -181,7 +185,7 @@ bool DiskBootMethod::IsBootDevice(KDiskDevice* device, bool strict) { - disk_identifier *disk; + disk_identifier* disk; int32 diskIdentifierSize; if (fBootVolume.FindData(BOOT_VOLUME_DISK_IDENTIFIER, B_RAW_TYPE, (const void**)&disk, &diskIdentifierSize) != B_OK) { @@ -195,7 +199,8 @@ switch (disk->bus_type) { case PCI_BUS: case LEGACY_BUS: - // TODO: implement this! (and then enable this feature in the boot loader) + // TODO: implement this! (and then enable this feature in the boot + // loader) // (we need a way to get the device_node of a device, then) break; @@ -244,13 +249,13 @@ if (!fBootVolume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) { // the simple case: we can just boot from the selected boot // device - if (partition->Offset() == fBootVolume.GetInt64( - BOOT_VOLUME_PARTITION_OFFSET, 0)) { + if (partition->Offset() + == fBootVolume.GetInt64(BOOT_VOLUME_PARTITION_OFFSET, 0)) { foundForSure = true; return true; } } else { - // for now, we will just collect all BFS volumes + // for now, we will just collect all BFS/ISO9660 volumes if (fMethod == BOOT_METHOD_CD && fBootVolume.GetBool(BOOT_VOLUME_USER_SELECTED, false) && partition->Type() != NULL @@ -272,7 +277,7 @@ void DiskBootMethod::SortPartitions(KPartition** partitions, int32 count) { - qsort(partitions, count, sizeof(KPartition *), + qsort(partitions, count, sizeof(KPartition*), fMethod == BOOT_METHOD_CD ? compare_cd_boot : compare_image_boot); } @@ -287,7 +292,7 @@ The boot code should then just try them one by one. */ static status_t -get_boot_partitions(kernel_args *args, PartitionStack &partitions) +get_boot_partitions(kernel_args* args, PartitionStack& partitions) { const KMessage& bootVolume = args->boot_volume; @@ -295,9 +300,9 @@ bootVolume.Dump(&dprintf); // create boot method - int32 bootMethodType = bootVolume.GetInt32(BOOT_METHOD, - BOOT_METHOD_DEFAULT); -dprintf("get_boot_partitions(): boot method type: %ld\n", bootMethodType); + int32 bootMethodType = bootVolume.GetInt32(BOOT_METHOD, BOOT_METHOD_DEFAULT); + dprintf("get_boot_partitions(): boot method type: %ld\n", bootMethodType); + BootMethod* bootMethod = NULL; switch (bootMethodType) { case BOOT_METHOD_NET: @@ -425,7 +430,7 @@ void -vfs_mount_boot_file_system(kernel_args *args) +vfs_mount_boot_file_system(kernel_args* args) { PartitionStack partitions; status_t status = get_boot_partitions(args, partitions); @@ -436,20 +441,25 @@ panic("did not find any boot partitions!"); } - KPartition *bootPartition; + KPartition* bootPartition; while (partitions.Pop(&bootPartition)) { KPath path; if (bootPartition->GetPath(&path) != B_OK) panic("could not get boot device!\n"); const char *fsName = NULL; - if (strcmp(bootPartition->ContentType(), "ISO9660 File System") == 0) + bool readOnly = false; + if (strcmp(bootPartition->ContentType(), "ISO9660 File System") == 0) { fsName = "iso9660:write_overlay:attribute_overlay"; + readOnly = true; + } TRACE(("trying to mount boot partition: %s\n", path.Path())); gBootDevice = _kern_mount("/boot", path.Path(), fsName, 0, NULL, 0); - if (gBootDevice >= B_OK) + if (gBootDevice >= B_OK) { + gReadOnlyBootDevice = true; break; + } } if (gBootDevice < B_OK) Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2009-06-05 13:03:05 UTC (rev 30974) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2009-06-05 15:52:58 UTC (rev 30975) @@ -1,7 +1,7 @@ /* * Copyright 2008, Zhao Shuai, upczhsh at 163.com. * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold at gmx.de. - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -1006,7 +1007,7 @@ status_t -swap_file_add(char *path) +swap_file_add(const char *path) { // open the file int fd = open(path, O_RDWR | O_NOCACHE, S_IRUSR | S_IWUSR); @@ -1083,7 +1084,7 @@ status_t -swap_file_delete(char *path) +swap_file_delete(const char *path) { vnode *node = NULL; status_t status = vfs_get_vnode_from_path(path, true, &node); @@ -1173,6 +1174,11 @@ void swap_init_post_modules() { + // Never try to create a swap file on a read-only device - when booting + // from CD, the write overlay is used. + if (gReadOnlyBootDevice) + return; + off_t size = 0; void *settings = load_driver_settings("virtual_memory"); @@ -1208,13 +1214,13 @@ close(fd); - error = swap_file_add((char *)"/var/swap"); + error = swap_file_add("/var/swap"); if (error != B_OK) dprintf("Failed to add swap file /var/swap: %s\n", strerror(error)); } -// used by page daemon to free swap space +//! Used by page daemon to free swap space. bool swap_free_page_swap_space(vm_page *page) { From axeld at mail.berlios.de Fri Jun 5 17:59:21 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 5 Jun 2009 17:59:21 +0200 Subject: [Haiku-commits] r30976 - haiku/trunk/data/system/boot Message-ID: <200906051559.n55FxLKH017479@sheep.berlios.de> Author: axeld Date: 2009-06-05 17:59:21 +0200 (Fri, 05 Jun 2009) New Revision: 30976 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30976&view=rev Modified: haiku/trunk/data/system/boot/Bootscript Log: * Improved variable naming. Modified: haiku/trunk/data/system/boot/Bootscript =================================================================== --- haiku/trunk/data/system/boot/Bootscript 2009-06-05 15:52:58 UTC (rev 30975) +++ haiku/trunk/data/system/boot/Bootscript 2009-06-05 15:59:21 UTC (rev 30976) @@ -70,8 +70,8 @@ launchscript $SCRIPTS/SetupEnvironment # If the boot volume is a CD we use another script -iw=`/bin/isvolume -readonly-partition /boot` -if [ "$iw" = "yes" ]; then +isReadOnly=`/bin/isvolume -readonly-partition /boot` +if [ "$isReadOnly" = "yes" ]; then # block the CD tray (avoid accidental ejection) # This option stays 'on' even if we continue booting to the desktop. /bin/eject -b /boot @@ -105,7 +105,7 @@ fi # Now ask the user if he wants to run the Installer or continue to the Desktop. -if [ "$iw" = "yes" ]; then +if [ "$isReadOnly" = "yes" ]; then /bin/alert "Do you wish to run the Installer or continue booting to the Desktop?" "Installer" "Desktop" if [ $? -eq 0 ]; then launchscript $SCRIPTS/Bootscript.cd From axeld at pinc-software.de Fri Jun 5 21:14:26 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 05 Jun 2009 21:14:26 +0200 CEST Subject: [Haiku-commits] r30960 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20090605162407.907.4@knochen-vm.localdomain> Message-ID: <28591685386-BeMail@zon> Ingo Weinhold wrote: > > So what happened if a program overwrites some file's contents, even > > if > > they end up being the same size or larger than before? > If opened with O_TRUNC -- which should be the case when overwriting - > - it > would at least be truncated. Whether it uses the same space on disk > supposedly depends on BFS's allocation strategy. Axel certainly > knows. A data stream allocation would always happen at the same place, but only if that is possible. If there already is a stream in the way, the new one will be created later. And if that earlier stream will be deleted, the new allocation might be at another place. In short: anything can happen. Bye, Axel. From stpere at mail.berlios.de Fri Jun 5 23:23:22 2009 From: stpere at mail.berlios.de (stpere at mail.berlios.de) Date: Fri, 5 Jun 2009 23:23:22 +0200 Subject: [Haiku-commits] r30977 - haiku/trunk/src/preferences/mouse Message-ID: <200906052123.n55LNMiG000438@sheep.berlios.de> Author: stpere Date: 2009-06-05 23:21:06 +0200 (Fri, 05 Jun 2009) New Revision: 30977 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30977&view=rev Removed: haiku/trunk/src/preferences/mouse/MouseBitmap.h Modified: haiku/trunk/src/preferences/mouse/Mouse.rdef haiku/trunk/src/preferences/mouse/MouseView.cpp Log: Load the bitmaps from resources rather than from a byte array in a header. Fixing a TODO in MouseView.cpp This patch was in ticket #3754. (Thanks to Axel for the reminder and thanks to Brecht for your help extracting the images from the header!) Modified: haiku/trunk/src/preferences/mouse/Mouse.rdef =================================================================== --- haiku/trunk/src/preferences/mouse/Mouse.rdef 2009-06-05 15:59:21 UTC (rev 30976) +++ haiku/trunk/src/preferences/mouse/Mouse.rdef 2009-06-05 21:21:06 UTC (rev 30977) @@ -302,3 +302,92 @@ $"8C420000984100008C4200000842430000FF00008C4200000C4200008C420000" $"484200" }; + +resource(604, "mouse_bmap") #'bits' array { + $"89504E470D0A1A0A0000000D4948445200000039000000520806000000EE2B7C" + $"1C000000017352474200AECE1CE900000006624B474400FF00FF00FFA0BDA793" + $"000000097048597300000B1300000B1301009A9C180000000774494D4507D904" + $"0B17142E3075A9E9000007474944415478DAE55CA176E34A0CD5FA0484C59F10" + $"1858D67E46685960616160580B0B0BFD09FD84C2C2C0941926CC6561FBC03BE3" + $"A328F74AB2B3D9D79E6792C68EC7A3917475258DFB6BB7DBFD962B1F4DD3C86A" + $"B5121191CD66D3FF3D9FCFE56F1C95FC0F8E5FD7D464D334F07CDBB6BD36FF86" + $"4627D714F0E9E9895EBFBFBFEF056DDBF6AA825E45934DD3C8CDCD4DF8BBB7B7" + $"371191AB6BF58F0B196930D2EA35047585643EF59D0EBD38837CB208B75C2EBF" + $"BD909BCDE6E433D4A4156EB1585C6D72C7E351A6D3E9E87BBAAE93BAAEA5EB3A" + $"111159AFD7BD66ADB9F742364D7315E13C61D8357BBEEB3A994EA7723C1EE938" + $"E5DAF3F3F319D9383357BD0AB3D9EC6221BD31D8357B3E9AC7E7E7672FEC6AB5" + $"EA1956094D13ADC5F97CDEAFE06C3693AFAFAF9469653582BE1F8F47A9EB1A9E" + $"2BA668EF2F5AB39F45E32EAD2B03CC6633391C0E67E7B30296DF96F3E83B9A50" + $"D7752713F64CD3CEA7FCBEEB3A592E973DBEB46D2B95D6A29E48C6D790206851" + $"EC8A6BF0289F4C284F30FB5C36864BD0F54DD3E9F464A53DAD14EDA28716818A" + $"89B289DB85B1CFD4BF29CFAFEBBA9F0F8C937A80E2E8DA57CA40560BCC67B4AF" + $"216D9705B38BA32D412F1E7397F29BFD7E1F9381F240BB5A7A1122F0B1F7E885" + $"40E6CB0460DFED18FA7CD1E27EBF3FBBBFCA808B36CBF2A9B5AC1FE4F9AF5D04" + $"F45D9F4748EAC5D23207AB8C6A2803F1D08F397EB4801E60A1FBEC73F4770462" + $"D5D08978E8C6263666DC31085F2C8C6A32130FB3146E8845448B63E754B48400" + $"4B447C9FB4AB12810BF2270B24DEC26440C71390B90D5AE4AB953F1822226BC9" + $"98774640661155163CB2020DA17F11C0447342088F9E31413716627E0968D8C0" + $"EEF15C3431E47B568BF63E4D444273B5748E05733BB89D10FADB9A2C03109685" + $"308191BFA78BCB2C605B0767BE8678288A8508603C7231240A8442B2958ED8CA" + $"1870B15A8C7C35EBF7833539368646F14F53330FFCBC6BCC27CF184F1944F347" + $"ED735E9E38445BE81A334FFB1B86092CD69F7157941E6901F5805E29023D4CDF" + $"97D15294246779F7043D68B7DBFD2735545495CB70EABAAE219D83427E7C7CFC" + $"98CAB93D4A19152D4A2FE476BBED857B7D7DFD71423E3C3CD09AF14444E4E5E5" + $"E5443816DF5828F17C8C8189364D66922831463EBC582CFA8232B2C28988C8E3" + $"E3A3DCDEDECAE170804082268180C822A4CDF3509D55331BE48F5EF5BC8CB9DD" + $"6EFBB920617B733D1C0E7DB8B0AB6C611A71C83271DDA32863E9CA9C46EF4C7C" + $"D5F7B2D44B8F57040EC98015C6C620CB31112DB3953D2FF78C2A725E7E9AC95D" + $"27CC571821462C8569C59A21ABC5322D659A3C8C76A668DD9FACD3583291A900" + $"6866C3DA09D6D2422123CE9869ECB0872066E46940FB34BB6EC14DD34F2AA406" + $"8F6C26C2BA48993093613143AB85A92CC4EB243161232D4642793136AA1AB0B0" + $"E60A995D3D1D3658963FB66E8BC24286607873A8BC1562E0A3BB470C4C6C553B" + $"6ADA6404B4097536FFADBC5C8D998A662ED92CC1D37499785DD730EEB21A4FD4" + $"FC3D8B9388CDB0029345E3284EA289977B34AD8BAA102856A3D0E45606B42699" + $"4659239615A150F3B63C27E2ADCC95180086D53A8F41204D46250C1617757375" + $"4821DB03C588DAD1AE96573745B68F80E6129445E18351C2E8A8221AE7D55D51" + $"31D8D3A007221E4BF2B4A9018801DB2422E0ACDB8B5670487DC6EB2267CA90F6" + $"7E6F6EB475E7B507B2DBC88694243DDA57428B87071E11A9B24EEC858B28948C" + $"69CA226D7A69DA45BD10869A8C85B02C652C2869E16CBCCDF2E6CACB34221FCC" + $"80855784F23638E805D41506D6646280E8A22BAB162058CF6AC726C3688CF277" + $"B429902134B2A6CA737C2D1822D943DAE088FD20ADD95D6088E0B3189E46D708" + $"E2197A46E062358834A5358AC64685B50C25A48CC74BB7F4EEA7085C8AF68600" + $"8EC77E50B9236AF8545E29839996AEB17A486C4B932CA388EA3E085133254CAA" + $"49560D1F0A34DA9F581DC66E588CF6BCA27662C675AAA184389B287B714D27DE" + $"1E2563355EA4758F69550CF9A2EDD1511CD4ED864C59F392FA6F1A78BC7D715A" + $"7034982E2ED938171596B38B1891F014F0B02CC46332DA7791EF0DE957A0A01E" + $"9532B35611321E5676C830996833A297B722D28DC031B39D26DC91C59A2FF635" + $"22AB49B4A38A8580689361761B6A6AF7078A732CFBB042587F8E6AA3515E9A49" + $"C33239F0992651AC625A1C92BDB38A41A6B560F7118D39AA4CF269C34AB40533" + $"33F98C4F458BC198142D2E479B65CBB1DFEF21C8B0B4C78B6D430B5DD1BB5FEC" + $"591364AACC3C6DB778A8063D7061C22253CD6C4B3D31D7F57ADDBF401D4D96F5" + $"4A86EC66646126EA7F64626DB9A65FF19FCFE75295D77F501E87B274E453C8DF" + $"B29B0B87D67CC6B09E4AE4DF5764DFDFDF4FCC96B5F1582D05759C325AC8D45F" + $"F5C2D97EA85DD4DD6E17BF095BCC52BFE0C5B4C538E9252FD1780529AF5AE1B9" + $"CCC98BDBE50DEFBBBB3BB8D533B33D2CF382E8986A5FF4BBB66DA558A5D6E299" + $"905A586FD761C43E2E6D210C39AC7056402AA4D6EA773FEC3F5340FF6DC2FD8F" + $"1165957EC2E1FD2B8D6AEC8DDF49B8689EFF005C55DCD2263C579C0000000049" + $"454E44AE426082" +}; + +resource(605, "pressed_mouse_bmap") #'bits' array { + $"89504E470D0A1A0A0000000D49484452000000380000001D0802000000708538" + $"CC000000017352474200AECE1CE9000000097048597300000B1300000B130100" + $"9A9C180000000774494D4507D9040B162E2CFA107C8B000001E54944415458C3" + $"CD58BBB583300C557C285452B241283382BB64848C4049999211283342CA9494" + $"E9B242CA8CE0D2E52BF4A2A3671BE30789830A8EB1FCB95C5D19C1E6F1788067" + $"4DD320A2B536FFF57C3EFB78B6DB6D118478381CE04B763C1E01E072B938FD1B" + $"6694206AAD01A02C4B7F097AE2F4FEB8CBF71A63CAB234C630D0BEEFABAA2246" + $"7F81364D432C12C420D06CF67C3EA971BD5EBBAE0380FD7EFF27F48C921E2B83" + $"C537D25A775D475815D319448988EF8542B7E665E91395C3A8E31E13E53C888C" + $"3271AE3166B7DB9D4E27005092CE441BCB0F1F81E46F6128D4E4A0B1ED27C99B" + $"9D91B41A4D67528AE050DE43EE1764452E4A571E362F237D7990D28A389D1156" + $"E2AC2F4C3BCA16FBB2D1D0073340825E12D974D088C889ABE685E35D2CC6E3C3" + $"74A602FD8A51993291F5996D2C38B25FAD0DE5D87B51AD16256B94E0AA55455C" + $"9E248E468BCF25F2124572B5CA35ABFA57DDF5169B3C80E5A9F4B5D0CB57EE24" + $"4192D12233D0F4AA5C7EF465051AC1177421A23126ACD18F0A34224DDF25651A" + $"AEF0F3336AADF55D14EED8F124E73827D9C2FEF470C9C1018DD247EA300C2C0B" + $"A791B3BFAA2AE7990B4649106FB7DB1ACA14FA0F52D735A3DF68AD29B9866160" + $"01904FCA99DBC19239D8C909E11016F9C22124F4770411DBB6A5C6FD7EFF01F7" + $"2616EDC24D58E30000000049454E44AE426082" +}; + Deleted: haiku/trunk/src/preferences/mouse/MouseBitmap.h Modified: haiku/trunk/src/preferences/mouse/MouseView.cpp =================================================================== --- haiku/trunk/src/preferences/mouse/MouseView.cpp 2009-06-05 15:59:21 UTC (rev 30976) +++ haiku/trunk/src/preferences/mouse/MouseView.cpp 2009-06-05 21:21:06 UTC (rev 30977) @@ -6,6 +6,7 @@ * J?r?me Duval, * Andrew McCall (mccall at digitalparadise.co.uk) * Axel D?rfler (axeld at pinc-software.de) + * Philippe Saint-Pierre stpere at gmail.com */ #include "MouseView.h" @@ -21,9 +22,9 @@ #include #include #include +#include #include -#include "MouseBitmap.h" #include "MouseConstants.h" #include "MouseSettings.h" #include "MouseWindow.h" @@ -83,16 +84,9 @@ fButtons(0), fOldButtons(0) { - fMouseBitmap = new BBitmap(BRect(0, 0, kMouseWidth - 1, kMouseHeight - 1), B_CMAP8); - fMouseBitmap->SetBits(kMouseBits, sizeof(kMouseBits), 0, kMouseColorSpace); + fMouseBitmap = BTranslationUtils::GetBitmap("mouse_bmap"); + fMouseDownBitmap = BTranslationUtils::GetBitmap("pressed_mouse_bmap"); - fMouseDownBitmap = new BBitmap(BRect(0, 0, kMouseDownWidth - 1, kMouseDownHeight - 1), B_CMAP8); - fMouseDownBitmap->SetBits(kMouseDownBits, sizeof(kMouseDownBits), 0, kMouseDownColorSpace); - - // ToDo: move these images to the resources as well - //fMouseBitmap = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "mouse_bmap"); - //fMouseDownBitmap = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "pressed_mouse_bmap"); - fMouseDownBounds = fMouseDownBitmap->Bounds(); SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); } From leavengood at mail.berlios.de Sat Jun 6 01:21:54 2009 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sat, 6 Jun 2009 01:21:54 +0200 Subject: [Haiku-commits] r30978 - haiku/trunk/src/data/beos_mime/text Message-ID: <200906052321.n55NLsrB029959@sheep.berlios.de> Author: leavengood Date: 2009-06-06 01:21:53 +0200 (Sat, 06 Jun 2009) New Revision: 30978 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30978&view=rev Modified: haiku/trunk/src/data/beos_mime/text/x-source-code Log: Added Eiffel, Rexx and Ruby file extensions to source code file type. Modified: haiku/trunk/src/data/beos_mime/text/x-source-code =================================================================== --- haiku/trunk/src/data/beos_mime/text/x-source-code 2009-06-05 21:21:06 UTC (rev 30977) +++ haiku/trunk/src/data/beos_mime/text/x-source-code 2009-06-05 23:21:53 UTC (rev 30978) @@ -16,6 +16,7 @@ "extensions" = "c", "extensions" = "cc", "extensions" = "cpp", + "extensions" = "e", "extensions" = "h", "extensions" = "h++", "extensions" = "inc", @@ -24,6 +25,8 @@ "extensions" = "pl", "extensions" = "pp", "extensions" = "py", + "extensions" = "rb", + "extensions" = "rexx", "extensions" = "S", "type" = "text/x-source-code" }; From joe.prostko+haiku at gmail.com Sat Jun 6 03:51:11 2009 From: joe.prostko+haiku at gmail.com (Joseph Prostko) Date: Sat, 6 Jun 2009 01:51:11 +0000 Subject: [Haiku-commits] r30573 - haiku/trunk/build/jam In-Reply-To: <20090502211108.1534.2@bee.hirschkaefer.site> References: <200905021539.n42Fdok8022021@sheep.berlios.de> <20090502211108.1534.2@bee.hirschkaefer.site> Message-ID: <7e5795b0906051851x55b404e1nf8731affe9aed1c4@mail.gmail.com> On Sat, May 2, 2009 at 7:11 PM, Oliver Tappe wrote: > > On 2009-05-02 at 18:40:42 [+0200], Michael Weirauch wrote: >> 2009/5/2 zooey at BerliOS : >> > Author: zooey >> > Date: 2009-05-02 17:39:49 +0200 (Sat, 02 May 2009) >> > New Revision: 30573 >> > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30573&view=rev >> > >> > Modified: >> > haiku/trunk/build/jam/HaikuImage >> > Log: >> > * now that it builds for gcc4 and gcc2, added locale kit back to image >> >> Can it be that $(TARGET_LIBSTDC++) is required in the Jamfile? Getting >> undefined reference to `std::__throw_bad_alloc()' >> on gcc4 native install. > > Possible - but what target triggered the error? > I know this conversation is over a month old, but I just filed a related ticket. Please see ticket 4003. The fix is to add a $(TARGET_LIBSTDC++) to the linkcatkeys line of the locale Jamfile. - joe From stippi at mail.berlios.de Sat Jun 6 12:35:26 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 6 Jun 2009 12:35:26 +0200 Subject: [Haiku-commits] r30979 - in haiku/trunk/src: apps/cdplayer bin/locale kits/bluetooth Message-ID: <200906061035.n56AZQDw007824@sheep.berlios.de> Author: stippi Date: 2009-06-06 12:35:14 +0200 (Sat, 06 Jun 2009) New Revision: 30979 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30979&view=rev Modified: haiku/trunk/src/apps/cdplayer/Jamfile haiku/trunk/src/bin/locale/Jamfile haiku/trunk/src/kits/bluetooth/Jamfile Log: Patch by Joe Prostko: Add linking to libstdc++ in some places, which is necessary when compiling the code for example with -O1 or with the upcomming GCC 4.4. Thanks a lot! Modified: haiku/trunk/src/apps/cdplayer/Jamfile =================================================================== --- haiku/trunk/src/apps/cdplayer/Jamfile 2009-06-05 23:21:53 UTC (rev 30978) +++ haiku/trunk/src/apps/cdplayer/Jamfile 2009-06-06 10:35:14 UTC (rev 30979) @@ -13,6 +13,7 @@ TwoStateDrawButton.cpp VolumeSlider.cpp - : be $(TARGET_SELECT_UNAME_ETC_LIB) $(TARGET_NETAPI_LIB) translation textencoding + : be $(TARGET_SELECT_UNAME_ETC_LIB) $(TARGET_NETAPI_LIB) $(TARGET_LIBSTDC++) + translation textencoding : CDPlayer.rdef ; Modified: haiku/trunk/src/bin/locale/Jamfile =================================================================== --- haiku/trunk/src/bin/locale/Jamfile 2009-06-05 23:21:53 UTC (rev 30978) +++ haiku/trunk/src/bin/locale/Jamfile 2009-06-06 10:35:14 UTC (rev 30979) @@ -6,6 +6,6 @@ BinCommand collectcatkeys : collectcatkeys.cpp RegExp.cpp : be liblocale.so ; -BinCommand linkcatkeys : linkcatkeys.cpp : be liblocale.so ; +BinCommand linkcatkeys : linkcatkeys.cpp : be liblocale.so $(TARGET_LIBSTDC++) ; BinCommand dumpcatalog : dumpcatalog.cpp : be liblocale.so ; Modified: haiku/trunk/src/kits/bluetooth/Jamfile =================================================================== --- haiku/trunk/src/kits/bluetooth/Jamfile 2009-06-05 23:21:53 UTC (rev 30978) +++ haiku/trunk/src/kits/bluetooth/Jamfile 2009-06-06 10:35:14 UTC (rev 30979) @@ -24,5 +24,5 @@ #UI PincodeWindow.cpp ConnectionIncoming.cpp - : be + : be $(TARGET_LIBSTDC++) ; From axeld at mail.berlios.de Sat Jun 6 13:23:19 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 6 Jun 2009 13:23:19 +0200 Subject: [Haiku-commits] r30980 - in haiku/trunk: headers/os/support src/kits/support Message-ID: <200906061123.n56BNJ5v027688@sheep.berlios.de> Author: axeld Date: 2009-06-06 13:23:17 +0200 (Sat, 06 Jun 2009) New Revision: 30980 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30980&view=rev Modified: haiku/trunk/headers/os/support/String.h haiku/trunk/src/kits/support/String.cpp Log: * Fixed a race condition in the former _Detach*() functions: since atomic_get() was used, two different threads could decide to share the same mutable string. * Renamed some functions to make clearer what they do, ie. _Detach() is now called _MakeWritable(). * Cleaned up some questionable semantics, like the const char* parameter in _DetachWith() - you can now choose to copy the original string or not with a boolean. This also makes sure that the string is actually copied when it has to, which wasn't the case before (but that was no problem with the way that function was used). * Made the header compliant with our style guide. * Further cleanup. * All BString related unit tests are passed, so I guess I didn't break too much :-) Modified: haiku/trunk/headers/os/support/String.h =================================================================== --- haiku/trunk/headers/os/support/String.h 2009-06-06 10:35:14 UTC (rev 30979) +++ haiku/trunk/headers/os/support/String.h 2009-06-06 11:23:17 UTC (rev 30980) @@ -1,5 +1,5 @@ /* -* Copyright 2001-2008, Haiku Inc. All Rights Reserved. +* Copyright 2001-2009, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef __BSTRING__ @@ -16,251 +16,281 @@ class BString { public: - BString(); - BString(const char* string); - BString(const BString& string); - BString(const char* string, int32 maxLength); - ~BString(); + BString(); + BString(const char* string); + BString(const BString& string); + BString(const char* string, int32 maxLength); + ~BString(); - // Access - const char* String() const; - int32 Length() const; - int32 CountChars() const; + // Access + const char* String() const; + int32 Length() const; + int32 CountChars() const; - // Assignment - BString& operator=(const BString& string); - BString& operator=(const char* string); - BString& operator=(char c); + // Assignment + BString& operator=(const BString& string); + BString& operator=(const char* string); + BString& operator=(char c); - BString& SetTo(const char* string); - BString& SetTo(const char* string, int32 maxLength); + BString& SetTo(const char* string); + BString& SetTo(const char* string, int32 maxLength); - BString& SetTo(const BString& string); - BString& Adopt(BString& from); + BString& SetTo(const BString& string); + BString& Adopt(BString& from); - BString& SetTo(const BString& string, int32 maxLength); - BString& Adopt(BString& from, int32 maxLength); + BString& SetTo(const BString& string, int32 maxLength); + BString& Adopt(BString& from, int32 maxLength); - BString& SetTo(char c, int32 count); + BString& SetTo(char c, int32 count); - // Substring copying - BString& CopyInto(BString& into, int32 fromOffset, int32 length) const; - void CopyInto(char* into, int32 fromOffset, int32 length) const; + // Substring copying + BString& CopyInto(BString& into, int32 fromOffset, + int32 length) const; + void CopyInto(char* into, int32 fromOffset, + int32 length) const; - // Appending - BString& operator+=(const BString& string); - BString& operator+=(const char* string); - BString& operator+=(char c); + // Appending + BString& operator+=(const BString& string); + BString& operator+=(const char* string); + BString& operator+=(char c); - BString& Append(const BString& string); - BString& Append(const char* string); + BString& Append(const BString& string); + BString& Append(const char* string); - BString& Append(const BString& string, int32 length); - BString& Append(const char* string, int32 length); - BString& Append(char c, int32 count); + BString& Append(const BString& string, int32 length); + BString& Append(const char* string, int32 length); + BString& Append(char c, int32 count); - // Prepending - BString& Prepend(const char* string); - BString& Prepend(const BString& string); - BString& Prepend(const char* string, int32 length); - BString& Prepend(const BString& string, int32 length); - BString& Prepend(char c, int32 count); + // Prepending + BString& Prepend(const char* string); + BString& Prepend(const BString& string); + BString& Prepend(const char* string, int32 length); + BString& Prepend(const BString& string, int32 length); + BString& Prepend(char c, int32 count); - // Inserting - BString& Insert(const char* string, int32 position); - BString& Insert(const char* string, int32 length, int32 position); - BString& Insert(const char* string, int32 fromOffset, int32 length, - int32 position); - BString& Insert(const BString& string, int32 position); - BString& Insert(const BString& string, int32 length, int32 position); - BString& Insert(const BString& string, int32 fromOffset, int32 length, - int32 position); - BString& Insert(char c, int32 count, int32 position); + // Inserting + BString& Insert(const char* string, int32 position); + BString& Insert(const char* string, int32 length, + int32 position); + BString& Insert(const char* string, int32 fromOffset, + int32 length, int32 position); + BString& Insert(const BString& string, int32 position); + BString& Insert(const BString& string, int32 length, + int32 position); + BString& Insert(const BString& string, int32 fromOffset, + int32 length, int32 position); + BString& Insert(char c, int32 count, int32 position); - // Removing - BString& Truncate(int32 newLength, bool lazy = true); - BString& Remove(int32 from, int32 length); + // Removing + BString& Truncate(int32 newLength, bool lazy = true); + BString& Remove(int32 from, int32 length); - BString& RemoveFirst(const BString& string); - BString& RemoveLast(const BString& string); - BString& RemoveAll(const BString& string); + BString& RemoveFirst(const BString& string); + BString& RemoveLast(const BString& string); + BString& RemoveAll(const BString& string); - BString& RemoveFirst(const char* string); - BString& RemoveLast(const char* string); - BString& RemoveAll(const char* string); + BString& RemoveFirst(const char* string); + BString& RemoveLast(const char* string); + BString& RemoveAll(const char* string); - BString& RemoveSet(const char* setOfCharsToRemove); + BString& RemoveSet(const char* setOfCharsToRemove); - BString& MoveInto(BString& into, int32 from, int32 length); - void MoveInto(char* into, int32 from, int32 length); + BString& MoveInto(BString& into, int32 from, int32 length); + void MoveInto(char* into, int32 from, int32 length); - // Compare functions - bool operator<(const BString& string) const; - bool operator<=(const BString& string) const; - bool operator==(const BString& string) const; - bool operator>=(const BString& string) const; - bool operator>(const BString& string) const; - bool operator!=(const BString& string) const; + // Compare functions + bool operator<(const BString& string) const; + bool operator<=(const BString& string) const; + bool operator==(const BString& string) const; + bool operator>=(const BString& string) const; + bool operator>(const BString& string) const; + bool operator!=(const BString& string) const; - bool operator<(const char* string) const; - bool operator<=(const char* string) const; - bool operator==(const char* string) const; - bool operator>=(const char* string) const; - bool operator>(const char* string) const; - bool operator!=(const char* string) const; + bool operator<(const char* string) const; + bool operator<=(const char* string) const; + bool operator==(const char* string) const; + bool operator>=(const char* string) const; + bool operator>(const char* string) const; + bool operator!=(const char* string) const; - // strcmp()-style compare functions - int Compare(const BString& string) const; - int Compare(const char* string) const; - int Compare(const BString& string, int32 length) const; - int Compare(const char* string, int32 length) const; - int ICompare(const BString& string) const; - int ICompare(const char* string) const; - int ICompare(const BString& string, int32 length) const; - int ICompare(const char* string, int32 length) const; + // strcmp()-style compare functions + int Compare(const BString& string) const; + int Compare(const char* string) const; + int Compare(const BString& string, int32 length) const; + int Compare(const char* string, int32 length) const; + int ICompare(const BString& string) const; + int ICompare(const char* string) const; + int ICompare(const BString& string, int32 length) const; + int ICompare(const char* string, int32 length) const; - // Searching - int32 FindFirst(const BString& string) const; - int32 FindFirst(const char* string) const; - int32 FindFirst(const BString& string, int32 fromOffset) const; - int32 FindFirst(const char* string, int32 fromOffset) const; - int32 FindFirst(char c) const; - int32 FindFirst(char c, int32 fromOffset) const; + // Searching + int32 FindFirst(const BString& string) const; + int32 FindFirst(const char* string) const; + int32 FindFirst(const BString& string, + int32 fromOffset) const; + int32 FindFirst(const char* string, + int32 fromOffset) const; + int32 FindFirst(char c) const; + int32 FindFirst(char c, int32 fromOffset) const; - int32 FindLast(const BString& string) const; - int32 FindLast(const char* string) const; - int32 FindLast(const BString& string, int32 beforeOffset) const; - int32 FindLast(const char* string, int32 beforeOffset) const; - int32 FindLast(char c) const; - int32 FindLast(char c, int32 beforeOffset) const; + int32 FindLast(const BString& string) const; + int32 FindLast(const char* string) const; + int32 FindLast(const BString& string, + int32 beforeOffset) const; + int32 FindLast(const char* string, + int32 beforeOffset) const; + int32 FindLast(char c) const; + int32 FindLast(char c, int32 beforeOffset) const; - int32 IFindFirst(const BString& string) const; - int32 IFindFirst(const char* string) const; - int32 IFindFirst(const BString& string, int32 fromOffset) const; - int32 IFindFirst(const char* string, int32 fromOffset) const; + int32 IFindFirst(const BString& string) const; + int32 IFindFirst(const char* string) const; + int32 IFindFirst(const BString& string, + int32 fromOffset) const; + int32 IFindFirst(const char* string, + int32 fromOffset) const; - int32 IFindLast(const BString& string) const; - int32 IFindLast(const char* string) const; - int32 IFindLast(const BString& string, int32 beforeOffset) const; - int32 IFindLast(const char* string, int32 beforeOffset) const; + int32 IFindLast(const BString& string) const; + int32 IFindLast(const char* string) const; + int32 IFindLast(const BString& string, + int32 beforeOffset) const; + int32 IFindLast(const char* string, + int32 beforeOffset) const; - // Replacing - BString& ReplaceFirst(char replaceThis, char withThis); - BString& ReplaceLast(char replaceThis, char withThis); - BString& ReplaceAll(char replaceThis, char withThis, int32 fromOffset = 0); - BString& Replace(char replaceThis, char withThis, int32 maxReplaceCount, - int32 fromOffset = 0); - BString& ReplaceFirst(const char* replaceThis, const char* withThis); - BString& ReplaceLast(const char* replaceThis, const char* withThis); - BString& ReplaceAll(const char* replaceThis, const char* withThis, - int32 fromOffset = 0); - BString& Replace(const char* replaceThis, const char* withThis, - int32 maxReplaceCount, int32 fromOffset = 0); + // Replacing + BString& ReplaceFirst(char replaceThis, char withThis); + BString& ReplaceLast(char replaceThis, char withThis); + BString& ReplaceAll(char replaceThis, char withThis, + int32 fromOffset = 0); + BString& Replace(char replaceThis, char withThis, + int32 maxReplaceCount, int32 fromOffset = 0); + BString& ReplaceFirst(const char* replaceThis, + const char* withThis); + BString& ReplaceLast(const char* replaceThis, + const char* withThis); + BString& ReplaceAll(const char* replaceThis, + const char* withThis, int32 fromOffset = 0); + BString& Replace(const char* replaceThis, + const char* withThis, int32 maxReplaceCount, + int32 fromOffset = 0); - BString& IReplaceFirst(char replaceThis, char withThis); - BString& IReplaceLast(char replaceThis, char withThis); - BString& IReplaceAll(char replaceThis, char withThis, int32 fromOffset = 0); - BString& IReplace(char replaceThis, char withThis, int32 maxReplaceCount, - int32 fromOffset = 0); - BString& IReplaceFirst(const char* replaceThis, const char* withThis); - BString& IReplaceLast(const char* replaceThis, const char* withThis); - BString& IReplaceAll(const char* replaceThis, const char* withThis, - int32 fromOffset = 0); - BString& IReplace(const char* replaceThis, const char* withThis, - int32 maxReplaceCount, int32 fromOffset = 0); + BString& IReplaceFirst(char replaceThis, char withThis); + BString& IReplaceLast(char replaceThis, char withThis); + BString& IReplaceAll(char replaceThis, char withThis, + int32 fromOffset = 0); + BString& IReplace(char replaceThis, char withThis, + int32 maxReplaceCount, int32 fromOffset = 0); + BString& IReplaceFirst(const char* replaceThis, + const char* withThis); + BString& IReplaceLast(const char* replaceThis, + const char* withThis); + BString& IReplaceAll(const char* replaceThis, + const char* withThis, int32 fromOffset = 0); + BString& IReplace(const char* replaceThis, + const char* withThis, int32 maxReplaceCount, + int32 fromOffset = 0); - BString& ReplaceSet(const char* setOfChars, char with); - BString& ReplaceSet(const char* setOfChars, const char* with); + BString& ReplaceSet(const char* setOfChars, char with); + BString& ReplaceSet(const char* setOfChars, const char* with); - // Unchecked char access - char operator[](int32 index) const; + // Unchecked char access + char operator[](int32 index) const; #if __GNUC__ > 3 - BStringRef operator[](int32 index); + BStringRef operator[](int32 index); #else - char& operator[](int32 index); + char& operator[](int32 index); #endif - // Checked char access - char ByteAt(int32 index) const; + // Checked char access + char ByteAt(int32 index) const; - // Fast low-level manipulation - char* LockBuffer(int32 maxLength); - BString& UnlockBuffer(int32 length = -1); + // Fast low-level manipulation + char* LockBuffer(int32 maxLength); + BString& UnlockBuffer(int32 length = -1); - // Upercase <-> Lowercase - BString& ToLower(); - BString& ToUpper(); + // Upercase <-> Lowercase + BString& ToLower(); + BString& ToUpper(); - BString& Capitalize(); - BString& CapitalizeEachWord(); + BString& Capitalize(); + BString& CapitalizeEachWord(); - // Escaping and De-escaping - BString& CharacterEscape(const char* original, const char* setOfCharsToEscape, - char escapeWith); - BString& CharacterEscape(const char* setOfCharsToEscape, char escapeWith); - BString& CharacterDeescape(const char* original, char escapeChar); - BString& CharacterDeescape(char escapeChar); + // Escaping and De-escaping + BString& CharacterEscape(const char* original, + const char* setOfCharsToEscape, char escapeWith); + BString& CharacterEscape(const char* setOfCharsToEscape, + char escapeWith); + BString& CharacterDeescape(const char* original, + char escapeChar); + BString& CharacterDeescape(char escapeChar); - // Insert - BString& operator<<(const char* string); - BString& operator<<(const BString& string); - BString& operator<<(char c); - BString& operator<<(int value); - BString& operator<<(unsigned int value); - BString& operator<<(uint32 value); - BString& operator<<(int32 value); - BString& operator<<(uint64 value); - BString& operator<<(int64 value); - // float output hardcodes %.2f style formatting - BString& operator<<(float value); + // Insert + BString& operator<<(const char* string); + BString& operator<<(const BString& string); + BString& operator<<(char c); + BString& operator<<(int value); + BString& operator<<(unsigned int value); + BString& operator<<(uint32 value); + BString& operator<<(int32 value); + BString& operator<<(uint64 value); + BString& operator<<(int64 value); + // float output hardcodes %.2f style formatting + BString& operator<<(float value); private: class PosVect; friend class BStringRef; - // Management - status_t _Detach(); - char* _Alloc(int32 length, bool adoptReferenceCount = true); - char* _Realloc(int32 length); - void _Init(const char* src, int32 length); - char* _Clone(const char* data, int32 length); - char* _OpenAtBy(int32 offset, int32 length); - char* _ShrinkAtBy(int32 offset, int32 length); - status_t _DetachWith(const char* string, int32 length); + // Management + status_t _MakeWritable(); + status_t _MakeWritable(int32 length, bool copy); + char* _Allocate(int32 length); + char* _Resize(int32 length); + void _Init(const char* src, int32 length); + char* _Clone(const char* data, int32 length); + char* _OpenAtBy(int32 offset, int32 length); + char* _ShrinkAtBy(int32 offset, int32 length); - // Data - void _SetLength(int32 length); - bool _DoAppend(const char* string, int32 length); - bool _DoPrepend(const char* string, int32 length); - bool _DoInsert(const char* string, int32 offset, int32 length); + // Data + void _SetLength(int32 length); + bool _DoAppend(const char* string, int32 length); + bool _DoPrepend(const char* string, int32 length); + bool _DoInsert(const char* string, int32 offset, + int32 length); - // Search - int32 _ShortFindAfter(const char* string, int32 len) const; - int32 _FindAfter(const char* string, int32 offset, int32 strlen) const; - int32 _IFindAfter(const char* string, int32 offset, int32 strlen) const; + // Search + int32 _ShortFindAfter(const char* string, + int32 length) const; + int32 _FindAfter(const char* string, int32 offset, + int32 length) const; + int32 _IFindAfter(const char* string, int32 offset, + int32 length) const; + int32 _FindBefore(const char* string, int32 offset, + int32 length) const; + int32 _IFindBefore(const char* string, int32 offset, + int32 length) const; - int32 _FindBefore(const char* string, int32 offset, int32 strlen) const; - int32 _IFindBefore(const char* string, int32 offset, int32 strlen) const; + // Escape + BString& _DoCharacterEscape(const char* string, + const char *setOfCharsToEscape, char escapeChar); + BString& _DoCharacterDeescape(const char* string, + char escapeChar); - // Escape - BString& _DoCharacterEscape(const char* string, - const char *setOfCharsToEscape, char escapeChar); - BString& _DoCharacterDeescape(const char* string, char escapeChar); + // Replace + BString& _DoReplace(const char* findThis, + const char* replaceWith, int32 maxReplaceCount, + int32 fromOffset, bool ignoreCase); + void _ReplaceAtPositions(const PosVect* positions, + int32 searchLength, const char* with, + int32 withLength); - // Replace - BString& _DoReplace(const char* findThis, const char* replaceWith, - int32 maxReplaceCount, int32 fromOffset, bool ignoreCase); - void _ReplaceAtPositions(const PosVect* positions, int32 searchLen, - const char* with, int32 withLen); - private: - int32& _ReferenceCount(); - const int32& _ReferenceCount() const; - bool _IsShareable() const; - void _FreePrivateData(); + vint32& _ReferenceCount(); + const vint32& _ReferenceCount() const; + bool _IsShareable() const; + void _FreePrivateData(); - char* fPrivateData; + char* fPrivateData; }; @@ -442,7 +472,7 @@ public: BStringRef(BString& string, int32 position); ~BStringRef() {} - + operator char() const; char* operator&(); Modified: haiku/trunk/src/kits/support/String.cpp =================================================================== --- haiku/trunk/src/kits/support/String.cpp 2009-06-06 10:35:14 UTC (rev 30979) +++ haiku/trunk/src/kits/support/String.cpp 2009-06-06 11:23:17 UTC (rev 30980) @@ -1,19 +1,18 @@ /* -* Copyright 2001-2008, Haiku, Inc. All Rights Reserved. -* Distributed under the terms of the MIT License. -* -* Authors: -* Marc Flerackers (mflerackers at androme.be) -* Stefano Ceccherini (burton666 at libero.it) -* Oliver Tappe (openbeos at hirschkaefer.de) -* Axel D?rfler, axeld at pinc-software.de -* Julun -*/ + * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marc Flerackers (mflerackers at androme.be) + * Stefano Ceccherini (burton666 at libero.it) + * Oliver Tappe (openbeos at hirschkaefer.de) + * Axel D?rfler, axeld at pinc-software.de + * Julun + */ /*! String class supporting common string operations. */ -#include #include #include @@ -21,9 +20,8 @@ #include #include +#include -// Set this to 1 to make some private methods inline -#define ENABLE_INLINES 0 // define proper names for case-option of _DoReplace() #define KEEP_CASE false @@ -35,7 +33,7 @@ const uint32 kPrivateDataOffset = 2 * sizeof(int32); -const char *B_EMPTY_STRING = ""; +const char* B_EMPTY_STRING = ""; // helper function, returns minimum of two given values (but clamps to 0): @@ -49,7 +47,7 @@ } -//! helper function, returns length of given string (but clamps to given maximum): +//! Returns length of given string (but clamps to given maximum). static inline int32 strlen_clamp(const char* str, int32 max) { @@ -62,23 +60,48 @@ } +//! Helper function for strlen() that can handle NULL strings. +static inline size_t +string_length(const char* string) +{ + return string != NULL ? strlen(string) : 0; +} + + //! helper function, massages given pointer into a legal c-string: -static inline const char * +static inline const char* safestr(const char* str) { return str ? str : ""; } +static inline vint32& +data_reference_count(char* data) +{ + return *(((int32 *)data) - 2); +} + + +static inline int32& +data_length(char* data) +{ + return *(((int32*)data) - 1); +} + + // #pragma mark - PosVect class BString::PosVect { public: PosVect() - : fSize(0), + : + fSize(0), fBufferSize(20), - fBuffer(NULL) { } + fBuffer(NULL) + { + } ~PosVect() { @@ -92,7 +115,7 @@ fBufferSize *= 2; int32* newBuffer = NULL; - newBuffer = (int32 *)realloc(fBuffer, fBufferSize * sizeof(int32)); + newBuffer = (int32*)realloc(fBuffer, fBufferSize * sizeof(int32)); if (newBuffer == NULL) return false; @@ -104,9 +127,14 @@ } inline int32 ItemAt(int32 index) const - { return fBuffer[index]; } + { + return fBuffer[index]; + } + inline int32 CountItems() const - { return fSize; } + { + return fSize; + } private: int32 fSize; @@ -133,7 +161,7 @@ BStringRef& BStringRef::operator=(char c) { - fString._Detach(); + fString._MakeWritable(); fString.fPrivateData[fPosition] = c; return *this; } @@ -156,7 +184,7 @@ char* BStringRef::operator&() { - if (fString._Detach() != B_OK) + if (fString._MakeWritable() != B_OK) return NULL; fString._ReferenceCount() = -1; @@ -169,21 +197,24 @@ BString::BString() - : fPrivateData(NULL) + : + fPrivateData(NULL) { _Init("", 0); } BString::BString(const char* string) - : fPrivateData(NULL) + : + fPrivateData(NULL) { _Init(string, strlen(safestr(string))); } BString::BString(const BString& string) - : fPrivateData(NULL) + : + fPrivateData(NULL) { // check if source is sharable - if so, share else clone if (string._IsShareable()) { @@ -217,8 +248,8 @@ { int32 count = 0; - const char *start = fPrivateData; - const char *end = fPrivateData + Length(); + const char* start = fPrivateData; + const char* end = fPrivateData + Length(); while (start++ != end) { count++; @@ -262,8 +293,10 @@ { if (maxLength < 0) maxLength = INT32_MAX; + maxLength = strlen_clamp(safestr(string), maxLength); - if (_DetachWith("", maxLength) == B_OK) + + if (_MakeWritable(maxLength, false) == B_OK) memcpy(fPrivateData, string, maxLength); return *this; @@ -318,7 +351,7 @@ // make sure we reassing in case length is different || (fPrivateData == string.fPrivateData && Length() > maxLength)) { maxLength = min_clamp0(maxLength, string.Length()); - if (_DetachWith("", maxLength) == B_OK) + if (_MakeWritable(maxLength, false) == B_OK) memcpy(fPrivateData, string.String(), maxLength); } return *this; @@ -341,7 +374,7 @@ if (count < 0) count = 0; - if (_DetachWith("", count) == B_OK) + if (_MakeWritable(count, false) == B_OK) memset(fPrivateData, c, count); return *this; } @@ -480,7 +513,7 @@ BString& BString::Insert(const char* string, int32 position) { - if (string && position <= Length()) { + if (string != NULL && position <= Length()) { int32 len = int32(strlen(string)); if (position < 0) { int32 skipLen = min_clamp0(-1 * position, len); @@ -499,7 +532,7 @@ BString& BString::Insert(const char* string, int32 length, int32 position) { - if (string && position <= Length()) { + if (string != NULL && position <= Length()) { int32 len = strlen_clamp(string, length); if (position < 0) { int32 skipLen = min_clamp0(-1 * position, len); @@ -578,9 +611,10 @@ if (newLength < 0) newLength = 0; - if (newLength < Length()) + if (newLength < Length()) { // ignore lazy, since we might detach - _DetachWith(fPrivateData, newLength); + _MakeWritable(newLength, true); + } return *this; } @@ -624,7 +658,7 @@ if (string.Length() == 0 || Length() == 0 || FindFirst(string) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(string.String(), "", REPLACE_ALL, 0, KEEP_CASE); @@ -663,7 +697,7 @@ if (!string || Length() == 0 || FindFirst(string) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(string, "", REPLACE_ALL, 0, KEEP_CASE); @@ -843,8 +877,8 @@ int32 BString::FindFirst(char c) const { - const char *start = String(); - const char *end = String() + Length(); + const char* start = String(); + const char* end = String() + Length(); // Scans the string until we found the // character, or we reach the string's start @@ -865,8 +899,8 @@ if (fromOffset < 0) return B_ERROR; - const char *start = String() + min_clamp0(fromOffset, Length()); - const char *end = String() + Length(); + const char* start = String() + min_clamp0(fromOffset, Length()); + const char* end = String() + Length(); // Scans the string until we found the // character, or we reach the string's start @@ -926,8 +960,8 @@ int32 BString::FindLast(char c) const { - const char *start = String(); - const char *end = String() + Length(); + const char* start = String(); + const char* end = String() + Length(); // Scans the string backwards until we found // the character, or we reach the string's start @@ -948,8 +982,8 @@ if (beforeOffset < 0) return B_ERROR; - const char *start = String(); - const char *end = String() + min_clamp0(beforeOffset, Length()); + const char* start = String(); + const char* end = String() + min_clamp0(beforeOffset, Length()); // Scans the string backwards until we found // the character, or we reach the string's start @@ -1055,7 +1089,7 @@ BString::ReplaceFirst(char replaceThis, char withThis) { int32 pos = FindFirst(replaceThis); - if (pos >= 0 && _Detach() == B_OK) + if (pos >= 0 && _MakeWritable() == B_OK) fPrivateData[pos] = withThis; return *this; } @@ -1065,7 +1099,7 @@ BString::ReplaceLast(char replaceThis, char withThis) { int32 pos = FindLast(replaceThis); - if (pos >= 0 && _Detach() == B_OK) + if (pos >= 0 && _MakeWritable() == B_OK) fPrivateData[pos] = withThis; return *this; } @@ -1078,7 +1112,7 @@ int32 pos = FindFirst(replaceThis, fromOffset); // detach and set first match - if (pos >= 0 && _Detach() == B_OK) { + if (pos >= 0 && _MakeWritable() == B_OK) { fPrivateData[pos] = withThis; for (pos = pos;;) { pos = FindFirst(replaceThis, pos); @@ -1098,7 +1132,7 @@ fromOffset = min_clamp0(fromOffset, Length()); int32 pos = FindFirst(replaceThis, fromOffset); - if (maxReplaceCount > 0 && pos >= 0 && _Detach() == B_OK) { + if (maxReplaceCount > 0 && pos >= 0 && _MakeWritable() == B_OK) { maxReplaceCount--; fPrivateData[pos] = withThis; for (pos = pos; maxReplaceCount > 0; maxReplaceCount--) { @@ -1118,7 +1152,7 @@ if (!replaceThis || !withThis || FindFirst(replaceThis) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(replaceThis, withThis, 1, 0, KEEP_CASE); @@ -1145,7 +1179,7 @@ if (!_ShrinkAtBy(pos, -difference)) return *this; } else { - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; } memcpy(fPrivateData + pos, withThis, withThisLength); @@ -1162,7 +1196,7 @@ if (!replaceThis || !withThis || FindFirst(replaceThis) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(replaceThis, withThis, REPLACE_ALL, @@ -1178,7 +1212,7 @@ || FindFirst(replaceThis) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(replaceThis, withThis, maxReplaceCount, @@ -1192,7 +1226,7 @@ char tmp[2] = { replaceThis, '\0' }; int32 pos = _IFindAfter(tmp, 0, 1); - if (pos >= 0 && _Detach() == B_OK) + if (pos >= 0 && _MakeWritable() == B_OK) fPrivateData[pos] = withThis; return *this; } @@ -1204,7 +1238,7 @@ char tmp[2] = { replaceThis, '\0' }; int32 pos = _IFindBefore(tmp, Length(), 1); - if (pos >= 0 && _Detach() == B_OK) + if (pos >= 0 && _MakeWritable() == B_OK) fPrivateData[pos] = withThis; return *this; } @@ -1217,7 +1251,7 @@ fromOffset = min_clamp0(fromOffset, Length()); int32 pos = _IFindAfter(tmp, fromOffset, 1); - if (pos >= 0 && _Detach() == B_OK) { + if (pos >= 0 && _MakeWritable() == B_OK) { fPrivateData[pos] = withThis; for (pos = pos;;) { pos = _IFindAfter(tmp, pos, 1); @@ -1238,7 +1272,7 @@ fromOffset = min_clamp0(fromOffset, Length()); int32 pos = _IFindAfter(tmp, fromOffset, 1); - if (maxReplaceCount > 0 && pos >= 0 && _Detach() == B_OK) { + if (maxReplaceCount > 0 && pos >= 0 && _MakeWritable() == B_OK) { fPrivateData[pos] = withThis; maxReplaceCount--; for (pos = pos; maxReplaceCount > 0; maxReplaceCount--) { @@ -1259,7 +1293,7 @@ if (!replaceThis || !withThis || IFindFirst(replaceThis) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(replaceThis, withThis, 1, 0, IGNORE_CASE); } @@ -1285,7 +1319,7 @@ if (!_ShrinkAtBy(pos, -difference)) return *this; } else { - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; } memcpy(fPrivateData + pos, withThis, withThisLength); @@ -1302,7 +1336,7 @@ if (!replaceThis || !withThis || IFindFirst(replaceThis) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(replaceThis, withThis, REPLACE_ALL, @@ -1318,7 +1352,7 @@ || FindFirst(replaceThis) < 0) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; return _DoReplace(replaceThis, withThis, maxReplaceCount, @@ -1332,7 +1366,7 @@ if (!setOfChars || strcspn(fPrivateData, setOfChars) >= uint32(Length())) return *this; - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; int32 offset = 0; @@ -1364,7 +1398,7 @@ if (withLen == 1) return ReplaceSet(setOfChars, *with); - if (_Detach() != B_OK) + if (_MakeWritable() != B_OK) return *this; int32 pos = 0; @@ -1398,7 +1432,7 @@ char& BString::operator[](int32 index) { - if (_Detach() != B_OK) { + if (_MakeWritable() != B_OK) { static char invalid; return invalid; } @@ -1421,7 +1455,7 @@ if (maxLength > length) length = maxLength; - if (_DetachWith(fPrivateData, length) == B_OK) { + if (_MakeWritable(length, true) == B_OK) { _ReferenceCount() = -1; // mark unshareable } @@ -1436,10 +1470,10 @@ [... truncated: 510 lines follow ...] From rudolf.cornelissen at gmail.com Sat Jun 6 15:01:46 2009 From: rudolf.cornelissen at gmail.com (Rudolf Cornelissen) Date: Sat, 6 Jun 2009 13:01:46 +0000 Subject: [Haiku-commits] r30946 - in haiku/trunk: headers/private/graphics/nvidia src/add-ons/accelerants/nvidia/engine In-Reply-To: <49171207270-BeMail@zon> References: <49171207270-BeMail@zon> Message-ID: Axel, I _am_ using the I2C code, but only for DDC/EDID. I rely on my own code for other uses of the I2C buses though. I copied the dumping code for logging it in my own logfile, as I stated before. About logging: I am using my own logfile. I am not going to change that. (did you ever have a look at the content that file?) Bye! Rudolf. On Thu, Jun 4, 2009 at 8:48 PM, Axel D?rfler wrote: > Hi Rudolf, > > Rudolf Cornelissen wrote: > > actually I am using it. Just not where I want something else than > > this code > > provides, like dumping stuff in my own logfile instead of syslog. > > Were you > > thinking of something specific? > > Yes, you are not using the I2C code there is, and you seem to have > copied the EDID dumping code for some reason. I guess this could > explained with the logfile stuff? I think the syslog is just fine for > most purposes. > > Bye, > Axel. > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: From axeld at pinc-software.de Sat Jun 6 17:25:27 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 06 Jun 2009 17:25:27 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30946_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/graphics/nvidia_src/add-ons/accelerants/nvidia/engine?= In-Reply-To: Message-ID: <19524965871-BeMail@zon> Rudolf Cornelissen wrote: > About logging: I am using my own logfile. I am not going to change > that. > (did you ever have a look at the content that file?) I would never suggest to dump all that to syslog by default. Just when you need it, as every other component does it as well. Bye, Axel. From mmlr at mail.berlios.de Sun Jun 7 16:54:13 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sun, 7 Jun 2009 16:54:13 +0200 Subject: [Haiku-commits] r30981 - haiku/trunk/src/add-ons/kernel/partitioning_systems/efi Message-ID: <200906071454.n57EsDvB009619@sheep.berlios.de> Author: mmlr Date: 2009-06-07 16:54:11 +0200 (Sun, 07 Jun 2009) New Revision: 30981 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30981&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp Log: Cleanup. Line length, white space. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2009-06-06 11:23:17 UTC (rev 30980) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2009-06-07 14:54:11 UTC (rev 30981) @@ -3,7 +3,6 @@ * Distributed under the terms of the MIT License. */ - #include "efi_gpt.h" #include @@ -39,7 +38,7 @@ uint64 data4; inline bool operator==(const guid &other) const; -}; +} _PACKED; const static struct type_map { static_guid guid; @@ -48,7 +47,7 @@ {{0x48465300, 0x0000, 0x11aa, 0xaa1100306543ECACLL}, "HFS+ File System"} }; - + namespace EFI { class Header { @@ -170,7 +169,8 @@ // read and check the partition table header - ssize_t bytesRead = read_pos(fd, block * blockSize, &fHeader, sizeof(fHeader)); + ssize_t bytesRead = read_pos(fd, block * blockSize, &fHeader, + sizeof(fHeader)); if (bytesRead != (ssize_t)sizeof(fHeader)) { if (bytesRead < B_OK) fStatus = bytesRead; @@ -249,11 +249,13 @@ const char * Header::_PrintGUID(const guid_t &id) { - static char guid[48]; - snprintf(guid, sizeof(guid), "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + static char guid[48]; + snprintf(guid, sizeof(guid), + "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", B_LENDIAN_TO_HOST_INT32(id.data1), B_LENDIAN_TO_HOST_INT16(id.data2), - B_LENDIAN_TO_HOST_INT16(id.data3), id.data4[0], id.data4[1], id.data4[2], - id.data4[3], id.data4[4], id.data4[5], id.data4[6], id.data4[7]); + B_LENDIAN_TO_HOST_INT16(id.data3), id.data4[0], id.data4[1], + id.data4[2], id.data4[3], id.data4[4], id.data4[5], id.data4[6], + id.data4[7]); return guid; } @@ -286,7 +288,8 @@ if (entry.partition_type == kEmptyGUID) continue; - dprintf("[%3ld] partition type: %s\n", i, _PrintGUID(entry.partition_type)); + dprintf("[%3ld] partition type: %s\n", i, + _PrintGUID(entry.partition_type)); dprintf(" unique id: %s\n", _PrintGUID(entry.unique_guid)); dprintf(" start block: %Ld\n", entry.StartBlock()); dprintf(" end block: %Ld\n", entry.EndBlock()); @@ -323,8 +326,8 @@ static float efi_gpt_identify_partition(int fd, partition_data *partition, void **_cookie) { - EFI::Header *header = new (std::nothrow) EFI::Header(fd, EFI_HEADER_LOCATION, - partition->block_size); + EFI::Header *header = new (std::nothrow) EFI::Header(fd, + EFI_HEADER_LOCATION, partition->block_size); status_t status = header->InitCheck(); if (status < B_OK) { delete header; @@ -356,13 +359,16 @@ if (entry.partition_type == kEmptyGUID) continue; - if (entry.EndBlock() * partition->block_size > (uint64)partition->size) { + if (entry.EndBlock() * partition->block_size + > (uint64)partition->size) { TRACE(("efi_gpt: child partition exceeds existing space (%Ld MB)\n", - (entry.EndBlock() - entry.StartBlock()) * partition->block_size / 1024 / 1024)); + (entry.EndBlock() - entry.StartBlock()) * partition->block_size + / 1024 / 1024)); continue; } - partition_data *child = create_child_partition(partition->id, index++, -1); + partition_data *child = create_child_partition(partition->id, index++, + -1); if (child == NULL) { TRACE(("efi_gpt: Creating child at index %ld failed\n", index - 1)); return B_ERROR; @@ -373,8 +379,10 @@ child->name = strdup(name); child->type = strdup(get_partition_type(entry.partition_type)); - child->offset = partition->offset + entry.StartBlock() * partition->block_size; - child->size = (entry.EndBlock() - entry.StartBlock()) * partition->block_size; + child->offset = partition->offset + entry.StartBlock() + * partition->block_size; + child->size = (entry.EndBlock() - entry.StartBlock()) + * partition->block_size; child->block_size = partition->block_size; } @@ -416,4 +424,3 @@ NULL }; #endif - From axeld at pinc-software.de Sun Jun 7 17:25:24 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 07 Jun 2009 17:25:24 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30981_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/partitioning=5Fsystems/efi?= In-Reply-To: <200906071454.n57EsDvB009619@sheep.berlios.de> Message-ID: <18491168544-BeMail@zon> mmlr at mail.berlios.de wrote: > inline bool operator==(const guid &other) const; > -}; > +} _PACKED; That structure should actually be _PACKED. Any reason to remove it? And BTW: > */ > > - > #include "efi_gpt.h" I prefer that extra space in the files I have written - so unless we write it down in our coding style guide either way, please don't change this :-) Bye, Axel. From anevilyak at gmail.com Sun Jun 7 18:01:53 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 7 Jun 2009 11:01:53 -0500 Subject: [Haiku-commits] r30981 - haiku/trunk/src/add-ons/kernel/partitioning_systems/efi In-Reply-To: <18491168544-BeMail@zon> References: <200906071454.n57EsDvB009619@sheep.berlios.de> <18491168544-BeMail@zon> Message-ID: On Sun, Jun 7, 2009 at 10:25 AM, Axel D?rfler wrote: > mmlr at mail.berlios.de wrote: >> inline bool operator==(const guid &other) const; >> -}; >> +} _PACKED; > > That structure should actually be _PACKED. Any reason to remove it? Didn't he add the keyword, not remove it? Regards, Rene From axeld at pinc-software.de Sun Jun 7 18:23:00 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 07 Jun 2009 18:23:00 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30981_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/partitioning=5Fsystems/efi?= In-Reply-To: Message-ID: <21947143822-BeMail@zon> Rene Gollent wrote: > On Sun, Jun 7, 2009 at 10:25 AM, Axel D?rfler > wrote: > > mmlr at mail.berlios.de wrote: > >> inline bool operator==(const guid &other) const; > >> -}; > >> +} _PACKED; > > That structure should actually be _PACKED. Any reason to remove it? > Didn't he add the keyword, not remove it? Wow, am I stupid - thanks for the heads up, and then just ignore me :-) Bye, Axel. From mmlr at mlotz.ch Sun Jun 7 18:31:02 2009 From: mmlr at mlotz.ch (Michael Lotz) Date: Sun, 7 Jun 2009 18:31:02 +0200 Subject: [Haiku-commits] r30981 - haiku/trunk/src/add-ons/kernel/partitioning_systems/efi In-Reply-To: <18491168544-BeMail@zon> References: <200906071454.n57EsDvB009619@sheep.berlios.de> <18491168544-BeMail@zon> Message-ID: <20090607162932.M28986@mlotz.ch> On Sun, 07 Jun 2009 17:25:24 +0200 CEST, Axel D?rfler wrote > mmlr at mail.berlios.de wrote: > > inline bool operator==(const guid &other) const; > > -}; > > +} _PACKED; > > That structure should actually be _PACKED. Any reason to remove it? I've added it, it was missing. > And BTW: > > > */ > > > > - > > #include "efi_gpt.h" > > I prefer that extra space in the files I have written - so unless we > write it down in our coding style guide either way, please don't > change this :-) I thought you put one blank line in implementation files and none between copyright header and header guard in headers? Regards Michael From anevilyak at gmail.com Sun Jun 7 18:30:52 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 7 Jun 2009 11:30:52 -0500 Subject: [Haiku-commits] r30981 - haiku/trunk/src/add-ons/kernel/partitioning_systems/efi In-Reply-To: <21947143822-BeMail@zon> References: <21947143822-BeMail@zon> Message-ID: On Sun, Jun 7, 2009 at 11:23 AM, Axel D?rfler wrote: > > Wow, am I stupid - thanks for the heads up, and then just ignore me :-) > Not enough sleep? :) Regards, Rene From axeld at pinc-software.de Sun Jun 7 18:50:03 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 07 Jun 2009 18:50:03 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30981_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/partitioning=5Fsystems/efi?= In-Reply-To: <20090607162932.M28986@mlotz.ch> Message-ID: <546101372-BeMail@zon> "Michael Lotz" wrote: > > I prefer that extra space in the files I have written - so unless > > we > > write it down in our coding style guide either way, please don't > > change this :-) > I thought you put one blank line in implementation files and none > between > copyright header and header guard in headers? AFAIK we never agreed on anything here, and I'm using the two blank lines like I do everywhere else (ie. between "sections"). I don't particularly care about the outcome, but I guess it wouldn't hurt to actually agree on something here :-) Rene Gollent wrote: > On Sun, Jun 7, 2009 at 11:23 AM, Axel D?rfler > wrote: > > Wow, am I stupid - thanks for the heads up, and then just ignore me > > :-) > Not enough sleep? :) I actually did have enough sleep. Must be the age. Bye, Axel. From stippi at mail.berlios.de Sun Jun 7 19:57:01 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 19:57:01 +0200 Subject: [Haiku-commits] r30982 - haiku/trunk/headers/private/media Message-ID: <200906071757.n57Hv1si003974@sheep.berlios.de> Author: stippi Date: 2009-06-07 19:56:59 +0200 (Sun, 07 Jun 2009) New Revision: 30982 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30982&view=rev Modified: haiku/trunk/headers/private/media/TList.h Log: Remove() was completely broken if not removing the very last item. Modified: haiku/trunk/headers/private/media/TList.h =================================================================== --- haiku/trunk/headers/private/media/TList.h 2009-06-07 14:54:11 UTC (rev 30981) +++ haiku/trunk/headers/private/media/TList.h 2009-06-07 17:56:59 UTC (rev 30982) @@ -68,9 +68,8 @@ return false; delete items[index]; item_count--; - items[index] = items[item_count]; - if (index == item_iter) - item_iter--; + for (int i = index; i < item_count; i++) + items[i] = items[i + 1]; return true; } From stippi at mail.berlios.de Sun Jun 7 20:04:33 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 20:04:33 +0200 Subject: [Haiku-commits] r30983 - haiku/trunk/headers/private/media Message-ID: <200906071804.n57I4XAN004544@sheep.berlios.de> Author: stippi Date: 2009-06-07 20:04:32 +0200 (Sun, 07 Jun 2009) New Revision: 30983 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30983&view=rev Modified: haiku/trunk/headers/private/media/TMap.h Log: Just saw that _Remove(index) here was as broken as in TList.h. Modified: haiku/trunk/headers/private/media/TMap.h =================================================================== --- haiku/trunk/headers/private/media/TMap.h 2009-06-07 17:56:59 UTC (rev 30982) +++ haiku/trunk/headers/private/media/TMap.h 2009-06-07 18:04:32 UTC (rev 30983) @@ -150,9 +150,8 @@ return false; delete items[index]; item_count--; - items[index] = items[item_count]; - if (index == item_iter) - item_iter--; + for (int i = index; i < item_count; i++) + items[i] = items[i + 1]; return true; } From stippi at mail.berlios.de Sun Jun 7 20:11:09 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 20:11:09 +0200 Subject: [Haiku-commits] r30984 - in haiku/trunk: headers/private/media src/kits/media Message-ID: <200906071811.n57IB9n4005111@sheep.berlios.de> Author: stippi Date: 2009-06-07 20:11:05 +0200 (Sun, 07 Jun 2009) New Revision: 30984 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30984&view=rev Modified: haiku/trunk/headers/private/media/DecoderPlugin.h haiku/trunk/headers/private/media/PluginManager.h haiku/trunk/headers/private/media/ReaderPlugin.h haiku/trunk/src/kits/media/DecoderPlugin.cpp haiku/trunk/src/kits/media/PluginManager.cpp haiku/trunk/src/kits/media/ReaderPlugin.cpp Log: Resolved TODOs in PluginManager about leaking plugins when they are no longer needed. I've added MediaPlugin* fields to Reader and Decoder plugin classes which are set when the PluginManager hands out new instances. This way the manager knows what plugin created the Decoder or Reader instance in the Destroy*() methods and can decrease the reference count accordingly. Also added some FBC stuffing to Decoder and Reader. All media plugins need to be recompiled, in case anyone has some outside the Haiku tree. Modified: haiku/trunk/headers/private/media/DecoderPlugin.h =================================================================== --- haiku/trunk/headers/private/media/DecoderPlugin.h 2009-06-07 18:04:32 UTC (rev 30983) +++ haiku/trunk/headers/private/media/DecoderPlugin.h 2009-06-07 18:11:05 UTC (rev 30984) @@ -9,53 +9,75 @@ namespace BPrivate { namespace media { +class PluginManager; + class ChunkProvider { public: - virtual ~ChunkProvider() {}; - virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize, - media_header *mediaHeader) = 0; + virtual ~ChunkProvider() {}; + virtual status_t GetNextChunk(const void** chunkBuffer, + size_t* chunkSize, + media_header* mediaHeader) = 0; }; -class Decoder -{ +class Decoder { public: - Decoder(); - virtual ~Decoder(); + Decoder(); + virtual ~Decoder(); - virtual void GetCodecInfo(media_codec_info *codecInfo) = 0; + virtual void GetCodecInfo(media_codec_info* codecInfo) = 0; - // Setup get's called with the info data from Reader::GetStreamInfo - virtual status_t Setup(media_format *ioEncodedFormat, const void *infoBuffer, size_t infoSize) = 0; + // Setup get's called with the info data from Reader::GetStreamInfo + virtual status_t Setup(media_format* ioEncodedFormat, + const void* infoBuffer, + size_t infoSize) = 0; - virtual status_t NegotiateOutputFormat(media_format *ioDecodedFormat) = 0; + virtual status_t NegotiateOutputFormat( + media_format* ioDecodedFormat) = 0; - virtual status_t Seek(uint32 seekTo, - int64 seekFrame, int64 *frame, - bigtime_t seekTime, bigtime_t *time) = 0; + virtual status_t Seek(uint32 seekTo, int64 seekFrame, + int64* frame, bigtime_t seekTime, + bigtime_t* time) = 0; - virtual status_t Decode(void *buffer, int64 *frameCount, - media_header *mediaHeader, media_decode_info *info = 0) = 0; + virtual status_t Decode(void* buffer, int64* frameCount, + media_header* mediaHeader, + media_decode_info* info = 0) = 0; - status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize, - media_header *mediaHeader); + status_t GetNextChunk(const void** chunkBuffer, + size_t* chunkSize, + media_header* mediaHeader); - void SetChunkProvider(ChunkProvider *provider); + void SetChunkProvider(ChunkProvider* provider); + + virtual status_t Perform(perform_code code, void* data); + private: - ChunkProvider * fChunkProvider; + virtual void _ReservedDecoder1(); + virtual void _ReservedDecoder2(); + virtual void _ReservedDecoder3(); + virtual void _ReservedDecoder4(); + virtual void _ReservedDecoder5(); + + ChunkProvider* fChunkProvider; + + // needed for plug-in reference count management + friend class PluginManager; + MediaPlugin* fMediaPlugin; + + uint32 fReserved[5]; }; -class DecoderPlugin : public virtual MediaPlugin -{ - public: - DecoderPlugin(); +class DecoderPlugin : public virtual MediaPlugin { +public: + DecoderPlugin(); - virtual Decoder *NewDecoder(uint index) = 0; - virtual status_t GetSupportedFormats(media_format ** formats, size_t * count) = 0; + virtual Decoder* NewDecoder(uint index) = 0; + virtual status_t GetSupportedFormats(media_format** formats, + size_t * count) = 0; }; } } // namespace BPrivate::media using namespace BPrivate::media; -#endif +#endif // _DECODER_PLUGIN_H Modified: haiku/trunk/headers/private/media/PluginManager.h =================================================================== --- haiku/trunk/headers/private/media/PluginManager.h 2009-06-07 18:04:32 UTC (rev 30983) +++ haiku/trunk/headers/private/media/PluginManager.h 2009-06-07 18:11:05 UTC (rev 30984) @@ -36,6 +36,15 @@ int usecount; MediaPlugin *plugin; image_id image; + + plugin_info& operator=(const plugin_info& other) + { + strcpy(name, other.name); + usecount = other.usecount; + plugin = other.plugin; + image = other.image; + return *this; + } }; List *fPluginList; Modified: haiku/trunk/headers/private/media/ReaderPlugin.h =================================================================== --- haiku/trunk/headers/private/media/ReaderPlugin.h 2009-06-07 18:04:32 UTC (rev 30983) +++ haiku/trunk/headers/private/media/ReaderPlugin.h 2009-06-07 18:11:05 UTC (rev 30984) @@ -6,6 +6,8 @@ namespace BPrivate { namespace media { +class PluginManager; + enum { B_MEDIA_SEEK_TO_TIME = 0x10000, B_MEDIA_SEEK_TO_FRAME = 0x20000 @@ -41,12 +43,26 @@ media_header* mediaHeader) = 0; BDataIO* Source() const; - + + virtual status_t Perform(perform_code code, void* data); + private: + virtual void _ReservedReader1(); + virtual void _ReservedReader2(); + virtual void _ReservedReader3(); + virtual void _ReservedReader4(); + virtual void _ReservedReader5(); + public: // XXX for test programs only void Setup(BDataIO* source); BDataIO* fSource; + + // needed for plug-in reference count management + friend class PluginManager; + MediaPlugin* fMediaPlugin; + + uint32 fReserved[5]; }; Modified: haiku/trunk/src/kits/media/DecoderPlugin.cpp =================================================================== --- haiku/trunk/src/kits/media/DecoderPlugin.cpp 2009-06-07 18:04:32 UTC (rev 30983) +++ haiku/trunk/src/kits/media/DecoderPlugin.cpp 2009-06-07 18:11:05 UTC (rev 30984) @@ -1,18 +1,20 @@ /* -** Copyright 2004, Marcus Overhagen. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2004, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ - #include "DecoderPlugin.h" -#include #include #include +#include + Decoder::Decoder() - : fChunkProvider(NULL) + : + fChunkProvider(NULL), + fMediaPlugin(NULL) { } @@ -39,6 +41,18 @@ } +status_t +Decoder::Perform(perform_code code, void* _data) +{ + return B_OK; +} + +void Decoder::_ReservedDecoder1() {} +void Decoder::_ReservedDecoder2() {} +void Decoder::_ReservedDecoder3() {} +void Decoder::_ReservedDecoder4() {} +void Decoder::_ReservedDecoder5() {} + // #pragma mark - Modified: haiku/trunk/src/kits/media/PluginManager.cpp =================================================================== --- haiku/trunk/src/kits/media/PluginManager.cpp 2009-06-07 18:04:32 UTC (rev 30983) +++ haiku/trunk/src/kits/media/PluginManager.cpp 2009-06-07 18:11:05 UTC (rev 30984) @@ -49,7 +49,7 @@ return B_ERROR; } - ReaderPlugin *readerPlugin = dynamic_cast(plugin); + ReaderPlugin *readerPlugin = dynamic_cast(plugin); if (!readerPlugin) { printf("PluginManager::CreateReader: dynamic_cast failed\n"); PutPlugin(plugin); @@ -57,7 +57,7 @@ } *reader = readerPlugin->NewReader(); - if (! *reader) { + if (*reader == NULL) { printf("PluginManager::CreateReader: NewReader failed\n"); PutPlugin(plugin); return B_ERROR; @@ -65,6 +65,7 @@ seekable_source->Seek(0, SEEK_SET); (*reader)->Setup(seekable_source); + (*reader)->fMediaPlugin = plugin; if ((*reader)->Sniff(streamCount) == B_OK) { TRACE("PluginManager::CreateReader: Sniff success " @@ -73,9 +74,7 @@ return B_OK; } - // _DestroyReader(*reader); - delete *reader; - PutPlugin(plugin); + DestroyReader(*reader); } TRACE("PluginManager::CreateReader leave\n"); @@ -84,10 +83,18 @@ void -PluginManager::DestroyReader(Reader *reader) +PluginManager::DestroyReader(Reader* reader) { - // ToDo: must call put plugin - delete reader; + if (reader != NULL) { + TRACE("PluginManager::DestroyReader(%p (plugin: %p))\n", reader, + reader->fMediaPlugin); + // NOTE: We have to put the plug-in after deleting the reader, + // since otherwise we may actually unload the code for the + // destructor... + MediaPlugin* plugin = reader->fMediaPlugin; + delete reader; + PutPlugin(plugin); + } } @@ -108,7 +115,7 @@ return ret; } - MediaPlugin *plugin = GetPlugin(reply.ref); + MediaPlugin* plugin = GetPlugin(reply.ref); if (!plugin) { printf("PluginManager::CreateDecoder: GetPlugin failed\n"); return B_ERROR; @@ -127,6 +134,8 @@ PutPlugin(plugin); return B_ERROR; } + TRACE(" created decoder: %p\n", *_decoder); + (*_decoder)->fMediaPlugin = plugin; TRACE("PluginManager::CreateDecoder leave\n"); @@ -161,8 +170,16 @@ void PluginManager::DestroyDecoder(Decoder *decoder) { - // ToDo: must call put plugin - delete decoder; + if (decoder != NULL) { + TRACE("PluginManager::DestroyDecoder(%p, plugin: %p)\n", decoder, + decoder->fMediaPlugin); + // NOTE: We have to put the plug-in after deleting the decoder, + // since otherwise we may actually unload the code for the + // destructor... + MediaPlugin* plugin = decoder->fMediaPlugin; + delete decoder; + PutPlugin(plugin); + } } @@ -180,14 +197,13 @@ PluginManager::~PluginManager() { CALLED(); - while (!fPluginList->IsEmpty()) { + for (int i = fPluginList->CountItems() - 1; i >= 0; i--) { plugin_info *info = NULL; - fPluginList->Get(fPluginList->CountItems() - 1, &info); + fPluginList->Get(i, &info); printf("PluginManager: Error, unloading PlugIn %s with usecount " "%d\n", info->name, info->usecount); delete info->plugin; unload_add_on(info->image); - fPluginList->Remove(fPluginList->CountItems() - 1); } delete fLocker; } @@ -196,6 +212,7 @@ MediaPlugin * PluginManager::GetPlugin(const entry_ref &ref) { + TRACE("PluginManager::GetPlugin(%s)\n", ref.name); fLocker->Lock(); MediaPlugin *plugin; @@ -206,6 +223,7 @@ if (0 == strcmp(ref.name, pinfo->name)) { plugin = pinfo->plugin; pinfo->usecount++; + TRACE(" found existing plugin: %p\n", pinfo->plugin); fLocker->Unlock(); return plugin; } @@ -224,6 +242,7 @@ TRACE("PluginManager: PlugIn %s loaded\n", ref.name); plugin = info.plugin; + TRACE(" loaded plugin: %p\n", plugin); fLocker->Unlock(); return plugin; @@ -231,8 +250,9 @@ void -PluginManager::PutPlugin(MediaPlugin *plugin) +PluginManager::PutPlugin(MediaPlugin* plugin) { + TRACE("PluginManager::PutPlugin()\n"); fLocker->Lock(); plugin_info *pinfo; @@ -241,7 +261,9 @@ if (plugin == pinfo->plugin) { pinfo->usecount--; if (pinfo->usecount == 0) { + TRACE(" deleting %p\n", pinfo->plugin); delete pinfo->plugin; + TRACE(" unloading add-on: %ld\n\n", pinfo->image); unload_add_on(pinfo->image); fPluginList->RemoveCurrent(); } @@ -266,6 +288,7 @@ image_id id; id = load_add_on(p.Path()); + TRACE(" loaded add-on: %ld\n", id); if (id < 0) return B_ERROR; Modified: haiku/trunk/src/kits/media/ReaderPlugin.cpp =================================================================== --- haiku/trunk/src/kits/media/ReaderPlugin.cpp 2009-06-07 18:04:32 UTC (rev 30983) +++ haiku/trunk/src/kits/media/ReaderPlugin.cpp 2009-06-07 18:11:05 UTC (rev 30984) @@ -1,8 +1,17 @@ +/* + * Copyright 2004, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ + #include "ReaderPlugin.h" +#include + Reader::Reader() - : fSource(0) + : + fSource(0), + fMediaPlugin(NULL) { } @@ -38,3 +47,17 @@ { fSource = source; } + + +status_t +Reader::Perform(perform_code code, void* _data) +{ + return B_OK; +} + +void Reader::_ReservedReader1() {} +void Reader::_ReservedReader2() {} +void Reader::_ReservedReader3() {} +void Reader::_ReservedReader4() {} +void Reader::_ReservedReader5() {} + From anevilyak at mail.berlios.de Sun Jun 7 21:07:34 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 7 Jun 2009 21:07:34 +0200 Subject: [Haiku-commits] r30985 - haiku/trunk/headers/private/media Message-ID: <200906071907.n57J7YtD010610@sheep.berlios.de> Author: anevilyak Date: 2009-06-07 21:07:34 +0200 (Sun, 07 Jun 2009) New Revision: 30985 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30985&view=rev Modified: haiku/trunk/headers/private/media/PluginManager.h Log: Fix GCC4 build. Modified: haiku/trunk/headers/private/media/PluginManager.h =================================================================== --- haiku/trunk/headers/private/media/PluginManager.h 2009-06-07 18:11:05 UTC (rev 30984) +++ haiku/trunk/headers/private/media/PluginManager.h 2009-06-07 19:07:34 UTC (rev 30985) @@ -1,6 +1,10 @@ #ifndef _PLUGIN_MANAGER_H #define _PLUGIN_MANAGER_H + +#include + + #include "ReaderPlugin.h" #include "DecoderPlugin.h" #include From stippi at mail.berlios.de Sun Jun 7 21:35:17 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 21:35:17 +0200 Subject: [Haiku-commits] r30986 - in haiku/trunk: headers/os/media src/kits/media Message-ID: <200906071935.n57JZHp2012530@sheep.berlios.de> Author: stippi Date: 2009-06-07 21:35:14 +0200 (Sun, 07 Jun 2009) New Revision: 30986 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30986&view=rev Modified: haiku/trunk/headers/os/media/MediaFile.h haiku/trunk/src/kits/media/MediaFile.cpp Log: * Coding style clean-up. * Use std::nothrow and check allocations. Modified: haiku/trunk/headers/os/media/MediaFile.h =================================================================== --- haiku/trunk/headers/os/media/MediaFile.h 2009-06-07 19:07:34 UTC (rev 30985) +++ haiku/trunk/headers/os/media/MediaFile.h 2009-06-07 19:35:14 UTC (rev 30986) @@ -1,3 +1,7 @@ +/* + * Copyright (c) 2002 - 2009, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _MEDIA_FILE_H #define _MEDIA_FILE_H @@ -2,7 +6,6 @@ #include -#include -#include #include #include #include +#include @@ -45,172 +48,178 @@ // class BMediaFile { - public: - // these four constructors are used for read-only access - BMediaFile( const entry_ref *ref); - BMediaFile( BDataIO * source); // BFile is a BDataIO - BMediaFile( const entry_ref * ref, - int32 flags); - BMediaFile( BDataIO * source, - int32 flags); // BFile is a BDataIO + // these four constructors are used for read-only access + BMediaFile(const entry_ref* ref); + BMediaFile(BDataIO* source); + // BFile is a BDataIO + BMediaFile(const entry_ref* ref, int32 flags); + BMediaFile(BDataIO* source, int32 flags); - // these three constructors are for read-write access - BMediaFile(const entry_ref *ref, // these two are write-only - const media_file_format * mfi, - int32 flags=0); - BMediaFile(BDataIO *destination, // BFile is a BDataIO - const media_file_format * mfi, - int32 flags=0); - BMediaFile(const media_file_format * mfi, // set file later using SetTo() - int32 flags=0); + // these three constructors are for read-write access + BMediaFile(const entry_ref* ref, + const media_file_format* mfi, + int32 flags = 0); + BMediaFile(BDataIO* destination, + const media_file_format* mfi, + int32 flags = 0); + BMediaFile(const media_file_format* mfi, + int32 flags = 0); + // set file later using SetTo() - status_t SetTo(const entry_ref *ref); - status_t SetTo(BDataIO *destination); // BFile is a BDataIO + virtual ~BMediaFile(); + + status_t SetTo(const entry_ref* ref); + status_t SetTo(BDataIO* destination); - virtual ~BMediaFile(); + status_t InitCheck() const; - status_t InitCheck() const; - // Get info about the underlying file format. - status_t GetFileFormatInfo(media_file_format *mfi) const; + status_t GetFileFormatInfo(media_file_format* mfi) const; // // These functions are for read-only access to a media file. // The data is read using the BMediaTrack object. // - const char *Copyright(void) const; - int32 CountTracks() const; + const char* Copyright() const; + int32 CountTracks() const; // Can be called multiple times with the same index. You must call // ReleaseTrack() when you're done with a track. - BMediaTrack *TrackAt(int32 index); + BMediaTrack* TrackAt(int32 index); // Release the resource used by a given BMediaTrack object, to reduce // the memory usage of your application. The specific 'track' object // can no longer be used, but you can create another one by calling // TrackAt() with the same track index. - status_t ReleaseTrack(BMediaTrack *track); + status_t ReleaseTrack(BMediaTrack* track); - // A convenience. - status_t ReleaseAllTracks(void); + // A convenience. Deleting a BMediaFile will also call this. + status_t ReleaseAllTracks(); // Create and add a track to the media file - BMediaTrack *CreateTrack(media_format *mf, const media_codec_info *mci, uint32 flags=0); + BMediaTrack* CreateTrack(media_format* mf, + const media_codec_info* mci, + uint32 flags = 0); // Create and add a raw track to the media file (it has no encoder) - BMediaTrack *CreateTrack(media_format *mf, uint32 flags=0); + BMediaTrack* CreateTrack(media_format* mf, + uint32 flags = 0); // Lets you set the copyright info for the entire file - status_t AddCopyright(const char *data); + status_t AddCopyright(const char* data); // Call this to add user-defined chunks to a file (if they're supported) - status_t AddChunk(int32 type, const void *data, size_t size); + status_t AddChunk(int32 type, const void* data, + size_t size); // After you have added all the tracks you want, call this - status_t CommitHeader(void); + status_t CommitHeader(); // After you have written all the data to the track objects, call this - status_t CloseFile(void); + status_t CloseFile(); // This is for controlling file format parameters // returns a copy of the parameter web - status_t GetParameterWeb(BParameterWeb** outWeb); - status_t GetParameterValue(int32 id, void *valu, size_t *size); - status_t SetParameterValue(int32 id, const void *valu, size_t size); - BView *GetParameterView(); + status_t GetParameterWeb(BParameterWeb** outWeb); + status_t GetParameterValue(int32 id, void* value, + size_t* size); + status_t SetParameterValue(int32 id, const void* value, + size_t size); + BView* GetParameterView(); // For the future... - virtual status_t Perform(int32 selector, void * data); + virtual status_t Perform(int32 selector, void* data); private: // deprecated, but for R5 compatibility - BParameterWeb *Web(); + BParameterWeb* Web(); // Does nothing, returns B_ERROR, for Zeta compatiblity only - status_t ControlFile(int32 selector, void * io_data, size_t size); + status_t ControlFile(int32 selector, void* ioData, + size_t size); - BPrivate::media::MediaExtractor *fExtractor; - int32 _reserved_BMediaFile_was_fExtractorID; - int32 fTrackNum; - status_t fErr; + BPrivate::media::MediaExtractor* fExtractor; + int32 _reserved_BMediaFile_was_fExtractorID; + int32 fTrackNum; + status_t fErr; - BPrivate::_AddonManager *fEncoderMgr; - BPrivate::_AddonManager *fWriterMgr; - BPrivate::MediaWriter *fWriter; - int32 fWriterID; - media_file_format fMFI; + BPrivate::_AddonManager* fEncoderMgr; + BPrivate::_AddonManager* fWriterMgr; + BPrivate::MediaWriter* fWriter; + int32 fWriterID; + media_file_format fMFI; - bool fFileClosed; - bool fDeleteSource; - bool _reserved_was_fUnused[2]; - BMediaTrack **fTrackList; + bool fFileClosed; + bool fDeleteSource; + bool _reserved_was_fUnused[2]; + BMediaTrack** fTrackList; - void Init(); - void InitReader(BDataIO *source, int32 flags = 0); - void InitWriter(BDataIO *source, const media_file_format * mfi, - int32 flags); + void _Init(); + void _InitReader(BDataIO* source, int32 flags = 0); + void _InitWriter(BDataIO* source, + const media_file_format* mfi, int32 flags); - BMediaFile(); - BMediaFile(const BMediaFile&); - BMediaFile& operator=(const BMediaFile&); + BMediaFile(); + BMediaFile(const BMediaFile&); + BMediaFile& operator=(const BMediaFile&); - BDataIO *fSource; + BDataIO* fSource; - /* fbc data and virtuals */ + // FBC data and virtuals - uint32 _reserved_BMediaFile_[32]; + uint32 _reserved_BMediaFile_[32]; -virtual status_t _Reserved_BMediaFile_0(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_1(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_2(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_3(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_4(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_5(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_6(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_7(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_8(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_9(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_10(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_11(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_12(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_13(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_14(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_15(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_16(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_17(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_18(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_19(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_20(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_21(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_22(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_23(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_24(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_25(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_26(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_27(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_28(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_29(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_30(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_31(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_32(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_33(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_34(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_35(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_36(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_37(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_38(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_39(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_40(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_41(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_42(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_43(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_44(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_45(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_46(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_47(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_0(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_1(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_2(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_3(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_4(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_5(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_6(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_7(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_8(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_9(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_10(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_11(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_12(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_13(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_14(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_15(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_16(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_17(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_18(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_19(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_20(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_21(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_22(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_23(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_24(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_25(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_26(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_27(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_28(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_29(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_30(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_31(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_32(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_33(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_34(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_35(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_36(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_37(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_38(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_39(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_40(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_41(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_42(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_43(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_44(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_45(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_46(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_47(int32 arg, ...); }; #endif Modified: haiku/trunk/src/kits/media/MediaFile.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:07:34 UTC (rev 30985) +++ haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:35:14 UTC (rev 30986) @@ -1,108 +1,82 @@ /* * Copyright (c) 2002-2004, Marcus Overhagen - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * All rights reserved. Distributed under the terms of the MIT License. */ #include + +#include +#include + #include #include -#include + #include "MediaExtractor.h" #include "debug.h" -/************************************************************* - * public BMediaFile - *************************************************************/ - - -BMediaFile::BMediaFile(const entry_ref *ref) +BMediaFile::BMediaFile(const entry_ref* ref) { CALLED(); - Init(); + _Init(); fDeleteSource = true; - InitReader(new BFile(ref, O_RDONLY)); + _InitReader(new (std::nothrow) BFile(ref, O_RDONLY)); } -BMediaFile::BMediaFile(BDataIO * source) +BMediaFile::BMediaFile(BDataIO* source) { CALLED(); - Init(); - InitReader(source); + _Init(); + _InitReader(source); } -BMediaFile::BMediaFile(const entry_ref * ref, - int32 flags) +BMediaFile::BMediaFile(const entry_ref* ref, int32 flags) { CALLED(); - Init(); + _Init(); fDeleteSource = true; - InitReader(new BFile(ref, O_RDONLY), flags); + _InitReader(new (std::nothrow) BFile(ref, O_RDONLY), flags); } -BMediaFile::BMediaFile(BDataIO * source, - int32 flags) +BMediaFile::BMediaFile(BDataIO* source, int32 flags) { CALLED(); - Init(); - InitReader(source, flags); + _Init(); + _InitReader(source, flags); } -BMediaFile::BMediaFile(const entry_ref *ref, - const media_file_format * mfi, - int32 flags) +BMediaFile::BMediaFile(const entry_ref* ref, const media_file_format* mfi, + int32 flags) { CALLED(); - Init(); + _Init(); fDeleteSource = true; - InitWriter(new BFile(ref, O_WRONLY), mfi, flags); + _InitWriter(new (std::nothrow) BFile(ref, O_WRONLY), mfi, flags); } -BMediaFile::BMediaFile(BDataIO *destination, - const media_file_format * mfi, - int32 flags) +BMediaFile::BMediaFile(BDataIO* destination, const media_file_format* mfi, + int32 flags) { CALLED(); - Init(); - InitWriter(destination, mfi, flags); + _Init(); + _InitWriter(destination, mfi, flags); } // File will be set later by SetTo() -BMediaFile::BMediaFile(const media_file_format * mfi, - int32 flags) +BMediaFile::BMediaFile(const media_file_format* mfi, int32 flags) { debugger("BMediaFile::BMediaFile not implemented"); } status_t -BMediaFile::SetTo(const entry_ref *ref) +BMediaFile::SetTo(const entry_ref* ref) { debugger("BMediaFile::SetTo not implemented"); return B_OK; @@ -110,14 +84,13 @@ status_t -BMediaFile::SetTo(BDataIO *destination) +BMediaFile::SetTo(BDataIO* destination) { debugger("BMediaFile::SetTo not implemented"); return B_OK; } -/* virtual */ BMediaFile::~BMediaFile() { CALLED(); @@ -140,9 +113,11 @@ // Get info about the underlying file format. status_t -BMediaFile::GetFileFormatInfo(media_file_format *mfi) const +BMediaFile::GetFileFormatInfo(media_file_format* mfi) const { CALLED(); + if (mfi == NULL) + return B_BAD_VALUE; if (fErr) return B_ERROR; *mfi = fMFI; @@ -150,8 +125,8 @@ } -const char * -BMediaFile::Copyright(void) const +const char* +BMediaFile::Copyright() const { return fExtractor->Copyright(); } @@ -166,15 +141,17 @@ // Can be called multiple times with the same index. You must call // ReleaseTrack() when you're done with a track. -BMediaTrack * +BMediaTrack* BMediaFile::TrackAt(int32 index) { CALLED(); - if (!fTrackList || !fExtractor || index < 0 || index >= fTrackNum) - return 0; - if (!fTrackList[index]) { + if (fTrackList == NULL || fExtractor == NULL + || index < 0 || index >= fTrackNum) { + return NULL; + } + if (fTrackList[index] == NULL) { TRACE("BMediaFile::TrackAt, creating new track for index %ld\n", index); - fTrackList[index] = new BMediaTrack(fExtractor, index); + fTrackList[index] = new (std::nothrow) BMediaTrack(fExtractor, index); TRACE("BMediaFile::TrackAt, new track is %p\n", fTrackList[index]); } return fTrackList[index]; @@ -186,16 +163,17 @@ // can no longer be used, but you can create another one by calling // TrackAt() with the same track index. status_t -BMediaFile::ReleaseTrack(BMediaTrack *track) +BMediaFile::ReleaseTrack(BMediaTrack* track) { CALLED(); if (!fTrackList || !track) return B_ERROR; for (int32 i = 0; i < fTrackNum; i++) { if (fTrackList[i] == track) { - TRACE("BMediaFile::ReleaseTrack, releasing track %p with index %ld\n", track, i); + TRACE("BMediaFile::ReleaseTrack, releasing track %p with index " + "%ld\n", track, i); delete track; - fTrackList[i] = 0; + fTrackList[i] = NULL; return B_OK; } } @@ -205,16 +183,17 @@ status_t -BMediaFile::ReleaseAllTracks(void) +BMediaFile::ReleaseAllTracks() { CALLED(); if (!fTrackList) return B_ERROR; for (int32 i = 0; i < fTrackNum; i++) { if (fTrackList[i]) { - TRACE("BMediaFile::ReleaseAllTracks, releasing track %p with index %ld\n", fTrackList[i], i); + TRACE("BMediaFile::ReleaseAllTracks, releasing track %p with " + "index %ld\n", fTrackList[i], i); delete fTrackList[i]; - fTrackList[i] = 0; + fTrackList[i] = NULL; } } return B_OK; @@ -222,10 +201,9 @@ // Create and add a track to the media file -BMediaTrack * -BMediaFile::CreateTrack(media_format *mf, - const media_codec_info *mci, - uint32 flags) +BMediaTrack* +BMediaFile::CreateTrack(media_format* mf, const media_codec_info* mci, + uint32 flags) { UNIMPLEMENTED(); return 0; @@ -233,33 +211,30 @@ // Create and add a raw track to the media file (it has no encoder) -BMediaTrack * -BMediaFile::CreateTrack(media_format *mf, uint32 flags) +BMediaTrack* +BMediaFile::CreateTrack(media_format* mf, uint32 flags) { return CreateTrack(mf, NULL, flags); } // For BeOS R5 compatibility -extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_formatPC16media_codec_info( - BMediaFile *self, media_format *mf, const media_codec_info *mci); -BMediaTrack * +extern "C" BMediaTrack* CreateTrack__10BMediaFileP12media_formatPC16media_codec_info( - BMediaFile *self, - media_format *mf, - const media_codec_info *mci) + BMediaFile* self, media_format* mf, const media_codec_info* mci); +BMediaTrack* +CreateTrack__10BMediaFileP12media_formatPC16media_codec_info(BMediaFile* self, + media_format* mf, const media_codec_info* mci) { return self->CreateTrack(mf, mci, 0); } // For BeOS R5 compatibility -extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_format( - BMediaFile *self, media_format *mf); -BMediaTrack * -CreateTrack__10BMediaFileP12media_format( - BMediaFile *self, - media_format *mf) +extern "C" BMediaTrack* CreateTrack__10BMediaFileP12media_format( + BMediaFile* self, media_format* mf); +BMediaTrack* +CreateTrack__10BMediaFileP12media_format(BMediaFile* self, media_format* mf) { return self->CreateTrack(mf, NULL, 0); } @@ -267,7 +242,7 @@ // Lets you set the copyright info for the entire file status_t -BMediaFile::AddCopyright(const char *data) +BMediaFile::AddCopyright(const char* data) { UNIMPLEMENTED(); return B_OK; @@ -276,7 +251,7 @@ // Call this to add user-defined chunks to a file (if they're supported) status_t -BMediaFile::AddChunk(int32 type, const void *data, size_t size) +BMediaFile::AddChunk(int32 type, const void* data, size_t size) { UNIMPLEMENTED(); return B_OK; @@ -285,7 +260,7 @@ // After you have added all the tracks you want, call this status_t -BMediaFile::CommitHeader(void) +BMediaFile::CommitHeader() { UNIMPLEMENTED(); return B_OK; @@ -294,7 +269,7 @@ // After you have written all the data to the track objects, call this status_t -BMediaFile::CloseFile(void) +BMediaFile::CloseFile() { UNIMPLEMENTED(); return B_OK; @@ -312,7 +287,7 @@ // deprecated BeOS R5 API -BParameterWeb * +BParameterWeb* BMediaFile::Web() { UNIMPLEMENTED(); @@ -321,7 +296,7 @@ status_t -BMediaFile::GetParameterValue(int32 id, void *valu, size_t *size) +BMediaFile::GetParameterValue(int32 id, void* value, size_t* size) { UNIMPLEMENTED(); return B_OK; @@ -329,14 +304,14 @@ status_t -BMediaFile::SetParameterValue(int32 id, const void *valu, size_t size) +BMediaFile::SetParameterValue(int32 id, const void* value, size_t size) { UNIMPLEMENTED(); return B_OK; } -BView * +BView* BMediaFile::GetParameterView() { UNIMPLEMENTED(); @@ -344,8 +319,8 @@ } -/* virtual */ status_t -BMediaFile::Perform(int32 selector, void * data) +status_t +BMediaFile::Perform(int32 selector, void* data) { UNIMPLEMENTED(); return B_OK; @@ -353,59 +328,69 @@ status_t -BMediaFile::ControlFile(int32 selector, void * io_data, size_t size) +BMediaFile::ControlFile(int32 selector, void* ioData, size_t size) { UNIMPLEMENTED(); return B_ERROR; } -/************************************************************* - * private BMediaFile - *************************************************************/ +// #pragma mark - private void -BMediaFile::Init() +BMediaFile::_Init() { CALLED(); - fSource = 0; + + fSource = NULL; fTrackNum = 0; - fTrackList = 0; - fExtractor = 0; + fTrackList = NULL; + fExtractor = NULL; fErr = B_OK; fDeleteSource = false; // not used so far: - fEncoderMgr = 0; - fWriterMgr = 0; - fWriter = 0; + fEncoderMgr = NULL; + fWriterMgr = NULL; + fWriter = NULL; fWriterID = 0; - fFileClosed = 0; + fFileClosed = false; } void -BMediaFile::InitReader(BDataIO *source, int32 flags) +BMediaFile::_InitReader(BDataIO* source, int32 flags) { CALLED(); + if (source == NULL) + return; + fSource = source; - fExtractor = new MediaExtractor(source, flags); - fErr = fExtractor->InitCheck(); - if (fErr) + fExtractor = new (std::nothrow) MediaExtractor(source, flags); + if (fExtractor == NULL) + fErr = B_NO_MEMORY; + else + fErr = fExtractor->InitCheck(); + if (fErr != B_OK) return; fExtractor->GetFileFormatInfo(&fMFI); fTrackNum = fExtractor->StreamCount(); - fTrackList = new BMediaTrack *[fTrackNum]; - memset(fTrackList, 0, fTrackNum * sizeof(BMediaTrack *)); + fTrackList = new (std::nothrow) BMediaTrack*[fTrackNum]; + if (fTrackList == NULL) { + fErr = B_NO_MEMORY; + return; + } + memset(fTrackList, 0, fTrackNum * sizeof(BMediaTrack*)); } void -BMediaFile::InitWriter(BDataIO *source, const media_file_format * mfi, int32 flags) +BMediaFile::_InitWriter(BDataIO* source, const media_file_format* mfi, + int32 flags) { UNIMPLEMENTED(); fSource = source; From stippi at mail.berlios.de Sun Jun 7 21:43:27 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 21:43:27 +0200 Subject: [Haiku-commits] r30987 - in haiku/trunk: headers/os/media src/kits/media Message-ID: <200906071943.n57JhR4O013106@sheep.berlios.de> Author: stippi Date: 2009-06-07 21:43:26 +0200 (Sun, 07 Jun 2009) New Revision: 30987 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30987&view=rev Modified: haiku/trunk/headers/os/media/MediaFile.h haiku/trunk/src/kits/media/MediaFile.cpp Log: Added BMediaFile::_UnInit() and implemented the two SetTo() methods. Modified: haiku/trunk/headers/os/media/MediaFile.h =================================================================== --- haiku/trunk/headers/os/media/MediaFile.h 2009-06-07 19:35:14 UTC (rev 30986) +++ haiku/trunk/headers/os/media/MediaFile.h 2009-06-07 19:43:26 UTC (rev 30987) @@ -157,6 +157,7 @@ BMediaTrack** fTrackList; void _Init(); + void _UnInit(); void _InitReader(BDataIO* source, int32 flags = 0); void _InitWriter(BDataIO* source, const media_file_format* mfi, int32 flags); Modified: haiku/trunk/src/kits/media/MediaFile.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:35:14 UTC (rev 30986) +++ haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:43:26 UTC (rev 30987) @@ -78,16 +78,25 @@ status_t BMediaFile::SetTo(const entry_ref* ref) { - debugger("BMediaFile::SetTo not implemented"); - return B_OK; + CALLED(); + + _UnInit(); + fDeleteSource = true; + _InitReader(new (std::nothrow) BFile(ref, O_RDONLY)); + + return fErr; } status_t BMediaFile::SetTo(BDataIO* destination) { - debugger("BMediaFile::SetTo not implemented"); - return B_OK; + CALLED(); + + _UnInit(); + _InitReader(destination); + + return fErr; } @@ -95,11 +104,7 @@ { CALLED(); - ReleaseAllTracks(); - delete[] fTrackList; - delete fExtractor; - if (fDeleteSource) - delete fSource; + _UnInit(); } @@ -360,6 +365,23 @@ void +BMediaFile::_UnInit() +{ + ReleaseAllTracks(); + delete[] fTrackList; + fTrackList = NULL; + fTrackNum = 0; + delete fExtractor; + fExtractor = NULL; + if (fDeleteSource) { + delete fSource; + fSource = NULL; + fDeleteSource = false; + } +} + + +void BMediaFile::_InitReader(BDataIO* source, int32 flags) { CALLED(); From stippi at mail.berlios.de Sun Jun 7 21:45:06 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 21:45:06 +0200 Subject: [Haiku-commits] r30988 - haiku/trunk/src/kits/media Message-ID: <200906071945.n57Jj6Br013220@sheep.berlios.de> Author: stippi Date: 2009-06-07 21:45:04 +0200 (Sun, 07 Jun 2009) New Revision: 30988 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30988&view=rev Modified: haiku/trunk/src/kits/media/MediaFile.cpp Log: Check the params in SetTo(). Modified: haiku/trunk/src/kits/media/MediaFile.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:43:26 UTC (rev 30987) +++ haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:45:04 UTC (rev 30988) @@ -80,6 +80,9 @@ { CALLED(); + if (ref == NULL) + return B_BAD_VALUE; + _UnInit(); fDeleteSource = true; _InitReader(new (std::nothrow) BFile(ref, O_RDONLY)); @@ -93,6 +96,9 @@ { CALLED(); + if (destination == NULL) + return B_BAD_VALUE; + _UnInit(); _InitReader(destination); From stippi at mail.berlios.de Sun Jun 7 21:47:17 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 7 Jun 2009 21:47:17 +0200 Subject: [Haiku-commits] r30989 - haiku/trunk/src/kits/media Message-ID: <200906071947.n57JlHKb013449@sheep.berlios.de> Author: stippi Date: 2009-06-07 21:47:16 +0200 (Sun, 07 Jun 2009) New Revision: 30989 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30989&view=rev Modified: haiku/trunk/src/kits/media/MediaFile.cpp Log: _InitReader(): source can only be NULL if we tried to allocate it ourself, so we can set fErr to B_NO_MEMORY in that case. Modified: haiku/trunk/src/kits/media/MediaFile.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:45:04 UTC (rev 30988) +++ haiku/trunk/src/kits/media/MediaFile.cpp 2009-06-07 19:47:16 UTC (rev 30989) @@ -392,8 +392,10 @@ { CALLED(); - if (source == NULL) + if (source == NULL) { + fErr = B_NO_MEMORY; return; + } fSource = source; From axeld at mail.berlios.de Sun Jun 7 23:18:32 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 7 Jun 2009 23:18:32 +0200 Subject: [Haiku-commits] r30990 - haiku/trunk/headers/os/media Message-ID: <200906072118.n57LIW19022040@sheep.berlios.de> Author: axeld Date: 2009-06-07 23:18:32 +0200 (Sun, 07 Jun 2009) New Revision: 30990 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30990&view=rev Modified: haiku/trunk/headers/os/media/MediaFile.h Log: * Fixed license header to look like our others. Modified: haiku/trunk/headers/os/media/MediaFile.h =================================================================== --- haiku/trunk/headers/os/media/MediaFile.h 2009-06-07 19:47:16 UTC (rev 30989) +++ haiku/trunk/headers/os/media/MediaFile.h 2009-06-07 21:18:32 UTC (rev 30990) @@ -1,11 +1,11 @@ /* - * Copyright (c) 2002 - 2009, Haiku, Inc. All rights reserved. + * Copyright 2002-2009, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _MEDIA_FILE_H #define _MEDIA_FILE_H -#include +#include #include #include #include From marcusoverhagen at arcor.de Sun Jun 7 23:47:14 2009 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Sun, 07 Jun 2009 23:47:14 +0200 Subject: [Haiku-commits] r30982 - haiku/trunk/headers/private/media In-Reply-To: <200906071757.n57Hv1si003974@sheep.berlios.de> References: <200906071757.n57Hv1si003974@sheep.berlios.de> Message-ID: <4A2C3562.2050209@arcor.de> stippi at mail.berlios.de schrieb: > Remove() was completely broken if not removing the very last item. It was not broken. But now it is slower. Example: count = 4 item 0 item 1 item 2 item 3 === index = 1 delete item 1 item 0 item x item 2 item 3 === count = 3 copy [count] to [index] item 0 item 3 item 2 > Modified: haiku/trunk/headers/private/media/TList.h > =================================================================== > --- haiku/trunk/headers/private/media/TList.h 2009-06-07 14:54:11 UTC (rev 30981) > +++ haiku/trunk/headers/private/media/TList.h 2009-06-07 17:56:59 UTC (rev 30982) > @@ -68,9 +68,8 @@ > return false; > delete items[index]; > item_count--; > - items[index] = items[item_count]; > - if (index == item_iter) > - item_iter--; > + for (int i = index; i < item_count; i++) > + items[i] = items[i + 1]; > return true; > } regards Marcus From zooey at mail.berlios.de Mon Jun 8 00:06:38 2009 From: zooey at mail.berlios.de (zooey at BerliOS) Date: Mon, 8 Jun 2009 00:06:38 +0200 Subject: [Haiku-commits] r30991 - in haiku/branches/components/gsoc-locale-kit: . build/config_headers build/jam data/bin data/develop data/system/boot data/system/data/licenses headers/os/media headers/os/support headers/posix headers/posix/sys headers/private/graphics headers/private/graphics/nvidia headers/private/graphics/vesa headers/private/kernel headers/private/kernel/arch/x86 headers/private/locale headers/private/media src/add-ons/accelerants src/add-ons/accelerants/nvidia/engine src/add-ons/accelerants/vesa src/add-ons/kernel/debugger/demangle src/add-ons/kernel/debugger/disasm src/add-ons/kernel/drivers/graphics src/add-ons/kernel/drivers/graphics/vesa src/add-ons/kernel/file_systems/bfs src/add-ons/kernel/file_systems/iso9660 src/add-ons/kernel/file_systems/layers/attribute_overlay src/add-ons/kernel/file_systems/layers/write_overlay src/add-ons/kernel/file_systems/ntfs src/add-ons/kernel/file_systems/ntfs/libntfs src/add-ons/kernel/file_systems/ntfs/settings src/add-ons/kernel! /network/stack src/add-ons/kernel/partitioning_systems/efi src/add-ons/media/plugins/avcodec/libavcodec src/add-ons/media/plugins/matroska src/add-ons/media/plugins/matroska/libMatroskaParser src/add-ons/media/plugins/matroska/libebml src/add-ons/media/plugins/matroska/libebml/ebml src/add-ons/media/plugins/matroska/libmatroska src/add-ons/translators/hvif src/apps/activitymonitor src/apps/cdplayer src/apps/sudoku src/bin src/bin/addattr src/bin/coreutils/src src/bin/desklink src/bin/locale src/bin/mkfs src/bin/zip src/build/libbe/support src/build/libroot src/data/beos_mime/text src/data/etc/keymaps src/kits/bluetooth src/kits/interface src/kits/media src/kits/network/dns/irs src/kits/storage/disk_device src/kits/support src/kits/tracker src/preferences src/preferences/mouse src/servers/app src/servers/net src/system/kernel src/system/kernel/arch/x86 src/system/kernel/cache src/system/kernel/debug src/system/kernel/device_manager src/system/kernel/fs src/system/kernel/slab! src/system/kernel/vm src/system/libroot/posix/glibc/arch/gene! ric src/ Message-ID: <200906072206.n57M6cfZ025738@sheep.berlios.de> Author: zooey Date: 2009-06-08 00:06:21 +0200 (Mon, 08 Jun 2009) New Revision: 30991 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30991&view=rev Added: haiku/branches/components/gsoc-locale-kit/data/bin/freetype-config haiku/branches/components/gsoc-locale-kit/data/system/data/licenses/GNU LGPL v3 haiku/branches/components/gsoc-locale-kit/headers/private/graphics/ati/ haiku/branches/components/gsoc-locale-kit/headers/private/kernel/debug_heap.h haiku/branches/components/gsoc-locale-kit/headers/private/locale/langinfo.h haiku/branches/components/gsoc-locale-kit/headers/private/locale/monetary.h haiku/branches/components/gsoc-locale-kit/headers/private/locale/nl_types.h haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/ati/ haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/debugger/demangle/demangle.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/debugger/demangle/demangle.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/drivers/graphics/ati/ haiku/branches/components/gsoc-locale-kit/src/bin/watch.c haiku/branches/components/gsoc-locale-kit/src/system/kernel/debug/debug_heap.cpp haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/generic/s_llrint.c haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/generic/s_llrintf.c haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/generic/s_llrintl.c haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/generic/s_lrint.c haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/generic/s_lrintf.c haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/generic/s_lrintl.c haiku/branches/components/gsoc-locale-kit/src/tests/system/kernel/cache/file_map_test.cpp Removed: haiku/branches/components/gsoc-locale-kit/headers/posix/langinfo.h haiku/branches/components/gsoc-locale-kit/headers/posix/monetary.h haiku/branches/components/gsoc-locale-kit/headers/posix/nl_types.h haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/atimach64/ haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/drivers/graphics/atimach64/ haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/fsproto.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/version.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/version.h haiku/branches/components/gsoc-locale-kit/src/preferences/menu/ haiku/branches/components/gsoc-locale-kit/src/preferences/mouse/MouseBitmap.h Modified: haiku/branches/components/gsoc-locale-kit/build/config_headers/kernel_debug_config.h haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackageDependencies haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackages haiku/branches/components/gsoc-locale-kit/build/jam/ReleaseBuildProfiles haiku/branches/components/gsoc-locale-kit/configure haiku/branches/components/gsoc-locale-kit/data/develop/makefile haiku/branches/components/gsoc-locale-kit/data/develop/makefile-engine haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript.cd haiku/branches/components/gsoc-locale-kit/headers/os/media/MediaFile.h haiku/branches/components/gsoc-locale-kit/headers/os/support/String.h haiku/branches/components/gsoc-locale-kit/headers/posix/math.h haiku/branches/components/gsoc-locale-kit/headers/posix/sys/ioctl.h haiku/branches/components/gsoc-locale-kit/headers/private/graphics/nvidia/DriverInterface.h haiku/branches/components/gsoc-locale-kit/headers/private/graphics/nvidia/nv_macros.h haiku/branches/components/gsoc-locale-kit/headers/private/graphics/vesa/vesa.h haiku/branches/components/gsoc-locale-kit/headers/private/graphics/vesa/vesa_info.h haiku/branches/components/gsoc-locale-kit/headers/private/kernel/arch/x86/arch_int.h haiku/branches/components/gsoc-locale-kit/headers/private/kernel/boot_device.h haiku/branches/components/gsoc-locale-kit/headers/private/kernel/vm_types.h haiku/branches/components/gsoc-locale-kit/headers/private/media/DecoderPlugin.h haiku/branches/components/gsoc-locale-kit/headers/private/media/PluginManager.h haiku/branches/components/gsoc-locale-kit/headers/private/media/ReaderPlugin.h haiku/branches/components/gsoc-locale-kit/headers/private/media/TList.h haiku/branches/components/gsoc-locale-kit/headers/private/media/TMap.h haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/nvidia/engine/nv_general.c haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/nvidia/engine/nv_i2c.c haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/nvidia/engine/nv_info.c haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/nvidia/engine/nv_proto.h haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/vesa/dpms.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/accelerants/vesa/mode.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/debugger/demangle/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/debugger/demangle/gcc2.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/debugger/demangle/gcc3+.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/debugger/disasm/disasm.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/drivers/graphics/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/drivers/graphics/vesa/device.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/bfs/Debug.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/iso9660/iso9660.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/layers/attribute_overlay/attribute_overlay.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/layers/write_overlay/write_overlay.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/attributes.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/fs_func.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/attrib.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/attrlist.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/bitmap.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/bitmap.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/bootsect.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/compat.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/compress.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/debug.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/device.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/endians.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/index.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/index.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/inode.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/layout.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/lcnalloc.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/logfile.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/logging.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/mft.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/misc.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/mst.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/runlist.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/security.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/security.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/unix_io.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/volume.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/libntfs/win32_io.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/lock.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/ntfs.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/ntfsdir.h haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/settings/ntfs haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/utils.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/file_systems/ntfs/volume_util.c haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/network/stack/net_socket.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/avcodec/libavcodec/config.h haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.c haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/libMatroskaParser/MatroskaParser.h haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/libMatroskaParser/StreamIO.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/libebml/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/libebml/ebml/EbmlTypes.h haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/libmatroska/Jamfile haiku/branches/components/gsoc-locale-kit/src/add-ons/media/plugins/matroska/matroska_reader.cpp haiku/branches/components/gsoc-locale-kit/src/add-ons/translators/hvif/HVIFTranslator.cpp haiku/branches/components/gsoc-locale-kit/src/apps/activitymonitor/ActivityView.cpp haiku/branches/components/gsoc-locale-kit/src/apps/activitymonitor/CircularBuffer.h haiku/branches/components/gsoc-locale-kit/src/apps/cdplayer/Jamfile haiku/branches/components/gsoc-locale-kit/src/apps/sudoku/SudokuView.cpp haiku/branches/components/gsoc-locale-kit/src/bin/Jamfile haiku/branches/components/gsoc-locale-kit/src/bin/addattr/addAttr.cpp haiku/branches/components/gsoc-locale-kit/src/bin/addattr/addAttr.h haiku/branches/components/gsoc-locale-kit/src/bin/addattr/main.cpp haiku/branches/components/gsoc-locale-kit/src/bin/coreutils/src/copy.c haiku/branches/components/gsoc-locale-kit/src/bin/desklink/VolumeControl.cpp haiku/branches/components/gsoc-locale-kit/src/bin/locale/Jamfile haiku/branches/components/gsoc-locale-kit/src/bin/mkfs/FsCreator.cpp haiku/branches/components/gsoc-locale-kit/src/bin/mountvolume.cpp haiku/branches/components/gsoc-locale-kit/src/bin/zip/ttyio.h haiku/branches/components/gsoc-locale-kit/src/build/libbe/support/String.cpp haiku/branches/components/gsoc-locale-kit/src/build/libroot/fs.cpp haiku/branches/components/gsoc-locale-kit/src/data/beos_mime/text/x-source-code haiku/branches/components/gsoc-locale-kit/src/data/etc/keymaps/Colemak.keymap haiku/branches/components/gsoc-locale-kit/src/kits/bluetooth/Jamfile haiku/branches/components/gsoc-locale-kit/src/kits/interface/TextView.cpp haiku/branches/components/gsoc-locale-kit/src/kits/interface/View.cpp haiku/branches/components/gsoc-locale-kit/src/kits/interface/Window.cpp haiku/branches/components/gsoc-locale-kit/src/kits/media/DecoderPlugin.cpp haiku/branches/components/gsoc-locale-kit/src/kits/media/MediaFile.cpp haiku/branches/components/gsoc-locale-kit/src/kits/media/PluginManager.cpp haiku/branches/components/gsoc-locale-kit/src/kits/media/ReaderPlugin.cpp haiku/branches/components/gsoc-locale-kit/src/kits/network/dns/irs/lcl_ho.c haiku/branches/components/gsoc-locale-kit/src/kits/network/dns/irs/lcl_sv.cpp haiku/branches/components/gsoc-locale-kit/src/kits/storage/disk_device/Partition.cpp haiku/branches/components/gsoc-locale-kit/src/kits/support/String.cpp haiku/branches/components/gsoc-locale-kit/src/kits/support/Url.cpp haiku/branches/components/gsoc-locale-kit/src/kits/tracker/InfoWindow.cpp haiku/branches/components/gsoc-locale-kit/src/kits/tracker/InfoWindow.h haiku/branches/components/gsoc-locale-kit/src/preferences/Jamfile haiku/branches/components/gsoc-locale-kit/src/preferences/mouse/Mouse.rdef haiku/branches/components/gsoc-locale-kit/src/preferences/mouse/MouseView.cpp haiku/branches/components/gsoc-locale-kit/src/servers/app/app_server.rdef haiku/branches/components/gsoc-locale-kit/src/servers/net/Services.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/arch/x86/arch_debug.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/cache/block_cache.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/cache/file_map.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/debug/Jamfile haiku/branches/components/gsoc-locale-kit/src/system/kernel/debug/debug.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/debug/debug_commands.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/debug/debug_parser.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/device_manager/IOScheduler.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/device_manager/devfs.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/fs/vfs.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/fs/vfs_boot.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/slab/Slab.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/thread.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/vm/VMAnonymousCache.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/vm/vm.cpp haiku/branches/components/gsoc-locale-kit/src/system/kernel/vm/vm_cache.cpp haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/m68k/Jamfile haiku/branches/components/gsoc-locale-kit/src/system/libroot/posix/glibc/arch/ppc/Jamfile haiku/branches/components/gsoc-locale-kit/src/tests/add-ons/kernel/file_systems/random_file_actions/random_file_actions.cpp haiku/branches/components/gsoc-locale-kit/src/tests/add-ons/kernel/kernelland_emu/debug.cpp haiku/branches/components/gsoc-locale-kit/src/tests/system/kernel/cache/Jamfile haiku/branches/components/gsoc-locale-kit/src/tools/gensyscalls/gensyscalls.cpp Log: * merged changes from trunk up to r30990 Modified: haiku/branches/components/gsoc-locale-kit/build/config_headers/kernel_debug_config.h =================================================================== --- haiku/branches/components/gsoc-locale-kit/build/config_headers/kernel_debug_config.h 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/build/config_headers/kernel_debug_config.h 2009-06-07 22:06:21 UTC (rev 30991) @@ -18,6 +18,9 @@ // benaphore-style. #define KDEBUG KDEBUG_LEVEL_2 +// Size of the heap used by the kernel debugger. +#define KDEBUG_HEAP (64 * 1024) + // Set to 0 to disable support for kernel breakpoints. #define KERNEL_BREAKPOINTS 1 Modified: haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage =================================================================== --- haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage 2009-06-07 22:06:21 UTC (rev 30991) @@ -60,7 +60,7 @@ tr traceroute translate trash true truncate tsort tty uname unchop unexpand unmount uniq unlink unrar unshar unzip unzipsfx updatedb uptime urlwrapper useradd uudecode uuencode - vdir version vim vmstat waitfor wc wget whoami xargs xres yes + vdir version vim vmstat waitfor watch wc wget whoami xargs xres yes zdiff zforce zgrep zip zipcloak zipgrep zipnote zipsplit zmore znew ; @@ -71,7 +71,7 @@ StyledEdit Terminal TextSearch TV Workspaces ; SYSTEM_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations E-mail - FileTypes Fonts Keyboard Keymap Locale Media Menu Mouse Network Printers + FileTypes Fonts Keyboard Keymap Locale Media Mouse Network Printers Screen ScreenSaver Sounds Time Touchpad Tracker VirtualMemory ; SYSTEM_DEMOS = BSnow Chart Clock Cortex FontDemo @@ -100,6 +100,7 @@ $(X86_ONLY)nvidia.accelerant $(X86_ONLY)matrox.accelerant $(X86_ONLY)neomagic.accelerant $(X86_ONLY)intel_extreme.accelerant $(X86_ONLY)s3.accelerant $(X86_ONLY)vesa.accelerant + $(X86_ONLY)ati.accelerant #$(X86_ONLY)via.accelerant #$(X86_ONLY)vmware.accelerant ; @@ -142,6 +143,7 @@ SYSTEM_ADD_ONS_DRIVERS_GRAPHICS = $(X86_ONLY)radeon $(X86_ONLY)nvidia $(X86_ONLY)neomagic $(X86_ONLY)matrox $(X86_ONLY)intel_extreme $(X86_ONLY)s3 $(X86_ONLY)vesa #$(X86_ONLY)via #$(X86_ONLY)vmware + $(X86_ONLY)ati ; SYSTEM_ADD_ONS_DRIVERS_MIDI = emuxki ; SYSTEM_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com $(X86_ONLY)broadcom440x @@ -183,8 +185,8 @@ : uhci ohci ehci ; AddFilesToHaikuImage system add-ons kernel console : vga_text ; AddFilesToHaikuImage system add-ons kernel debugger - : $(X86_ONLY)disasm hangman invalidate_on_exit - usb_keyboard run_on_exit ; + : demangle $(X86_ONLY)disasm hangman + invalidate_on_exit usb_keyboard run_on_exit ; AddFilesToHaikuImage system add-ons kernel file_systems : $(SYSTEM_ADD_ONS_FILE_SYSTEMS) ; AddFilesToHaikuImage system add-ons kernel generic @@ -197,11 +199,6 @@ if $(TARGET_ARCH) = x86 { AddFilesToHaikuImage system add-ons kernel cpu : generic_x86 ; - - if $(HAIKU_GCC_VERSION[1]) = 2 { - AddFilesToHaikuImage system add-ons kernel debugger demangle : - gcc2 ; - } } # drivers Modified: haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackageDependencies =================================================================== --- haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackageDependencies 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackageDependencies 2009-06-07 22:06:21 UTC (rev 30991) @@ -3,11 +3,12 @@ # For transitive dependencies dependants should be listed before their # dependencies. +OptionalPackageDependencies Subversion : APR-util Neon LibIconv LibXML2 OpenSSL SQLite ; OptionalPackageDependencies APR-util : APR ; OptionalPackageDependencies BeHappy : BeBook NetSurf ; OptionalPackageDependencies Development : DevelopmentBase Perl ; -OptionalPackageDependencies DevelopmentBase : DevelopmentMin Yasm ; +OptionalPackageDependencies DevelopmentBase : CDRecord DevelopmentMin Yasm ; OptionalPackageDependencies LibLayout : DevelopmentBase ; OptionalPackageDependencies NetSurf : OpenSSL ; OptionalPackageDependencies OpenSSH : OpenSSL ; -OptionalPackageDependencies Subversion : OpenSSL ; + Modified: haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackages =================================================================== --- haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackages 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/build/jam/OptionalPackages 2009-06-07 22:06:21 UTC (rev 30991) @@ -20,14 +20,19 @@ # BeOSCompatibility # BePDF # Bluetooth +# CDRecord # CVS # Development - more complete dev environment (including autotools) # DevelopmentBase - basic development environment (gcc, headers, libs,...) # DevelopmentMin - development headers, libs, tools, from sources only # Firefox # KeymapSwitcher +# LibIconv # LibLayout +# LibXML2 # Links +# Nano +# Neon # NetSurf # OpenSound # OpenSSH @@ -35,10 +40,13 @@ # P7zip # Pe # Perl +# Python # Rsync +# SQLite # Subversion # Tar # UserlandFS +# Vim # Vision # VLC # Welcome @@ -51,9 +59,9 @@ if $(TARGET_ARCH) != x86 { Echo "No optional package APR available for $(TARGET_ARCH)" ; } else { - local baseURL = http://haiku-files.org/files/optional-packages ; - InstallOptionalHaikuImagePackage apr-0.9.17-gcc2-2008-05-20 - : $(baseURL)/apr-0.9.17-gcc2-2008-05-20.zip + local baseURL = http://www.haiku-ports.de/packages/dev-libs/apr ; + InstallOptionalHaikuImagePackage apr-1.3.3-gcc2-haiku-2009-05-27 + : $(baseURL)/apr-1.3.3-gcc2-haiku-2009-05-27.zip : ; } @@ -65,9 +73,9 @@ if $(TARGET_ARCH) != x86 { Echo "No optional package APR-util available for $(TARGET_ARCH)" ; } else { - local baseURL = http://haiku-files.org/files/optional-packages ; - InstallOptionalHaikuImagePackage apr-util-0.9.15-gcc2-2008-05-15 - : $(baseURL)/apr-util-0.9.15-gcc2-2008-05-15.zip + local baseURL = http://www.haiku-ports.de/packages/dev-libs/apr-util ; + InstallOptionalHaikuImagePackage apr-util-1.3.4-gcc2-haiku-2009-05-27 + : $(baseURL)/apr-util-1.3.4-gcc2-haiku-2009-05-27.zip : ; } @@ -179,6 +187,20 @@ } +# CDRecord +if [ IsOptionalHaikuImagePackageAdded CDRecord ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package CDRecord available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages ; + InstallOptionalHaikuImagePackage cdrecord-2.01.01a59-gcc2-haiku-2009-05-26 + : $(baseURL)/app-cdr/cdrtools/cdrecord-2.01.01a59-gcc2-haiku-2009-05-26.zip + : + ; + } +} + + # CVS if [ IsOptionalHaikuImagePackageAdded CVS ] { if $(TARGET_ARCH) != x86 { @@ -242,12 +264,14 @@ local baseURL = http://haiku-files.org/files/optional-packages ; InstallOptionalHaikuImagePackage bison-2.4-gcc2-2008-11-09 : $(baseURL)/bison-2.4-gcc2-2008-11-09.zip ; - InstallOptionalHaikuImagePackage flex-2.5.35-gcc2-2008-11-09 - : $(baseURL)/flex-2.5.35-gcc2-2008-11-09.zip ; - InstallOptionalHaikuImagePackage jam-haiku-gcc2-2008-03-27-2 - : $(baseURL)/jam-haiku-gcc2-2008-03-27-2.zip ; InstallOptionalHaikuImagePackage m4-1.4.12-gcc2-2008-11-04 : $(baseURL)/m4-1.4.12-gcc2-2008-11-04.zip ; + local baseURL = http://www.haiku-ports.de/packages ; + InstallOptionalHaikuImagePackage flex-2.5.35-gcc2-haiku-2009-05-26 + : $(baseURL)/sys-devel/flex/flex-2.5.35-gcc2-haiku-2009-05-26.zip ; + InstallOptionalHaikuImagePackage jam-gcc2-haiku-2009-05-26 + : $(baseURL)/dev-util/jam/jam-gcc2-haiku-2009-05-26.zip ; + } @@ -302,8 +326,8 @@ # ABI independent stuff - # scripts: cc and c++ wrapper, setgcc - local scripts = cc c++ setgcc ; + # scripts: cc and c++ wrapper, freetype-config, setgcc + local scripts = cc c++ freetype-config setgcc ; SEARCH on $(scripts) = [ FDirName $(HAIKU_TOP) data bin ] ; AddFilesToHaikuImage system bin : $(scripts) ; @@ -359,8 +383,9 @@ if $(TARGET_ARCH) != x86 { Echo "No optional package Firefox available for $(TARGET_ARCH)" ; } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + local baseURL = http://haiku-files.org/files/optional-packages ; InstallOptionalHaikuImagePackage BeZillaBrowser-2.0.0.21pre-haiku-gcc4-x86-09-03-01 - : http://haiku-files.org/files/optional-packages/BeZillaBrowser-2.0.0.21pre-haiku-gcc4-x86-09-03-01.zip + : $(baseURL)/BeZillaBrowser-2.0.0.21pre-haiku-gcc4-x86-09-03-01.zip : apps ; AddSymlinkToHaikuImage home config be Applications @@ -383,11 +408,17 @@ if $(TARGET_ARCH) != x86 { Echo "No optional package KeymapSwitcher available for $(TARGET_ARCH)" ; } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { - Echo "No optional package KeymapSwitcher available for gcc4" ; + local baseURL = http://downloads.sourceforge.net/dotmatrix4beos ; + InstallOptionalHaikuImagePackage KeymapSwitcher-gcc4-20090531 + : $(baseURL)/KeymapSwitcher-1.2.3-gcc4-2009-05-31.zip + : + ; + AddSymlinkToHaikuImage home config be Desktop\ Applets + : /boot/common/bin/KeymapSwitcher ; } else { local baseURL = http://downloads.sourceforge.net/dotmatrix4beos ; - InstallOptionalHaikuImagePackage KeymapSwitcher-gcc2-20090409 - : $(baseURL)/HaikuKeymapSwitcher-package-1.0.2.zip + InstallOptionalHaikuImagePackage KeymapSwitcher-gcc2-20090531 + : $(baseURL)/KeymapSwitcher-1.2.3-gcc2-2009-05-31.zip : ; AddSymlinkToHaikuImage home config be Desktop\ Applets @@ -396,6 +427,20 @@ } +# LibIconv +if [ IsOptionalHaikuImagePackageAdded LibIconv ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package LibIconv available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages/dev-libs/libiconv ; + InstallOptionalHaikuImagePackage libiconv-1.13-gcc2-haiku-2009-05-27 + : $(baseURL)/libiconv-1.13-gcc2-haiku-2009-05-27.zip + : + ; + } +} + + # LibLayout library if [ IsOptionalHaikuImagePackageAdded LibLayout ] { if $(TARGET_ARCH) != x86 { @@ -412,6 +457,20 @@ } +# LibXML2 +if [ IsOptionalHaikuImagePackageAdded LibXML2 ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package LibXML2 available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages/dev-libs/libxml2 ; + InstallOptionalHaikuImagePackage libxml2-2.7.3-gcc2-haiku-2009-05-27 + : $(baseURL)/libxml2-2.7.3-gcc2-haiku-2009-05-27.zip + : + ; + } +} + + # Links web browser if [ IsOptionalHaikuImagePackageAdded Links ] { if $(TARGET_ARCH) != x86 { @@ -429,6 +488,34 @@ } +# Nano +if [ IsOptionalHaikuImagePackageAdded Nano ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package Nano available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages ; + InstallOptionalHaikuImagePackage nano-2.0.9-gcc2-haiku-2009-05-27 + : $(baseURL)/app-editors/nano/nano-2.0.9-gcc2-haiku-2009-05-27.zip + : + ; + } +} + + +# Neon +if [ IsOptionalHaikuImagePackageAdded Neon ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package Neon available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages/net-misc/neon ; + InstallOptionalHaikuImagePackage neon-0.28.4-gcc2-haiku-2009-05-23 + : $(baseURL)/neon-0.28.4-gcc2-haiku-2009-05-23.zip + : + ; + } +} + + # NetSurf web browser if [ IsOptionalHaikuImagePackageAdded NetSurf ] { if $(TARGET_ARCH) != x86 { @@ -470,9 +557,9 @@ "variable to be set!" ; } - local baseURL = http://haiku-files.org/files/optional-packages ; - InstallOptionalHaikuImagePackage openssh-5.0p1-gcc2-2008-05-04-1 - : $(baseURL)/openssh-5.0p1-gcc2-2008-05-04-1.zip + local baseURL = http://www.haiku-ports.de/packages/net-misc/openssh ; + InstallOptionalHaikuImagePackage openssh-5.2p1-gcc2-haiku-2009-05-27 + : $(baseURL)/openssh-5.2p1-gcc2-haiku-2009-05-27.zip : ; @@ -502,8 +589,9 @@ } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { Echo "No optional package P7zip available for gcc4" ; } else { - InstallOptionalHaikuImagePackage p7zip-4.65-gcc2-haiku-2009-05-20 - : http://haiku-files.org/files/optional-packages/p7zip-4.65-gcc2-haiku-2009-05-20.zip + local baseURL = http://www.haiku-ports.de/packages/app-arch/p7zip ; + InstallOptionalHaikuImagePackage p7zip-4.65-gcc2-haiku-2009-05-24 + : $(baseURL)/p7zip-4.65-gcc2-haiku-2009-05-24.zip : ; @@ -560,6 +648,34 @@ } +# Python +if [ IsOptionalHaikuImagePackageAdded Python ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package Python available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages/dev-lang/python ; + InstallOptionalHaikuImagePackage python-2.6.2-gcc2-haiku-2009-05-27 + : $(baseURL)/python-2.6.2-gcc2-haiku-2009-05-27.zip + : + ; + } +} + + +# SQLite +if [ IsOptionalHaikuImagePackageAdded SQLite ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package SQLite available for $(TARGET_ARCH)" ; + } else { + local baseURL = http://www.haiku-ports.de/packages/dev-db/sqlite ; + InstallOptionalHaikuImagePackage sqlite-3.6.14-gcc2-haiku-2009-05-10 + : $(baseURL)/sqlite-3.6.14-gcc2-haiku-2009-05-10.zip + : + ; + } +} + + # Rsync if [ IsOptionalHaikuImagePackageAdded Rsync ] { if $(TARGET_ARCH) != x86 { @@ -579,9 +695,10 @@ if $(TARGET_ARCH) != x86 { Echo "No optional package Subversion available for $(TARGET_ARCH)" ; } else { - InstallOptionalHaikuImagePackage Subversion - : http://haiku.mlotz.ch/subversion-1.4.6-haiku-20080628.zip - : home + local baseURL = http://www.haiku-ports.de/packages/dev-util/subversion ; + InstallOptionalHaikuImagePackage subversion-1.6.2-gcc2-haiku-2009-05-20 + : $(baseURL)/subversion-1.6.2-gcc2-haiku-2009-05-20.zip + : ; } } @@ -654,6 +771,30 @@ } +# Vim +if [ IsOptionalHaikuImagePackageAdded Vim ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package Vim available for $(TARGET_ARCH)" ; + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + local baseURL = http://haiku-ports.de/packages/app-editors/vim ; + InstallOptionalHaikuImagePackage vim-7.2-gcc4-20090531 + : $(baseURL)/vim-7.2-gcc4-haiku-2009-05-31.zip + : + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/common/bin/gvim ; + } else { + local baseURL = http://haiku-ports.de/packages/app-editors/vim ; + InstallOptionalHaikuImagePackage vim-7.2-gcc2-20090531 + : $(baseURL)/vim-7.2-gcc2-haiku-2009-05-31.zip + : + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/common/bin/gvim ; + } +} + + # Vision if [ IsOptionalHaikuImagePackageAdded Vision ] { if $(TARGET_ARCH) != x86 { Modified: haiku/branches/components/gsoc-locale-kit/build/jam/ReleaseBuildProfiles =================================================================== --- haiku/branches/components/gsoc-locale-kit/build/jam/ReleaseBuildProfiles 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/build/jam/ReleaseBuildProfiles 2009-06-07 22:06:21 UTC (rev 30991) @@ -9,7 +9,7 @@ HAIKU_ROOT_USER_REAL_NAME = "Yourself" ; AddGroupToHaikuImage party : 101 : user sshd ; HAIKU_IMAGE_HOST_NAME = shredder ; - HAIKU_IMAGE_SIZE = 400 ; + HAIKU_IMAGE_SIZE = 500 ; AddOptionalHaikuImagePackages BePDF Firefox Pe Vision VLC WonderBrush ; AddOptionalHaikuImagePackages CVS Development Subversion OpenSSH Yasm ; Modified: haiku/branches/components/gsoc-locale-kit/configure =================================================================== --- haiku/branches/components/gsoc-locale-kit/configure 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/configure 2009-06-07 22:06:21 UTC (rev 30991) @@ -399,6 +399,17 @@ fi fi +# check for case-sensitive filesystem if on darwin +if [ $buildPlatform = "darwin" ]; then + diskutil info . | grep -i "case-sensitive" > /dev/null + if [ $? != 0 ]; then + echo "You need a case-sensitive file-system to build Haiku." + echo "Please see the following guide on how to set one up:" + echo "http://haiku-os.org/documents/dev/how_to_build_haiku_on_mac_os_x" + exit 1 + fi +fi + # create output directory if [ "$currentDir" = "$sourceDir" ]; then outputDir=$currentDir/generated Copied: haiku/branches/components/gsoc-locale-kit/data/bin/freetype-config (from rev 30990, haiku/trunk/data/bin/freetype-config) Modified: haiku/branches/components/gsoc-locale-kit/data/develop/makefile =================================================================== --- haiku/branches/components/gsoc-locale-kit/data/develop/makefile 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/data/develop/makefile 2009-06-07 22:06:21 UTC (rev 30991) @@ -1,4 +1,4 @@ -## BeOS Generic Makefile v2.2 ## +## BeOS Generic Makefile v2.3 ## ## Fill in this file to specify the project being created, and the referenced ## makefile-engine will do all of the hard work for you. This handles both Modified: haiku/branches/components/gsoc-locale-kit/data/develop/makefile-engine =================================================================== --- haiku/branches/components/gsoc-locale-kit/data/develop/makefile-engine 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/data/develop/makefile-engine 2009-06-07 22:06:21 UTC (rev 30991) @@ -2,7 +2,7 @@ ## Does all the hard work for the Generic Makefile ## which simply defines the project parameters -## Supports Generic Makefile v2.0, 2.01, 2.1, 2.2 +## Supports Generic Makefile v2.0, 2.01, 2.1, 2.2, 2.3 # determine wheather running on x86 or ppc MACHINE=$(shell uname -m) @@ -351,9 +351,9 @@ # rules to compile resource definition files $(OBJ_DIR)/%.rsrc : %.rdef - $(RESCOMP) -o $@ $< + cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -o $@ - $(OBJ_DIR)/%.rsrc : %.RDEF - $(RESCOMP) -o $@ $< + cat $< | $(CC) -E $(INCLUDES) $(CFLAGS) - | grep -v '^#' | $(RESCOMP) -o $@ - # rules to handle lex/flex and yacc/bison files Modified: haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript =================================================================== --- haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript 2009-06-07 22:06:21 UTC (rev 30991) @@ -70,8 +70,8 @@ launchscript $SCRIPTS/SetupEnvironment # If the boot volume is a CD we use another script -iw=`/bin/isvolume -readonly-partition /boot` -if [ "$iw" = "yes" ]; then +isReadOnly=`/bin/isvolume -readonly-partition /boot` +if [ "$isReadOnly" = "yes" ]; then # block the CD tray (avoid accidental ejection) # This option stays 'on' even if we continue booting to the desktop. /bin/eject -b /boot @@ -105,7 +105,7 @@ fi # Now ask the user if he wants to run the Installer or continue to the Desktop. -if [ "$iw" = "yes" ]; then +if [ "$isReadOnly" = "yes" ]; then /bin/alert "Do you wish to run the Installer or continue booting to the Desktop?" "Installer" "Desktop" if [ $? -eq 0 ]; then launchscript $SCRIPTS/Bootscript.cd Modified: haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript.cd =================================================================== --- haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript.cd 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/data/system/boot/Bootscript.cd 2009-06-07 22:06:21 UTC (rev 30991) @@ -57,6 +57,7 @@ #launch system/apps/Terminal else launch system/bin/consoled + exit 0 # return so we don't eject and reboot fi # sync disks Copied: haiku/branches/components/gsoc-locale-kit/data/system/data/licenses/GNU LGPL v3 (from rev 30990, haiku/trunk/data/system/data/licenses/GNU LGPL v3) Modified: haiku/branches/components/gsoc-locale-kit/headers/os/media/MediaFile.h =================================================================== --- haiku/branches/components/gsoc-locale-kit/headers/os/media/MediaFile.h 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/headers/os/media/MediaFile.h 2009-06-07 22:06:21 UTC (rev 30991) @@ -1,12 +1,15 @@ +/* + * Copyright 2002-2009, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _MEDIA_FILE_H #define _MEDIA_FILE_H -#include -#include -#include +#include #include #include #include +#include namespace BPrivate { @@ -45,172 +48,179 @@ // class BMediaFile { - public: - // these four constructors are used for read-only access - BMediaFile( const entry_ref *ref); - BMediaFile( BDataIO * source); // BFile is a BDataIO - BMediaFile( const entry_ref * ref, - int32 flags); - BMediaFile( BDataIO * source, - int32 flags); // BFile is a BDataIO + // these four constructors are used for read-only access + BMediaFile(const entry_ref* ref); + BMediaFile(BDataIO* source); + // BFile is a BDataIO + BMediaFile(const entry_ref* ref, int32 flags); + BMediaFile(BDataIO* source, int32 flags); - // these three constructors are for read-write access - BMediaFile(const entry_ref *ref, // these two are write-only - const media_file_format * mfi, - int32 flags=0); - BMediaFile(BDataIO *destination, // BFile is a BDataIO - const media_file_format * mfi, - int32 flags=0); - BMediaFile(const media_file_format * mfi, // set file later using SetTo() - int32 flags=0); + // these three constructors are for read-write access + BMediaFile(const entry_ref* ref, + const media_file_format* mfi, + int32 flags = 0); + BMediaFile(BDataIO* destination, + const media_file_format* mfi, + int32 flags = 0); + BMediaFile(const media_file_format* mfi, + int32 flags = 0); + // set file later using SetTo() - status_t SetTo(const entry_ref *ref); - status_t SetTo(BDataIO *destination); // BFile is a BDataIO + virtual ~BMediaFile(); + + status_t SetTo(const entry_ref* ref); + status_t SetTo(BDataIO* destination); - virtual ~BMediaFile(); + status_t InitCheck() const; - status_t InitCheck() const; - // Get info about the underlying file format. - status_t GetFileFormatInfo(media_file_format *mfi) const; + status_t GetFileFormatInfo(media_file_format* mfi) const; // // These functions are for read-only access to a media file. // The data is read using the BMediaTrack object. // - const char *Copyright(void) const; - int32 CountTracks() const; + const char* Copyright() const; + int32 CountTracks() const; // Can be called multiple times with the same index. You must call // ReleaseTrack() when you're done with a track. - BMediaTrack *TrackAt(int32 index); + BMediaTrack* TrackAt(int32 index); // Release the resource used by a given BMediaTrack object, to reduce // the memory usage of your application. The specific 'track' object // can no longer be used, but you can create another one by calling // TrackAt() with the same track index. - status_t ReleaseTrack(BMediaTrack *track); + status_t ReleaseTrack(BMediaTrack* track); - // A convenience. - status_t ReleaseAllTracks(void); + // A convenience. Deleting a BMediaFile will also call this. + status_t ReleaseAllTracks(); // Create and add a track to the media file - BMediaTrack *CreateTrack(media_format *mf, const media_codec_info *mci, uint32 flags=0); + BMediaTrack* CreateTrack(media_format* mf, + const media_codec_info* mci, + uint32 flags = 0); // Create and add a raw track to the media file (it has no encoder) - BMediaTrack *CreateTrack(media_format *mf, uint32 flags=0); + BMediaTrack* CreateTrack(media_format* mf, + uint32 flags = 0); // Lets you set the copyright info for the entire file - status_t AddCopyright(const char *data); + status_t AddCopyright(const char* data); // Call this to add user-defined chunks to a file (if they're supported) - status_t AddChunk(int32 type, const void *data, size_t size); + status_t AddChunk(int32 type, const void* data, + size_t size); // After you have added all the tracks you want, call this - status_t CommitHeader(void); + status_t CommitHeader(); // After you have written all the data to the track objects, call this - status_t CloseFile(void); + status_t CloseFile(); // This is for controlling file format parameters // returns a copy of the parameter web - status_t GetParameterWeb(BParameterWeb** outWeb); - status_t GetParameterValue(int32 id, void *valu, size_t *size); - status_t SetParameterValue(int32 id, const void *valu, size_t size); - BView *GetParameterView(); + status_t GetParameterWeb(BParameterWeb** outWeb); + status_t GetParameterValue(int32 id, void* value, + size_t* size); + status_t SetParameterValue(int32 id, const void* value, + size_t size); + BView* GetParameterView(); // For the future... - virtual status_t Perform(int32 selector, void * data); + virtual status_t Perform(int32 selector, void* data); private: // deprecated, but for R5 compatibility - BParameterWeb *Web(); + BParameterWeb* Web(); // Does nothing, returns B_ERROR, for Zeta compatiblity only - status_t ControlFile(int32 selector, void * io_data, size_t size); + status_t ControlFile(int32 selector, void* ioData, + size_t size); - BPrivate::media::MediaExtractor *fExtractor; - int32 _reserved_BMediaFile_was_fExtractorID; - int32 fTrackNum; - status_t fErr; + BPrivate::media::MediaExtractor* fExtractor; + int32 _reserved_BMediaFile_was_fExtractorID; + int32 fTrackNum; + status_t fErr; - BPrivate::_AddonManager *fEncoderMgr; - BPrivate::_AddonManager *fWriterMgr; - BPrivate::MediaWriter *fWriter; - int32 fWriterID; - media_file_format fMFI; + BPrivate::_AddonManager* fEncoderMgr; + BPrivate::_AddonManager* fWriterMgr; + BPrivate::MediaWriter* fWriter; + int32 fWriterID; + media_file_format fMFI; - bool fFileClosed; - bool fDeleteSource; - bool _reserved_was_fUnused[2]; - BMediaTrack **fTrackList; + bool fFileClosed; + bool fDeleteSource; + bool _reserved_was_fUnused[2]; + BMediaTrack** fTrackList; - void Init(); - void InitReader(BDataIO *source, int32 flags = 0); - void InitWriter(BDataIO *source, const media_file_format * mfi, - int32 flags); + void _Init(); + void _UnInit(); + void _InitReader(BDataIO* source, int32 flags = 0); + void _InitWriter(BDataIO* source, + const media_file_format* mfi, int32 flags); - BMediaFile(); - BMediaFile(const BMediaFile&); - BMediaFile& operator=(const BMediaFile&); + BMediaFile(); + BMediaFile(const BMediaFile&); + BMediaFile& operator=(const BMediaFile&); - BDataIO *fSource; + BDataIO* fSource; - /* fbc data and virtuals */ + // FBC data and virtuals - uint32 _reserved_BMediaFile_[32]; + uint32 _reserved_BMediaFile_[32]; -virtual status_t _Reserved_BMediaFile_0(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_1(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_2(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_3(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_4(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_5(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_6(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_7(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_8(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_9(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_10(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_11(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_12(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_13(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_14(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_15(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_16(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_17(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_18(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_19(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_20(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_21(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_22(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_23(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_24(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_25(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_26(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_27(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_28(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_29(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_30(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_31(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_32(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_33(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_34(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_35(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_36(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_37(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_38(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_39(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_40(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_41(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_42(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_43(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_44(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_45(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_46(int32 arg, ...); -virtual status_t _Reserved_BMediaFile_47(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_0(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_1(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_2(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_3(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_4(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_5(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_6(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_7(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_8(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_9(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_10(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_11(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_12(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_13(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_14(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_15(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_16(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_17(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_18(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_19(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_20(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_21(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_22(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_23(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_24(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_25(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_26(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_27(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_28(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_29(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_30(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_31(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_32(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_33(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_34(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_35(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_36(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_37(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_38(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_39(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_40(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_41(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_42(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_43(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_44(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_45(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_46(int32 arg, ...); + virtual status_t _Reserved_BMediaFile_47(int32 arg, ...); }; #endif Modified: haiku/branches/components/gsoc-locale-kit/headers/os/support/String.h =================================================================== --- haiku/branches/components/gsoc-locale-kit/headers/os/support/String.h 2009-06-07 21:18:32 UTC (rev 30990) +++ haiku/branches/components/gsoc-locale-kit/headers/os/support/String.h 2009-06-07 22:06:21 UTC (rev 30991) @@ -1,5 +1,5 @@ /* -* Copyright 2001-2008, Haiku Inc. All Rights Reserved. +* Copyright 2001-2009, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef __BSTRING__ @@ -16,251 +16,281 @@ class BString { public: - BString(); - BString(const char* string); - BString(const BString& string); - BString(const char* string, int32 maxLength); - ~BString(); + BString(); + BString(const char* string); + BString(const BString& string); + BString(const char* string, int32 maxLength); + ~BString(); - // Access - const char* String() const; - int32 Length() const; - int32 CountChars() const; + // Access + const char* String() const; + int32 Length() const; + int32 CountChars() const; - // Assignment - BString& operator=(const BString& string); - BString& operator=(const char* string); - BString& operator=(char c); + // Assignment + BString& operator=(const BString& string); + BString& operator=(const char* string); + BString& operator=(char c); - BString& SetTo(const char* string); - BString& SetTo(const char* string, int32 maxLength); + BString& SetTo(const char* string); + BString& SetTo(const char* string, int32 maxLength); - BString& SetTo(const BString& string); - BString& Adopt(BString& from); + BString& SetTo(const BString& string); + BString& Adopt(BString& from); - BString& SetTo(const BString& string, int32 maxLength); - BString& Adopt(BString& from, int32 maxLength); + BString& SetTo(const BString& string, int32 maxLength); + BString& Adopt(BString& from, int32 maxLength); - BString& SetTo(char c, int32 count); + BString& SetTo(char c, int32 count); - // Substring copying - BString& CopyInto(BString& into, int32 fromOffset, int32 length) const; - void CopyInto(char* into, int32 fromOffset, int32 length) const; + // Substring copying + BString& CopyInto(BString& into, int32 fromOffset, + int32 length) const; + void CopyInto(char* into, int32 fromOffset, + int32 length) const; - // Appending - BString& operator+=(const BString& string); - BString& operator+=(const char* string); - BString& operator+=(char c); + // Appending + BString& operator+=(const BString& string); + BString& operator+=(const char* string); + BString& operator+=(char c); - BString& Append(const BString& string); - BString& Append(const char* string); + BString& Append(const BString& string); + BString& Append(const char* string); - BString& Append(const BString& string, int32 length); - BString& Append(const char* string, int32 length); - BString& Append(char c, int32 count); + BString& Append(const BString& string, int32 length); + BString& Append(const char* string, int32 length); + BString& Append(char c, int32 count); - // Prepending - BString& Prepend(const char* string); - BString& Prepend(const BString& string); - BString& Prepend(const char* string, int32 length); - BString& Prepend(const BString& string, int32 length); - BString& Prepend(char c, int32 count); + // Prepending + BString& Prepend(const char* string); + BString& Prepend(const BString& string); + BString& Prepend(const char* string, int32 length); + BString& Prepend(const BString& string, int32 length); + BString& Prepend(char c, int32 count); - // Inserting - BString& Insert(const char* string, int32 position); - BString& Insert(const char* string, int32 length, int32 position); - BString& Insert(const char* string, int32 fromOffset, int32 length, - int32 position); - BString& Insert(const BString& string, int32 position); - BString& Insert(const BString& string, int32 length, int32 position); - BString& Insert(const BString& string, int32 fromOffset, int32 length, - int32 position); - BString& Insert(char c, int32 count, int32 position); + // Inserting + BString& Insert(const char* string, int32 position); + BString& Insert(const char* string, int32 length, + int32 position); + BString& Insert(const char* string, int32 fromOffset, + int32 length, int32 position); + BString& Insert(const BString& string, int32 position); + BString& Insert(const BString& string, int32 length, + int32 position); + BString& Insert(const BString& string, int32 fromOffset, + int32 length, int32 position); + BString& Insert(char c, int32 count, int32 position); - // Removing - BString& Truncate(int32 newLength, bool lazy = true); - BString& Remove(int32 from, int32 length); + // Removing + BString& Truncate(int32 newLength, bool lazy = true); + BString& Remove(int32 from, int32 length); - BString& RemoveFirst(const BString& string); - BString& RemoveLast(const BString& string); - BString& RemoveAll(const BString& string); + BString& RemoveFirst(const BString& string); + BString& RemoveLast(const BString& string); [... truncated: 25666 lines follow ...] From zooey at mail.berlios.de Mon Jun 8 00:19:05 2009 From: zooey at mail.berlios.de (zooey at BerliOS) Date: Mon, 8 Jun 2009 00:19:05 +0200 Subject: [Haiku-commits] r30992 - in haiku/branches/components/gsoc-locale-kit/headers: posix private/locale Message-ID: <200906072219.n57MJ5uc026624@sheep.berlios.de> Author: zooey Date: 2009-06-08 00:19:04 +0200 (Mon, 08 Jun 2009) New Revision: 30992 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30992&view=rev Added: haiku/branches/components/gsoc-locale-kit/headers/posix/langinfo.h haiku/branches/components/gsoc-locale-kit/headers/posix/monetary.h haiku/branches/components/gsoc-locale-kit/headers/posix/nl_types.h Removed: haiku/branches/components/gsoc-locale-kit/headers/private/locale/langinfo.h haiku/branches/components/gsoc-locale-kit/headers/private/locale/monetary.h haiku/branches/components/gsoc-locale-kit/headers/private/locale/nl_types.h Log: * undid protective move of three locale kit related headers that has just been merged from trunk Copied: haiku/branches/components/gsoc-locale-kit/headers/posix/langinfo.h (from rev 30991, haiku/branches/components/gsoc-locale-kit/headers/private/locale/langinfo.h) Copied: haiku/branches/components/gsoc-locale-kit/headers/posix/monetary.h (from rev 30991, haiku/branches/components/gsoc-locale-kit/headers/private/locale/monetary.h) Copied: haiku/branches/components/gsoc-locale-kit/headers/posix/nl_types.h (from rev 30991, haiku/branches/components/gsoc-locale-kit/headers/private/locale/nl_types.h) Deleted: haiku/branches/components/gsoc-locale-kit/headers/private/locale/langinfo.h Deleted: haiku/branches/components/gsoc-locale-kit/headers/private/locale/monetary.h Deleted: haiku/branches/components/gsoc-locale-kit/headers/private/locale/nl_types.h From zooey at mail.berlios.de Mon Jun 8 00:23:47 2009 From: zooey at mail.berlios.de (zooey at BerliOS) Date: Mon, 8 Jun 2009 00:23:47 +0200 Subject: [Haiku-commits] r30993 - in haiku/branches/components/gsoc-locale-kit: build/jam src/kits/locale Message-ID: <200906072223.n57MNlnJ027982@sheep.berlios.de> Author: zooey Date: 2009-06-08 00:23:46 +0200 (Mon, 08 Jun 2009) New Revision: 30993 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30993&view=rev Modified: haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage haiku/branches/components/gsoc-locale-kit/src/kits/locale/LocaleRoster.cpp Log: * applying patch from Adrien that allows proper loading of catalog add-ons Modified: haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage =================================================================== --- haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage 2009-06-07 22:19:04 UTC (rev 30992) +++ haiku/branches/components/gsoc-locale-kit/build/jam/HaikuImage 2009-06-07 22:23:46 UTC (rev 30993) @@ -109,6 +109,7 @@ RAWTranslator RTF-Translator SGITranslator STXTTranslator TGATranslator TIFFTranslator WonderBrushTranslator ; +SYSTEM_ADD_ONS_LOCALE_CATALOGS = zeta ; SYSTEM_ADD_ONS_MEDIA = cortex_audioadapter.media_addon cortex_flanger.media_addon dvb.media_addon hmulti_audio.media_addon @@ -452,6 +453,7 @@ : Mesa\ Software\ Renderer ; AddFilesToHaikuHybridImage system add-ons Translators : $(SYSTEM_ADD_ONS_TRANSLATORS) : : true ; +AddFilesToHaikuImage system add-ons locale catalogs : $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ; AddFilesToHaikuImage system add-ons mail_daemon inbound_protocols : POP3 IMAP ; AddFilesToHaikuImage system add-ons mail_daemon outbound_protocols : SMTP ; AddFilesToHaikuImage system add-ons mail_daemon inbound_filters : Match\ Header Spam\ Filter R5\ Daemon\ Filter ; Modified: haiku/branches/components/gsoc-locale-kit/src/kits/locale/LocaleRoster.cpp =================================================================== --- haiku/branches/components/gsoc-locale-kit/src/kits/locale/LocaleRoster.cpp 2009-06-07 22:19:04 UTC (rev 30992) +++ haiku/branches/components/gsoc-locale-kit/src/kits/locale/LocaleRoster.cpp 2009-06-07 22:23:46 UTC (rev 30993) @@ -211,7 +211,7 @@ directory_which folders[] = { B_COMMON_ADDONS_DIRECTORY, - B_BEOS_ADDONS_DIRECTORY, + B_SYSTEM_ADDONS_DIRECTORY, static_cast(-1) }; BPath addOnPath; @@ -255,11 +255,15 @@ if (image >= B_OK) { uint8 *prioPtr; if (get_image_symbol(image, "gCatalogAddOnPriority", - B_SYMBOL_TYPE_TEXT, + B_SYMBOL_TYPE_DATA, (void **)&prioPtr) == B_OK) { priority = *prioPtr; node.WriteAttr(kPriorityAttr, B_INT8_TYPE, 0, &priority, sizeof(int8)); + } else { + log_team(LOG_ERR, + "couldn't get priority for add-on %s\n", + fullAddOnPath.String()); } unload_add_on(image); } else { From superstippi at gmx.de Mon Jun 8 01:05:11 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 08 Jun 2009 01:05:11 +0200 Subject: [Haiku-commits] r30982 - haiku/trunk/headers/private/media In-Reply-To: <4A2C3562.2050209@arcor.de> References: <200906071757.n57Hv1si003974@sheep.berlios.de> <4A2C3562.2050209@arcor.de> Message-ID: <20090607230511.157240@gmx.net> Hi Marcus, > stippi at mail.berlios.de schrieb: > > Remove() was completely broken if not removing the very last item. > > It was not broken. But now it is slower. Indeed. Sorry about that. Somehow I thought keeping the order was important... Will fix ASAP. Best regards, -Stephan From leavengood at gmail.com Mon Jun 8 02:03:11 2009 From: leavengood at gmail.com (Ryan Leavengood) Date: Sun, 7 Jun 2009 20:03:11 -0400 Subject: [Haiku-commits] r30983 - haiku/trunk/headers/private/media In-Reply-To: <200906071804.n57I4XAN004544@sheep.berlios.de> References: <200906071804.n57I4XAN004544@sheep.berlios.de> Message-ID: On Sun, Jun 7, 2009 at 2:04 PM, wrote: > > Just saw that _Remove(index) here was as broken as in TList.h. This should also be reverted. Regards, Ryan From leavengood at mail.berlios.de Mon Jun 8 07:46:16 2009 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Mon, 8 Jun 2009 07:46:16 +0200 Subject: [Haiku-commits] r30994 - haiku/trunk/src/apps/terminal Message-ID: <200906080546.n585kGV4027902@sheep.berlios.de> Author: leavengood Date: 2009-06-08 07:46:16 +0200 (Mon, 08 Jun 2009) New Revision: 30994 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30994&view=rev Modified: haiku/trunk/src/apps/terminal/TermScrollView.cpp Log: Overlapping the top of the scrollbar button no longer makes sense with a tabbed Terminal. It just makes the button look improperly clipped when tabs are being used. I am not totally happy in how this looks though, and if someone has other ideas feel free to fix it up (maybe a line under the tabs when they are showing?) Modified: haiku/trunk/src/apps/terminal/TermScrollView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermScrollView.cpp 2009-06-07 22:23:46 UTC (rev 30993) +++ haiku/trunk/src/apps/terminal/TermScrollView.cpp 2009-06-08 05:46:16 UTC (rev 30994) @@ -42,9 +42,8 @@ BRect frame(fVerticalScrollBar->Frame()); RemoveChild(fVerticalScrollBar); - // Overlap one pixel at the top and the bottom of the scroll bar with - // the menu respectively resize knob for aesthetical reasons. - frame.top -= 1; + // Overlap one pixel at the bottom of the scroll bar with + // the resize knob for aesthetical reasons. frame.bottom -= B_H_SCROLL_BAR_HEIGHT - 1; TermScrollBar* scrollBar = new TermScrollBar(frame, "_VSB_", target, 0, From stippi at mail.berlios.de Mon Jun 8 09:02:00 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Mon, 8 Jun 2009 09:02:00 +0200 Subject: [Haiku-commits] r30995 - haiku/trunk/headers/private/media Message-ID: <200906080702.n58720l7000960@sheep.berlios.de> Author: stippi Date: 2009-06-08 09:01:58 +0200 (Mon, 08 Jun 2009) New Revision: 30995 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30995&view=rev Modified: haiku/trunk/headers/private/media/TList.h haiku/trunk/headers/private/media/TMap.h Log: Fixed Remove() operations to be O(1) again, I just didn't get it. The item sorting does not need to be preserved. Thanks Marcus! Modified: haiku/trunk/headers/private/media/TList.h =================================================================== --- haiku/trunk/headers/private/media/TList.h 2009-06-08 05:46:16 UTC (rev 30994) +++ haiku/trunk/headers/private/media/TList.h 2009-06-08 07:01:58 UTC (rev 30995) @@ -68,8 +68,9 @@ return false; delete items[index]; item_count--; - for (int i = index; i < item_count; i++) - items[i] = items[i + 1]; + items[index] = items[item_count]; + if (index == item_iter) + item_iter--; return true; } Modified: haiku/trunk/headers/private/media/TMap.h =================================================================== --- haiku/trunk/headers/private/media/TMap.h 2009-06-08 05:46:16 UTC (rev 30994) +++ haiku/trunk/headers/private/media/TMap.h 2009-06-08 07:01:58 UTC (rev 30995) @@ -150,8 +150,9 @@ return false; delete items[index]; item_count--; - for (int i = index; i < item_count; i++) - items[i] = items[i + 1]; + items[index] = items[item_count]; + if (index == item_iter) + item_iter--; return true; } From axeld at pinc-software.de Mon Jun 8 09:58:03 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 08 Jun 2009 09:58:03 +0200 CEST Subject: [Haiku-commits] r30994 - haiku/trunk/src/apps/terminal In-Reply-To: <200906080546.n585kGV4027902@sheep.berlios.de> Message-ID: <802235362-BeMail@zon> leavengood at BerliOS wrote: > I am not totally happy in how this looks though, and if someone has > other ideas > feel free to fix it up (maybe a line under the tabs when they are > showing?) I think this should be made conditionally, at least, so that it does not "hurt" the looks without tabs. Bye, Axel. From axeld at mail.berlios.de Mon Jun 8 10:53:55 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 8 Jun 2009 10:53:55 +0200 Subject: [Haiku-commits] r30996 - haiku/trunk/src/add-ons/kernel/file_systems/ntfs Message-ID: <200906080853.n588rt2U014117@sheep.berlios.de> Author: axeld Date: 2009-06-08 10:53:53 +0200 (Mon, 08 Jun 2009) New Revision: 30996 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30996&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.h Log: * Fixed missing B_FS_IS_READONLY flag in fs_rfsstat(). This fixes bug #4009. * Fixed many occurences of incorrect operator order, ie. "!flags & FLAG" does not what you might think it does. * Added TODOs to functionally questionable code. I really don't think this file system should actually be used read-write. Deleting files seems to be completely broken. * Fixed mixup of B_MOUNT_READ_ONLY vs. B_FS_IS_READONLY in nspace::flags. * Fixed many, many style issues, that file really was a mess. * Honoured 80 characters per line limit. Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c 2009-06-08 07:01:58 UTC (rev 30995) +++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c 2009-06-08 08:53:53 UTC (rev 30996) @@ -66,7 +66,7 @@ if (!na) return ENOENT; - if (!ni->flags & FILE_ATTR_HIDDEN) { + if (!(ni->flags & FILE_ATTR_HIDDEN)) { if (na->data_size == 0) *_type = S_IFIFO; } @@ -101,9 +101,9 @@ { NTFS_BOOT_SECTOR boot; identify_cookie *cookie; - ntfs_volume *ntVolume; - uint8 *buf=(uint8*)&boot; - char devpath[256]; + ntfs_volume *ntVolume; + uint8 *buf = (uint8*)&boot; + char devpath[256]; // read in the boot sector ERRPRINT("fs_identify_partition: read in the boot sector\n"); @@ -112,53 +112,56 @@ } // check boot signature - if (((buf[0x1fe] != 0x55) || (buf[0x1ff] != 0xaa)) && (buf[0x15] == 0xf8)) + if ((buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) && buf[0x15] == 0xf8) return -1; - //check boot signature NTFS - if (memcmp(buf+3, "NTFS ", 8)!=0) + // check boot signature NTFS + if (memcmp(buf + 3, "NTFS ", 8) != 0) return -1; - //get path for device - if(!ioctl(fd,B_GET_PATH_FOR_DEVICE,devpath)) + // get path for device + if (!ioctl(fd, B_GET_PATH_FOR_DEVICE, devpath)) return -1; - //try mount - ntVolume = utils_mount_volume(devpath,MS_RDONLY,true); - if(!ntVolume) + + // try mount + ntVolume = utils_mount_volume(devpath, MS_RDONLY, true); + if (!ntVolume) return -1; - //allocate identify_cookie + // allocate identify_cookie cookie = (identify_cookie *)malloc(sizeof(identify_cookie)); if (!cookie) return -1; - memcpy(&(cookie->boot),&boot,512); + memcpy(&cookie->boot, &boot, 512); - strcpy(cookie->label,"NTFS Volume"); + strcpy(cookie->label, "NTFS Volume"); - if(ntVolume->vol_name) - if(strlen(ntVolume->vol_name)>0) - strcpy(cookie->label,ntVolume->vol_name); + if (ntVolume->vol_name && ntVolume->vol_name[0] != '\0') + strcpy(cookie->label, ntVolume->vol_name); - ntfs_umount( ntVolume, true ); + ntfs_umount(ntVolume, true); *_cookie = cookie; return 0.8f; } + status_t fs_scan_partition(int fd, partition_data *partition, void *_cookie) { identify_cookie *cookie = (identify_cookie *)_cookie; partition->status = B_PARTITION_VALID; partition->flags |= B_PARTITION_FILE_SYSTEM; - partition->content_size = sle64_to_cpu(cookie->boot.number_of_sectors) * le16_to_cpu(cookie->boot.bpb.bytes_per_sector); + partition->content_size = sle64_to_cpu(cookie->boot.number_of_sectors) + * le16_to_cpu(cookie->boot.bpb.bytes_per_sector); partition->block_size = le16_to_cpu(cookie->boot.bpb.bytes_per_sector); partition->content_name = strdup(cookie->label); return B_OK; } + void fs_free_identify_partition_cookie(partition_data *partition, void *_cookie) { @@ -168,51 +171,55 @@ status_t -fs_mount(fs_volume *_vol, const char *device, ulong flags, const char *args, ino_t *_rootID) +fs_mount(fs_volume *_vol, const char *device, ulong flags, const char *args, + ino_t *_rootID) { - nspace *ns; - vnode *newNode = NULL; - char lockname[32]; - void *handle; - unsigned long mnt_flags = 0; - status_t result = B_NO_ERROR; + nspace *ns; + vnode *newNode = NULL; + char lockname[32]; + void *handle; + unsigned long mountFlags = 0; + status_t result = B_NO_ERROR; ERRPRINT("fs_mount - ENTER\n"); ns = ntfs_malloc(sizeof(nspace)); if (!ns) { result = ENOMEM; - goto exit; + goto exit; } *ns = (nspace) { .state = NF_FreeClustersOutdate | NF_FreeMFTOutdate, .show_sys_files = false, - .ro = false + .ro = false, + .flags = 0 }; - ns->flags = flags; - strcpy(ns->devicePath,device); sprintf(lockname, "ntfs_lock %lx", ns->id); recursive_lock_init_etc(&(ns->vlock), lockname, MUTEX_FLAG_CLONE_NAME); handle = load_driver_settings("ntfs"); - ns->show_sys_files = ! (strcasecmp(get_driver_parameter(handle, "hide_sys_files", "true", "true"), "true") == 0); - ns->ro = strcasecmp(get_driver_parameter(handle, "read_only", "false", "false"), "false") != 0; - ns->noatime = strcasecmp(get_driver_parameter(handle, "no_atime", "true", "true"), "true") == 0; + ns->show_sys_files = ! (strcasecmp(get_driver_parameter(handle, + "hide_sys_files", "true", "true"), "true") == 0); + ns->ro = strcasecmp(get_driver_parameter(handle, "read_only", "false", + "false"), "false") != 0; + ns->noatime = strcasecmp(get_driver_parameter(handle, "no_atime", "true", + "true"), "true") == 0; unload_driver_settings(handle); - if (ns->ro || ns->flags & B_MOUNT_READ_ONLY) { - mnt_flags |= MS_RDONLY; - ns->flags |= B_MOUNT_READ_ONLY; + if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0) { + mountFlags |= MS_RDONLY; + ns->flags |= B_FS_IS_READONLY; } // if (ns->noatime) // mnt_flags |= MS_NOATIME; - ns->ntvol=utils_mount_volume(device,mnt_flags,true); - if(ns->ntvol!=NULL) + // TODO: this does not take read-only volumes into account! + ns->ntvol = utils_mount_volume(device, mountFlags, true); + if (ns->ntvol != NULL) result = B_NO_ERROR; else result = errno; @@ -223,22 +230,20 @@ _vol->private_volume = (void *)ns; _vol->ops = &gNTFSVolumeOps; - newNode = (vnode*)ntfs_calloc( sizeof(vnode) ); - if ( newNode == NULL ) + newNode = (vnode*)ntfs_calloc(sizeof(vnode)); + if (newNode == NULL) result = ENOMEM; else { - newNode->vnid = *_rootID; newNode->parent_vnid = -1; - result = publish_vnode( _vol, *_rootID, (void*)newNode, + result = publish_vnode(_vol, *_rootID, (void*)newNode, &gNTFSVnodeOps, S_IFDIR, 0); - if ( result != B_NO_ERROR ) { - free( ns ); + if (result != B_NO_ERROR) { + free(ns); result = EINVAL; - goto exit; - } - else { + goto exit; + } else { result = B_NO_ERROR; ntfs_mark_free_space_outdated(ns); ntfs_calc_free_space(ns); @@ -247,36 +252,37 @@ } exit: - ERRPRINT("fs_mount - EXIT, result code is %s\n", strerror(result)); return result; } + status_t fs_unmount(fs_volume *_vol) { - nspace *ns = (nspace*)_vol->private_volume; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + status_t result = B_NO_ERROR; ERRPRINT("fs_unmount - ENTER\n"); - ntfs_umount( ns->ntvol, true ); + ntfs_umount(ns->ntvol, true); recursive_lock_destroy(&(ns->vlock)); - free( ns ); + free(ns); ERRPRINT("fs_unmount - EXIT, result is %s\n", strerror(result)); return result; } + status_t -fs_rfsstat( fs_volume *_vol, struct fs_info * fss ) +fs_rfsstat(fs_volume *_vol, struct fs_info *fss) { - nspace *ns = (nspace*)_vol->private_volume; - int i; + nspace *ns = (nspace*)_vol->private_volume; + int i; LOCK_VOL(ns); @@ -286,23 +292,25 @@ fss->dev = ns->id; fss->root = FILE_root; - fss->flags = B_FS_IS_PERSISTENT|B_FS_HAS_MIME|B_FS_HAS_ATTR; + fss->flags = B_FS_IS_PERSISTENT | B_FS_HAS_MIME | B_FS_HAS_ATTR | ns->flags; + fss->block_size = ns->ntvol->cluster_size; fss->io_size = 65536; fss->total_blocks = ns->ntvol->nr_clusters; fss->free_blocks = ns->free_clusters; - strncpy( fss->device_name, ns->devicePath, sizeof(fss->device_name)); - strncpy( fss->volume_name, ns->ntvol->vol_name, sizeof(fss->volume_name) ); + strncpy(fss->device_name, ns->devicePath, sizeof(fss->device_name)); + strncpy(fss->volume_name, ns->ntvol->vol_name, sizeof(fss->volume_name)); - for (i = strlen(fss->volume_name)-1; i >=0 ; i--) + for (i = strlen(fss->volume_name) - 1; i >=0 ; i--) { if (fss->volume_name[i] != ' ') break; + } if (i < 0) strcpy(fss->volume_name, "NTFS Untitled"); else fss->volume_name[i + 1] = 0; - strcpy( fss->fsh_name, "NTFS" ); + strcpy(fss->fsh_name, "NTFS"); ERRPRINT("fs_rfsstat - EXIT\n"); @@ -313,10 +321,10 @@ status_t -fs_wfsstat( fs_volume *_vol, const struct fs_info * fss, uint32 mask) +fs_wfsstat(fs_volume *_vol, const struct fs_info *fss, uint32 mask) { - nspace* ns = (nspace*)_vol->private_volume; - status_t result = B_NO_ERROR; + nspace* ns = (nspace*)_vol->private_volume; + status_t result = B_NO_ERROR; if (ns->flags & B_FS_IS_READONLY) { ERRPRINT("ntfs is read-only\n"); @@ -326,79 +334,78 @@ LOCK_VOL(ns); if (mask & FS_WRITE_FSINFO_NAME) { - result = ntfs_change_label( ns->ntvol, (char*)fss->volume_name ); + result = ntfs_change_label(ns->ntvol, (char*)fss->volume_name); goto exit; } exit: - UNLOCK_VOL(ns); return result; } + status_t fs_walk(fs_volume *_vol, fs_vnode *_dir, const char *file, ino_t *vnid) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *baseNode = (vnode*)_dir->private_node; - vnode *newNode = NULL; - ntfschar *unicode = NULL; - ntfs_inode *bi = NULL; - status_t result = B_NO_ERROR; - int len; + nspace *ns = (nspace*)_vol->private_volume; + vnode *baseNode = (vnode*)_dir->private_node; + vnode *newNode = NULL; + ntfschar *unicode = NULL; + ntfs_inode *bi = NULL; + status_t result = B_NO_ERROR; + int len; LOCK_VOL(ns); ERRPRINT("fs_walk - ENTER : find for \"%s\"\n",file); - if(ns == NULL || _dir == NULL || file == NULL || vnid == NULL) { - result = EINVAL; - goto exit; - } + if (ns == NULL || _dir == NULL || file == NULL || vnid == NULL) { + result = EINVAL; + goto exit; + } - if ( !strcmp( file, "." ) ) { + if (!strcmp(file, ".")) { *vnid = baseNode->vnid; - if ( get_vnode( _vol, *vnid, (void**)&newNode ) != 0 ) + if (get_vnode(_vol, *vnid, (void**)&newNode) != 0) result = ENOENT; - } else if ( !strcmp( file, ".." ) && baseNode->vnid != FILE_root ) { + } else if (!strcmp(file, "..") && baseNode->vnid != FILE_root) { *vnid = baseNode->parent_vnid; - if ( get_vnode( _vol, *vnid, (void**)&newNode ) != 0 ) + if (get_vnode(_vol, *vnid, (void**)&newNode) != 0) result = ENOENT; } else { - unicode = ntfs_calloc(MAX_PATH); - len = ntfs_mbstoucs(file, &unicode); - if (len < 0) { - result = EILSEQ; - goto exit; - } + unicode = ntfs_calloc(MAX_PATH); + len = ntfs_mbstoucs(file, &unicode); + if (len < 0) { + result = EILSEQ; + goto exit; + } - bi = ntfs_inode_open(ns->ntvol, baseNode->vnid); - if(!bi) { - result = ENOENT; - goto exit; - } + bi = ntfs_inode_open(ns->ntvol, baseNode->vnid); + if (!bi) { + result = ENOENT; + goto exit; + } - *vnid = MREF( ntfs_inode_lookup_by_name(bi, unicode, len) ); - ERRPRINT("fs_walk - VNID = %d\n",*vnid); + *vnid = MREF(ntfs_inode_lookup_by_name(bi, unicode, len)); + ERRPRINT("fs_walk - VNID = %d\n",*vnid); - ntfs_inode_close(bi); - free(unicode); + ntfs_inode_close(bi); + free(unicode); - if ( *vnid == (u64) -1 ) { - result = EINVAL; - goto exit; - } + if (*vnid == (u64)-1) { + result = EINVAL; + goto exit; + } - if( get_vnode( _vol, *vnid, (void**)&newNode ) !=0 ) - result = ENOENT; + if (get_vnode(_vol, *vnid, (void**)&newNode) != 0) + result = ENOENT; - if(newNode!=NULL) - newNode->parent_vnid = baseNode->vnid; + if (newNode!=NULL) + newNode->parent_vnid = baseNode->vnid; } exit: - ERRPRINT("fs_walk - EXIT, result is %s\n", strerror(result)); UNLOCK_VOL(ns); @@ -406,37 +413,39 @@ return result; } + status_t -fs_get_vnode_name(fs_volume *_vol, fs_vnode *_vnode, char *buffer, size_t bufferSize) +fs_get_vnode_name(fs_volume *_vol, fs_vnode *_vnode, char *buffer, + size_t bufferSize) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_vnode->private_node; - ntfs_inode *ni=NULL; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_vnode->private_node; + ntfs_inode *ni = NULL; + status_t result = B_NO_ERROR; - char path[MAX_PATH]; - char *name; + char path[MAX_PATH]; + char *name; LOCK_VOL(ns); ni = ntfs_inode_open(ns->ntvol, node->vnid); - if(ni==NULL) { - result = ENOENT; - goto exit; + if (ni == NULL) { + result = ENOENT; + goto exit; } - if(utils_inode_get_name(ni, path, MAX_PATH)==0) { + if (utils_inode_get_name(ni, path, MAX_PATH) == 0) { result = EINVAL; - goto exit; + goto exit; } + name = strrchr(path, '/'); name++; strlcpy(buffer, name, bufferSize); exit: - - if(ni) + if (ni) ntfs_inode_close(ni); UNLOCK_VOL(ns); @@ -446,14 +455,15 @@ status_t -fs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type, uint32 *_flags, bool reenter) +fs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type, + uint32 *_flags, bool reenter) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *newNode = NULL; - ntfs_inode *ni=NULL; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *newNode = NULL; + ntfs_inode *ni = NULL; + status_t result = B_NO_ERROR; - if ( !reenter ) + if (!reenter) LOCK_VOL(ns); ERRPRINT("fs_read_vnode - ENTER\n"); @@ -462,8 +472,8 @@ _node->ops = &gNTFSVnodeOps; _flags = 0; - newNode = (vnode*)ntfs_calloc( sizeof(vnode) ); - if ( newNode != NULL ) { + newNode = (vnode*)ntfs_calloc(sizeof(vnode)); + if (newNode != NULL) { char *name = NULL; ni = ntfs_inode_open(ns->ntvol, vnid); @@ -480,23 +490,22 @@ newNode->vnid = vnid; newNode->parent_vnid = ntfs_get_parent_ref(ni); - if( ni->mrec->flags & MFT_RECORD_IS_DIRECTORY ) + if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) set_mime(newNode, ".***"); else { name = (char*)malloc(MAX_PATH); - if(name!=NULL) { - if(utils_inode_get_name(ni, name,MAX_PATH)==1) + if (name != NULL) { + if (utils_inode_get_name(ni, name,MAX_PATH) == 1) set_mime(newNode, name); free(name); } } _node->private_node = newNode; - } - else + } else result = ENOMEM; + exit: - if (ni != NULL) ntfs_inode_close(ni); @@ -505,78 +514,80 @@ ERRPRINT("fs_read_vnode - EXIT, result is %s\n", strerror(result)); - if ( !reenter ) + if (!reenter) UNLOCK_VOL(ns); return result; } + status_t -fs_write_vnode( fs_volume *_vol, fs_vnode *_node, bool reenter ) +fs_write_vnode(fs_volume *_vol, fs_vnode *_node, bool reenter) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_node->private_node; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_node->private_node; + status_t result = B_NO_ERROR; - if ( !reenter ) + if (!reenter) LOCK_VOL(ns); ERRPRINT("fs_write_vnode - ENTER (%Ld)\n", node->vnid); - if (node) - free( node ); + free(node); ERRPRINT("fs_write_vnode - EXIT\n"); - if ( !reenter ) + if (!reenter) UNLOCK_VOL(ns); return result; } + status_t -fs_remove_vnode( fs_volume *_vol, fs_vnode *_node, bool reenter ) +fs_remove_vnode(fs_volume *_vol, fs_vnode *_node, bool reenter) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_node->private_node; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_node->private_node; + status_t result = B_NO_ERROR; - if ( !reenter ) + // TODO: this does not look right! The space if the node must be freed *here* + if (!reenter) LOCK_VOL(ns); ERRPRINT("fs_remove_vnode - ENTER (%Ld)\n", node->vnid); - if(node) - free(node); + free(node); ERRPRINT("fs_remove_vnode - EXIT, result is %s\n", strerror(result)); - if ( !reenter ) + if (!reenter) UNLOCK_VOL(ns); return result; } + status_t -fs_rstat( fs_volume *_vol, fs_vnode *_node, struct stat *stbuf ) +fs_rstat(fs_volume *_vol, fs_vnode *_node, struct stat *stbuf) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_node->private_node; - ntfs_inode *ni = NULL; - ntfs_attr *na; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_node->private_node; + ntfs_inode *ni = NULL; + ntfs_attr *na; + status_t result = B_NO_ERROR; LOCK_VOL(ns); ERRPRINT("fs_rstat - ENTER:\n"); - if(ns==NULL || node ==NULL ||stbuf==NULL) { + if (ns == NULL || node == NULL ||stbuf == NULL) { result = ENOENT; goto exit; } ni = ntfs_inode_open(ns->ntvol, node->vnid); - if(ni==NULL) { + if (ni == NULL) { result = ENOENT; goto exit; } @@ -584,7 +595,7 @@ stbuf->st_dev = ns->id; stbuf->st_ino = MREF(ni->mft_no); - if ( ni->mrec->flags & MFT_RECORD_IS_DIRECTORY ) { + if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) { stbuf->st_mode = FS_DIR_MODE; na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (na) { @@ -608,12 +619,14 @@ stbuf->st_size = na->data_size; - if (!ni->flags & FILE_ATTR_HIDDEN) { + if (!(ni->flags & FILE_ATTR_HIDDEN)) { if (na->data_size == 0) stbuf->st_mode = S_IFIFO; } - if (na->data_size <= sizeof(INTX_FILE_TYPES) + sizeof(ntfschar) * MAX_PATH && na->data_size >sizeof(INTX_FILE_TYPES)) { + if (na->data_size <= sizeof(INTX_FILE_TYPES) + + sizeof(ntfschar) * MAX_PATH + && na->data_size >sizeof(INTX_FILE_TYPES)) { INTX_FILE *intx_file; intx_file = ntfs_malloc(na->data_size); @@ -622,7 +635,8 @@ ntfs_attr_close(na); goto exit; } - if (ntfs_attr_pread(na, 0, na->data_size,intx_file) != na->data_size) { + if (ntfs_attr_pread(na, 0, na->data_size,intx_file) + != na->data_size) { result = EINVAL; free(intx_file); ntfs_attr_close(na); @@ -637,7 +651,7 @@ } if (ns->flags & B_FS_IS_READONLY) { - stbuf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); + stbuf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); } stbuf->st_uid = 0; @@ -647,8 +661,7 @@ stbuf->st_mtime = ni->last_data_change_time; exit: - - if(ni) + if (ni) ntfs_inode_close(ni); ERRPRINT("fs_rstat - EXIT, result is %s\n", strerror(result)); @@ -656,35 +669,33 @@ UNLOCK_VOL(ns); return result; - } + status_t -fs_wstat( fs_volume *_vol, fs_vnode *_node, const struct stat *st, uint32 mask ) +fs_wstat(fs_volume *_vol, fs_vnode *_node, const struct stat *st, uint32 mask) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_node->private_node; - ntfs_inode *ni = NULL; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_node->private_node; + ntfs_inode *ni = NULL; + status_t result = B_NO_ERROR; LOCK_VOL(ns); ERRPRINT("fs_wstat: ENTER\n"); ni = ntfs_inode_open(ns->ntvol, node->vnid); - if(ni==NULL) { - result = ENOENT; - goto exit; + if (ni == NULL) { + result = ENOENT; + goto exit; } - if ( mask & B_STAT_SIZE ) { - + if (mask & B_STAT_SIZE) { ERRPRINT("fs_wstat: setting file size to %Lx\n", st->st_size); - if ( ni->mrec->flags & MFT_RECORD_IS_DIRECTORY ) { + if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) { result = EISDIR; } else { - ntfs_attr *na = ntfs_attr_open(ni, AT_DATA, NULL, 0); if (!na) { result = EINVAL; @@ -701,7 +712,6 @@ } if (mask & B_STAT_MODIFICATION_TIME) { - ERRPRINT("fs_wstat: setting modification time\n"); ni->last_access_time = st->st_atime; @@ -712,8 +722,7 @@ } exit: - - if(ni) + if (ni) ntfs_inode_close(ni); ERRPRINT("fs_wstat: EXIT with (%s)\n", strerror(result)); @@ -744,10 +753,10 @@ status_t fs_fsync(fs_volume *_vol, fs_vnode *_node) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_node->private_node; - ntfs_inode *ni = NULL; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_node->private_node; + ntfs_inode *ni = NULL; + status_t result = B_NO_ERROR; LOCK_VOL(ns); @@ -759,16 +768,15 @@ } ni = ntfs_inode_open(ns->ntvol, node->vnid); - if(ni==NULL) { - result = ENOENT; - goto exit; + if (ni == NULL) { + result = ENOENT; + goto exit; } ntfs_inode_sync(ni); exit: - - if(ni) + if (ni) ntfs_inode_close(ni); ERRPRINT("fs_fsync: EXIT\n"); @@ -778,56 +786,54 @@ return result; } + status_t fs_open(fs_volume *_vol, fs_vnode *_node, int omode, void **_cookie) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *node = (vnode*)_node->private_node; - filecookie *cookie=NULL; - ntfs_inode *ni=NULL; - ntfs_attr *na = NULL; - status_t result = B_NO_ERROR; + nspace *ns = (nspace*)_vol->private_volume; + vnode *node = (vnode*)_node->private_node; + filecookie *cookie = NULL; + ntfs_inode *ni = NULL; + ntfs_attr *na = NULL; + status_t result = B_NO_ERROR; LOCK_VOL(ns); ERRPRINT("fs_open - ENTER\n"); - if(node==NULL) { + if (node == NULL) { result = EINVAL; - goto exit; + goto exit; } ni = ntfs_inode_open(ns->ntvol, node->vnid); - if(ni==NULL) { - result = errno; - goto exit; + if (ni == NULL) { + result = errno; + goto exit; } - if(omode & O_TRUNC) { - na = ntfs_attr_open(ni, AT_DATA, NULL, 0); - if(na) { - if(ntfs_attr_truncate(na, 0)) - result = errno; - } else + if (omode & O_TRUNC) { + na = ntfs_attr_open(ni, AT_DATA, NULL, 0); + if (na) { + if (ntfs_attr_truncate(na, 0)) result = errno; - } + } else + result = errno; + } - cookie = (filecookie*)ntfs_calloc( sizeof(filecookie) ); + cookie = (filecookie*)ntfs_calloc(sizeof(filecookie)); - if ( cookie != NULL ) - { + if (cookie != NULL) { cookie->omode = omode; *_cookie = (void*)cookie; - } - else + } else result = ENOMEM; exit: - - if(na) + if (na) ntfs_attr_close(na); - if(ni) + if (ni) ntfs_inode_close(ni); ERRPRINT("fs_open - EXIT\n"); @@ -839,18 +845,19 @@ status_t -fs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode, int perms, void **_cookie, ino_t *_vnid) +fs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode, + int perms, void **_cookie, ino_t *_vnid) { - nspace *ns = (nspace*)_vol->private_volume; - vnode *dir = (vnode*)_dir->private_node; - filecookie *cookie = NULL; - vnode *newNode = NULL; - ntfs_attr *na = NULL; - ntfs_inode *ni=NULL; - ntfs_inode *bi=NULL; - ntfschar *uname = NULL; - status_t result = B_NO_ERROR; - int uname_len; + nspace *ns = (nspace*)_vol->private_volume; + vnode *dir = (vnode*)_dir->private_node; + filecookie *cookie = NULL; + vnode *newNode = NULL; + ntfs_attr *na = NULL; + ntfs_inode *ni = NULL; + ntfs_inode *bi = NULL; + ntfschar *uname = NULL; + status_t result = B_NO_ERROR; + int unameLength; if (ns->flags & B_FS_IS_READONLY) { ERRPRINT("ntfs is read-only\n"); @@ -861,64 +868,65 @@ ERRPRINT("fs_create - ENTER: name=%s\n",name); - if(_vol==NULL || _dir==NULL) { + if (_vol == NULL || _dir == NULL) { result = EINVAL; goto exit; } - if (name == NULL || *name == '\0' || strchr(name, '/') || strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { + if (name == NULL || *name == '\0' || strchr(name, '/') + || strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { result = EINVAL; goto exit; } bi = ntfs_inode_open(ns->ntvol, dir->vnid); - if(bi==NULL) { - result = ENOENT; - goto exit; + if (bi == NULL) { + result = ENOENT; + goto exit; } - if ( !bi->mrec->flags & MFT_RECORD_IS_DIRECTORY ) { - result = EINVAL; + if (!(bi->mrec->flags & MFT_RECORD_IS_DIRECTORY)) { + result = EINVAL; goto exit; } - uname_len = ntfs_mbstoucs(name, &uname); - if (uname_len < 0) { + unameLength = ntfs_mbstoucs(name, &uname); + if (unameLength < 0) { result = EINVAL; goto exit; } - cookie = (filecookie*)ntfs_calloc( sizeof(filecookie) ); + cookie = (filecookie*)ntfs_calloc(sizeof(filecookie)); - if ( cookie != NULL ) { + if (cookie != NULL) { cookie->omode = omode; } else { result = ENOMEM; - goto exit; + goto exit; } ni = ntfs_pathname_to_inode(ns->ntvol, bi, name); - if(ni) { //file exist - *_vnid = MREF( ni->mft_no ); - if(omode & O_TRUNC) { + if (ni) { + // file exists + *_vnid = MREF(ni->mft_no); + if (omode & O_TRUNC) { na = ntfs_attr_open(ni, AT_DATA, NULL, 0); - if(na) { - if(ntfs_attr_truncate(na, 0)) + if (na) { + if (ntfs_attr_truncate(na, 0)) result = errno; } else result = errno; } } else { - ni = ntfs_create(bi, uname, uname_len, S_IFREG); - + ni = ntfs_create(bi, uname, unameLength, S_IFREG); if (ni) { - *_vnid = MREF( ni->mft_no ); + *_vnid = MREF(ni->mft_no); - newNode = (vnode*)ntfs_calloc( sizeof(vnode) ); - if(newNode==NULL) { - result=ENOMEM; + newNode = (vnode*)ntfs_calloc(sizeof(vnode)); + if (newNode == NULL) { + result = ENOMEM; goto exit; - } + } newNode->vnid = *_vnid; newNode->parent_vnid = MREF(bi->mft_no); @@ -930,8 +938,7 @@ ntfs_mark_free_space_outdated(ns); - notify_entry_created(ns->id, MREF( bi->mft_no ), name, *_vnid); [... truncated: 1148 lines follow ...] From axeld at mail.berlios.de Mon Jun 8 11:40:58 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 8 Jun 2009 11:40:58 +0200 Subject: [Haiku-commits] r30997 - haiku/trunk/build/jam Message-ID: <200906080940.n589ewVM018965@sheep.berlios.de> Author: axeld Date: 2009-06-08 11:40:58 +0200 (Mon, 08 Jun 2009) New Revision: 30997 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30997&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * Fixed TODO and replaced the target duplication of DESKBAR_PREFERENCES by stripping the grist of SYSTEM_PREFERENCES. This also finally closes #3976 again. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-08 08:53:53 UTC (rev 30996) +++ haiku/trunk/build/jam/HaikuImage 2009-06-08 09:40:58 UTC (rev 30997) @@ -292,12 +292,7 @@ # Deskbar Preferences links AddDirectoryToHaikuImage home config be Preferences ; -# TODO/NOTE: Cannot use $(SYSTEM_PREFERENCES) here since there is -# "Tracker"... -DESKBAR_PREFERENCES = Appearance Backgrounds CPUFrequency DataTranslations - E-mail FileTypes Fonts Keyboard Keymap Locale Media Menu Mouse Network - Printers Screen ScreenSaver Sounds Time Touchpad Tracker VirtualMemory -; +DESKBAR_PREFERENCES = $(SYSTEM_PREFERENCES:B) ; for linkTarget in $(DESKBAR_PREFERENCES) { AddSymlinkToHaikuImage home config be Preferences : /boot/system/preferences/$(linkTarget) : $(linkTarget) ; From ingo_weinhold at gmx.de Mon Jun 8 12:14:12 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 08 Jun 2009 12:14:12 +0200 Subject: [Haiku-commits] r30996 - haiku/trunk/src/add-ons/kernel/file_systems/ntfs In-Reply-To: <200906080853.n588rt2U014117@sheep.berlios.de> References: <200906080853.n588rt2U014117@sheep.berlios.de> Message-ID: <20090608121412.436.1@knochen-vm.localdomain> On 2009-06-08 at 10:53:55 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2009-06-08 10:53:53 +0200 (Mon, 08 Jun 2009) > New Revision: 30996 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30996&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.c > haiku/trunk/src/add-ons/kernel/file_systems/ntfs/fs_func.h > Log: > * Fixed missing B_FS_IS_READONLY flag in fs_rfsstat(). This fixes bug #4009. > * Fixed many occurences of incorrect operator order, ie. "!flags & FLAG" > does > not what you might think it does. > * Added TODOs to functionally questionable code. I really don't think this > file > system should actually be used read-write. Deleting files seems to be > completely broken. Besides, as long as our VFS doesn't translate sync() to fsync()s it's not really safe to use file systems that don't explicitly support sync() anyway. CU, Ingo From axeld at mail.berlios.de Mon Jun 8 15:06:38 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 8 Jun 2009 15:06:38 +0200 Subject: [Haiku-commits] r30998 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200906081306.n58D6cPc006127@sheep.berlios.de> Author: axeld Date: 2009-06-08 15:06:37 +0200 (Mon, 08 Jun 2009) New Revision: 30998 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30998&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp Log: * The attribute directory of the root directory was ignored. This could lead to data corruption after a checkfs run. Fixes bug #3963. * Added some more debug output. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp 2009-06-08 09:40:58 UTC (rev 30997) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp 2009-06-08 13:06:37 UTC (rev 30998) @@ -1233,8 +1233,9 @@ // TODO: update the allocation groups used blocks info for (uint32 i = size >> 2; i-- > 0;) { uint32 compare = 1; + // Count the number of bits set for (int16 j = 0; j < 32; j++, compare <<= 1) { - if (compare & fCheckBitmap[i]) + if ((compare & fCheckBitmap[i]) != 0) usedBlocks++; } } @@ -1247,10 +1248,28 @@ // Should we fix errors? Were there any errors we can fix? if ((control->flags & BFS_FIX_BITMAP_ERRORS) != 0 && (control->stats.freed != 0 || control->stats.missing != 0)) { - // if so, write the check bitmap back over the original one, + // If so, write the check bitmap back over the original one, // and use transactions here to play safe - we even use several // transactions, so that we don't blow the maximum log size - // on large disks; since we don't need to make this atomic + // on large disks, since we don't need to make this atomic. +#if 0 + // prints the blocks that differ + off_t block = 0; + for (int32 i = 0; i < fNumGroups; i++) { + AllocationBlock cached(fVolume); + for (uint32 j = 0; j < fGroups[i].NumBlocks(); j++) { + cached.SetTo(fGroups[i], j); + for (uint32 k = 0; k < cached.NumBlockBits(); k++) { + if (cached.IsUsed(k) != _CheckBitmapIsUsedAt(block)) { + dprintf("differ block %lld (should be %d)\n", block, + _CheckBitmapIsUsedAt(block)); + } + block++; + } + } + } +#endif + fVolume->SuperBlock().used_blocks = HOST_ENDIAN_TO_BFS_INT64(usedBlocks); @@ -1442,10 +1461,6 @@ return B_OK; } - // If the inode has an attribute directory, push it on the stack - if (!inode->Attributes().IsZero()) - cookie->stack.Push(inode->Attributes()); - // push the directory on the stack so that it will be scanned later if (inode->IsContainer() && !inode->IsIndex()) cookie->stack.Push(inode->BlockRun()); @@ -1554,6 +1569,8 @@ if (firstSet == -1) { firstSet = firstGroupBlock + offset; control->errors |= BFS_BLOCKS_ALREADY_SET; + dprintf("block %lld is already set!!!\n", + firstGroupBlock + offset); } control->stats.already_set++; } else { @@ -1601,9 +1618,15 @@ return B_BAD_VALUE; status_t status = CheckBlockRun(inode->BlockRun(), "inode", control); - if (status < B_OK) + if (status != B_OK) return status; + // If the inode has an attribute directory, push it on the stack + if (!inode->Attributes().IsZero()) { + check_cookie* cookie = (check_cookie*)control->cookie; + cookie->stack.Push(inode->Attributes()); + } + if (inode->IsSymLink() && (inode->Flags() & INODE_LONG_SYMLINK) == 0) { // symlinks may not have a valid data stream if (strlen(inode->Node().short_symlink) >= SHORT_SYMLINK_NAME_LENGTH) From rudolf.cornelissen at gmail.com Mon Jun 8 19:13:44 2009 From: rudolf.cornelissen at gmail.com (Rudolf Cornelissen) Date: Mon, 8 Jun 2009 17:13:44 +0000 Subject: [Haiku-commits] r30946 - in haiku/trunk: headers/private/graphics/nvidia src/add-ons/accelerants/nvidia/engine In-Reply-To: <19524965871-BeMail@zon> References: <19524965871-BeMail@zon> Message-ID: It's good to know I would have a green light to dump all that in the syslog. Thanks. Since the settings file is ignored anyway BTW (non existing on a Haiku build), nothing is dumped in any file unless I request someone to do it for me, which gives me a clean, and complete, logfile of the driver. On a sidenote: Axel, did you read about the gfx ram measuring speed tool that exists for Haiku? The author is willing to donate it to Haiku. Personally I like that tool for benchmarking, it helped me on a number of occasions. What do you think? If it's handy it should be accepted I'd say. Rudolf. On Sat, Jun 6, 2009 at 3:25 PM, Axel D?rfler wrote: > Rudolf Cornelissen wrote: > > About logging: I am using my own logfile. I am not going to change > > that. > > (did you ever have a look at the content that file?) > > I would never suggest to dump all that to syslog by default. Just when > you need it, as every other component does it as well. > > Bye, > Axel. > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: From axeld at pinc-software.de Tue Jun 9 12:47:26 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 09 Jun 2009 12:47:26 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30946_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/graphics/nvidia_src/add-ons/accelerants/nvidia/engine?= In-Reply-To: Message-ID: <6544409477-BeMail@zon> Rudolf Cornelissen wrote: > It's good to know I would have a green light to dump all that in the > syslog. > Thanks. Since the settings file is ignored anyway BTW (non existing > on a > Haiku build), nothing is dumped in any file unless I request someone > to do > it for me, which gives me a clean, and complete, logfile of the > driver. No problem, I just wondered. > On a sidenote: Axel, did you read about the gfx ram measuring speed > tool > that exists for Haiku? The author is willing to donate it to Haiku. > Personally I like that tool for benchmarking, it helped me on a > number of > occasions. What do you think? If it's handy it should be accepted I'd > say. I wouldn't mind putting it in our repository, but I wouldn't put it on the image by default (as all the other benchmark tools). Bye, Axel. From imker at mail.berlios.de Tue Jun 9 20:18:55 2009 From: imker at mail.berlios.de (imker at BerliOS) Date: Tue, 9 Jun 2009 20:18:55 +0200 Subject: [Haiku-commits] r30999 - haiku/trunk/src/add-ons/kernel/network/devices/ethernet Message-ID: <200906091818.n59IIt2b007155@sheep.berlios.de> Author: imker Date: 2009-06-09 20:18:54 +0200 (Tue, 09 Jun 2009) New Revision: 30999 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30999&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/devices/ethernet/ethernet.cpp Log: Looks like ethernet_set_promiscuous() call should use ETHER_SETPROMISC ioctl instead of ETHER_GETADDR one. Modified: haiku/trunk/src/add-ons/kernel/network/devices/ethernet/ethernet.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/devices/ethernet/ethernet.cpp 2009-06-08 13:06:37 UTC (rev 30998) +++ haiku/trunk/src/add-ons/kernel/network/devices/ethernet/ethernet.cpp 2009-06-09 18:18:54 UTC (rev 30999) @@ -365,7 +365,7 @@ ethernet_device *device = (ethernet_device *)_device; int32 value = (int32)promiscuous; - if (ioctl(device->fd, ETHER_GETADDR, &value, sizeof(value)) < 0) + if (ioctl(device->fd, ETHER_SETPROMISC, &value, sizeof(value)) < 0) return EOPNOTSUPP; return B_OK; From rudolf.cornelissen at gmail.com Tue Jun 9 21:04:37 2009 From: rudolf.cornelissen at gmail.com (Rudolf Cornelissen) Date: Tue, 9 Jun 2009 19:04:37 +0000 Subject: [Haiku-commits] r30946 - in haiku/trunk: headers/private/graphics/nvidia src/add-ons/accelerants/nvidia/engine In-Reply-To: <6544409477-BeMail@zon> References: <6544409477-BeMail@zon> Message-ID: Hi again, Who'll put it in our repository then? Shall I point him at you? I mean, you no doubt know where you'd want to put it and how.. :-) Bye! Rudolf. On Tue, Jun 9, 2009 at 10:47 AM, Axel D?rfler wrote: > Rudolf Cornelissen wrote: > > It's good to know I would have a green light to dump all that in the > > syslog. > > Thanks. Since the settings file is ignored anyway BTW (non existing > > on a > > Haiku build), nothing is dumped in any file unless I request someone > > to do > > it for me, which gives me a clean, and complete, logfile of the > > driver. > > No problem, I just wondered. > > > On a sidenote: Axel, did you read about the gfx ram measuring speed > > tool > > that exists for Haiku? The author is willing to donate it to Haiku. > > Personally I like that tool for benchmarking, it helped me on a > > number of > > occasions. What do you think? If it's handy it should be accepted I'd > > say. > > I wouldn't mind putting it in our repository, but I wouldn't put it on > the image by default (as all the other benchmark tools). > > Bye, > Axel. > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: From axeld at pinc-software.de Tue Jun 9 22:12:07 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 09 Jun 2009 22:12:07 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30946_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/graphics/nvidia_src/add-ons/accelerants/nvidia/engine?= In-Reply-To: Message-ID: <40425824244-BeMail@zon> Rudolf Cornelissen wrote: > Who'll put it in our repository then? Shall I point him at you? I > mean, you > no doubt know where you'd want to put it and how.. :-) We have some at src/tests/system/benchmarks, but there are other locations, too. I guess we can just put it there for now, and clean up this mess one day (later) :-) Bye, Axel. From axeld at mail.berlios.de Tue Jun 9 22:25:21 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 9 Jun 2009 22:25:21 +0200 Subject: [Haiku-commits] r31000 - haiku/trunk/src/bin/coreutils/src Message-ID: <200906092025.n59KPL3j024043@sheep.berlios.de> Author: axeld Date: 2009-06-09 22:25:20 +0200 (Tue, 09 Jun 2009) New Revision: 31000 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31000&view=rev Modified: haiku/trunk/src/bin/coreutils/src/copy.c Log: * This should recreate 0 byte attributes, and therefore fix bug #4015. Modified: haiku/trunk/src/bin/coreutils/src/copy.c =================================================================== --- haiku/trunk/src/bin/coreutils/src/copy.c 2009-06-09 18:18:54 UTC (rev 30999) +++ haiku/trunk/src/bin/coreutils/src/copy.c 2009-06-09 20:25:20 UTC (rev 31000) @@ -153,15 +153,17 @@ if (fs_stat_attr(fromFd, dirent->d_name, &info) != 0) continue; - while (info.size > 0) { + while (info.size >= 0) { ssize_t bytesRead, bytesWritten; - - bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos, buffer, sizeof(buffer)); - if (bytesRead <= 0) + + bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos, + buffer, sizeof(buffer)); + if (bytesRead < 0) break; - - bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos, buffer, bytesRead); - if (bytesWritten != bytesRead) + + bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos, + buffer, bytesRead); + if (bytesWritten != bytesRead || bytesRead == 0) break; pos += bytesWritten; @@ -189,7 +191,7 @@ } result = copy_attributes(fromFd, toFd); - + close(fromFd); close(toFd); From anevilyak at mail.berlios.de Tue Jun 9 22:41:04 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Tue, 9 Jun 2009 22:41:04 +0200 Subject: [Haiku-commits] r31001 - haiku/trunk/headers/os/storage Message-ID: <200906092041.n59Kf40j025500@sheep.berlios.de> Author: anevilyak Date: 2009-06-09 22:41:04 +0200 (Tue, 09 Jun 2009) New Revision: 31001 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31001&view=rev Modified: haiku/trunk/headers/os/storage/Path.h Log: Provide a default value for the leaf argument as is done in the const char * versions of the constructor/setter. This is consistent with the Be Book, though R5 and/or Dano's headers were likewise missing this. Modified: haiku/trunk/headers/os/storage/Path.h =================================================================== --- haiku/trunk/headers/os/storage/Path.h 2009-06-09 20:25:20 UTC (rev 31000) +++ haiku/trunk/headers/os/storage/Path.h 2009-06-09 20:41:04 UTC (rev 31001) @@ -25,7 +25,8 @@ BPath(const BEntry* entry); BPath(const char* dir, const char* leaf = NULL, bool normalize = false); - BPath(const BDirectory* dir, const char* leaf, + BPath(const BDirectory* dir, + const char* leaf = NULL, bool normalize = false); virtual ~BPath(); @@ -36,7 +37,8 @@ status_t SetTo(const BEntry* entry); status_t SetTo(const char* path, const char* leaf = NULL, bool normalize = false); - status_t SetTo(const BDirectory* dir, const char* path, + status_t SetTo(const BDirectory* dir, + const char* leaf = NULL, bool normalize = false); void Unset(); From korli at mail.berlios.de Tue Jun 9 23:02:21 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 9 Jun 2009 23:02:21 +0200 Subject: [Haiku-commits] r31002 - haiku/trunk/src/bin Message-ID: <200906092102.n59L2LxD027424@sheep.berlios.de> Author: korli Date: 2009-06-09 23:02:21 +0200 (Tue, 09 Jun 2009) New Revision: 31002 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31002&view=rev Modified: haiku/trunk/src/bin/rmattr.cpp Log: rmattr now handles attributes on symlinks and directories Modified: haiku/trunk/src/bin/rmattr.cpp =================================================================== --- haiku/trunk/src/bin/rmattr.cpp 2009-06-09 20:41:04 UTC (rev 31001) +++ haiku/trunk/src/bin/rmattr.cpp 2009-06-09 21:02:21 UTC (rev 31002) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -29,8 +29,9 @@ void usage() { - printf("usage: %s [-p] attr filename1 [filename2...]\n" + printf("usage: %s [-P] [-p] attr filename1 [filename2...]\n" "\t'attr' is the name of an attribute of the file\n" + "\t-P : Don't resolve links\n" "\tIf '-p' is specified, 'attr' is regarded as a pattern.\n", kProgramName); exit(1); @@ -91,31 +92,37 @@ int main(int argc, const char **argv) { - // Make sure we have the minimum number of arguments. - if (argc < 3) - usage(); - bool isPattern = false; - int attr = 1; - if (!strcmp(argv[attr], "-p")) { - isPattern = true; - attr++; + bool resolveLinks = true; - if (argc < 4) - usage(); + /* get all options */ + + while (*++argv) { + const char *arg = *argv; + argc--; + if (*arg != '-') + break; + if (!strcmp(arg, "-P")) + resolveLinks = false; + else if (!strcmp(arg, "-p")) + isPattern = true; } - for (int32 i = attr + 1; i < argc; i++) { - int fd = open(argv[i], O_WRONLY); + // Make sure we have the minimum number of arguments. + if (argc < 2) + usage(); + + for (int32 i = 1; i < argc; i++) { + int fd = open(argv[i], O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE)); if (fd < 0) { fprintf(stderr, "%s: can\'t open file %s to remove attribute: %s\n", kProgramName, argv[i], strerror(errno)); return 1; } - if (remove_attribute(fd, argv[attr], isPattern) != B_OK) { + if (remove_attribute(fd, argv[0], isPattern) != B_OK) { fprintf(stderr, "%s: error removing attribute %s from %s: %s\n", - kProgramName, argv[attr], argv[i], strerror(errno)); + kProgramName, argv[0], argv[i], strerror(errno)); } close(fd); From dlmcpaul at mail.berlios.de Wed Jun 10 04:49:45 2009 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Wed, 10 Jun 2009 04:49:45 +0200 Subject: [Haiku-commits] r31003 - haiku/trunk/src/add-ons/media/plugins/wav_reader Message-ID: <200906100249.n5A2njxi002094@sheep.berlios.de> Author: dlmcpaul Date: 2009-06-10 04:49:45 +0200 (Wed, 10 Jun 2009) New Revision: 31003 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31003&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp haiku/trunk/src/add-ons/media/plugins/wav_reader/wav.h Log: Ensure extra data is passed to decoder Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp 2009-06-09 21:02:21 UTC (rev 31002) +++ haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp 2009-06-10 02:49:45 UTC (rev 31003) @@ -31,7 +31,7 @@ #include "WavReaderPlugin.h" #include "RawFormats.h" -//#define TRACE_WAVE_READER +#define TRACE_WAVE_READER #ifdef TRACE_WAVE_READER #define TRACE printf #else @@ -136,12 +136,13 @@ return B_ERROR; } - format_struct format; - wave_format_ex wav_format; + wave_format_ex format; format_struct_extensible format_ext; mpeg1_wav_format mpeg1_format; mpeg3_wav_format mpeg3_format; + uint32 wavFmtSize = sizeof(format_struct) + 2; + fact_struct fact; // read all chunks and search for "fact", "fmt" (normal or extensible) and "data" @@ -167,49 +168,56 @@ switch (UINT32(chunk.fourcc)) { case FOURCC('f','m','t',' '): // So what do we have a std format structure, a wav_format structure or a extended structure - if (UINT32(chunk.len) >= sizeof(wav_format)) { - // Read both format and wav format - if (sizeof(format) != Source()->ReadAt(pos, &format, sizeof(format))) { + if (UINT32(chunk.len) >= wavFmtSize) { + // Must be some sort of extended format structure + // First Read common data + extra size + if (wavFmtSize != Source()->ReadAt(pos, &format, wavFmtSize)) { ERROR("WavReader::Sniff: format chunk reading failed\n"); break; } - if (sizeof(wav_format) != Source()->ReadAt(pos, &wav_format, sizeof(wav_format))) { - ERROR("WavReader::Sniff: format chunk reading failed\n"); - break; + + // If extra size seems valid then re-read with the extra data included + if (UINT16(format.extra_size) > 0 && UINT16(format.extra_size) < 64) { + // Read the extra data we need to pass across to the decoder + if ((wavFmtSize + format.extra_size) != Source()->ReadAt(pos, &format, wavFmtSize + format.extra_size)) { + ERROR("WavReader::Sniff: format extensible chunk reading failed\n"); + break; + } } foundFmt = true; - - if (UINT16(wav_format.extra_size) == 12) { + + // Check for structure we recognise and might need values from. + if (UINT16(format.extra_size) == 12) { // MPEG3 WAV FORMAT Structure if (sizeof(mpeg3_format) != Source()->ReadAt(pos, &mpeg3_format, sizeof(mpeg3_format))) { ERROR("WavReader::Sniff: format chunk reading failed\n"); break; } foundMPEG3 = true; - } - if (UINT16(wav_format.extra_size) == 22) { - // MPEG1 WAV FORMAT Structure - if (sizeof(mpeg1_format) != Source()->ReadAt(pos, &mpeg1_format, sizeof(mpeg1_format))) { - ERROR("WavReader::Sniff: format chunk reading failed\n"); - break; + } else if (UINT16(format.extra_size) == 22) { + if (UINT16(format.format_tag) == 0xfffe) { + // GUID structure + if (sizeof(format_ext) != Source()->ReadAt(pos, &format_ext, sizeof(format_ext))) { + ERROR("WavReader::Sniff: format extensible chunk reading failed\n"); + break; + } + foundFmtExt = true; + } else { + // MPEG1 WAV FORMAT Structure + if (sizeof(mpeg1_format) != Source()->ReadAt(pos, &mpeg1_format, sizeof(mpeg1_format))) { + ERROR("WavReader::Sniff: format chunk reading failed\n"); + break; + } + foundMPEG1 = true; } - foundMPEG1 = true; } - - } else if (UINT32(chunk.len) >= sizeof(format)) { - if (sizeof(format) != Source()->ReadAt(pos, &format, sizeof(format))) { + } else if (UINT32(chunk.len) >= wavFmtSize - 2) { + if ((wavFmtSize - 2) != Source()->ReadAt(pos, &format, wavFmtSize - 2)) { ERROR("WavReader::Sniff: format chunk reading failed\n"); break; } + format.extra_size = 0; foundFmt = true; - - if (UINT32(chunk.len) >= sizeof(format_ext) && UINT16(format.format_tag) == 0xfffe) { - if (sizeof(format_ext) != Source()->ReadAt(pos, &format_ext, sizeof(format_ext))) { - ERROR("WavReader::Sniff: format extensible chunk reading failed\n"); - break; - } - foundFmtExt = true; - } } break; case FOURCC('f','a','c','t'): @@ -260,8 +268,8 @@ TRACE(" avg_bytes_per_sec %ld\n", UINT32(format.avg_bytes_per_sec)); TRACE(" block_align %d\n", UINT16(format.block_align)); TRACE(" bits_per_sample %d\n", UINT16(format.bits_per_sample)); + TRACE(" ext_size %d\n", UINT16(format.extra_size)); if (foundFmtExt) { - TRACE(" ext_size %d\n", UINT16(format_ext.ext_size)); TRACE(" valid_bits_per_sample %d\n", UINT16(format_ext.valid_bits_per_sample)); TRACE(" channel_mask %ld\n", UINT32(format_ext.channel_mask)); TRACE(" guid[0-1] format 0x%04x\n", (format_ext.guid[1] << 8) | format_ext.guid[0]); @@ -292,7 +300,10 @@ fBufferSize = BUFFER_SIZE; } - fMetaData.extra_size = 0; + fMetaData.extra_size = format.extra_size; + if (fMetaData.extra_size > 0) { + fMetaData.extra_data = format.extra_data; + } fMetaData.channels = UINT16(format.channels); fMetaData.samples_per_sec = UINT32(format.samples_per_sec); fMetaData.block_align = UINT16(format.block_align); @@ -420,9 +431,9 @@ data->format.u.encoded_audio.output.channel_count = fMetaData.channels; } - printf("SetMetaData called with size %ld\n",sizeof(wave_format_ex)); + printf("SetMetaData called with size %ld\n",sizeof(format_struct) + fMetaData.extra_size + 2); - if (data->format.SetMetaData(&fMetaData, sizeof(wave_format_ex)) != B_OK) { + if (data->format.SetMetaData(&fMetaData, (sizeof(format_struct) + fMetaData.extra_size + 2)) != B_OK) { ERROR("WavReader::Failed to SetMetaData\n"); delete data; return B_ERROR; @@ -457,7 +468,7 @@ *duration = data->duration; *format = data->format; *infoBuffer = &fMetaData; - *infoSize = sizeof(wave_format_ex); + *infoSize = (sizeof(format_struct) + fMetaData.extra_size + 2); return B_OK; } Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/wav.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/wav_reader/wav.h 2009-06-09 21:02:21 UTC (rev 31002) +++ haiku/trunk/src/add-ons/media/plugins/wav_reader/wav.h 2009-06-10 02:49:45 UTC (rev 31003) @@ -56,6 +56,7 @@ uint16 block_align; uint16 bits_per_sample; uint16 extra_size; + uint8 extra_data[64]; // allow for 64 bytes of extra data }; struct mpeg3_wav_format { From dlmcpaul at mail.berlios.de Wed Jun 10 04:53:26 2009 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Wed, 10 Jun 2009 04:53:26 +0200 Subject: [Haiku-commits] r31004 - haiku/trunk/src/add-ons/media/plugins/avcodec Message-ID: <200906100253.n5A2rQVn002851@sheep.berlios.de> Author: dlmcpaul Date: 2009-06-10 04:53:26 +0200 (Wed, 10 Jun 2009) New Revision: 31004 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31004&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp Log: Read Extra Data needed by MSADPCM and others Modified: haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp 2009-06-10 02:49:45 UTC (rev 31003) +++ haiku/trunk/src/add-ons/media/plugins/avcodec/avcodec.cpp 2009-06-10 02:53:26 UTC (rev 31004) @@ -186,7 +186,7 @@ } TRACE("avCodec: found decoder %s\n",fCodec->name); - if (gCodecTable[i].family == B_WAV_FORMAT_FAMILY && infoSize == sizeof(wave_format_ex)) { + if (gCodecTable[i].family == B_WAV_FORMAT_FAMILY && infoSize >= sizeof(wave_format_ex)) { const wave_format_ex *wfmt_data = (const wave_format_ex *)infoBuffer; size_t wfmt_size = infoSize; @@ -595,9 +595,15 @@ diff2 += prof_t3 - prof_t2; prof_cnt++; if (!(fFrame % 10)) { - TRACE("[%c] profile: d1 = %lld, d2 = %lld (%Ld)\n", - isAudio?('a'):('v'), diff1/prof_cnt, diff2/prof_cnt, - fFrame); + if (info) { + TRACE("[%c] profile: d1 = %lld, d2 = %lld (%Ld) required %Ld\n", + isAudio?('a'):('v'), diff1/prof_cnt, diff2/prof_cnt, + fFrame, info->time_to_decode); + } else { + TRACE("[%c] profile: d1 = %lld, d2 = %lld (%Ld) required %Ld\n", + isAudio?('a'):('v'), diff1/prof_cnt, diff2/prof_cnt, + fFrame, bigtime_t(1000000LL / fOutputFrameRate)); + } } #endif } From joe.prostko+haiku at gmail.com Wed Jun 10 14:05:24 2009 From: joe.prostko+haiku at gmail.com (Joseph Prostko) Date: Wed, 10 Jun 2009 08:05:24 -0400 Subject: [Haiku-commits] r31003 - haiku/trunk/src/add-ons/media/plugins/wav_reader In-Reply-To: <200906100249.n5A2njxi002094@sheep.berlios.de> References: <200906100249.n5A2njxi002094@sheep.berlios.de> Message-ID: <7e5795b0906100505p654af1b4r6b48b2ffd00ff250@mail.gmail.com> On Tue, Jun 9, 2009 at 10:49 PM, dlmcpaul at BerliOS wrote: > Author: dlmcpaul > Date: 2009-06-10 04:49:45 +0200 (Wed, 10 Jun 2009) > New Revision: 31003 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31003&view=rev > > Modified: > ? haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp > ? haiku/trunk/src/add-ons/media/plugins/wav_reader/wav.h > Log: > Ensure extra data is passed to decoder > > Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp > =================================================================== > --- haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp ? ? ? ?2009-06-09 21:02:21 UTC (rev 31002) > +++ haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp ? ? ? ?2009-06-10 02:49:45 UTC (rev 31003) > @@ -292,7 +300,10 @@ > ? ? ? ? ? ? ? ?fBufferSize = BUFFER_SIZE; > ? ? ? ?} > > - ? ? ? fMetaData.extra_size = 0; > + ? ? ? fMetaData.extra_size = format.extra_size; > + ? ? ? if (fMetaData.extra_size > 0) { > + ? ? ? ? ? ? ? fMetaData.extra_data = format.extra_data; > + ? ? ? } > ? ? ? ?fMetaData.channels = UINT16(format.channels); > ? ? ? ?fMetaData.samples_per_sec = UINT32(format.samples_per_sec); > ? ? ? ?fMetaData.block_align = UINT16(format.block_align); The above hunk broke the build for me with the following error: /home/joe/haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp:305: error: invalid array assignment I can't say I'm familiar at all with what the code at hand, but line 305 looked like the first occurence of extra_data anywhere that I saw in the source files. Did you just mean to set fMetaData.extra_size to format.extra_size if format.extra_size happened to be bigger than zero? - joe From anevilyak at mail.berlios.de Wed Jun 10 14:51:17 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Wed, 10 Jun 2009 14:51:17 +0200 Subject: [Haiku-commits] r31005 - haiku/trunk/src/add-ons/media/plugins/wav_reader Message-ID: <200906101251.n5ACpHIG014461@sheep.berlios.de> Author: anevilyak Date: 2009-06-10 14:51:17 +0200 (Wed, 10 Jun 2009) New Revision: 31005 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31005&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp Log: Fix gcc4 build. Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp 2009-06-10 02:53:26 UTC (rev 31004) +++ haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp 2009-06-10 12:51:17 UTC (rev 31005) @@ -302,7 +302,7 @@ fMetaData.extra_size = format.extra_size; if (fMetaData.extra_size > 0) { - fMetaData.extra_data = format.extra_data; + memcpy(fMetaData.extra_data, format.extra_data, format.extra_size); } fMetaData.channels = UINT16(format.channels); fMetaData.samples_per_sec = UINT32(format.samples_per_sec); From anevilyak at mail.berlios.de Wed Jun 10 16:47:57 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Wed, 10 Jun 2009 16:47:57 +0200 Subject: [Haiku-commits] r31006 - haiku/trunk/src/add-ons/media/plugins/wav_reader Message-ID: <200906101447.n5AElvig031349@sheep.berlios.de> Author: anevilyak Date: 2009-06-10 16:47:57 +0200 (Wed, 10 Jun 2009) New Revision: 31006 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31006&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp Log: Be a bit more defensive here just in case the wav header has invalid data. Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp 2009-06-10 12:51:17 UTC (rev 31005) +++ haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp 2009-06-10 14:47:57 UTC (rev 31006) @@ -302,7 +302,7 @@ fMetaData.extra_size = format.extra_size; if (fMetaData.extra_size > 0) { - memcpy(fMetaData.extra_data, format.extra_data, format.extra_size); + memcpy(fMetaData.extra_data, format.extra_data, min_c(format.extra_size, sizeof(format.extra_data))); } fMetaData.channels = UINT16(format.channels); fMetaData.samples_per_sec = UINT32(format.samples_per_sec); From dlmcpaul at gmail.com Thu Jun 11 02:32:55 2009 From: dlmcpaul at gmail.com (David McPaul) Date: Thu, 11 Jun 2009 10:32:55 +1000 Subject: [Haiku-commits] r31003 - haiku/trunk/src/add-ons/media/plugins/wav_reader In-Reply-To: <7e5795b0906100505p654af1b4r6b48b2ffd00ff250@mail.gmail.com> References: <200906100249.n5A2njxi002094@sheep.berlios.de> <7e5795b0906100505p654af1b4r6b48b2ffd00ff250@mail.gmail.com> Message-ID: 2009/6/10 Joseph Prostko : > On Tue, Jun 9, 2009 at 10:49 PM, dlmcpaul at > BerliOS wrote: >> Author: dlmcpaul >> Date: 2009-06-10 04:49:45 +0200 (Wed, 10 Jun 2009) >> New Revision: 31003 >> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31003&view=rev >> >> Modified: >> ? haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp >> ? haiku/trunk/src/add-ons/media/plugins/wav_reader/wav.h >> Log: >> Ensure extra data is passed to decoder >> >> Modified: haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp >> =================================================================== >> --- haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp ? ? ? ?2009-06-09 21:02:21 UTC (rev 31002) >> +++ haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp ? ? ? ?2009-06-10 02:49:45 UTC (rev 31003) >> @@ -292,7 +300,10 @@ >> ? ? ? ? ? ? ? ?fBufferSize = BUFFER_SIZE; >> ? ? ? ?} >> >> - ? ? ? fMetaData.extra_size = 0; >> + ? ? ? fMetaData.extra_size = format.extra_size; >> + ? ? ? if (fMetaData.extra_size > 0) { >> + ? ? ? ? ? ? ? fMetaData.extra_data = format.extra_data; >> + ? ? ? } >> ? ? ? ?fMetaData.channels = UINT16(format.channels); >> ? ? ? ?fMetaData.samples_per_sec = UINT32(format.samples_per_sec); >> ? ? ? ?fMetaData.block_align = UINT16(format.block_align); > > The above hunk broke the build for me with the following error: > > /home/joe/haiku/trunk/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp:305: > error: invalid array assignment > > I can't say I'm familiar at all with what the code at hand, but line > 305 looked like the first occurence of extra_data anywhere that I saw > in the source files. > > Did you just mean to set fMetaData.extra_size to format.extra_size if > format.extra_size happened to be bigger than zero? extra_size will be 0 or > at that point. If 0 then there is no extra_data. The problem with the distorted wav files was that the extra_data was not being passed to the decoder. So now wav_reader should read in the extra data and pass the correct size of the structure across to the decoder. A later change fixes the error you are seeing by using a memcpy which is what I should have used. My appologies. -- Cheers David From axeld at mail.berlios.de Thu Jun 11 10:30:41 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 11 Jun 2009 10:30:41 +0200 Subject: [Haiku-commits] r31007 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200906110830.n5B8Ufbv005585@sheep.berlios.de> Author: axeld Date: 2009-06-11 10:30:40 +0200 (Thu, 11 Jun 2009) New Revision: 31007 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31007&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp Log: * Applied a patch by Lukasz that already collected dust on my HD - sorry Lukasz! * It makes split_buffer() more efficient by avoiding making a copy of the original buffer. * Minor cleanup, and coding style changes by myself. Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2009-06-10 14:47:57 UTC (rev 31006) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2009-06-11 08:30:40 UTC (rev 31007) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -956,6 +956,51 @@ } +/*! Appends up to \a size bytes from the data of the \a from net_buffer to the + \a to net_buffer. The source buffer will remain unchanged. +*/ +static status_t +append_data_from_buffer(net_buffer *to, const net_buffer *from, size_t size) +{ + net_buffer_private *source = (net_buffer_private *)from; + net_buffer_private *dest = (net_buffer_private *)to; + + if (size > from->size) + return B_BAD_VALUE; + if (size == 0) + return B_OK; + + data_node *nodeTo = get_node_at_offset(source, size); + if (nodeTo == NULL) + return B_BAD_VALUE; + + data_node *node = (data_node *)list_get_first_item(&source->buffers); + if (node == NULL) { + CHECK_BUFFER(source); + return B_ERROR; + } + + while (node != nodeTo) { + if (append_data(dest, node->start, node->used) < B_OK) { + CHECK_BUFFER(dest); + return B_ERROR; + } + + node = (data_node *)list_get_next_item(&source->buffers, node); + } + + int32 diff = node->offset + node->used - size; + if (append_data(dest, node->start, node->used - diff) < B_OK) { + CHECK_BUFFER(dest); + return B_ERROR; + } + + CHECK_BUFFER(dest); + + return B_OK; +} + + static void copy_metadata(net_buffer *destination, const net_buffer *source) { @@ -1213,27 +1258,23 @@ /*! Split the buffer at offset, the header data is returned as new buffer. - TODO: optimize and avoid making a copy. */ static net_buffer * split_buffer(net_buffer *from, uint32 offset) { - // TODO: Copying the whole buffer becomes less and less efficient with - // greater size - offset differences. What we actually want is a method - // to copy data from one buffer to another. Then the following should be: - // create buffer, resize, copy data. An additional append_data_from_buffer() - // method would be even better. - net_buffer *buffer = duplicate_buffer(from); + net_buffer *buffer = create_buffer(DATA_NODE_SIZE); if (buffer == NULL) return NULL; + copy_metadata(buffer, from); + ParanoiaChecker _(from); ParanoiaChecker _2(buffer); TRACE(("%ld: split_buffer(buffer %p -> %p, offset %ld)\n", find_thread(NULL), from, buffer, offset)); - if (trim_data(buffer, offset) == B_OK) { + if (append_data_from_buffer(buffer, from, offset) == B_OK) { if (remove_header(from, offset) == B_OK) { CHECK_BUFFER(from); CHECK_BUFFER(buffer); From axeld at mail.berlios.de Thu Jun 11 10:48:41 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 11 Jun 2009 10:48:41 +0200 Subject: [Haiku-commits] r31008 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200906110848.n5B8mfGk006832@sheep.berlios.de> Author: axeld Date: 2009-06-11 10:48:40 +0200 (Thu, 11 Jun 2009) New Revision: 31008 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31008&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp Log: * Cleanup. Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2009-06-11 08:30:40 UTC (rev 31007) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2009-06-11 08:48:40 UTC (rev 31008) @@ -54,27 +54,27 @@ }; struct free_data { - struct free_data *next; - uint16 size; + struct free_data* next; + uint16 size; }; struct data_header { - int32 ref_count; - addr_t physical_address; - free_data *first_free; - uint8 *data_end; + int32 ref_count; + addr_t physical_address; + free_data* first_free; + uint8* data_end; header_space space; - uint16 tail_space; + uint16 tail_space; }; struct data_node { struct list_link link; - struct data_header *header; - struct data_header *located; - size_t offset; // the net_buffer-wide offset of this node - uint8 *start; // points to the start of the data - uint16 flags; - uint16 used; // defines how much memory is used by this node + struct data_header* header; + struct data_header* located; + size_t offset; // the net_buffer-wide offset of this node + uint8* start; // points to the start of the data + uint16 flags; + uint16 used; // defines how much memory is used by this node uint16 HeaderSpace() const { @@ -124,14 +124,14 @@ }; struct net_buffer_private : net_buffer { - struct list buffers; - data_header *allocation_header; // the current place where we - // allocate header space (nodes,...) + struct list buffers; + data_header* allocation_header; + // the current place where we allocate header space (nodes, ...) ancillary_data_container* ancillary_data; struct { - struct sockaddr_storage source; - struct sockaddr_storage destination; + struct sockaddr_storage source; + struct sockaddr_storage destination; } storage; }; @@ -141,17 +141,17 @@ #define MAX_FREE_BUFFER_SIZE (BUFFER_SIZE - DATA_HEADER_SIZE) -static object_cache *sNetBufferCache; -static object_cache *sDataNodeCache; +static object_cache* sNetBufferCache; +static object_cache* sDataNodeCache; -static status_t append_data(net_buffer *buffer, const void *data, size_t size); -static status_t trim_data(net_buffer *_buffer, size_t newSize); -static status_t remove_header(net_buffer *_buffer, size_t bytes); -static status_t remove_trailer(net_buffer *_buffer, size_t bytes); -static status_t append_cloned_data(net_buffer *_buffer, net_buffer *_source, +static status_t append_data(net_buffer* buffer, const void* data, size_t size); +static status_t trim_data(net_buffer* _buffer, size_t newSize); +static status_t remove_header(net_buffer* _buffer, size_t bytes); +static status_t remove_trailer(net_buffer* _buffer, size_t bytes); +static status_t append_cloned_data(net_buffer* _buffer, net_buffer* _source, uint32 offset, size_t bytes); -static status_t read_data(net_buffer *_buffer, size_t offset, void *data, +static status_t read_data(net_buffer* _buffer, size_t offset, void* data, size_t size); @@ -170,389 +170,389 @@ class NetBufferTraceEntry : public AbstractTraceEntry { - public: - NetBufferTraceEntry(net_buffer* buffer) - : - fBuffer(buffer) - { +public: + NetBufferTraceEntry(net_buffer* buffer) + : + fBuffer(buffer) + { #if NET_BUFFER_TRACING_STACK_TRACE - fStackTrace = capture_tracing_stack_trace( - NET_BUFFER_TRACING_STACK_TRACE, 0, false); + fStackTrace = capture_tracing_stack_trace( + NET_BUFFER_TRACING_STACK_TRACE, 0, false); #endif - } + } #if NET_BUFFER_TRACING_STACK_TRACE - virtual void DumpStackTrace(TraceOutput& out) - { - out.PrintStackTrace(fStackTrace); - } + virtual void DumpStackTrace(TraceOutput& out) + { + out.PrintStackTrace(fStackTrace); + } #endif - protected: - net_buffer* fBuffer; +protected: + net_buffer* fBuffer; #if NET_BUFFER_TRACING_STACK_TRACE - tracing_stack_trace* fStackTrace; + tracing_stack_trace* fStackTrace; #endif }; class Create : public NetBufferTraceEntry { - public: - Create(size_t headerSpace, net_buffer* buffer) - : - NetBufferTraceEntry(buffer), - fHeaderSpace(headerSpace) - { - Initialized(); - } +public: + Create(size_t headerSpace, net_buffer* buffer) + : + NetBufferTraceEntry(buffer), + fHeaderSpace(headerSpace) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer create: header space: %lu -> buffer: %p", - fHeaderSpace, fBuffer); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer create: header space: %lu -> buffer: %p", + fHeaderSpace, fBuffer); + } - private: - size_t fHeaderSpace; +private: + size_t fHeaderSpace; }; class Free : public NetBufferTraceEntry { - public: - Free(net_buffer* buffer) - : - NetBufferTraceEntry(buffer) - { - Initialized(); - } +public: + Free(net_buffer* buffer) + : + NetBufferTraceEntry(buffer) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer free: buffer: %p", fBuffer); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer free: buffer: %p", fBuffer); + } }; class Duplicate : public NetBufferTraceEntry { - public: - Duplicate(net_buffer* buffer, net_buffer* clone) - : - NetBufferTraceEntry(buffer), - fClone(clone) - { - Initialized(); - } +public: + Duplicate(net_buffer* buffer, net_buffer* clone) + : + NetBufferTraceEntry(buffer), + fClone(clone) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer dup: buffer: %p -> %p", fBuffer, fClone); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer dup: buffer: %p -> %p", fBuffer, fClone); + } - private: - net_buffer* fClone; +private: + net_buffer* fClone; }; class Clone : public NetBufferTraceEntry { - public: - Clone(net_buffer* buffer, bool shareFreeSpace, net_buffer* clone) - : - NetBufferTraceEntry(buffer), - fClone(clone), - fShareFreeSpace(shareFreeSpace) - { - Initialized(); - } +public: + Clone(net_buffer* buffer, bool shareFreeSpace, net_buffer* clone) + : + NetBufferTraceEntry(buffer), + fClone(clone), + fShareFreeSpace(shareFreeSpace) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer clone: buffer: %p, share free space: %s " - "-> %p", fBuffer, fShareFreeSpace ? "true" : "false", fClone); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer clone: buffer: %p, share free space: %s " + "-> %p", fBuffer, fShareFreeSpace ? "true" : "false", fClone); + } - private: - net_buffer* fClone; - bool fShareFreeSpace; +private: + net_buffer* fClone; + bool fShareFreeSpace; }; class Split : public NetBufferTraceEntry { - public: - Split(net_buffer* buffer, uint32 offset, net_buffer* newBuffer) - : - NetBufferTraceEntry(buffer), - fNewBuffer(newBuffer), - fOffset(offset) - { - Initialized(); - } +public: + Split(net_buffer* buffer, uint32 offset, net_buffer* newBuffer) + : + NetBufferTraceEntry(buffer), + fNewBuffer(newBuffer), + fOffset(offset) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer split: buffer: %p, offset: %lu " - "-> %p", fBuffer, fOffset, fNewBuffer); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer split: buffer: %p, offset: %lu " + "-> %p", fBuffer, fOffset, fNewBuffer); + } - private: - net_buffer* fNewBuffer; - uint32 fOffset; +private: + net_buffer* fNewBuffer; + uint32 fOffset; }; class Merge : public NetBufferTraceEntry { - public: - Merge(net_buffer* buffer, net_buffer* otherBuffer, bool after) - : - NetBufferTraceEntry(buffer), - fOtherBuffer(otherBuffer), - fAfter(after) - { - Initialized(); - } +public: + Merge(net_buffer* buffer, net_buffer* otherBuffer, bool after) + : + NetBufferTraceEntry(buffer), + fOtherBuffer(otherBuffer), + fAfter(after) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer merge: buffers: %p + %p, after: %s " - "-> %p", fBuffer, fOtherBuffer, fAfter ? "true" : "false", - fOtherBuffer); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer merge: buffers: %p + %p, after: %s " + "-> %p", fBuffer, fOtherBuffer, fAfter ? "true" : "false", + fOtherBuffer); + } - private: - net_buffer* fOtherBuffer; - bool fAfter; +private: + net_buffer* fOtherBuffer; + bool fAfter; }; class AppendCloned : public NetBufferTraceEntry { - public: - AppendCloned(net_buffer* buffer, net_buffer* source, uint32 offset, - size_t size) - : - NetBufferTraceEntry(buffer), - fSource(source), - fOffset(offset), - fSize(size) - { - Initialized(); - } +public: + AppendCloned(net_buffer* buffer, net_buffer* source, uint32 offset, + size_t size) + : + NetBufferTraceEntry(buffer), + fSource(source), + fOffset(offset), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer append cloned: buffer: %p, from: %p, " - "offset: %lu, size: %lu", fBuffer, fSource, fOffset, fSize); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer append cloned: buffer: %p, from: %p, " + "offset: %lu, size: %lu", fBuffer, fSource, fOffset, fSize); + } - private: - net_buffer* fSource; - uint32 fOffset; - size_t fSize; +private: + net_buffer* fSource; + uint32 fOffset; + size_t fSize; }; class PrependSize : public NetBufferTraceEntry { - public: - PrependSize(net_buffer* buffer, size_t size) - : - NetBufferTraceEntry(buffer), - fSize(size) - { - Initialized(); - } +public: + PrependSize(net_buffer* buffer, size_t size) + : + NetBufferTraceEntry(buffer), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer prepend size: buffer: %p, size: %lu", fBuffer, - fSize); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer prepend size: buffer: %p, size: %lu", fBuffer, + fSize); + } - private: - size_t fSize; +private: + size_t fSize; }; class AppendSize : public NetBufferTraceEntry { - public: - AppendSize(net_buffer* buffer, size_t size) - : - NetBufferTraceEntry(buffer), - fSize(size) - { - Initialized(); - } +public: + AppendSize(net_buffer* buffer, size_t size) + : + NetBufferTraceEntry(buffer), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer append size: buffer: %p, size: %lu", fBuffer, - fSize); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer append size: buffer: %p, size: %lu", fBuffer, + fSize); + } - private: - size_t fSize; +private: + size_t fSize; }; class RemoveHeader : public NetBufferTraceEntry { - public: - RemoveHeader(net_buffer* buffer, size_t size) - : - NetBufferTraceEntry(buffer), - fSize(size) - { - Initialized(); - } +public: + RemoveHeader(net_buffer* buffer, size_t size) + : + NetBufferTraceEntry(buffer), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer remove header: buffer: %p, size: %lu", - fBuffer, fSize); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer remove header: buffer: %p, size: %lu", + fBuffer, fSize); + } - private: - size_t fSize; +private: + size_t fSize; }; class Trim : public NetBufferTraceEntry { - public: - Trim(net_buffer* buffer, size_t size) - : - NetBufferTraceEntry(buffer), - fSize(size) - { - Initialized(); - } +public: + Trim(net_buffer* buffer, size_t size) + : + NetBufferTraceEntry(buffer), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer trim: buffer: %p, size: %lu", - fBuffer, fSize); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer trim: buffer: %p, size: %lu", + fBuffer, fSize); + } - private: - size_t fSize; +private: + size_t fSize; }; class Read : public NetBufferTraceEntry { - public: - Read(net_buffer* buffer, uint32 offset, void* data, size_t size) - : - NetBufferTraceEntry(buffer), - fData(data), - fOffset(offset), - fSize(size) - { - Initialized(); - } +public: + Read(net_buffer* buffer, uint32 offset, void* data, size_t size) + : + NetBufferTraceEntry(buffer), + fData(data), + fOffset(offset), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer read: buffer: %p, offset: %lu, size: %lu, " - "data: %p", fBuffer, fOffset, fSize, fData); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer read: buffer: %p, offset: %lu, size: %lu, " + "data: %p", fBuffer, fOffset, fSize, fData); + } - private: - void* fData; - uint32 fOffset; - size_t fSize; +private: + void* fData; + uint32 fOffset; + size_t fSize; }; class Write : public NetBufferTraceEntry { - public: - Write(net_buffer* buffer, uint32 offset, const void* data, size_t size) - : - NetBufferTraceEntry(buffer), - fData(data), - fOffset(offset), - fSize(size) - { - Initialized(); - } +public: + Write(net_buffer* buffer, uint32 offset, const void* data, size_t size) + : + NetBufferTraceEntry(buffer), + fData(data), + fOffset(offset), + fSize(size) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer write: buffer: %p, offset: %lu, size: %lu, " - "data: %p", fBuffer, fOffset, fSize, fData); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer write: buffer: %p, offset: %lu, size: %lu, " + "data: %p", fBuffer, fOffset, fSize, fData); + } - private: - const void* fData; - uint32 fOffset; - size_t fSize; +private: + const void* fData; + uint32 fOffset; + size_t fSize; }; #if NET_BUFFER_TRACING >= 2 class DataHeaderTraceEntry : public AbstractTraceEntry { - public: - DataHeaderTraceEntry(data_header* header) - : - fHeader(header) - { - } +public: + DataHeaderTraceEntry(data_header* header) + : + fHeader(header) + { + } - protected: - data_header* fHeader; +protected: + data_header* fHeader; }; class CreateDataHeader : public DataHeaderTraceEntry { - public: - CreateDataHeader(data_header* header) - : - DataHeaderTraceEntry(header) - { - Initialized(); - } +public: + CreateDataHeader(data_header* header) + : + DataHeaderTraceEntry(header) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer data header create: header: %p", fHeader); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer data header create: header: %p", fHeader); + } }; class AcquireDataHeader : public DataHeaderTraceEntry { - public: - AcquireDataHeader(data_header* header, int32 refCount) - : - DataHeaderTraceEntry(header), - fRefCount(refCount) - { - Initialized(); - } +public: + AcquireDataHeader(data_header* header, int32 refCount) + : + DataHeaderTraceEntry(header), + fRefCount(refCount) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer data header acquire: header: %p " - "-> ref count: %ld", fHeader, fRefCount); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer data header acquire: header: %p " + "-> ref count: %ld", fHeader, fRefCount); + } - private: - int32 fRefCount; +private: + int32 fRefCount; }; class ReleaseDataHeader : public DataHeaderTraceEntry { - public: - ReleaseDataHeader(data_header* header, int32 refCount) - : - DataHeaderTraceEntry(header), - fRefCount(refCount) - { - Initialized(); - } +public: + ReleaseDataHeader(data_header* header, int32 refCount) + : + DataHeaderTraceEntry(header), + fRefCount(refCount) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("net buffer data header release: header: %p " - "-> ref count: %ld", fHeader, fRefCount); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("net buffer data header release: header: %p " + "-> ref count: %ld", fHeader, fRefCount); + } - private: - int32 fRefCount; +private: + int32 fRefCount; }; # define T2(x) new(std::nothrow) NetBufferTracing::x @@ -572,17 +572,19 @@ #if 1 static void -dump_buffer(net_buffer *_buffer) +dump_buffer(net_buffer* _buffer) { - net_buffer_private *buffer = (net_buffer_private *)_buffer; + net_buffer_private* buffer = (net_buffer_private*)_buffer; dprintf("buffer %p, size %ld\n", buffer, buffer->size); - data_node *node = NULL; - while ((node = (data_node *)list_get_next_item(&buffer->buffers, node)) != NULL) { - dprintf(" node %p, offset %lu, used %u, header %u, tail %u, header %p\n", - node, node->offset, node->used, node->HeaderSpace(), node->TailSpace(), node->header); - //dump_block((char *)node->start, node->used, " "); - dump_block((char *)node->start, min_c(node->used, 32), " "); + data_node* node = NULL; + while ((node = (data_node*)list_get_next_item(&buffer->buffers, node)) + != NULL) { + dprintf(" node %p, offset %lu, used %u, header %u, tail %u, " + "header %p\n", node, node->offset, node->used, node->HeaderSpace(), + node->TailSpace(), node->header); + //dump_block((char*)node->start, node->used, " "); + dump_block((char*)node->start, min_c(node->used, 32), " "); } } #endif @@ -606,14 +608,14 @@ #if PARANOID_BUFFER_CHECK static void -check_buffer(net_buffer *_buffer) +check_buffer(net_buffer* _buffer) { - net_buffer_private *buffer = (net_buffer_private*)_buffer; + net_buffer_private* buffer = (net_buffer_private*)_buffer; // sum up the size of all nodes size_t size = 0; - data_node *node = (data_node *)list_get_first_item(&buffer->buffers); + data_node* node = (data_node*)list_get_first_item(&buffer->buffers); while (node != NULL) { if (node->offset != size) { panic("net_buffer %p: bad node %p offset (%lu vs. %lu)", @@ -621,7 +623,7 @@ return; } size += node->used; - node = (data_node *)list_get_next_item(&buffer->buffers, node); + node = (data_node*)list_get_next_item(&buffer->buffers, node); } if (size != buffer->size) { @@ -634,7 +636,7 @@ #if 0 static void -check_buffer_contents(net_buffer *buffer, size_t offset, const void* data, +check_buffer_contents(net_buffer* buffer, size_t offset, const void* data, size_t size) { void* bufferData = malloc(size); @@ -660,7 +662,7 @@ static void -check_buffer_contents(net_buffer *buffer, size_t offset, net_buffer *source, +check_buffer_contents(net_buffer* buffer, size_t offset, net_buffer* source, size_t sourceOffset, size_t size) { void* bufferData = malloc(size); @@ -685,31 +687,31 @@ #endif // !PARANOID_BUFFER_CHECK -static inline data_header * +static inline data_header* allocate_data_header() { #if ENABLE_DEBUGGER_COMMANDS atomic_add(&sAllocatedDataHeaderCount, 1); atomic_add(&sEverAllocatedDataHeaderCount, 1); #endif - return (data_header *)object_cache_alloc(sDataNodeCache, CACHE_DONT_SLEEP); + return (data_header*)object_cache_alloc(sDataNodeCache, CACHE_DONT_SLEEP); } -static inline net_buffer_private * +static inline net_buffer_private* allocate_net_buffer() { #if ENABLE_DEBUGGER_COMMANDS atomic_add(&sAllocatedNetBufferCount, 1); atomic_add(&sEverAllocatedNetBufferCount, 1); #endif - return (net_buffer_private *)object_cache_alloc(sNetBufferCache, + return (net_buffer_private*)object_cache_alloc(sNetBufferCache, CACHE_DONT_SLEEP); } static inline void -free_data_header(data_header *header) +free_data_header(data_header* header) { #if ENABLE_DEBUGGER_COMMANDS if (header != NULL) @@ -720,7 +722,7 @@ static inline void -free_net_buffer(net_buffer_private *buffer) +free_net_buffer(net_buffer_private* buffer) { #if ENABLE_DEBUGGER_COMMANDS if (buffer != NULL) @@ -730,10 +732,10 @@ } -static data_header * +static data_header* create_data_header(size_t headerSpace) { - data_header *header = allocate_data_header(); + data_header* header = allocate_data_header(); if (header == NULL) return NULL; @@ -742,8 +744,8 @@ // TODO: initialize this correctly header->space.size = headerSpace; header->space.free = headerSpace; - header->data_end = (uint8 *)header + DATA_HEADER_SIZE; - header->tail_space = (uint8 *)header + BUFFER_SIZE - header->data_end + header->data_end = (uint8*)header + DATA_HEADER_SIZE; + header->tail_space = (uint8*)header + BUFFER_SIZE - header->data_end - headerSpace; header->first_free = NULL; @@ -754,7 +756,7 @@ static void -release_data_header(data_header *header) +release_data_header(data_header* header) { int32 refCount = atomic_add(&header->ref_count, -1); T2(ReleaseDataHeader(header, refCount - 1)); @@ -767,7 +769,7 @@ inline void -acquire_data_header(data_header *header) +acquire_data_header(data_header* header) { int32 refCount = atomic_add(&header->ref_count, 1); (void)refCount; @@ -776,12 +778,12 @@ static void -free_data_header_space(data_header *header, uint8 *data, size_t size) +free_data_header_space(data_header* header, uint8* data, size_t size) { if (size < sizeof(free_data)) size = sizeof(free_data); - free_data *freeData = (free_data *)data; + free_data* freeData = (free_data*)data; freeData->next = header->first_free; freeData->size = size; @@ -789,11 +791,10 @@ } -/*! - Tries to allocate \a size bytes from the free space in the header. +/*! Tries to allocate \a size bytes from the free space in the header. */ -static uint8 * -alloc_data_header_space(data_header *header, size_t size) +static uint8* +alloc_data_header_space(data_header* header, size_t size) { if (size < sizeof(free_data)) size = sizeof(free_data); @@ -801,25 +802,26 @@ if (header->first_free != NULL && header->first_free->size >= size) { // the first entry of the header space matches the allocation's needs -// TODO: If the free space is greater than what shall be allocated, we leak -// the remainder of the space. We should only allocate multiples of -// _ALIGN(sizeof(free_data)) and split free space in this case. It's not that -// pressing, since the only thing allocated ATM are data_nodes, and thus the -// free space entries will always have the right size. - uint8 *data = (uint8 *)header->first_free; + + // TODO: If the free space is greater than what shall be allocated, we + // leak the remainder of the space. We should only allocate multiples of + // _ALIGN(sizeof(free_data)) and split free space in this case. It's not + // that pressing, since the only thing allocated ATM are data_nodes, and + // thus the free space entries will always have the right size. + uint8* data = (uint8*)header->first_free; header->first_free = header->first_free->next; return data; } if (header->space.free < size) { // there is no free space left, search free list - free_data *freeData = header->first_free; - free_data *last = NULL; + free_data* freeData = header->first_free; + free_data* last = NULL; while (freeData != NULL) { if (last != NULL && freeData->size >= size) { // take this one last->next = freeData->next; - return (uint8 *)freeData; + return (uint8*)freeData; } last = freeData; @@ -831,7 +833,7 @@ // allocate new space - uint8 *data = header->data_end; + uint8* data = header->data_end; header->data_end += size; header->space.free -= size; @@ -839,15 +841,15 @@ } -static uint8 * -alloc_data_header_space(net_buffer_private *buffer, size_t size, - data_header **_header = NULL) +static uint8* +alloc_data_header_space(net_buffer_private* buffer, size_t size, [... truncated: 873 lines follow ...] From axeld at mail.berlios.de Thu Jun 11 20:44:16 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 11 Jun 2009 20:44:16 +0200 Subject: [Haiku-commits] r31009 - haiku/trunk/src/tools/fs_shell Message-ID: <200906111844.n5BIiGPU002872@sheep.berlios.de> Author: axeld Date: 2009-06-11 20:44:16 +0200 (Thu, 11 Jun 2009) New Revision: 31009 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31009&view=rev Modified: haiku/trunk/src/tools/fs_shell/fssh.cpp Log: * Added "mv" command (BFS only, cannot access the host yet). * Fixed warning in print_flag(). Modified: haiku/trunk/src/tools/fs_shell/fssh.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/fssh.cpp 2009-06-11 08:48:40 UTC (rev 31008) +++ haiku/trunk/src/tools/fs_shell/fssh.cpp 2009-06-11 18:44:16 UTC (rev 31009) @@ -321,7 +321,7 @@ print_flag(uint32_t deviceFlags, uint32_t testFlag, const char *yes, const char *no) { - printf((deviceFlags & testFlag) != 0 ? yes : no); + printf("%s", (deviceFlags & testFlag) != 0 ? yes : no); } @@ -576,6 +576,26 @@ } +static fssh_status_t +move_entry(int dir, const char *entry, int targetDir, const char* target, + bool force) +{ + // stat the file + struct fssh_stat st; + fssh_status_t status = _kern_read_stat(dir, entry, false, &st, sizeof(st)); + if (status != FSSH_B_OK) { + if (force && status == FSSH_B_ENTRY_NOT_FOUND) + return FSSH_B_OK; + + fprintf(stderr, "Error: Failed to move \"%s\": %s\n", entry, + fssh_strerror(status)); + return status; + } + + return _kern_rename(dir, entry, targetDir, target); +} + + // #pragma mark - Commands @@ -962,6 +982,80 @@ static fssh_status_t +command_mv(int argc, const char* const* argv) +{ + bool force = false; + + // parse parameters + int argi = 1; + for (argi = 1; argi < argc; argi++) { + const char *arg = argv[argi]; + if (arg[0] != '-') + break; + + if (arg[1] == '\0') { + fprintf(stderr, "Error: Invalid option \"-\"\n"); + return FSSH_B_BAD_VALUE; + } + + for (int i = 1; arg[i]; i++) { + switch (arg[i]) { + case 'f': + force = true; + break; + default: + fprintf(stderr, "Error: Unknown option \"-%c\"\n", arg[i]); + return FSSH_B_BAD_VALUE; + } + } + } + + // check params + int count = argc - 1 - argi; + if (count <= 0) { + fprintf(stderr, "Usage: %s [-f] ... \n", argv[0]); + return FSSH_B_BAD_VALUE; + } + + const char* target = argv[argc - 1]; + + // stat the target + struct fssh_stat st; + fssh_status_t status = _kern_read_stat(-1, target, true, &st, sizeof(st)); + if (status != FSSH_B_OK && count != 1) { + fprintf(stderr, "Error: Failed to stat target \"%s\": %s\n", target, + fssh_strerror(status)); + return status; + } + + if (status == FSSH_B_OK && FSSH_S_ISDIR(st.fssh_st_mode)) { + // move several entries + int targetDir = _kern_open_dir(-1, target); + if (targetDir < 0) { + fprintf(stderr, "Error: Failed to open dir \"%s\": %s\n", target, + fssh_strerror(targetDir)); + return targetDir; + } + + // move loop + for (; argi < argc - 1; argi++) { + status = move_entry(-1, argv[argi], targetDir, argv[argi], force); + if (status != FSSH_B_OK) { + _kern_close(targetDir); + return status; + } + } + + _kern_close(targetDir); + return FSSH_B_OK; + } + + // rename single entry + return move_entry(-1, argv[argi], -1, target, force); +} + + +static fssh_status_t command_query(int argc, const char* const* argv) { if (argc != 2) { @@ -1024,7 +1118,7 @@ static fssh_status_t -command_rm(int argc, char **argv) +command_rm(int argc, const char* const* argv) { bool recursive = false; bool force = false; @@ -1099,6 +1193,7 @@ command_ls, "ls", "list files or directories", command_mkdir, "mkdir", "create directories", command_mkindex, "mkindex", "create an index", + command_mv, "mv", "move/rename files and directories", command_query, "query", "query for files", command_quit, "quit/exit", "quit the shell", command_rm, "rm", "remove files and directories", From axeld at mail.berlios.de Thu Jun 11 23:47:19 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 11 Jun 2009 23:47:19 +0200 Subject: [Haiku-commits] r31010 - haiku/trunk/src/system/kernel/fs Message-ID: <200906112147.n5BLlJOC030577@sheep.berlios.de> Author: axeld Date: 2009-06-11 23:47:19 +0200 (Thu, 11 Jun 2009) New Revision: 31010 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31010&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * Returning random stat data isn't really nice. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2009-06-11 18:44:16 UTC (rev 31009) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2009-06-11 21:47:19 UTC (rev 31010) @@ -6086,6 +6086,12 @@ FUNCTION(("common_read_stat: stat %p\n", stat)); + // TODO: remove this once all file systems properly set them! + stat->st_crtim.tv_nsec = 0; + stat->st_ctim.tv_nsec = 0; + stat->st_mtim.tv_nsec = 0; + stat->st_atim.tv_nsec = 0; + status_t status = FS_CALL(vnode, read_stat, stat); // fill in the st_dev and st_ino fields From korli at users.berlios.de Fri Jun 12 11:01:34 2009 From: korli at users.berlios.de (=?ISO-8859-1?B?Suly9G1lIER1dmFs?=) Date: Fri, 12 Jun 2009 11:01:34 +0200 Subject: [Haiku-commits] r31010 - haiku/trunk/src/system/kernel/fs In-Reply-To: <200906112147.n5BLlJOC030577@sheep.berlios.de> References: <200906112147.n5BLlJOC030577@sheep.berlios.de> Message-ID: 2009/6/11 axeld at BerliOS : > + ? ? ? // TODO: remove this once all file systems properly set them! I'm wondering why this should be removed in the end. Why not be on the safe side and init the struct ? You can't expect every filesystem (user and system) to be bug free. Bye, J?r?me From axeld at mail.berlios.de Fri Jun 12 11:09:20 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 12 Jun 2009 11:09:20 +0200 Subject: [Haiku-commits] r31011 - haiku/trunk/src/apps/debuganalyzer/model_loader Message-ID: <200906120909.n5C99Kkq010974@sheep.berlios.de> Author: axeld Date: 2009-06-12 11:09:20 +0200 (Fri, 12 Jun 2009) New Revision: 31011 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31011&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/model_loader/AbstractModelLoader.h Log: * Fixed warning. Modified: haiku/trunk/src/apps/debuganalyzer/model_loader/AbstractModelLoader.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/model_loader/AbstractModelLoader.h 2009-06-11 21:47:19 UTC (rev 31010) +++ haiku/trunk/src/apps/debuganalyzer/model_loader/AbstractModelLoader.h 2009-06-12 09:09:20 UTC (rev 31011) @@ -15,7 +15,7 @@ void* targetCookie); protected: - ~AbstractModelLoader(); + virtual ~AbstractModelLoader(); public: virtual status_t StartLoading(); From axeld at mail.berlios.de Fri Jun 12 11:31:27 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 12 Jun 2009 11:31:27 +0200 Subject: [Haiku-commits] r31012 - in haiku/trunk: headers/private/fs_shell src/tools/fs_shell Message-ID: <200906120931.n5C9VRbi013196@sheep.berlios.de> Author: axeld Date: 2009-06-12 11:31:25 +0200 (Fri, 12 Jun 2009) New Revision: 31012 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31012&view=rev Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h haiku/trunk/headers/private/fs_shell/fssh_stat.h haiku/trunk/src/tools/fs_shell/time.cpp haiku/trunk/src/tools/fs_shell/vfs.cpp Log: * Added real_time_clock(), and real_time_clock_usecs(). * Added support for timespec stat times. Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2009-06-12 09:09:20 UTC (rev 31011) +++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2009-06-12 09:31:25 UTC (rev 31012) @@ -1221,6 +1221,10 @@ #define st_size fssh_st_size #define st_rdev fssh_st_rdev #define st_blksize fssh_st_blksize +#define st_atim fssh_st_atim +#define st_mtim fssh_st_mtim +#define st_ctim fssh_st_ctim +#define st_crtim fssh_st_crtim #define st_atime fssh_st_atime #define st_mtime fssh_st_mtime #define st_ctime fssh_st_ctime Modified: haiku/trunk/headers/private/fs_shell/fssh_stat.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_stat.h 2009-06-12 09:09:20 UTC (rev 31011) +++ haiku/trunk/headers/private/fs_shell/fssh_stat.h 2009-06-12 09:31:25 UTC (rev 31012) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Haiku Inc. All Rights Reserved. + * Copyright 2002-2009, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _FSSH_SYS_STAT_H_ @@ -20,10 +20,10 @@ fssh_off_t fssh_st_size; /* size in bytes of this file */ fssh_dev_t fssh_st_rdev; /* device type (not used) */ fssh_size_t fssh_st_blksize; /* preferred block size for i/o */ - fssh_time_t fssh_st_atime; /* last access time */ - fssh_time_t fssh_st_mtime; /* last modification time */ - fssh_time_t fssh_st_ctime; /* last change time, not creation time */ - fssh_time_t fssh_st_crtime; /* creation time */ + fssh_timespec fssh_st_atim; /* last access time */ + fssh_timespec fssh_st_mtim; /* last modification time */ + fssh_timespec fssh_st_ctim; /* last change time, not creation time */ + fssh_timespec fssh_st_crtim; /* creation time */ // Haiku extensions: // TODO: we might also define special types for files and TTYs @@ -34,6 +34,12 @@ }; typedef struct fssh_stat fssh_struct_stat; +/* compatibility with older apps */ +#define fssh_st_atime fssh_st_atim.tv_sec +#define fssh_st_mtime fssh_st_mtim.tv_sec +#define fssh_st_ctime fssh_st_ctim.tv_sec +#define fssh_st_crtime fssh_st_crtim.tv_sec + /* extended file types */ #define FSSH_S_ATTR_DIR 01000000000 /* attribute directory */ #define FSSH_S_ATTR 02000000000 /* attribute */ Modified: haiku/trunk/src/tools/fs_shell/time.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/time.cpp 2009-06-12 09:09:20 UTC (rev 31011) +++ haiku/trunk/src/tools/fs_shell/time.cpp 2009-06-12 09:31:25 UTC (rev 31012) @@ -1,5 +1,7 @@ /* + * Copyright 2009, Axel D?rfler, axeld at pinc-software.de. * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de. + * * Distributed under the terms of the MIT License. */ @@ -9,6 +11,7 @@ #include "fssh_time.h" #include +#include #include @@ -17,30 +20,38 @@ #if 0 -uint32_t -fssh_real_time_clock(void) +void +fssh_set_real_time_clock(uint32_t secs_since_jan1_1970) { } -void -fssh_set_real_time_clock(uint32_t secs_since_jan1_1970) +fssh_status_t +fssh_set_timezone(char *timezone) { } +#endif // 0 -fssh_bigtime_t -fssh_real_time_clock_usecs(void) +uint32_t +fssh_real_time_clock(void) { + timeval tv; + gettimeofday(&tv, NULL); + + return tv.tv_sec; } -fssh_status_t -fssh_set_timezone(char *timezone) +fssh_bigtime_t +fssh_real_time_clock_usecs(void) { + timeval tv; + gettimeofday(&tv, NULL); + + return tv.tv_sec * 1000000LL + tv.tv_usec; } -#endif // 0 fssh_bigtime_t fssh_system_time(void) Modified: haiku/trunk/src/tools/fs_shell/vfs.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/vfs.cpp 2009-06-12 09:09:20 UTC (rev 31011) +++ haiku/trunk/src/tools/fs_shell/vfs.cpp 2009-06-12 09:31:25 UTC (rev 31012) @@ -1,12 +1,12 @@ /* - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. * Distributed under the terms of the NewOS License. */ -/* Virtual File System and File System Interface Layer */ +/*! Virtual File System and File System Interface Layer */ #include "vfs.h" @@ -3828,6 +3828,11 @@ FUNCTION(("common_read_stat: stat %p\n", stat)); + stat->fssh_st_atim.tv_nsec = 0; + stat->fssh_st_mtim.tv_nsec = 0; + stat->fssh_st_ctim.tv_nsec = 0; + stat->fssh_st_crtim.tv_nsec = 0; + fssh_status_t status = FS_CALL(vnode, read_stat, stat); // fill in the st_dev and st_ino fields From axeld at pinc-software.de Fri Jun 12 14:33:21 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 12 Jun 2009 14:33:21 +0200 CEST Subject: [Haiku-commits] r31010 - haiku/trunk/src/system/kernel/fs In-Reply-To: Message-ID: <14749531256-BeMail@zon> J?r?me Duval wrote: > 2009/6/11 axeld at BerliOS : > > + ? ? ? // TODO: remove this once all file systems properly set > > them! > I'm wondering why this should be removed in the end. > Why not be on the safe side and init the struct ? You can't expect > every filesystem (user and system) to be bug free. Well, we have the source, haven't we? But apart from that, we can keep it in as well, as most file systems cannot deliver the extra resolution, anyway. Bye, Axel. From ingo_weinhold at gmx.de Fri Jun 12 15:24:06 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 12 Jun 2009 15:24:06 +0200 Subject: [Haiku-commits] r31010 - haiku/trunk/src/system/kernel/fs In-Reply-To: <14749531256-BeMail@zon> References: <14749531256-BeMail@zon> Message-ID: <20090612152406.375.1@knochen-vm.localdomain> On 2009-06-12 at 14:33:21 [+0200], Axel D?rfler wrote: > J?r?me Duval wrote: > > 2009/6/11 axeld at BerliOS : > > > + // TODO: remove this once all file systems properly set > > > them! > > I'm wondering why this should be removed in the end. > > Why not be on the safe side and init the struct ? You can't expect > > every filesystem (user and system) to be bug free. > > Well, we have the source, haven't we? But apart from that, we can keep > it in as well, as most file systems cannot deliver the extra > resolution, anyway. Then they should set it to 0. No reason to do extra work for file systems that can (e.g. BFS). CU, Ingo From mmlr at mail.berlios.de Fri Jun 12 17:19:45 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Fri, 12 Jun 2009 17:19:45 +0200 Subject: [Haiku-commits] r31013 - haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam Message-ID: <200906121519.n5CFJjmN003377@sheep.berlios.de> Author: mmlr Date: 2009-06-12 17:19:43 +0200 (Fri, 12 Jun 2009) New Revision: 31013 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31013&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp Log: Need to stop the roster before deleting it. Should fix bug #4017. Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2009-06-12 09:31:25 UTC (rev 31012) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2009-06-12 15:19:43 UTC (rev 31013) @@ -43,6 +43,7 @@ WebCamMediaAddOn::~WebCamMediaAddOn() { + fRoster->Stop(); delete fRoster; } From superstippi at gmx.de Fri Jun 12 17:21:42 2009 From: superstippi at gmx.de (=?ISO-8859-1?Q?Stephan_A=DFmus?=) Date: Fri, 12 Jun 2009 17:21:42 +0200 Subject: [Haiku-commits] r31013 - haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam In-Reply-To: <200906121519.n5CFJjmN003377@sheep.berlios.de> References: <200906121519.n5CFJjmN003377@sheep.berlios.de> Message-ID: <4A327286.1030909@gmx.de> mmlr at mail.berlios.de schrieb: > Author: mmlr > Date: 2009-06-12 17:19:43 +0200 (Fri, 12 Jun 2009) > New Revision: 31013 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31013&view=rev > > Modified: > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp > Log: > Need to stop the roster before deleting it. Should fix bug #4017. > > > Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp > =================================================================== > --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2009-06-12 09:31:25 UTC (rev 31012) > +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2009-06-12 15:19:43 UTC (rev 31013) > @@ -43,6 +43,7 @@ > > WebCamMediaAddOn::~WebCamMediaAddOn() > { > + fRoster->Stop(); > delete fRoster; > } If this is something that any client of BUSBRoster has to do before deleting a roster instance, this may as well be called in the roster destructor itself, no? Or is Stop() a virtual method and BUSBRoster can be subclassed? Best regards, -Stephan From mmlr at mlotz.ch Fri Jun 12 18:25:39 2009 From: mmlr at mlotz.ch (Michael Lotz) Date: Fri, 12 Jun 2009 18:25:39 Subject: [Haiku-commits] =?windows-1252?q?r31013_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/media/media-add-ons/usb=5Fwebcam?= In-Reply-To: <4A327286.1030909@gmx.de> Message-ID: <380546744-BeMail@haiku> > mmlr at mail.berlios.de schrieb: > > Need to stop the roster before deleting it. Should fix bug #4017. > > If this is something that any client of BUSBRoster has to do before > deleting a roster instance, this may as well be called in the roster > destructor itself, no? Or is Stop() a virtual method and BUSBRoster > can > be subclassed? In principle yes, and it does, but it cannot work. When the BUSBRoster destructor is called, it is called with "this" being the BUSBRoster base class only, and not the subclassed roster anymore. At this point the pure virtual functions that were provided by the subclass aren't available anymore, hence the pure virtual function call in the first place. It basically means that you need to call Stop() while the object is still intact and the subclass vtable is in place. Another way of "solving" it would be to check if the function call is still available and then just not call it if not, but I don't know off hand how to do that. Regards Michael From mmlr at mail.berlios.de Fri Jun 12 18:31:18 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Fri, 12 Jun 2009 18:31:18 +0200 Subject: [Haiku-commits] r31014 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200906121631.n5CGVIgb010196@sheep.berlios.de> Author: mmlr Date: 2009-06-12 18:31:14 +0200 (Fri, 12 Jun 2009) New Revision: 31014 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31014&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.h Log: * Call PostReset() at the end of ResetPort() as it's always used in that way. * Reset the port directly after executing a command failed instead of letting the next call do the reset first. This is arbitrary but looks cleaner to me. * Provide a way to check if a given sata_request is a SCSI_OP_TEST_UNIT_READY over ATAPI and use this info to calm down all error output. This avoids spamming the syslog with error output on each media status poll when no disk is present in a ATAPI device. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2009-06-12 15:19:43 UTC (rev 31013) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2009-06-12 16:31:14 UTC (rev 31014) @@ -43,6 +43,7 @@ fSectorSize(0), fSectorCount(0), fIsATAPI(false), + fTestUnitReadyActive(false), fResetPort(false), fError(false) { @@ -140,7 +141,6 @@ FlushPostedWrites(); ResetPort(true); - PostReset(); TRACE("ie 0x%08lx\n", fRegs->ie); TRACE("is 0x%08lx\n", fRegs->is); @@ -233,7 +233,8 @@ status_t AHCIPort::ResetPort(bool forceDeviceReset) { - TRACE("AHCIPort::ResetPort port %d\n", fIndex); + if (!fTestUnitReadyActive) + TRACE("AHCIPort::ResetPort port %d\n", fIndex); // stop DMA engine fRegs->cmd &= ~PORT_CMD_ST; @@ -246,8 +247,10 @@ bool deviceBusy = fRegs->tfd & (ATA_BSY | ATA_DRQ); - TRACE("AHCIPort::ResetPort port %d, deviceBusy %d, forceDeviceReset %d\n", - fIndex, deviceBusy, forceDeviceReset); + if (!fTestUnitReadyActive) { + TRACE("AHCIPort::ResetPort port %d, deviceBusy %d, " + "forceDeviceReset %d\n", fIndex, deviceBusy, forceDeviceReset); + } if (deviceBusy || forceDeviceReset) ResetDevice(); @@ -256,14 +259,15 @@ fRegs->cmd |= PORT_CMD_ST; FlushPostedWrites(); - return B_OK; + return PostReset(); } status_t AHCIPort::PostReset() { - TRACE("AHCIPort::PostReset port %d\n", fIndex); + if (!fTestUnitReadyActive) + TRACE("AHCIPort::PostReset port %d\n", fIndex); if ((fRegs->ssts & 0xf) != 0x3 || (fRegs->tfd & 0xff) == 0x7f) { TRACE("AHCIPort::PostReset port %d: no device\n", fIndex); @@ -289,9 +293,11 @@ fRegs->cmd &= ~PORT_CMD_ATAPI; FlushPostedWrites(); - TRACE("device signature 0x%08lx (%s)\n", fRegs->sig, - (fRegs->sig == 0xeb140101) ? "ATAPI" : (fRegs->sig == 0x00000101) ? - "ATA" : "unknown"); + if (!fTestUnitReadyActive) { + TRACE("device signature 0x%08lx (%s)\n", fRegs->sig, + (fRegs->sig == 0xeb140101) ? "ATAPI" : (fRegs->sig == 0x00000101) ? + "ATA" : "unknown"); + } return B_OK; } @@ -345,20 +351,25 @@ { uint32 ci = fRegs->ci; - TRACE("AHCIPort::InterruptErrorHandler port %d, fCommandsActive 0x%08lx, " - "is 0x%08lx, ci 0x%08lx\n", fIndex, fCommandsActive, is, ci); + if (!fTestUnitReadyActive) { + TRACE("AHCIPort::InterruptErrorHandler port %d, " + "fCommandsActive 0x%08lx, is 0x%08lx, ci 0x%08lx\n", fIndex, + fCommandsActive, is, ci); - TRACE("ssts 0x%08lx\n", fRegs->ssts); - TRACE("sctl 0x%08lx\n", fRegs->sctl); - TRACE("serr 0x%08lx\n", fRegs->serr); - TRACE("sact 0x%08lx\n", fRegs->sact); + TRACE("ssts 0x%08lx\n", fRegs->ssts); + TRACE("sctl 0x%08lx\n", fRegs->sctl); + TRACE("serr 0x%08lx\n", fRegs->serr); + TRACE("sact 0x%08lx\n", fRegs->sact); + } // read and clear SError uint32 serr = fRegs->serr; fRegs->serr = serr; if (is & PORT_INT_TFE) { - TRACE("Task File Error\n"); + if (!fTestUnitReadyActive) + TRACE("Task File Error\n"); + fResetPort = true; fError = true; } @@ -740,6 +751,7 @@ fCommandList->cfl = 5; // 20 bytes, length in DWORDS memcpy((char *)fCommandTable->cfis, request->fis(), 20); + fTestUnitReadyActive = request->is_test_unit_ready(); if (request->is_atapi()) { // ATAPI PACKET is a 12 or 16 byte SCSI command memset((char *)fCommandTable->acmd, 0, 32); @@ -755,7 +767,7 @@ if (wait_until_clear(&fRegs->tfd, ATA_BSY | ATA_DRQ, 1000000) < B_OK) { TRACE("ExecuteAtaRequest port %d: device is busy\n", fIndex); - fResetPort = true; + ResetPort(); FinishTransfer(); request->abort(); return; @@ -763,9 +775,9 @@ cpu_status cpu = disable_interrupts(); acquire_spinlock(&fSpinlock); + fCommandsActive |= 1; fRegs->ci = 1; FlushPostedWrites(); - fCommandsActive |= 1; release_spinlock(&fSpinlock); restore_interrupts(cpu); @@ -790,13 +802,17 @@ TRACE("tfd 0x%08lx\n", fRegs->tfd); */ + if (fResetPort || status == B_TIMED_OUT) { + fResetPort = false; + ResetPort(); + } + size_t bytesTransfered = fCommandList->prdbc; FinishTransfer(); if (status == B_TIMED_OUT) { TRACE("ExecuteAtaRequest port %d: device timeout\n", fIndex); - fResetPort = true; request->abort(); } else { request->finish(tfd, bytesTransfered); @@ -807,12 +823,6 @@ void AHCIPort::ScsiExecuteRequest(scsi_ccb *request) { - if (fResetPort) { - fResetPort = false; - ResetPort(); - PostReset(); - } - // TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode 0x%02x, length %u\n", fIndex, request->cdb[0], request->cdb_length); if (fIsATAPI && request->cdb[0] != SCSI_OP_INQUIRY) { Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2009-06-12 15:19:43 UTC (rev 31013) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2009-06-12 16:31:14 UTC (rev 31014) @@ -67,6 +67,7 @@ uint32 fSectorSize; uint64 fSectorCount; bool fIsATAPI; + bool fTestUnitReadyActive; bool fResetPort; bool fError; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.cpp 2009-06-12 15:19:43 UTC (rev 31013) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.cpp 2009-06-12 16:31:14 UTC (rev 31014) @@ -105,8 +105,13 @@ if (tfd & (ATA_ERR | ATA_DF)) { uint8 status = tfd & 0xff; uint8 error = (tfd >> 8) & 0xff; - dprintf("ahci: sata_request::finish ATA command 0x%02x failed\n", fFis[2]); - dprintf("ahci: sata_request::finish status 0x%02x, error 0x%02x\n", status, error); + + if (!is_test_unit_ready()) { + dprintf("ahci: sata_request::finish ATA command 0x%02x failed\n", + fFis[2]); + dprintf("ahci: sata_request::finish status 0x%02x, error 0x%02x\n", + status, error); + } } if (fCcb) { @@ -116,13 +121,16 @@ if (tfd & (ATA_ERR | ATA_DF)) { fCcb->subsys_status = SCSI_REQ_CMP_ERR; if (fIsATAPI) { - dprintf("ahci: sata_request::finish ATAPI packet %02x %02x %02x %02x " + if (!is_test_unit_ready()) { + dprintf("ahci: sata_request::finish ATAPI packet %02x %02x %02x %02x " "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x (len %d)\n", fCcb->cdb[0], fCcb->cdb[1], fCcb->cdb[2], fCcb->cdb[3], fCcb->cdb[4], fCcb->cdb[5], fCcb->cdb[6], fCcb->cdb[7], fCcb->cdb[8], fCcb->cdb[9], fCcb->cdb[10], fCcb->cdb[11], fCcb->cdb[12], fCcb->cdb[13], fCcb->cdb[14], fCcb->cdb[15], fCcb->cdb_length); + } + fCcb->device_status = SCSI_STATUS_CHECK_CONDITION; } else { // TODO ATA error handling goes here Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.h 2009-06-12 15:19:43 UTC (rev 31013) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/sata_request.h 2009-06-12 16:31:14 UTC (rev 31014) @@ -6,6 +6,7 @@ #define _SATA_REQUEST_H #include "ahci_defs.h" +#include "scsi_cmds.h" class sata_request { @@ -22,6 +23,7 @@ void set_atapi_cmd(size_t transferLength); bool is_atapi(); + bool is_test_unit_ready(); scsi_ccb * ccb(); const void * fis(); @@ -65,6 +67,13 @@ } +inline bool +sata_request::is_test_unit_ready() +{ + return fIsATAPI && fCcb != NULL && fCcb->cdb[0] == SCSI_OP_TEST_UNIT_READY; +} + + inline void * sata_request::data() { From oruizdorantes at mail.berlios.de Fri Jun 12 20:14:52 2009 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 12 Jun 2009 20:14:52 +0200 Subject: [Haiku-commits] r31015 - in haiku/trunk: headers/private/bluetooth src/servers/bluetooth Message-ID: <200906121814.n5CIEqYF024897@sheep.berlios.de> Author: oruizdorantes Date: 2009-06-12 20:14:51 +0200 (Fri, 12 Jun 2009) New Revision: 31015 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31015&view=rev Added: haiku/trunk/headers/private/bluetooth/PortListener.h Removed: haiku/trunk/src/servers/bluetooth/BPortNot.cpp haiku/trunk/src/servers/bluetooth/BPortNot.h Modified: haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp haiku/trunk/src/servers/bluetooth/BluetoothServer.h haiku/trunk/src/servers/bluetooth/Jamfile Log: Make a bit more elegant the processing of bluetooth events Added: haiku/trunk/headers/private/bluetooth/PortListener.h =================================================================== --- haiku/trunk/headers/private/bluetooth/PortListener.h 2009-06-12 16:31:14 UTC (rev 31014) +++ haiku/trunk/headers/private/bluetooth/PortListener.h 2009-06-12 18:14:51 UTC (rev 31015) @@ -0,0 +1,160 @@ +#ifndef PORTLISTENER_H_ +#define PORTLISTENER_H_ + +#include + + +template < + typename TYPE, + ssize_t MAX_MESSAGE_SIZE = 256, + size_t MAX_MESSAGE_DEEP = 16, + uint32 PRIORITY = B_URGENT_DISPLAY_PRIORITY> +class PortListener { + + typedef status_t (*port_listener_func)(TYPE*, int32, size_t); + + struct PortListenerInfo { + port_id* port; + port_listener_func func; + } fInformation; + + + public: + PortListener(const char* name, port_listener_func handler) + { + fInformation.func = handler; + fInformation.port = &fPort; + + InitCheck(); + fPortName = strdup(name); + fThreadName = strdup(name); + fThreadName = strcat(fThreadName, " thread"); + } + + + ~PortListener() { + + status_t status; + + close_port(fPort); + // Closing the port should provoke the thread to finish + wait_for_thread(fThread, &status); + + delete fThreadName; + delete fPortName; + + return status; + } + + + status_t TriggerCode(int32 code) { + + return write_port(fPort, code, NULL, 0); + + } + + + status_t InitCheck() { + + // Create Port + fPort = find_port(fPortName); + if (fPort == B_NAME_NOT_FOUND) { + fPort = create_port(MAX_MESSAGE_DEEP, fPortName); + } + + if (fPort < B_OK) + return fPort; + + // Create Thread + + fThread = find_thread(fThreadName); + if (fThread < B_OK) { +#ifdef KERNEL_LAND + fThread = spawn_kernel_thread((thread_func)&PortListener::threadFunction, fThreadName, PRIORITY, &fInformation); +#else + fThread = spawn_thread((thread_func)&PortListener::threadFunction, fThreadName, PRIORITY, &fInformation); +#endif + } + + if (fThread < B_OK) + return fThread; + + return B_OK; + } + + + status_t Launch() { + + status_t check = InitCheck(); + + if (check < B_OK) + return check; + + return resume_thread(fThread); + } + + + status_t Stop() { + status_t status; + + wait_for_thread(fThread, &status); + + return status; + } + + private: + port_id fPort; + thread_id fThread; + char* fThreadName; + char* fPortName; + + static int32 threadFunction(void* data) + { + ssize_t ssizePort; + ssize_t ssizeRead; + status_t status = B_OK; + int32 code; + + port_id* port = ((struct PortListenerInfo*)data)->port; + port_listener_func handler = ((struct PortListenerInfo*)data)->func; + + + TYPE* buffer = (TYPE*)malloc(MAX_MESSAGE_SIZE); + + while ((ssizePort = port_buffer_size(*port)) != B_BAD_PORT_ID) { + + if (ssizePort <= 0) { + snooze(500*1000); + continue; + } + + if (ssizePort > MAX_MESSAGE_SIZE) { + snooze(500*1000); + continue; + } + + ssizeRead = read_port(*port, &code, (void*)buffer, ssizePort); + + if (ssizeRead != ssizePort) + continue; + + status = handler(buffer, code, ssizePort); + + if (status != B_OK) + break; + } + + free(buffer); + + if (ssizePort == B_BAD_PORT_ID) // the port dissapeared + return ssizePort; + + return status; + } + +}; // PortListener + + +#endif // PORTLISTENER_H_ Deleted: haiku/trunk/src/servers/bluetooth/BPortNot.cpp Deleted: haiku/trunk/src/servers/bluetooth/BPortNot.h Modified: haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp =================================================================== --- haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp 2009-06-12 16:31:14 UTC (rev 31014) +++ haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp 2009-06-12 18:14:51 UTC (rev 31015) @@ -2,7 +2,6 @@ * Copyright 2007-2009 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com * All rights reserved. Distributed under the terms of the MIT License. - * */ #include @@ -28,6 +27,28 @@ #include "Output.h" +status_t +DispatchEvent(struct hci_event_header* header, int32 code, size_t size) +{ + // we only handle events + if (GET_PORTCODE_TYPE(code)!= BT_EVENT) { + Output::Instance()->Post("Wrong type frame code", BLACKBOARD_GENERAL); + return B_OK; + } + + // fetch the LocalDevice who belongs this event + LocalDeviceImpl* lDeviceImplementation = ((BluetoothServer*)be_app)->LocateLocalDeviceImpl(GET_PORTCODE_HID(code)); + if (lDeviceImplementation == NULL) { + Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_GENERAL); + return B_OK; + } + + lDeviceImplementation->HandleEvent(header); + + return B_OK; +} + + BluetoothServer::BluetoothServer() : BApplication(BLUETOOTH_SIGNATURE) { Output::Instance()->Run(); @@ -42,9 +63,9 @@ fDeviceManager = new DeviceManager(); fLocalDevicesList.MakeEmpty(); - // TODO: Some events should be handled faster than in KL... - fEventListener = spawn_thread(notification_Thread, "BT port listener" , - B_URGENT_DISPLAY_PRIORITY , this); + fEventListener2 = new BluetoothPortListener(BT_USERLAND_PORT_NAME, + (BluetoothPortListener::port_listener_func)&DispatchEvent); + } @@ -80,13 +101,12 @@ fDeviceManager->StartMonitoringDevice("bluetooth/h3"); fDeviceManager->StartMonitoringDevice("bluetooth/h4"); fDeviceManager->StartMonitoringDevice("bluetooth/h5"); - // Launch the notifier thread - if ( resume_thread(fEventListener) != B_OK ) - { + + if (fEventListener2->Launch() != B_OK) Output::Instance()->Post("Bluetooth port listener failed\n", BLACKBOARD_GENERAL); - } + else + Output::Instance()->Post("Bluetooth server Ready\n", BLACKBOARD_GENERAL); - Output::Instance()->Post("Bluetooth server Ready\n", BLACKBOARD_GENERAL); } @@ -175,6 +195,7 @@ #pragma mark - #endif + LocalDeviceImpl* BluetoothServer::LocateDelegateFromMessage(BMessage* message) { @@ -369,17 +390,7 @@ #pragma mark - #endif - int32 -BluetoothServer::notification_Thread(void* data) -{ - BPortNot notifierd((BluetoothServer*)data, BT_USERLAND_PORT_NAME); - - notifierd.loop(); - return B_NO_ERROR; -} - -int32 BluetoothServer::sdp_server_Thread(void* data) { Modified: haiku/trunk/src/servers/bluetooth/BluetoothServer.h =================================================================== --- haiku/trunk/src/servers/bluetooth/BluetoothServer.h 2009-06-12 16:31:14 UTC (rev 31014) +++ haiku/trunk/src/servers/bluetooth/BluetoothServer.h 2009-06-12 18:14:51 UTC (rev 31015) @@ -9,21 +9,22 @@ #define _BLUETOOTH_SERVER_APP_H #include + #include +#include #include -#include -#include "BPortNot.h" -#include "HCIDelegate.h" -#include "DeviceManager.h" -#include "LocalDeviceImpl.h" - #include #include #include #include +#include "HCIDelegate.h" +#include "DeviceManager.h" +#include "LocalDeviceImpl.h" +#include + #define BT "bluetooth_server: " typedef enum { @@ -37,8 +38,8 @@ #define BLACKBOARD_LD(X) (BLACKBOARD_END+X-HCI_DEVICE_INDEX_OFFSET) typedef BObjectList LocalDevicesList; +typedef PortListener BluetoothPortListener; - class BluetoothServer : public BApplication { public: @@ -52,9 +53,7 @@ virtual void AppActivated(bool act); virtual void MessageReceived(BMessage *message); - - - static int32 notification_Thread(void* data); + static int32 sdp_server_Thread(void* data); /* Messages reply */ @@ -66,7 +65,7 @@ LocalDeviceImpl* LocateLocalDeviceImpl(hci_id hid); - + private: LocalDeviceImpl* LocateDelegateFromMessage(BMessage* message); @@ -74,12 +73,13 @@ void ShowWindow(BWindow* pWindow); LocalDevicesList fLocalDevicesList; - // UI + // Notification system - thread_id fEventListener; + BluetoothPortListener* fEventListener2; + DeviceManager* fDeviceManager; - + BPoint fCenter; }; Modified: haiku/trunk/src/servers/bluetooth/Jamfile =================================================================== --- haiku/trunk/src/servers/bluetooth/Jamfile 2009-06-12 16:31:14 UTC (rev 31014) +++ haiku/trunk/src/servers/bluetooth/Jamfile 2009-06-12 18:14:51 UTC (rev 31015) @@ -8,9 +8,7 @@ Server bluetooth_server : - BPortNot.cpp BluetoothServer.cpp -# CommandManager.cpp DeviceManager.cpp HCIControllerAccessor.cpp HCITransportAccessor.cpp From oruizdorantes at mail.berlios.de Fri Jun 12 20:25:57 2009 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Fri, 12 Jun 2009 20:25:57 +0200 Subject: [Haiku-commits] r31016 - haiku/trunk/headers/private/bluetooth Message-ID: <200906121825.n5CIPvJ5026356@sheep.berlios.de> Author: oruizdorantes Date: 2009-06-12 20:25:57 +0200 (Fri, 12 Jun 2009) New Revision: 31016 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31016&view=rev Modified: haiku/trunk/headers/private/bluetooth/PortListener.h Log: License header & style Modified: haiku/trunk/headers/private/bluetooth/PortListener.h =================================================================== --- haiku/trunk/headers/private/bluetooth/PortListener.h 2009-06-12 18:14:51 UTC (rev 31015) +++ haiku/trunk/headers/private/bluetooth/PortListener.h 2009-06-12 18:25:57 UTC (rev 31016) @@ -1,3 +1,7 @@ +/* + * Copyright 2009 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com + * All rights reserved. Distributed under the terms of the MIT License. + */ #ifndef PORTLISTENER_H_ #define PORTLISTENER_H_ @@ -6,7 +10,7 @@ template < typename TYPE, - ssize_t MAX_MESSAGE_SIZE = 256, + ssize_t MAX_MESSAGE_SIZE = 256, size_t MAX_MESSAGE_DEEP = 16, uint32 PRIORITY = B_URGENT_DISPLAY_PRIORITY> class PortListener { @@ -18,13 +22,12 @@ port_listener_func func; } fInformation; - - public: + public: PortListener(const char* name, port_listener_func handler) { fInformation.func = handler; fInformation.port = &fPort; - + InitCheck(); fPortName = strdup(name); fThreadName = strdup(name); @@ -48,9 +51,9 @@ status_t TriggerCode(int32 code) { - + return write_port(fPort, code, NULL, 0); - + } @@ -77,10 +80,10 @@ MAX_MESSAGE_DEEP, PRIORITY>::threadFunction, fThreadName, PRIORITY, &fInformation); #endif } - + if (fThread < B_OK) return fThread; - + return B_OK; } @@ -97,6 +100,7 @@ status_t Stop() { + status_t status; wait_for_thread(fThread, &status); From korli at mail.berlios.de Fri Jun 12 20:36:42 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 12 Jun 2009 20:36:42 +0200 Subject: [Haiku-commits] r31017 - in haiku/vendor/freebsd/current/dev: mii msk Message-ID: <200906121836.n5CIagKs027224@sheep.berlios.de> Author: korli Date: 2009-06-12 20:36:41 +0200 (Fri, 12 Jun 2009) New Revision: 31017 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31017&view=rev Modified: haiku/vendor/freebsd/current/dev/mii/e1000phy.c haiku/vendor/freebsd/current/dev/mii/e1000phyreg.h haiku/vendor/freebsd/current/dev/mii/miidevs haiku/vendor/freebsd/current/dev/mii/ukphy.c haiku/vendor/freebsd/current/dev/mii/ukphy_subr.c haiku/vendor/freebsd/current/dev/msk/if_msk.c haiku/vendor/freebsd/current/dev/msk/if_mskreg.h Log: updated msk and some mii to freebsd current Modified: haiku/vendor/freebsd/current/dev/mii/e1000phy.c =================================================================== --- haiku/vendor/freebsd/current/dev/mii/e1000phy.c 2009-06-12 18:25:57 UTC (rev 31016) +++ haiku/vendor/freebsd/current/dev/mii/e1000phy.c 2009-06-12 18:36:41 UTC (rev 31017) @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/e1000phy.c,v 1.18 2006/12/11 11:09:48 yongari Exp $"); +__FBSDID("$FreeBSD$"); /* * driver for the Marvell 88E1000 series external 1000/100/10-BT PHY. @@ -105,7 +105,9 @@ MII_PHY_DESC(MARVELL, E1149), MII_PHY_DESC(MARVELL, E1111), MII_PHY_DESC(MARVELL, E1116), + MII_PHY_DESC(MARVELL, E1116R), MII_PHY_DESC(MARVELL, E1118), + MII_PHY_DESC(MARVELL, E3016), MII_PHY_DESC(xxMARVELL, E1000), MII_PHY_DESC(xxMARVELL, E1011), MII_PHY_DESC(xxMARVELL, E1000_3), @@ -128,7 +130,6 @@ struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; - int fast_ether; esc = device_get_softc(dev); sc = &esc->mii_sc; @@ -141,10 +142,8 @@ sc->mii_phy = ma->mii_phyno; sc->mii_service = e1000phy_service; sc->mii_pdata = mii; - sc->mii_anegticks = MII_ANEGTICKS_GIGE; mii->mii_instance++; - fast_ether = 0; esc->mii_model = MII_MODEL(ma->mii_id2); switch (esc->mii_model) { case MII_MODEL_MARVELL_E1011: @@ -152,55 +151,31 @@ if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK) sc->mii_flags |= MIIF_HAVEFIBER; break; - case MII_MODEL_MARVELL_E3082: - /* 88E3082 10/100 Fast Ethernet PHY. */ - sc->mii_anegticks = MII_ANEGTICKS; - fast_ether = 1; + case MII_MODEL_MARVELL_E1149: + /* + * Some 88E1149 PHY's page select is initialized to + * point to other bank instead of copper/fiber bank + * which in turn resulted in wrong registers were + * accessed during PHY operation. It is believed that + * page 0 should be used for copper PHY so reinitialize + * E1000_EADR to select default copper PHY. If parent + * device know the type of PHY(either copper or fiber), + * that information should be used to select default + * type of PHY. + */ + PHY_WRITE(sc, E1000_EADR, 0); break; } e1000phy_reset(sc); + sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + if (sc->mii_capabilities & BMSR_EXTSTAT) + sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); + mii_phy_add_media(sc); + printf("\n"); -#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), - E1000_CR_ISOLATE); - if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst), - E1000_CR_SPEED_10); - printf("10baseT, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst), - E1000_CR_SPEED_10 | E1000_CR_FULL_DUPLEX); - printf("10baseT-FDX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst), - E1000_CR_SPEED_100); - printf("100baseTX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst), - E1000_CR_SPEED_100 | E1000_CR_FULL_DUPLEX); - printf("100baseTX-FDX, "); - if (fast_ether == 0) { - /* - * 1000BT-simplex not supported; driver must ignore - * this entry, but it must be present in order to - * manually set full-duplex. - */ - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0, - sc->mii_inst), E1000_CR_SPEED_1000); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX, - sc->mii_inst), - E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); - printf("1000baseTX-FDX, "); - } - } else { - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX, sc->mii_inst), - E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); - printf("1000baseSX-FDX, "); - } - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), 0); - printf("auto\n"); -#undef ADD - MIIBUS_MEDIAINIT(sc->mii_dev); return (0); } @@ -209,7 +184,7 @@ e1000phy_reset(struct mii_softc *sc) { struct e1000phy_softc *esc; - uint16_t reg; + uint16_t reg, page; esc = (struct e1000phy_softc *)sc; reg = PHY_READ(sc, E1000_SCR); @@ -218,12 +193,13 @@ PHY_WRITE(sc, E1000_SCR, reg); if (esc->mii_model == MII_MODEL_MARVELL_E1112) { /* Select 1000BASE-X only mode. */ + page = PHY_READ(sc, E1000_EADR); PHY_WRITE(sc, E1000_EADR, 2); reg = PHY_READ(sc, E1000_SCR); reg &= ~E1000_SCR_MODE_MASK; reg |= E1000_SCR_MODE_1000BX; PHY_WRITE(sc, E1000_SCR, reg); - PHY_WRITE(sc, E1000_EADR, 1); + PHY_WRITE(sc, E1000_EADR, page); } } else { switch (esc->mii_model) { @@ -235,28 +211,72 @@ /* Disable energy detect mode. */ reg &= ~E1000_SCR_EN_DETECT_MASK; reg |= E1000_SCR_AUTO_X_MODE; + if (esc->mii_model == MII_MODEL_MARVELL_E1116) + reg &= ~E1000_SCR_POWER_DOWN; + reg |= E1000_SCR_ASSERT_CRS_ON_TX; break; case MII_MODEL_MARVELL_E3082: reg |= (E1000_SCR_AUTO_X_MODE >> 1); + reg |= E1000_SCR_ASSERT_CRS_ON_TX; break; + case MII_MODEL_MARVELL_E3016: + reg |= E1000_SCR_AUTO_MDIX; + reg &= ~(E1000_SCR_EN_DETECT | + E1000_SCR_SCRAMBLER_DISABLE); + reg |= E1000_SCR_LPNP; + /* XXX Enable class A driver for Yukon FE+ A0. */ + PHY_WRITE(sc, 0x1C, PHY_READ(sc, 0x1C) | 0x0001); + break; default: reg &= ~E1000_SCR_AUTO_X_MODE; + reg |= E1000_SCR_ASSERT_CRS_ON_TX; break; } - /* Enable CRS on TX. */ - reg |= E1000_SCR_ASSERT_CRS_ON_TX; - /* Auto correction for reversed cable polarity. */ - reg &= ~E1000_SCR_POLARITY_REVERSAL; + if (esc->mii_model != MII_MODEL_MARVELL_E3016) { + /* Auto correction for reversed cable polarity. */ + reg &= ~E1000_SCR_POLARITY_REVERSAL; + } PHY_WRITE(sc, E1000_SCR, reg); + + if (esc->mii_model == MII_MODEL_MARVELL_E1116 || + esc->mii_model == MII_MODEL_MARVELL_E1149) { + page = PHY_READ(sc, E1000_EADR); + /* Select page 2, MAC specific control register. */ + PHY_WRITE(sc, E1000_EADR, 2); + reg = PHY_READ(sc, E1000_SCR); + reg |= E1000_SCR_RGMII_POWER_UP; + PHY_WRITE(sc, E1000_SCR, reg); + PHY_WRITE(sc, E1000_EADR, page); + } } switch (MII_MODEL(esc->mii_model)) { case MII_MODEL_MARVELL_E3082: case MII_MODEL_MARVELL_E1112: + case MII_MODEL_MARVELL_E1118: + break; case MII_MODEL_MARVELL_E1116: - case MII_MODEL_MARVELL_E1118: case MII_MODEL_MARVELL_E1149: + page = PHY_READ(sc, E1000_EADR); + /* Select page 3, LED control register. */ + PHY_WRITE(sc, E1000_EADR, 3); + PHY_WRITE(sc, E1000_SCR, + E1000_SCR_LED_LOS(1) | /* Link/Act */ + E1000_SCR_LED_INIT(8) | /* 10Mbps */ + E1000_SCR_LED_STAT1(7) | /* 100Mbps */ + E1000_SCR_LED_STAT0(7)); /* 1000Mbps */ + /* Set blink rate. */ + PHY_WRITE(sc, E1000_IER, E1000_PULSE_DUR(E1000_PULSE_170MS) | + E1000_BLINK_RATE(E1000_BLINK_84MS)); + PHY_WRITE(sc, E1000_EADR, page); break; + case MII_MODEL_MARVELL_E3016: + /* LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED. */ + PHY_WRITE(sc, 0x16, 0x0B << 8 | 0x05 << 4 | 0x04); + /* Integrated register calibration workaround. */ + PHY_WRITE(sc, 0x1D, 17); + PHY_WRITE(sc, 0x1E, 0x3F60); + break; default: /* Force TX_CLK to 25MHz clock. */ reg = PHY_READ(sc, E1000_ESCR); @@ -313,12 +333,14 @@ speed = 0; switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_1000_T: - if (esc->mii_model == MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & + (EXTSR_1000TFDX | EXTSR_1000THDX)) == 0) return (EINVAL); speed = E1000_CR_SPEED_1000; break; case IFM_1000_SX: - if (esc->mii_model == MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & + (EXTSR_1000XFDX | EXTSR_1000XHDX)) == 0) return (EINVAL); speed = E1000_CR_SPEED_1000; break; @@ -364,7 +386,8 @@ PHY_WRITE(sc, E1000_1GCR, gig | E1000_1GCR_MS_ENABLE); } else { - if (esc->mii_model != MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & + (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) PHY_WRITE(sc, E1000_1GCR, 0); } PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD); @@ -387,8 +410,10 @@ /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { + sc->mii_ticks = 0; break; + } /* * check for link. @@ -401,8 +426,10 @@ } /* Announce link loss right after it happens. */ + if (sc->mii_ticks++ == 0) + break; if (sc->mii_ticks <= sc->mii_anegticks) - return (0); + break; sc->mii_ticks = 0; e1000phy_reset(sc); @@ -422,18 +449,14 @@ e1000phy_status(struct mii_softc *sc) { struct mii_data *mii = sc->mii_pdata; - int bmsr, bmcr, esr, gsr, ssr, isr, ar, lpar; + int bmcr, bmsr, gsr, ssr, ar, lpar; mii->mii_media_status = IFM_AVALID; mii->mii_media_active = IFM_ETHER; bmsr = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR); - esr = PHY_READ(sc, E1000_ESR); bmcr = PHY_READ(sc, E1000_CR); ssr = PHY_READ(sc, E1000_SSR); - isr = PHY_READ(sc, E1000_ISR); - ar = PHY_READ(sc, E1000_AR); - lpar = PHY_READ(sc, E1000_LPAR); if (bmsr & E1000_SR_LINK_STATUS) mii->mii_media_status |= IFM_ACTIVE; @@ -441,22 +464,28 @@ if (bmcr & E1000_CR_LOOPBACK) mii->mii_media_active |= IFM_LOOP; - if ((((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0) && - ((bmsr & E1000_SR_AUTO_NEG_COMPLETE) == 0)) || - ((ssr & E1000_SSR_LINK) == 0) || - ((ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0)) { + if ((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0 && + (ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0) { /* Erg, still trying, I guess... */ mii->mii_media_active |= IFM_NONE; return; } if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { - if (ssr & E1000_SSR_1000MBS) + switch (ssr & E1000_SSR_SPEED) { + case E1000_SSR_1000MBS: mii->mii_media_active |= IFM_1000_T; - else if (ssr & E1000_SSR_100MBS) + break; + case E1000_SSR_100MBS: mii->mii_media_active |= IFM_100_TX; - else + break; + case E1000_SSR_10MBS: mii->mii_media_active |= IFM_10_T; + break; + default: + mii->mii_media_active |= IFM_NONE; + return; + } } else { if (ssr & E1000_SSR_1000MBS) mii->mii_media_active |= IFM_1000_SX; @@ -468,6 +497,8 @@ mii->mii_media_active |= IFM_HDX; if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + ar = PHY_READ(sc, E1000_AR); + lpar = PHY_READ(sc, E1000_LPAR); /* FLAG0==rx-flow-control FLAG1==tx-flow-control */ if ((ar & E1000_AR_PAUSE) && (lpar & E1000_LPAR_PAUSE)) { mii->mii_media_active |= IFM_FLAG0 | IFM_FLAG1; @@ -494,16 +525,19 @@ e1000phy_mii_phy_auto(struct e1000phy_softc *esc) { struct mii_softc *sc; + uint16_t reg; sc = &esc->mii_sc; - if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) - PHY_WRITE(sc, E1000_AR, E1000_AR_10T | E1000_AR_10T_FD | + if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + reg = PHY_READ(sc, E1000_AR); + reg |= E1000_AR_10T | E1000_AR_10T_FD | E1000_AR_100TX | E1000_AR_100TX_FD | - E1000_AR_PAUSE | E1000_AR_ASM_DIR); - else + E1000_AR_PAUSE | E1000_AR_ASM_DIR; + PHY_WRITE(sc, E1000_AR, reg | E1000_AR_SELECTOR_FIELD); + } else PHY_WRITE(sc, E1000_AR, E1000_FA_1000X_FD | E1000_FA_1000X | E1000_FA_SYM_PAUSE | E1000_FA_ASYM_PAUSE); - if (esc->mii_model != MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) PHY_WRITE(sc, E1000_1GCR, E1000_1GCR_1000T_FD | E1000_1GCR_1000T); PHY_WRITE(sc, E1000_CR, Modified: haiku/vendor/freebsd/current/dev/mii/e1000phyreg.h =================================================================== --- haiku/vendor/freebsd/current/dev/mii/e1000phyreg.h 2009-06-12 18:25:57 UTC (rev 31016) +++ haiku/vendor/freebsd/current/dev/mii/e1000phyreg.h 2009-06-12 18:36:41 UTC (rev 31017) @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mii/e1000phyreg.h,v 1.4 2006/12/11 10:43:32 yongari Exp $ */ +/* $FreeBSD$ */ /*- * Principal Author: Parag Patel * Copyright (c) 2001 @@ -236,6 +236,16 @@ #define E1000_SCR_TX_FIFO_DEPTH_10 0x8000 #define E1000_SCR_TX_FIFO_DEPTH_12 0xC000 +/* 88E3016 only */ +#define E1000_SCR_AUTO_MDIX 0x0030 +#define E1000_SCR_SIGDET_POLARITY 0x0040 +#define E1000_SCR_EXT_DISTANCE 0x0080 +#define E1000_SCR_FEFI_DISABLE 0x0100 +#define E1000_SCR_NLP_GEN_DISABLE 0x0800 +#define E1000_SCR_LPNP 0x1000 +#define E1000_SCR_NLP_CHK_DISABLE 0x2000 +#define E1000_SCR_EN_DETECT 0x4000 + #define E1000_SCR_EN_DETECT_MASK 0x0300 /* 88E1112 page 2 */ @@ -244,6 +254,21 @@ #define E1000_SCR_MODE_COPPER 0x0280 #define E1000_SCR_MODE_1000BX 0x0380 +/* 88E1116 page 0 */ +#define E1000_SCR_POWER_DOWN 0x0004 +/* 88E1116, 88E1149 page 2 */ +#define E1000_SCR_RGMII_POWER_UP 0x0008 + +/* 88E1116, 88E1149 page 3 */ +#define E1000_SCR_LED_STAT0_MASK 0x000F +#define E1000_SCR_LED_STAT1_MASK 0x00F0 +#define E1000_SCR_LED_INIT_MASK 0x0F00 +#define E1000_SCR_LED_LOS_MASK 0xF000 +#define E1000_SCR_LED_STAT0(x) ((x) & E1000_SCR_LED_STAT0_MASK) +#define E1000_SCR_LED_STAT1(x) ((x) & E1000_SCR_LED_STAT1_MASK) +#define E1000_SCR_LED_INIT(x) ((x) & E1000_SCR_LED_INIT_MASK) +#define E1000_SCR_LED_LOS(x) ((x) & E1000_SCR_LED_LOS_MASK) + #define E1000_SSR 0x11 /* special status register */ #define E1000_SSR_JABBER 0x0001 #define E1000_SSR_REV_POLARITY 0x0002 @@ -271,6 +296,26 @@ #define E1000_IER_SPEED_CHANGED 0x4000 #define E1000_IER_AUTO_NEG_ERR 0x8000 +/* 88E1116, 88E1149 page 3, LED timer control. */ +#define E1000_PULSE_MASK 0x7000 +#define E1000_PULSE_NO_STR 0 /* no pulse stretching */ +#define E1000_PULSE_21MS 1 /* 21 ms to 42 ms */ +#define E1000_PULSE_42MS 2 /* 42 ms to 84 ms */ +#define E1000_PULSE_84MS 3 /* 84 ms to 170 ms */ +#define E1000_PULSE_170MS 4 /* 170 ms to 340 ms */ +#define E1000_PULSE_340MS 5 /* 340 ms to 670 ms */ +#define E1000_PULSE_670MS 6 /* 670 ms to 1300 ms */ +#define E1000_PULSE_1300MS 7 /* 1300 ms to 2700 ms */ +#define E1000_PULSE_DUR(x) ((x) & E1000_PULSE_MASK) + +#define E1000_BLINK_MASK 0x0700 +#define E1000_BLINK_42MS 0 /* 42 ms */ +#define E1000_BLINK_84MS 1 /* 84 ms */ +#define E1000_BLINK_170MS 2 /* 170 ms */ +#define E1000_BLINK_340MS 3 /* 340 ms */ +#define E1000_BLINK_670MS 4 /* 670 ms */ +#define E1000_BLINK_RATE(x) ((x) & E1000_BLINK_MASK) + #define E1000_ISR 0x13 /* interrupt status reg */ #define E1000_ISR_JABBER 0x0001 #define E1000_ISR_POLARITY_CHANGE 0x0002 Modified: haiku/vendor/freebsd/current/dev/mii/miidevs =================================================================== --- haiku/vendor/freebsd/current/dev/mii/miidevs 2009-06-12 18:25:57 UTC (rev 31016) +++ haiku/vendor/freebsd/current/dev/mii/miidevs 2009-06-12 18:36:41 UTC (rev 31017) @@ -1,4 +1,4 @@ -$FreeBSD: src/sys/dev/mii/miidevs,v 1.62 2008/10/23 01:27:15 yongari Exp $ +$FreeBSD$ /*$NetBSD: miidevs,v 1.6 1999/05/14 11:37:30 drochner Exp $*/ /*- @@ -52,6 +52,7 @@ oui AGERE 0x00a0bc Agere Systems oui ALTIMA 0x0010a9 Altima Communications oui AMD 0x00001a Advanced Micro Devices +oui ASIX 0x00602e Asix Semiconductor oui ATHEROS 0x001374 Atheros Communications oui BROADCOM 0x001018 Broadcom Corporation oui BROADCOM2 0x000af7 Broadcom Corporation @@ -120,6 +121,9 @@ model AMD 79c978 0x0039 Am79c978 HomePNA PHY model xxAMD 79C873 0x0000 Am79C873/DM9101 10/100 media interface +/* Asix semiconductor PHYs. */ +model ASIX AX88X9X 0x0031 Ax88x9x internal PHY + /* Atheros Communications/Attansic PHYs. */ model ATHEROS F1 0x0001 Atheros F1 10/100/1000 PHY model ATHEROS F2 0x0002 Atheros F2 10/100 PHY @@ -243,6 +247,7 @@ model MARVELL E1116 0x0021 Marvell 88E1116 Gigabit PHY model MARVELL E1116R 0x0024 Marvell 88E1116R Gigabit PHY model MARVELL E1118 0x0022 Marvell 88E1118 Gigabit PHY +model MARVELL E3016 0x0026 Marvell 88E3016 10/100 Fast Ethernet PHY model xxMARVELL E1000 0x0005 Marvell 88E1000 Gigabit PHY model xxMARVELL E1011 0x0002 Marvell 88E1011 Gigabit PHY model xxMARVELL E1000_3 0x0003 Marvell 88E1000 Gigabit PHY Modified: haiku/vendor/freebsd/current/dev/mii/ukphy.c =================================================================== --- haiku/vendor/freebsd/current/dev/mii/ukphy.c 2009-06-12 18:25:57 UTC (rev 31016) +++ haiku/vendor/freebsd/current/dev/mii/ukphy.c 2009-06-12 18:36:41 UTC (rev 31017) @@ -67,7 +67,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.20 2007/01/20 00:52:29 marius Exp $"); +__FBSDID("$FreeBSD$"); /* * driver for generic unknown PHYs Modified: haiku/vendor/freebsd/current/dev/mii/ukphy_subr.c =================================================================== --- haiku/vendor/freebsd/current/dev/mii/ukphy_subr.c 2009-06-12 18:25:57 UTC (rev 31016) +++ haiku/vendor/freebsd/current/dev/mii/ukphy_subr.c 2009-06-12 18:36:41 UTC (rev 31017) @@ -38,7 +38,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy_subr.c,v 1.9 2006/05/19 03:51:42 yongari Exp $"); +__FBSDID("$FreeBSD$"); /* * Subroutines shared by the ukphy driver and other PHY drivers. @@ -112,10 +112,10 @@ else if ((gtcr & GTCR_ADV_1000THDX) && (gtsr & GTSR_LP_1000THDX)) mii->mii_media_active |= IFM_1000_T; + else if (anlpar & ANLPAR_TX_FD) + mii->mii_media_active |= IFM_100_TX|IFM_FDX; else if (anlpar & ANLPAR_T4) mii->mii_media_active |= IFM_100_T4; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; else if (anlpar & ANLPAR_TX) mii->mii_media_active |= IFM_100_TX; else if (anlpar & ANLPAR_10_FD) Modified: haiku/vendor/freebsd/current/dev/msk/if_msk.c =================================================================== --- haiku/vendor/freebsd/current/dev/msk/if_msk.c 2009-06-12 18:25:57 UTC (rev 31016) +++ haiku/vendor/freebsd/current/dev/msk/if_msk.c 2009-06-12 18:36:41 UTC (rev 31017) @@ -99,7 +99,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.18 2007/07/20 00:25:20 yongari Exp $"); +__FBSDID("$FreeBSD$"); #include #include @@ -156,6 +156,8 @@ TUNABLE_INT("hw.msk.msi_disable", &msi_disable); static int legacy_intr = 0; TUNABLE_INT("hw.msk.legacy_intr", &legacy_intr); +static int jumbo_disable = 0; +TUNABLE_INT("hw.msk.jumbo_disable", &jumbo_disable); #define MSK_CSUM_FEATURES (CSUM_TCP | CSUM_UDP) @@ -188,11 +190,19 @@ { VENDORID_MARVELL, DEVICEID_MRVL_8062X, "Marvell Yukon 88E8062 SX/LX Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8035, - "Marvell Yukon 88E8035 Gigabit Ethernet" }, + "Marvell Yukon 88E8035 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8036, - "Marvell Yukon 88E8036 Gigabit Ethernet" }, + "Marvell Yukon 88E8036 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8038, - "Marvell Yukon 88E8038 Gigabit Ethernet" }, + "Marvell Yukon 88E8038 Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8039, + "Marvell Yukon 88E8039 Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8040, + "Marvell Yukon 88E8040 Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8040T, + "Marvell Yukon 88E8040T Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8048, + "Marvell Yukon 88E8048 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4361, "Marvell Yukon 88E8050 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4360, @@ -203,6 +213,14 @@ "Marvell Yukon 88E8055 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4364, "Marvell Yukon 88E8056 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4365, + "Marvell Yukon 88E8070 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436A, + "Marvell Yukon 88E8058 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436B, + "Marvell Yukon 88E8071 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436C, + "Marvell Yukon 88E8072 Gigabit Ethernet" }, { VENDORID_DLINK, DEVICEID_DLINK_DGE550SX, "D-Link 550SX Gigabit Ethernet" }, { VENDORID_DLINK, DEVICEID_DLINK_DGE560T, @@ -212,15 +230,16 @@ static const char *model_name[] = { "Yukon XL", "Yukon EC Ultra", - "Yukon Unknown", + "Yukon EX", "Yukon EC", - "Yukon FE" + "Yukon FE", + "Yukon FE+" }; static int mskc_probe(device_t); static int mskc_attach(device_t); static int mskc_detach(device_t); -static void mskc_shutdown(device_t); +static int mskc_shutdown(device_t); static int mskc_setup_rambuffer(struct msk_softc *); static int mskc_suspend(device_t); static int mskc_resume(device_t); @@ -240,16 +259,19 @@ static int msk_handle_events(struct msk_softc *); static void msk_handle_hwerr(struct msk_if_softc *, uint32_t); static void msk_intr_hwerr(struct msk_softc *); -static void msk_rxeof(struct msk_if_softc *, uint32_t, int); -static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, int); +#ifndef __NO_STRICT_ALIGNMENT +static __inline void msk_fixup_rx(struct mbuf *); +#endif +static void msk_rxeof(struct msk_if_softc *, uint32_t, uint32_t, int); +static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, uint32_t, int); static void msk_txeof(struct msk_if_softc *, int); -static struct mbuf *msk_defrag(struct mbuf *, int, int); static int msk_encap(struct msk_if_softc *, struct mbuf **); static void msk_tx_task(void *, int); static void msk_start(struct ifnet *); static int msk_ioctl(struct ifnet *, u_long, caddr_t); static void msk_set_prefetch(struct msk_softc *, int, bus_addr_t, uint32_t); static void msk_set_rambuffer(struct msk_if_softc *); +static void msk_set_tx_stfwd(struct msk_if_softc *); static void msk_init(void *); static void msk_init_locked(struct msk_if_softc *); static void msk_stop(struct msk_if_softc *); @@ -261,9 +283,9 @@ static int msk_status_dma_alloc(struct msk_softc *); static void msk_status_dma_free(struct msk_softc *); static int msk_txrx_dma_alloc(struct msk_if_softc *); +static int msk_rx_dma_jalloc(struct msk_if_softc *); static void msk_txrx_dma_free(struct msk_if_softc *); -static void *msk_jalloc(struct msk_if_softc *); -static void msk_jfree(void *, void *); +static void msk_rx_dma_jfree(struct msk_if_softc *); static int msk_init_rx_ring(struct msk_if_softc *); static int msk_init_jumbo_rx_ring(struct msk_if_softc *); static void msk_init_tx_ring(struct msk_if_softc *); @@ -277,12 +299,15 @@ static int msk_miibus_readreg(device_t, int, int); static int msk_miibus_writereg(device_t, int, int, int); static void msk_miibus_statchg(device_t); -static void msk_link_task(void *, int); -static void msk_setmulti(struct msk_if_softc *); +static void msk_rxfilter(struct msk_if_softc *); static void msk_setvlan(struct msk_if_softc *, struct ifnet *); -static void msk_setpromisc(struct msk_if_softc *); +static void msk_stats_clear(struct msk_if_softc *); +static void msk_stats_update(struct msk_if_softc *); +static int msk_sysctl_stat32(SYSCTL_HANDLER_ARGS); +static int msk_sysctl_stat64(SYSCTL_HANDLER_ARGS); +static void msk_sysctl_node(struct msk_if_softc *); static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); static int sysctl_hw_msk_proc_limit(SYSCTL_HANDLER_ARGS); @@ -358,6 +383,11 @@ static struct resource_spec msk_irq_spec_msi[] = { { SYS_RES_IRQ, 1, RF_ACTIVE }, + { -1, 0, 0 } +}; + +static struct resource_spec msk_irq_spec_msi2[] = { + { SYS_RES_IRQ, 1, RF_ACTIVE }, { SYS_RES_IRQ, 2, RF_ACTIVE }, { -1, 0, 0 } }; @@ -367,6 +397,9 @@ { struct msk_if_softc *sc_if; + if (phy != PHY_ADDR_MARV) + return (0); + sc_if = device_get_softc(dev); return (msk_phy_readreg(sc_if, phy, reg)); @@ -405,6 +438,9 @@ { struct msk_if_softc *sc_if; + if (phy != PHY_ADDR_MARV) + return (0); + sc_if = device_get_softc(dev); return (msk_phy_writereg(sc_if, phy, reg, val)); @@ -436,40 +472,44 @@ static void msk_miibus_statchg(device_t dev) { - struct msk_if_softc *sc_if; - - sc_if = device_get_softc(dev); - taskqueue_enqueue(taskqueue_swi, &sc_if->msk_link_task); -} - -static void -msk_link_task(void *arg, int pending) -{ struct msk_softc *sc; struct msk_if_softc *sc_if; struct mii_data *mii; struct ifnet *ifp; uint32_t gmac; - sc_if = (struct msk_if_softc *)arg; + sc_if = device_get_softc(dev); sc = sc_if->msk_softc; - MSK_IF_LOCK(sc_if); + MSK_IF_LOCK_ASSERT(sc_if); mii = device_get_softc(sc_if->msk_miibus); ifp = sc_if->msk_ifp; - if (mii == NULL || ifp == NULL) { - MSK_IF_UNLOCK(sc_if); + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return; + + sc_if->msk_flags &= ~MSK_FLAG_LINK; + if ((mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) == + (IFM_AVALID | IFM_ACTIVE)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc_if->msk_flags |= MSK_FLAG_LINK; + break; + case IFM_1000_T: + case IFM_1000_SX: + case IFM_1000_LX: + case IFM_1000_CX: + if ((sc_if->msk_flags & MSK_FLAG_FASTETHER) == 0) + sc_if->msk_flags |= MSK_FLAG_LINK; + break; + default: + break; + } } - if (mii->mii_media_status & IFM_ACTIVE) { - if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) - sc_if->msk_link = 1; - } else - sc_if->msk_link = 0; - - if (sc_if->msk_link != 0) { + if ((sc_if->msk_flags & MSK_FLAG_LINK) != 0) { /* Enable Tx FIFO Underrun. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK), GM_IS_TX_FF_UR | GM_IS_RX_FF_OR); @@ -516,30 +556,27 @@ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), gmac); /* Enable PHY interrupt for FIFO underrun/overflow. */ - if (sc->msk_marvell_phy) - msk_phy_writereg(sc_if, PHY_ADDR_MARV, - PHY_MARV_INT_MASK, PHY_M_IS_FIFO_ERROR); + msk_phy_writereg(sc_if, PHY_ADDR_MARV, + PHY_MARV_INT_MASK, PHY_M_IS_FIFO_ERROR); } else { /* * Link state changed to down. * Disable PHY interrupts. */ - if (sc->msk_marvell_phy) - msk_phy_writereg(sc_if, PHY_ADDR_MARV, - PHY_MARV_INT_MASK, 0); + msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0); /* Disable Rx/Tx MAC. */ gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); - gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); - GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); - /* Read again to ensure writing. */ - GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + if ((GM_GPCR_RX_ENA | GM_GPCR_TX_ENA) != 0) { + gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); + GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); + /* Read again to ensure writing. */ + GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + } } - - MSK_IF_UNLOCK(sc_if); } static void -msk_setmulti(struct msk_if_softc *sc_if) +msk_rxfilter(struct msk_if_softc *sc_if) { struct msk_softc *sc; struct ifnet *ifp; @@ -556,15 +593,14 @@ bzero(mchash, sizeof(mchash)); mode = GMAC_READ_2(sc, sc_if->msk_port, GM_RX_CTRL); - mode |= GM_RXCR_UCF_ENA; - if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) { - if ((ifp->if_flags & IFF_PROMISC) != 0) - mode &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - else if ((ifp->if_flags & IFF_ALLMULTI) != 0) { - mchash[0] = 0xffff; - mchash[1] = 0xffff; - } + if ((ifp->if_flags & IFF_PROMISC) != 0) + mode &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); + else if ((ifp->if_flags & IFF_ALLMULTI) != 0) { + mode |= GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA; + mchash[0] = 0xffff; + mchash[1] = 0xffff; } else { + mode |= GM_RXCR_UCF_ENA; IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) @@ -577,7 +613,8 @@ mchash[crc >> 5] |= 1 << (crc & 0x1f); } IF_ADDR_UNLOCK(ifp); - mode |= GM_RXCR_MCF_ENA; + if (mchash[0] != 0 || mchash[1] != 0) + mode |= GM_RXCR_MCF_ENA; } GMAC_WRITE_2(sc, sc_if->msk_port, GM_MC_ADDR_H1, @@ -610,26 +647,6 @@ } } -static void -msk_setpromisc(struct msk_if_softc *sc_if) -{ - struct msk_softc *sc; - struct ifnet *ifp; - uint16_t mode; - - MSK_IF_LOCK_ASSERT(sc_if); - - sc = sc_if->msk_softc; - ifp = sc_if->msk_ifp; - - mode = GMAC_READ_2(sc, sc_if->msk_port, GM_RX_CTRL); - if (ifp->if_flags & IFF_PROMISC) - mode &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - else - mode |= (GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - GMAC_WRITE_2(sc, sc_if->msk_port, GM_RX_CTRL, mode); -} - static int msk_init_rx_ring(struct msk_if_softc *sc_if) { @@ -772,7 +789,12 @@ return (ENOBUFS); m->m_len = m->m_pkthdr.len = MCLBYTES; - m_adj(m, ETHER_ALIGN); + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_rx_tag, sc_if->msk_cdata.msk_rx_sparemap, m, segs, &nsegs, @@ -811,25 +833,21 @@ bus_dma_segment_t segs[1]; bus_dmamap_t map; int nsegs; - void *buf; - MGETHDR(m, M_DONTWAIT, MT_DATA); + m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); - buf = msk_jalloc(sc_if); - if (buf == NULL) { - m_freem(m); - return (ENOBUFS); - } - /* Attach the buffer to the mbuf. */ - MEXTADD(m, buf, MSK_JLEN, msk_jfree, (struct msk_if_softc *)sc_if, 0, - EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); return (ENOBUFS); } - m->m_pkthdr.len = m->m_len = MSK_JLEN; - m_adj(m, ETHER_ALIGN); + m->m_len = m->m_pkthdr.len = MJUM9BYTES; + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_jumbo_rx_tag, sc_if->msk_cdata.msk_jumbo_rx_sparemap, m, segs, &nsegs, @@ -868,15 +886,16 @@ { struct msk_if_softc *sc_if; struct mii_data *mii; + int error; sc_if = ifp->if_softc; MSK_IF_LOCK(sc_if); mii = device_get_softc(sc_if->msk_miibus); - mii_mediachg(mii); + error = mii_mediachg(mii); MSK_IF_UNLOCK(sc_if); - return (0); + return (error); } /* @@ -890,6 +909,10 @@ sc_if = ifp->if_softc; MSK_IF_LOCK(sc_if); + if ((ifp->if_flags & IFF_UP) == 0) { + MSK_IF_UNLOCK(sc_if); + return; + } mii = device_get_softc(sc_if->msk_miibus); mii_pollstat(mii); @@ -912,38 +935,41 @@ switch(command) { case SIOCSIFMTU: - if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) { + MSK_IF_LOCK(sc_if); + if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) error = EINVAL; - break; + else if (ifp->if_mtu != ifr->ifr_mtu) { + if (ifr->ifr_mtu > ETHERMTU) { + if ((sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) { + error = EINVAL; + MSK_IF_UNLOCK(sc_if); + break; + } + if ((sc_if->msk_flags & + MSK_FLAG_JUMBO_NOCSUM) != 0) { + ifp->if_hwassist &= + ~(MSK_CSUM_FEATURES | CSUM_TSO); + ifp->if_capenable &= + ~(IFCAP_TSO4 | IFCAP_TXCSUM); + VLAN_CAPABILITIES(ifp); + } + } + ifp->if_mtu = ifr->ifr_mtu; + msk_init_locked(sc_if); } - if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U && - ifr->ifr_mtu > MSK_MAX_FRAMELEN) { - error = EINVAL; - break; - } - MSK_IF_LOCK(sc_if); - ifp->if_mtu = ifr->ifr_mtu; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_init_locked(sc_if); MSK_IF_UNLOCK(sc_if); break; case SIOCSIFFLAGS: MSK_IF_LOCK(sc_if); if ((ifp->if_flags & IFF_UP) != 0) { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - if (((ifp->if_flags ^ sc_if->msk_if_flags) - & IFF_PROMISC) != 0) { - msk_setpromisc(sc_if); - msk_setmulti(sc_if); - } - } else { - if (sc_if->msk_detach == 0) - msk_init_locked(sc_if); - } - } else { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_stop(sc_if); - } + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 && + ((ifp->if_flags ^ sc_if->msk_if_flags) & + (IFF_PROMISC | IFF_ALLMULTI)) != 0) + msk_rxfilter(sc_if); + else if ((sc_if->msk_flags & MSK_FLAG_DETACH) == 0) + msk_init_locked(sc_if); + } else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + msk_stop(sc_if); sc_if->msk_if_flags = ifp->if_flags; MSK_IF_UNLOCK(sc_if); break; @@ -951,7 +977,7 @@ case SIOCDELMULTI: MSK_IF_LOCK(sc_if); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_setmulti(sc_if); + msk_rxfilter(sc_if); MSK_IF_UNLOCK(sc_if); break; [... truncated: 2573 lines follow ...] From korli at mail.berlios.de Fri Jun 12 20:47:23 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 12 Jun 2009 20:47:23 +0200 Subject: [Haiku-commits] r31018 - in haiku/trunk/src: add-ons/kernel/drivers/network/marvell_yukon/dev/mii add-ons/kernel/drivers/network/marvell_yukon/dev/msk libs/compat/freebsd_network/compat/dev/mii Message-ID: <200906121847.n5CIlNGx028002@sheep.berlios.de> Author: korli Date: 2009-06-12 20:47:22 +0200 (Fri, 12 Jun 2009) New Revision: 31018 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31018&view=rev Removed: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_mskreg.h haiku/trunk/src/libs/compat/freebsd_network/compat/dev/mii/miidevs Log: updated mii, msk to freebsd current Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile 2009-06-12 18:36:41 UTC (rev 31017) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/Jamfile 2009-06-12 18:47:22 UTC (rev 31018) @@ -14,3 +14,6 @@ ukphy_subr.c ; +ObjectHdrs [ FGristFiles e1000phy$(SUFOBJ) ] + : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) libs compat freebsd_network ] ; +Includes [ FGristFiles e1000phy.c ] : miidevs.h ; Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c 2009-06-12 18:36:41 UTC (rev 31017) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phy.c 2009-06-12 18:47:22 UTC (rev 31018) @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/e1000phy.c,v 1.18 2006/12/11 11:09:48 yongari Exp $"); +__FBSDID("$FreeBSD$"); /* * driver for the Marvell 88E1000 series external 1000/100/10-BT PHY. @@ -105,7 +105,9 @@ MII_PHY_DESC(MARVELL, E1149), MII_PHY_DESC(MARVELL, E1111), MII_PHY_DESC(MARVELL, E1116), + MII_PHY_DESC(MARVELL, E1116R), MII_PHY_DESC(MARVELL, E1118), + MII_PHY_DESC(MARVELL, E3016), MII_PHY_DESC(xxMARVELL, E1000), MII_PHY_DESC(xxMARVELL, E1011), MII_PHY_DESC(xxMARVELL, E1000_3), @@ -128,7 +130,6 @@ struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; - int fast_ether; esc = device_get_softc(dev); sc = &esc->mii_sc; @@ -141,10 +142,8 @@ sc->mii_phy = ma->mii_phyno; sc->mii_service = e1000phy_service; sc->mii_pdata = mii; - sc->mii_anegticks = MII_ANEGTICKS_GIGE; mii->mii_instance++; - fast_ether = 0; esc->mii_model = MII_MODEL(ma->mii_id2); switch (esc->mii_model) { case MII_MODEL_MARVELL_E1011: @@ -152,55 +151,31 @@ if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK) sc->mii_flags |= MIIF_HAVEFIBER; break; - case MII_MODEL_MARVELL_E3082: - /* 88E3082 10/100 Fast Ethernet PHY. */ - sc->mii_anegticks = MII_ANEGTICKS; - fast_ether = 1; + case MII_MODEL_MARVELL_E1149: + /* + * Some 88E1149 PHY's page select is initialized to + * point to other bank instead of copper/fiber bank + * which in turn resulted in wrong registers were + * accessed during PHY operation. It is believed that + * page 0 should be used for copper PHY so reinitialize + * E1000_EADR to select default copper PHY. If parent + * device know the type of PHY(either copper or fiber), + * that information should be used to select default + * type of PHY. + */ + PHY_WRITE(sc, E1000_EADR, 0); break; } e1000phy_reset(sc); + sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + if (sc->mii_capabilities & BMSR_EXTSTAT) + sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); + mii_phy_add_media(sc); + printf("\n"); -#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), - E1000_CR_ISOLATE); - if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst), - E1000_CR_SPEED_10); - printf("10baseT, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst), - E1000_CR_SPEED_10 | E1000_CR_FULL_DUPLEX); - printf("10baseT-FDX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst), - E1000_CR_SPEED_100); - printf("100baseTX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst), - E1000_CR_SPEED_100 | E1000_CR_FULL_DUPLEX); - printf("100baseTX-FDX, "); - if (fast_ether == 0) { - /* - * 1000BT-simplex not supported; driver must ignore - * this entry, but it must be present in order to - * manually set full-duplex. - */ - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0, - sc->mii_inst), E1000_CR_SPEED_1000); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX, - sc->mii_inst), - E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); - printf("1000baseTX-FDX, "); - } - } else { - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX, sc->mii_inst), - E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); - printf("1000baseSX-FDX, "); - } - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), 0); - printf("auto\n"); -#undef ADD - MIIBUS_MEDIAINIT(sc->mii_dev); return (0); } @@ -209,7 +184,7 @@ e1000phy_reset(struct mii_softc *sc) { struct e1000phy_softc *esc; - uint16_t reg; + uint16_t reg, page; esc = (struct e1000phy_softc *)sc; reg = PHY_READ(sc, E1000_SCR); @@ -218,12 +193,13 @@ PHY_WRITE(sc, E1000_SCR, reg); if (esc->mii_model == MII_MODEL_MARVELL_E1112) { /* Select 1000BASE-X only mode. */ + page = PHY_READ(sc, E1000_EADR); PHY_WRITE(sc, E1000_EADR, 2); reg = PHY_READ(sc, E1000_SCR); reg &= ~E1000_SCR_MODE_MASK; reg |= E1000_SCR_MODE_1000BX; PHY_WRITE(sc, E1000_SCR, reg); - PHY_WRITE(sc, E1000_EADR, 1); + PHY_WRITE(sc, E1000_EADR, page); } } else { switch (esc->mii_model) { @@ -235,28 +211,72 @@ /* Disable energy detect mode. */ reg &= ~E1000_SCR_EN_DETECT_MASK; reg |= E1000_SCR_AUTO_X_MODE; + if (esc->mii_model == MII_MODEL_MARVELL_E1116) + reg &= ~E1000_SCR_POWER_DOWN; + reg |= E1000_SCR_ASSERT_CRS_ON_TX; break; case MII_MODEL_MARVELL_E3082: reg |= (E1000_SCR_AUTO_X_MODE >> 1); + reg |= E1000_SCR_ASSERT_CRS_ON_TX; break; + case MII_MODEL_MARVELL_E3016: + reg |= E1000_SCR_AUTO_MDIX; + reg &= ~(E1000_SCR_EN_DETECT | + E1000_SCR_SCRAMBLER_DISABLE); + reg |= E1000_SCR_LPNP; + /* XXX Enable class A driver for Yukon FE+ A0. */ + PHY_WRITE(sc, 0x1C, PHY_READ(sc, 0x1C) | 0x0001); + break; default: reg &= ~E1000_SCR_AUTO_X_MODE; + reg |= E1000_SCR_ASSERT_CRS_ON_TX; break; } - /* Enable CRS on TX. */ - reg |= E1000_SCR_ASSERT_CRS_ON_TX; - /* Auto correction for reversed cable polarity. */ - reg &= ~E1000_SCR_POLARITY_REVERSAL; + if (esc->mii_model != MII_MODEL_MARVELL_E3016) { + /* Auto correction for reversed cable polarity. */ + reg &= ~E1000_SCR_POLARITY_REVERSAL; + } PHY_WRITE(sc, E1000_SCR, reg); + + if (esc->mii_model == MII_MODEL_MARVELL_E1116 || + esc->mii_model == MII_MODEL_MARVELL_E1149) { + page = PHY_READ(sc, E1000_EADR); + /* Select page 2, MAC specific control register. */ + PHY_WRITE(sc, E1000_EADR, 2); + reg = PHY_READ(sc, E1000_SCR); + reg |= E1000_SCR_RGMII_POWER_UP; + PHY_WRITE(sc, E1000_SCR, reg); + PHY_WRITE(sc, E1000_EADR, page); + } } switch (MII_MODEL(esc->mii_model)) { case MII_MODEL_MARVELL_E3082: case MII_MODEL_MARVELL_E1112: + case MII_MODEL_MARVELL_E1118: + break; case MII_MODEL_MARVELL_E1116: - case MII_MODEL_MARVELL_E1118: case MII_MODEL_MARVELL_E1149: + page = PHY_READ(sc, E1000_EADR); + /* Select page 3, LED control register. */ + PHY_WRITE(sc, E1000_EADR, 3); + PHY_WRITE(sc, E1000_SCR, + E1000_SCR_LED_LOS(1) | /* Link/Act */ + E1000_SCR_LED_INIT(8) | /* 10Mbps */ + E1000_SCR_LED_STAT1(7) | /* 100Mbps */ + E1000_SCR_LED_STAT0(7)); /* 1000Mbps */ + /* Set blink rate. */ + PHY_WRITE(sc, E1000_IER, E1000_PULSE_DUR(E1000_PULSE_170MS) | + E1000_BLINK_RATE(E1000_BLINK_84MS)); + PHY_WRITE(sc, E1000_EADR, page); break; + case MII_MODEL_MARVELL_E3016: + /* LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED. */ + PHY_WRITE(sc, 0x16, 0x0B << 8 | 0x05 << 4 | 0x04); + /* Integrated register calibration workaround. */ + PHY_WRITE(sc, 0x1D, 17); + PHY_WRITE(sc, 0x1E, 0x3F60); + break; default: /* Force TX_CLK to 25MHz clock. */ reg = PHY_READ(sc, E1000_ESCR); @@ -313,12 +333,14 @@ speed = 0; switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_1000_T: - if (esc->mii_model == MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & + (EXTSR_1000TFDX | EXTSR_1000THDX)) == 0) return (EINVAL); speed = E1000_CR_SPEED_1000; break; case IFM_1000_SX: - if (esc->mii_model == MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & + (EXTSR_1000XFDX | EXTSR_1000XHDX)) == 0) return (EINVAL); speed = E1000_CR_SPEED_1000; break; @@ -364,7 +386,8 @@ PHY_WRITE(sc, E1000_1GCR, gig | E1000_1GCR_MS_ENABLE); } else { - if (esc->mii_model != MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & + (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) PHY_WRITE(sc, E1000_1GCR, 0); } PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD); @@ -387,8 +410,10 @@ /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { + sc->mii_ticks = 0; break; + } /* * check for link. @@ -401,8 +426,10 @@ } /* Announce link loss right after it happens. */ + if (sc->mii_ticks++ == 0) + break; if (sc->mii_ticks <= sc->mii_anegticks) - return (0); + break; sc->mii_ticks = 0; e1000phy_reset(sc); @@ -422,18 +449,14 @@ e1000phy_status(struct mii_softc *sc) { struct mii_data *mii = sc->mii_pdata; - int bmsr, bmcr, esr, gsr, ssr, isr, ar, lpar; + int bmcr, bmsr, gsr, ssr, ar, lpar; mii->mii_media_status = IFM_AVALID; mii->mii_media_active = IFM_ETHER; bmsr = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR); - esr = PHY_READ(sc, E1000_ESR); bmcr = PHY_READ(sc, E1000_CR); ssr = PHY_READ(sc, E1000_SSR); - isr = PHY_READ(sc, E1000_ISR); - ar = PHY_READ(sc, E1000_AR); - lpar = PHY_READ(sc, E1000_LPAR); if (bmsr & E1000_SR_LINK_STATUS) mii->mii_media_status |= IFM_ACTIVE; @@ -441,22 +464,28 @@ if (bmcr & E1000_CR_LOOPBACK) mii->mii_media_active |= IFM_LOOP; - if ((((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0) && - ((bmsr & E1000_SR_AUTO_NEG_COMPLETE) == 0)) || - ((ssr & E1000_SSR_LINK) == 0) || - ((ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0)) { + if ((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0 && + (ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0) { /* Erg, still trying, I guess... */ mii->mii_media_active |= IFM_NONE; return; } if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { - if (ssr & E1000_SSR_1000MBS) + switch (ssr & E1000_SSR_SPEED) { + case E1000_SSR_1000MBS: mii->mii_media_active |= IFM_1000_T; - else if (ssr & E1000_SSR_100MBS) + break; + case E1000_SSR_100MBS: mii->mii_media_active |= IFM_100_TX; - else + break; + case E1000_SSR_10MBS: mii->mii_media_active |= IFM_10_T; + break; + default: + mii->mii_media_active |= IFM_NONE; + return; + } } else { if (ssr & E1000_SSR_1000MBS) mii->mii_media_active |= IFM_1000_SX; @@ -468,6 +497,8 @@ mii->mii_media_active |= IFM_HDX; if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + ar = PHY_READ(sc, E1000_AR); + lpar = PHY_READ(sc, E1000_LPAR); /* FLAG0==rx-flow-control FLAG1==tx-flow-control */ if ((ar & E1000_AR_PAUSE) && (lpar & E1000_LPAR_PAUSE)) { mii->mii_media_active |= IFM_FLAG0 | IFM_FLAG1; @@ -494,16 +525,19 @@ e1000phy_mii_phy_auto(struct e1000phy_softc *esc) { struct mii_softc *sc; + uint16_t reg; sc = &esc->mii_sc; - if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) - PHY_WRITE(sc, E1000_AR, E1000_AR_10T | E1000_AR_10T_FD | + if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { + reg = PHY_READ(sc, E1000_AR); + reg |= E1000_AR_10T | E1000_AR_10T_FD | E1000_AR_100TX | E1000_AR_100TX_FD | - E1000_AR_PAUSE | E1000_AR_ASM_DIR); - else + E1000_AR_PAUSE | E1000_AR_ASM_DIR; + PHY_WRITE(sc, E1000_AR, reg | E1000_AR_SELECTOR_FIELD); + } else PHY_WRITE(sc, E1000_AR, E1000_FA_1000X_FD | E1000_FA_1000X | E1000_FA_SYM_PAUSE | E1000_FA_ASYM_PAUSE); - if (esc->mii_model != MII_MODEL_MARVELL_E3082) + if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) PHY_WRITE(sc, E1000_1GCR, E1000_1GCR_1000T_FD | E1000_1GCR_1000T); PHY_WRITE(sc, E1000_CR, Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h 2009-06-12 18:36:41 UTC (rev 31017) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/e1000phyreg.h 2009-06-12 18:47:22 UTC (rev 31018) @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/mii/e1000phyreg.h,v 1.4 2006/12/11 10:43:32 yongari Exp $ */ +/* $FreeBSD$ */ /*- * Principal Author: Parag Patel * Copyright (c) 2001 @@ -236,6 +236,16 @@ #define E1000_SCR_TX_FIFO_DEPTH_10 0x8000 #define E1000_SCR_TX_FIFO_DEPTH_12 0xC000 +/* 88E3016 only */ +#define E1000_SCR_AUTO_MDIX 0x0030 +#define E1000_SCR_SIGDET_POLARITY 0x0040 +#define E1000_SCR_EXT_DISTANCE 0x0080 +#define E1000_SCR_FEFI_DISABLE 0x0100 +#define E1000_SCR_NLP_GEN_DISABLE 0x0800 +#define E1000_SCR_LPNP 0x1000 +#define E1000_SCR_NLP_CHK_DISABLE 0x2000 +#define E1000_SCR_EN_DETECT 0x4000 + #define E1000_SCR_EN_DETECT_MASK 0x0300 /* 88E1112 page 2 */ @@ -244,6 +254,21 @@ #define E1000_SCR_MODE_COPPER 0x0280 #define E1000_SCR_MODE_1000BX 0x0380 +/* 88E1116 page 0 */ +#define E1000_SCR_POWER_DOWN 0x0004 +/* 88E1116, 88E1149 page 2 */ +#define E1000_SCR_RGMII_POWER_UP 0x0008 + +/* 88E1116, 88E1149 page 3 */ +#define E1000_SCR_LED_STAT0_MASK 0x000F +#define E1000_SCR_LED_STAT1_MASK 0x00F0 +#define E1000_SCR_LED_INIT_MASK 0x0F00 +#define E1000_SCR_LED_LOS_MASK 0xF000 +#define E1000_SCR_LED_STAT0(x) ((x) & E1000_SCR_LED_STAT0_MASK) +#define E1000_SCR_LED_STAT1(x) ((x) & E1000_SCR_LED_STAT1_MASK) +#define E1000_SCR_LED_INIT(x) ((x) & E1000_SCR_LED_INIT_MASK) +#define E1000_SCR_LED_LOS(x) ((x) & E1000_SCR_LED_LOS_MASK) + #define E1000_SSR 0x11 /* special status register */ #define E1000_SSR_JABBER 0x0001 #define E1000_SSR_REV_POLARITY 0x0002 @@ -271,6 +296,26 @@ #define E1000_IER_SPEED_CHANGED 0x4000 #define E1000_IER_AUTO_NEG_ERR 0x8000 +/* 88E1116, 88E1149 page 3, LED timer control. */ +#define E1000_PULSE_MASK 0x7000 +#define E1000_PULSE_NO_STR 0 /* no pulse stretching */ +#define E1000_PULSE_21MS 1 /* 21 ms to 42 ms */ +#define E1000_PULSE_42MS 2 /* 42 ms to 84 ms */ +#define E1000_PULSE_84MS 3 /* 84 ms to 170 ms */ +#define E1000_PULSE_170MS 4 /* 170 ms to 340 ms */ +#define E1000_PULSE_340MS 5 /* 340 ms to 670 ms */ +#define E1000_PULSE_670MS 6 /* 670 ms to 1300 ms */ +#define E1000_PULSE_1300MS 7 /* 1300 ms to 2700 ms */ +#define E1000_PULSE_DUR(x) ((x) & E1000_PULSE_MASK) + +#define E1000_BLINK_MASK 0x0700 +#define E1000_BLINK_42MS 0 /* 42 ms */ +#define E1000_BLINK_84MS 1 /* 84 ms */ +#define E1000_BLINK_170MS 2 /* 170 ms */ +#define E1000_BLINK_340MS 3 /* 340 ms */ +#define E1000_BLINK_670MS 4 /* 670 ms */ +#define E1000_BLINK_RATE(x) ((x) & E1000_BLINK_MASK) + #define E1000_ISR 0x13 /* interrupt status reg */ #define E1000_ISR_JABBER 0x0001 #define E1000_ISR_POLARITY_CHANGE 0x0002 Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c 2009-06-12 18:36:41 UTC (rev 31017) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy.c 2009-06-12 18:47:22 UTC (rev 31018) @@ -67,7 +67,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy.c,v 1.20 2007/01/20 00:52:29 marius Exp $"); +__FBSDID("$FreeBSD$"); /* * driver for generic unknown PHYs Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c 2009-06-12 18:36:41 UTC (rev 31017) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/mii/ukphy_subr.c 2009-06-12 18:47:22 UTC (rev 31018) @@ -38,7 +38,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/mii/ukphy_subr.c,v 1.8.8.1 2006/07/19 04:40:26 yongari Exp $"); +__FBSDID("$FreeBSD$"); /* * Subroutines shared by the ukphy driver and other PHY drivers. @@ -112,10 +112,10 @@ else if ((gtcr & GTCR_ADV_1000THDX) && (gtsr & GTSR_LP_1000THDX)) mii->mii_media_active |= IFM_1000_T; + else if (anlpar & ANLPAR_TX_FD) + mii->mii_media_active |= IFM_100_TX|IFM_FDX; else if (anlpar & ANLPAR_T4) mii->mii_media_active |= IFM_100_T4; - else if (anlpar & ANLPAR_TX_FD) - mii->mii_media_active |= IFM_100_TX|IFM_FDX; else if (anlpar & ANLPAR_TX) mii->mii_media_active |= IFM_100_TX; else if (anlpar & ANLPAR_10_FD) Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c 2009-06-12 18:36:41 UTC (rev 31017) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/if_msk.c 2009-06-12 18:47:22 UTC (rev 31018) @@ -99,7 +99,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/msk/if_msk.c,v 1.26 2007/12/05 09:41:58 remko Exp $"); +__FBSDID("$FreeBSD$"); #include #include @@ -156,6 +156,8 @@ TUNABLE_INT("hw.msk.msi_disable", &msi_disable); static int legacy_intr = 0; TUNABLE_INT("hw.msk.legacy_intr", &legacy_intr); +static int jumbo_disable = 0; +TUNABLE_INT("hw.msk.jumbo_disable", &jumbo_disable); #define MSK_CSUM_FEATURES (CSUM_TCP | CSUM_UDP) @@ -188,13 +190,19 @@ { VENDORID_MARVELL, DEVICEID_MRVL_8062X, "Marvell Yukon 88E8062 SX/LX Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8035, - "Marvell Yukon 88E8035 Gigabit Ethernet" }, + "Marvell Yukon 88E8035 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8036, - "Marvell Yukon 88E8036 Gigabit Ethernet" }, + "Marvell Yukon 88E8036 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8038, - "Marvell Yukon 88E8038 Gigabit Ethernet" }, + "Marvell Yukon 88E8038 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_8039, - "Marvell Yukon 88E8039 Gigabit Ethernet" }, + "Marvell Yukon 88E8039 Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8040, + "Marvell Yukon 88E8040 Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8040T, + "Marvell Yukon 88E8040T Fast Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_8048, + "Marvell Yukon 88E8048 Fast Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4361, "Marvell Yukon 88E8050 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4360, @@ -205,8 +213,14 @@ "Marvell Yukon 88E8055 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4364, "Marvell Yukon 88E8056 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4365, + "Marvell Yukon 88E8070 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_436A, "Marvell Yukon 88E8058 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436B, + "Marvell Yukon 88E8071 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436C, + "Marvell Yukon 88E8072 Gigabit Ethernet" }, { VENDORID_DLINK, DEVICEID_DLINK_DGE550SX, "D-Link 550SX Gigabit Ethernet" }, { VENDORID_DLINK, DEVICEID_DLINK_DGE560T, @@ -216,9 +230,10 @@ static const char *model_name[] = { "Yukon XL", "Yukon EC Ultra", - "Yukon Unknown", + "Yukon EX", "Yukon EC", - "Yukon FE" + "Yukon FE", + "Yukon FE+" }; static int mskc_probe(device_t); @@ -244,16 +259,19 @@ static int msk_handle_events(struct msk_softc *); static void msk_handle_hwerr(struct msk_if_softc *, uint32_t); static void msk_intr_hwerr(struct msk_softc *); -static void msk_rxeof(struct msk_if_softc *, uint32_t, int); -static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, int); +#ifndef __NO_STRICT_ALIGNMENT +static __inline void msk_fixup_rx(struct mbuf *); +#endif +static void msk_rxeof(struct msk_if_softc *, uint32_t, uint32_t, int); +static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, uint32_t, int); static void msk_txeof(struct msk_if_softc *, int); -static struct mbuf *msk_defrag(struct mbuf *, int, int); static int msk_encap(struct msk_if_softc *, struct mbuf **); static void msk_tx_task(void *, int); static void msk_start(struct ifnet *); static int msk_ioctl(struct ifnet *, u_long, caddr_t); static void msk_set_prefetch(struct msk_softc *, int, bus_addr_t, uint32_t); static void msk_set_rambuffer(struct msk_if_softc *); +static void msk_set_tx_stfwd(struct msk_if_softc *); static void msk_init(void *); static void msk_init_locked(struct msk_if_softc *); static void msk_stop(struct msk_if_softc *); @@ -265,9 +283,9 @@ static int msk_status_dma_alloc(struct msk_softc *); static void msk_status_dma_free(struct msk_softc *); static int msk_txrx_dma_alloc(struct msk_if_softc *); +static int msk_rx_dma_jalloc(struct msk_if_softc *); static void msk_txrx_dma_free(struct msk_if_softc *); -static void *msk_jalloc(struct msk_if_softc *); -static void msk_jfree(void *, void *); +static void msk_rx_dma_jfree(struct msk_if_softc *); static int msk_init_rx_ring(struct msk_if_softc *); static int msk_init_jumbo_rx_ring(struct msk_if_softc *); static void msk_init_tx_ring(struct msk_if_softc *); @@ -281,12 +299,15 @@ static int msk_miibus_readreg(device_t, int, int); static int msk_miibus_writereg(device_t, int, int, int); static void msk_miibus_statchg(device_t); -static void msk_link_task(void *, int); -static void msk_setmulti(struct msk_if_softc *); +static void msk_rxfilter(struct msk_if_softc *); static void msk_setvlan(struct msk_if_softc *, struct ifnet *); -static void msk_setpromisc(struct msk_if_softc *); +static void msk_stats_clear(struct msk_if_softc *); +static void msk_stats_update(struct msk_if_softc *); +static int msk_sysctl_stat32(SYSCTL_HANDLER_ARGS); +static int msk_sysctl_stat64(SYSCTL_HANDLER_ARGS); +static void msk_sysctl_node(struct msk_if_softc *); static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); static int sysctl_hw_msk_proc_limit(SYSCTL_HANDLER_ARGS); @@ -451,40 +472,44 @@ static void msk_miibus_statchg(device_t dev) { - struct msk_if_softc *sc_if; - - sc_if = device_get_softc(dev); - taskqueue_enqueue(taskqueue_swi, &sc_if->msk_link_task); -} - -static void -msk_link_task(void *arg, int pending) -{ struct msk_softc *sc; struct msk_if_softc *sc_if; struct mii_data *mii; struct ifnet *ifp; uint32_t gmac; - sc_if = (struct msk_if_softc *)arg; + sc_if = device_get_softc(dev); sc = sc_if->msk_softc; - MSK_IF_LOCK(sc_if); + MSK_IF_LOCK_ASSERT(sc_if); mii = device_get_softc(sc_if->msk_miibus); ifp = sc_if->msk_ifp; - if (mii == NULL || ifp == NULL) { - MSK_IF_UNLOCK(sc_if); + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return; + + sc_if->msk_flags &= ~MSK_FLAG_LINK; + if ((mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) == + (IFM_AVALID | IFM_ACTIVE)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc_if->msk_flags |= MSK_FLAG_LINK; + break; + case IFM_1000_T: + case IFM_1000_SX: + case IFM_1000_LX: + case IFM_1000_CX: + if ((sc_if->msk_flags & MSK_FLAG_FASTETHER) == 0) + sc_if->msk_flags |= MSK_FLAG_LINK; + break; + default: + break; + } } - if (mii->mii_media_status & IFM_ACTIVE) { - if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) - sc_if->msk_link = 1; - } else - sc_if->msk_link = 0; - - if (sc_if->msk_link != 0) { + if ((sc_if->msk_flags & MSK_FLAG_LINK) != 0) { /* Enable Tx FIFO Underrun. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK), GM_IS_TX_FF_UR | GM_IS_RX_FF_OR); @@ -541,17 +566,17 @@ msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0); /* Disable Rx/Tx MAC. */ gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); - gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); - GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); - /* Read again to ensure writing. */ - GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + if ((GM_GPCR_RX_ENA | GM_GPCR_TX_ENA) != 0) { + gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); + GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); + /* Read again to ensure writing. */ + GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + } } - - MSK_IF_UNLOCK(sc_if); } static void -msk_setmulti(struct msk_if_softc *sc_if) +msk_rxfilter(struct msk_if_softc *sc_if) { struct msk_softc *sc; struct ifnet *ifp; @@ -568,15 +593,14 @@ bzero(mchash, sizeof(mchash)); mode = GMAC_READ_2(sc, sc_if->msk_port, GM_RX_CTRL); - mode |= GM_RXCR_UCF_ENA; - if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) { - if ((ifp->if_flags & IFF_PROMISC) != 0) - mode &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - else if ((ifp->if_flags & IFF_ALLMULTI) != 0) { - mchash[0] = 0xffff; - mchash[1] = 0xffff; - } + if ((ifp->if_flags & IFF_PROMISC) != 0) + mode &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); + else if ((ifp->if_flags & IFF_ALLMULTI) != 0) { + mode |= GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA; + mchash[0] = 0xffff; + mchash[1] = 0xffff; } else { + mode |= GM_RXCR_UCF_ENA; IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) @@ -589,7 +613,8 @@ mchash[crc >> 5] |= 1 << (crc & 0x1f); } IF_ADDR_UNLOCK(ifp); - mode |= GM_RXCR_MCF_ENA; + if (mchash[0] != 0 || mchash[1] != 0) + mode |= GM_RXCR_MCF_ENA; } GMAC_WRITE_2(sc, sc_if->msk_port, GM_MC_ADDR_H1, @@ -622,26 +647,6 @@ } } -static void -msk_setpromisc(struct msk_if_softc *sc_if) -{ - struct msk_softc *sc; - struct ifnet *ifp; - uint16_t mode; - - MSK_IF_LOCK_ASSERT(sc_if); - - sc = sc_if->msk_softc; - ifp = sc_if->msk_ifp; - - mode = GMAC_READ_2(sc, sc_if->msk_port, GM_RX_CTRL); - if (ifp->if_flags & IFF_PROMISC) - mode &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - else - mode |= (GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - GMAC_WRITE_2(sc, sc_if->msk_port, GM_RX_CTRL, mode); -} - static int msk_init_rx_ring(struct msk_if_softc *sc_if) { @@ -784,7 +789,12 @@ return (ENOBUFS); m->m_len = m->m_pkthdr.len = MCLBYTES; - m_adj(m, ETHER_ALIGN); + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_rx_tag, sc_if->msk_cdata.msk_rx_sparemap, m, segs, &nsegs, @@ -823,25 +833,21 @@ bus_dma_segment_t segs[1]; bus_dmamap_t map; int nsegs; - void *buf; - MGETHDR(m, M_DONTWAIT, MT_DATA); + m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); - buf = msk_jalloc(sc_if); - if (buf == NULL) { - m_freem(m); - return (ENOBUFS); - } - /* Attach the buffer to the mbuf. */ - MEXTADD(m, buf, MSK_JLEN, msk_jfree, (struct msk_if_softc *)sc_if, 0, - EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); return (ENOBUFS); } - m->m_pkthdr.len = m->m_len = MSK_JLEN; - m_adj(m, ETHER_ALIGN); + m->m_len = m->m_pkthdr.len = MJUM9BYTES; + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_jumbo_rx_tag, sc_if->msk_cdata.msk_jumbo_rx_sparemap, m, segs, &nsegs, @@ -880,15 +886,16 @@ { struct msk_if_softc *sc_if; struct mii_data *mii; + int error; sc_if = ifp->if_softc; MSK_IF_LOCK(sc_if); mii = device_get_softc(sc_if->msk_miibus); - mii_mediachg(mii); + error = mii_mediachg(mii); MSK_IF_UNLOCK(sc_if); - return (0); + return (error); } /* @@ -902,6 +909,10 @@ sc_if = ifp->if_softc; MSK_IF_LOCK(sc_if); + if ((ifp->if_flags & IFF_UP) == 0) { + MSK_IF_UNLOCK(sc_if); + return; + } mii = device_get_softc(sc_if->msk_miibus); mii_pollstat(mii); @@ -924,38 +935,41 @@ switch(command) { case SIOCSIFMTU: - if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) { + MSK_IF_LOCK(sc_if); + if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) error = EINVAL; - break; + else if (ifp->if_mtu != ifr->ifr_mtu) { + if (ifr->ifr_mtu > ETHERMTU) { + if ((sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) { + error = EINVAL; + MSK_IF_UNLOCK(sc_if); + break; + } + if ((sc_if->msk_flags & + MSK_FLAG_JUMBO_NOCSUM) != 0) { + ifp->if_hwassist &= + ~(MSK_CSUM_FEATURES | CSUM_TSO); + ifp->if_capenable &= + ~(IFCAP_TSO4 | IFCAP_TXCSUM); + VLAN_CAPABILITIES(ifp); + } + } + ifp->if_mtu = ifr->ifr_mtu; + msk_init_locked(sc_if); } - if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE && - ifr->ifr_mtu > MSK_MAX_FRAMELEN) { - error = EINVAL; - break; - } - MSK_IF_LOCK(sc_if); - ifp->if_mtu = ifr->ifr_mtu; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_init_locked(sc_if); MSK_IF_UNLOCK(sc_if); break; case SIOCSIFFLAGS: MSK_IF_LOCK(sc_if); if ((ifp->if_flags & IFF_UP) != 0) { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - if (((ifp->if_flags ^ sc_if->msk_if_flags) - & IFF_PROMISC) != 0) { - msk_setpromisc(sc_if); - msk_setmulti(sc_if); - } - } else { - if (sc_if->msk_detach == 0) - msk_init_locked(sc_if); - } - } else { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_stop(sc_if); - } + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 && + ((ifp->if_flags ^ sc_if->msk_if_flags) & + (IFF_PROMISC | IFF_ALLMULTI)) != 0) + msk_rxfilter(sc_if); + else if ((sc_if->msk_flags & MSK_FLAG_DETACH) == 0) + msk_init_locked(sc_if); + } else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + msk_stop(sc_if); sc_if->msk_if_flags = ifp->if_flags; MSK_IF_UNLOCK(sc_if); break; @@ -963,7 +977,7 @@ case SIOCDELMULTI: MSK_IF_LOCK(sc_if); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_setmulti(sc_if); + msk_rxfilter(sc_if); MSK_IF_UNLOCK(sc_if); break; case SIOCGIFMEDIA: @@ -974,33 +988,35 @@ case SIOCSIFCAP: MSK_IF_LOCK(sc_if); mask = ifr->ifr_reqcap ^ ifp->if_capenable; - if ((mask & IFCAP_TXCSUM) != 0) { + if ((mask & IFCAP_TXCSUM) != 0 && + (IFCAP_TXCSUM & ifp->if_capabilities) != 0) { ifp->if_capenable ^= IFCAP_TXCSUM; - if ((IFCAP_TXCSUM & ifp->if_capenable) != 0 && - (IFCAP_TXCSUM & ifp->if_capabilities) != 0) + if ((IFCAP_TXCSUM & ifp->if_capenable) != 0) ifp->if_hwassist |= MSK_CSUM_FEATURES; else ifp->if_hwassist &= ~MSK_CSUM_FEATURES; } - if ((mask & IFCAP_VLAN_HWTAGGING) != 0) { + if ((mask & IFCAP_RXCSUM) != 0 && + (IFCAP_RXCSUM & ifp->if_capabilities) != 0) + ifp->if_capenable ^= IFCAP_RXCSUM; + if ((mask & IFCAP_VLAN_HWTAGGING) != 0 && + (IFCAP_VLAN_HWTAGGING & ifp->if_capabilities) != 0) { ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; msk_setvlan(sc_if, ifp); } - - if ((mask & IFCAP_TSO4) != 0) { + if ((mask & IFCAP_VLAN_HWCSUM) != 0 && + (IFCAP_VLAN_HWCSUM & ifp->if_capabilities) != 0) + ifp->if_capenable ^= IFCAP_VLAN_HWCSUM; + if ((mask & IFCAP_TSO4) != 0 && + (IFCAP_TSO4 & ifp->if_capabilities) != 0) { ifp->if_capenable ^= IFCAP_TSO4; - if ((IFCAP_TSO4 & ifp->if_capenable) != 0 && - (IFCAP_TSO4 & ifp->if_capabilities) != 0) + if ((IFCAP_TSO4 & ifp->if_capenable) != 0) ifp->if_hwassist |= CSUM_TSO; else ifp->if_hwassist &= ~CSUM_TSO; } - if (sc_if->msk_framesize > MSK_MAX_FRAMELEN && - sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { - /* - * In Yukon EC Ultra, TSO & checksum offload is not - * supported for jumbo frame. - */ + if (ifp->if_mtu > ETHERMTU && + (sc_if->msk_flags & MSK_FLAG_JUMBO_NOCSUM) != 0) { ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); } @@ -1042,14 +1058,16 @@ { int next; int i; - uint8_t val; /* Get adapter SRAM size. */ - val = CSR_READ_1(sc, B2_E_0); - sc->msk_ramsize = (val == 0) ? 128 : val * 4; + sc->msk_ramsize = CSR_READ_1(sc, B2_E_0) * 4; if (bootverbose) device_printf(sc->msk_dev, "RAM buffer size : %dKB\n", sc->msk_ramsize); + if (sc->msk_ramsize == 0) + return (0); + + sc->msk_pflags |= MSK_FLAG_RAMBUF; /* * Give receiver 2/3 of memory and round down to the multiple * of 1024. Tx/Rx RAM buffer size of Yukon II shoud be multiple @@ -1082,7 +1100,7 @@ static void msk_phy_power(struct msk_softc *sc, int mode) { - uint32_t val; + uint32_t our, val; [... truncated: 2241 lines follow ...] From mmlr at mail.berlios.de Fri Jun 12 22:41:08 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Fri, 12 Jun 2009 22:41:08 +0200 Subject: [Haiku-commits] r31019 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200906122041.n5CKf8fM005381@sheep.berlios.de> Author: mmlr Date: 2009-06-12 22:41:07 +0200 (Fri, 12 Jun 2009) New Revision: 31019 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31019&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp Log: Not really sure why the inquiry command was special cased on ATAPI, but it prevents tools that try to read other inquiry pages (like cdrecord) from getting the required infos. This way the inquiry command is sent to the ATAPI device, which seems to work fine (at least for the drive I have here). Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2009-06-12 18:47:22 UTC (rev 31018) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2009-06-12 20:41:07 UTC (rev 31019) @@ -825,7 +825,7 @@ { // TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode 0x%02x, length %u\n", fIndex, request->cdb[0], request->cdb_length); - if (fIsATAPI && request->cdb[0] != SCSI_OP_INQUIRY) { + if (fIsATAPI) { bool isWrite = false; switch (request->flags & SCSI_DIR_MASK) { case SCSI_DIR_NONE: From korli at mail.berlios.de Fri Jun 12 23:16:05 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 12 Jun 2009 23:16:05 +0200 Subject: [Haiku-commits] r31020 - in haiku/trunk: headers/os/drivers src/add-ons/kernel/bus_managers/pci Message-ID: <200906122116.n5CLG5i1009138@sheep.berlios.de> Author: korli Date: 2009-06-12 23:16:04 +0200 (Fri, 12 Jun 2009) New Revision: 31020 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31020&view=rev Modified: haiku/trunk/headers/os/drivers/PCI.h haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp Log: added some PCI capabilities, wireless class values Modified: haiku/trunk/headers/os/drivers/PCI.h =================================================================== --- haiku/trunk/headers/os/drivers/PCI.h 2009-06-12 20:41:07 UTC (rev 31019) +++ haiku/trunk/headers/os/drivers/PCI.h 2009-06-12 21:16:04 UTC (rev 31020) @@ -265,8 +265,8 @@ #define PCI_input 0x09 /* input devices */ #define PCI_docking_station 0x0a /* docking stations */ #define PCI_processor 0x0b /* processors */ -#define PCI_serial_bus 0x0c /* serial_bus_controller */ -#define PCI_wireless 0x0d +#define PCI_serial_bus 0x0c /* serial bus controllers */ +#define PCI_wireless 0x0d /* wireless controllers */ #define PCI_intelligent_io 0x0e #define PCI_satellite_communications 0x0f #define PCI_encryption_decryption 0x10 @@ -362,8 +362,10 @@ #define PCI_pcmcia 0x05 /* PCMCIA bridge */ #define PCI_nubus 0x06 /* NuBus bridge */ #define PCI_cardbus 0x07 /* CardBus bridge */ -#define PCI_raceway 0x08 /* RACEway bridge */ -#define PCI_bridge_other 0x80 /* other bridge device */ +#define PCI_raceway 0x08 /* RACEway bridge */ +#define PCI_bridge_transparent 0x09 /* PCI transparent */ +#define PCI_bridge_infiniband 0x0a /* Infiniband */ +#define PCI_bridge_other 0x80 /* other bridge device */ /* --- @@ -469,6 +471,7 @@ --- */ #define PCI_docking_generic 0x00 /* generic docking station */ +#define PCI_docking_other 0x80 /* other docking stations */ /* --- values for the class_sub field for class_base = 0x0b (processor) @@ -492,6 +495,11 @@ #define PCI_ssa 0x02 /* SSA */ #define PCI_usb 0x03 /* Universal Serial Bus */ #define PCI_fibre_channel 0x04 /* Fibre channel */ +#define PCI_smbus 0x05 +#define PCI_infiniband 0x06 +#define PCI_ipmi 0x07 +#define PCI_sercos 0x08 +#define PCI_canbus 0x09 /* --- values of the class_api field for @@ -503,6 +511,17 @@ #define PCI_usb_ohci 0x10 /* Open Host Controller Interface */ #define PCI_usb_ehci 0x20 /* Enhanced Host Controller Interface */ +/* --- + values for the class_sub field for class_base = 0x0d (wireless controller) +--- */ +#define PCI_wireless_irda 0x00 +#define PCI_wireless_consumer_ir 0x01 +#define PCI_wireless_rf 0x02 +#define PCI_wireless_bluetooth 0x03 +#define PCI_wireless_broadband 0x04 +#define PCI_wireless_80211A 0x10 +#define PCI_wireless_80211B 0x20 +#define PCI_wireless_other 0x80 /* --- masks for command register bits @@ -614,22 +633,26 @@ #define PCI_pin_max 0x04 /** PCI Capability Codes */ -#define PCI_cap_id_reserved 0x00 -#define PCI_cap_id_pm 0x01 /* Power management */ -#define PCI_cap_id_agp 0x02 /* AGP */ -#define PCI_cap_id_vpd 0x03 /* Vital product data */ -#define PCI_cap_id_slotid 0x04 /* Slot ID */ -#define PCI_cap_id_msi 0x05 /* Message signalled interrupt */ -#define PCI_cap_id_chswp 0x06 /* Compact PCI HotSwap */ -#define PCI_cap_id_pcix 0x07 /* PCI-X */ -#define PCI_cap_id_ldt 0x08 -#define PCI_cap_id_vendspec 0x09 -#define PCI_cap_id_debugport 0x0a +#define PCI_cap_id_reserved 0x00 +#define PCI_cap_id_pm 0x01 /* Power management */ +#define PCI_cap_id_agp 0x02 /* AGP */ +#define PCI_cap_id_vpd 0x03 /* Vital product data */ +#define PCI_cap_id_slotid 0x04 /* Slot ID */ +#define PCI_cap_id_msi 0x05 /* Message signalled interrupt */ +#define PCI_cap_id_chswp 0x06 /* Compact PCI HotSwap */ +#define PCI_cap_id_pcix 0x07 /* PCI-X */ +#define PCI_cap_id_ldt 0x08 +#define PCI_cap_id_vendspec 0x09 +#define PCI_cap_id_debugport 0x0a #define PCI_cap_id_cpci_rsrcctl 0x0b #define PCI_cap_id_hotplug 0x0c -#define PCI_cap_id_pcie 0x10 /* PCIe (PCI express) */ -#define PCI_cap_id_msix 0x11 /* MSI-X */ -#define PCI_cap_id_sata 0x12 /* Serial ATA Capability */ +#define PCI_cap_id_subvendor 0x0d +#define PCI_cap_id_agp8x 0x0e +#define PCI_cap_id_secure_dev 0x0f +#define PCI_cap_id_pcie 0x10 /* PCIe (PCI express) */ +#define PCI_cap_id_msix 0x11 /* MSI-X */ +#define PCI_cap_id_sata 0x12 /* Serial ATA Capability */ +#define PCI_cap_id_pciaf 0x13 /* PCI Advanced Features */ /** Power Management Control Status Register settings */ #define PCI_pm_mask 0x03 Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 2009-06-12 20:41:07 UTC (rev 31019) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 2009-06-12 21:16:04 UTC (rev 31020) @@ -235,7 +235,7 @@ case PCI_cap_id_msi: return "MSI"; case PCI_cap_id_chswp: - return "chswp"; + return "CompactPCIHotSwap"; case PCI_cap_id_pcix: return "PCI-X"; case PCI_cap_id_ldt: @@ -248,12 +248,20 @@ return "cpci_rsrcctl"; case PCI_cap_id_hotplug: return "HotPlug"; + case PCI_cap_id_subvendor: + return "subvendor"; + case PCI_cap_id_agp8x: + return "AGP8x"; + case PCI_cap_id_secure_dev: + return "Secure Device"; case PCI_cap_id_pcie: return "PCIe"; case PCI_cap_id_msix: return "MSI-X"; case PCI_cap_id_sata: return "SATA"; + case PCI_cap_id_pciaf: + return "AdvancedFeatures"; default: return NULL; } From mmu_man at mail.berlios.de Sat Jun 13 00:02:22 2009 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 13 Jun 2009 00:02:22 +0200 Subject: [Haiku-commits] r31021 - haiku/trunk/src/system/runtime_loader/arch/m68k Message-ID: <200906122202.n5CM2Miu017657@sheep.berlios.de> Author: mmu_man Date: 2009-06-13 00:02:21 +0200 (Sat, 13 Jun 2009) New Revision: 31021 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31021&view=rev Modified: haiku/trunk/src/system/runtime_loader/arch/m68k/arch_relocate.cpp Log: Fix build due to stricter type checking in C++ than C. Modified: haiku/trunk/src/system/runtime_loader/arch/m68k/arch_relocate.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/arch/m68k/arch_relocate.cpp 2009-06-12 21:16:04 UTC (rev 31020) +++ haiku/trunk/src/system/runtime_loader/arch/m68k/arch_relocate.cpp 2009-06-12 22:02:21 UTC (rev 31021) @@ -26,14 +26,14 @@ static inline void -write_32(addr_t P, Elf32_Word value) +write_32(addr_t *P, Elf32_Word value) { *(Elf32_Word*)P = value; } static inline void -write_16(addr_t P, Elf32_Word value) +write_16(addr_t *P, Elf32_Word value) { // bits 16:29 *(Elf32_Half*)P = (Elf32_Half)value; @@ -41,7 +41,7 @@ static inline bool -write_16_check(addr_t P, Elf32_Word value) +write_16_check(addr_t *P, Elf32_Word value) { // bits 15:0 if ((value & 0xffff0000) && (~value & 0xffff8000)) @@ -52,7 +52,7 @@ static inline bool -write_8(addr_t P, Elf32_Word value) +write_8(addr_t *P, Elf32_Word value) { // bits 7:0 *(uint8 *)P = (uint8)value; @@ -61,7 +61,7 @@ static inline bool -write_8_check(addr_t P, Elf32_Word value) +write_8_check(addr_t *P, Elf32_Word value) { // bits 7:0 if ((value & 0xffffff00) && (~value & 0xffffff80)) From mmlr at mail.berlios.de Sat Jun 13 02:08:05 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sat, 13 Jun 2009 02:08:05 +0200 Subject: [Haiku-commits] r31022 - haiku/trunk/src/add-ons/kernel/cpu/x86 Message-ID: <200906130008.n5D085ut001506@sheep.berlios.de> Author: mmlr Date: 2009-06-13 02:08:04 +0200 (Sat, 13 Jun 2009) New Revision: 31022 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31022&view=rev Modified: haiku/trunk/src/add-ons/kernel/cpu/x86/Jamfile Log: Update to use UsePrivateKernelHeaders so things like safemode.h can be properly included. Modified: haiku/trunk/src/add-ons/kernel/cpu/x86/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/cpu/x86/Jamfile 2009-06-12 22:02:21 UTC (rev 31021) +++ haiku/trunk/src/add-ons/kernel/cpu/x86/Jamfile 2009-06-13 00:08:04 UTC (rev 31022) @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src add-ons kernel cpu x86 ; -UsePrivateHeaders kernel [ FDirName kernel arch $(TARGET_ARCH) ] ; +UsePrivateKernelHeaders ; KernelAddon generic_x86 : generic_x86.cpp From mmlr at mail.berlios.de Sat Jun 13 04:35:20 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sat, 13 Jun 2009 04:35:20 +0200 Subject: [Haiku-commits] r31024 - haiku/trunk/src/add-ons/kernel/cpu/x86 Message-ID: <200906130235.n5D2ZKNT032325@sheep.berlios.de> Author: mmlr Date: 2009-06-13 04:35:19 +0200 (Sat, 13 Jun 2009) New Revision: 31024 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31024&view=rev Modified: haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp Log: Fix the length calculated in generic_get_mtrr(). The +1 would usually be added to the mask and then shifted, but as we don't do the shifting at all, we need to add a page size instead of just 1. Modified: haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp 2009-06-13 02:32:25 UTC (rev 31023) +++ haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp 2009-06-13 02:35:19 UTC (rev 31024) @@ -151,7 +151,7 @@ uint64 base = x86_read_msr(IA32_MSR_MTRR_PHYSICAL_BASE_0 + index * 2); *_base = base & ~(B_PAGE_SIZE - 1); - *_length = (~mask & gPhysicalMask) + 1; + *_length = (~mask & gPhysicalMask) + B_PAGE_SIZE; *_type = base & 0xff; return B_OK; From joe.prostko+haiku at gmail.com Sat Jun 13 04:56:21 2009 From: joe.prostko+haiku at gmail.com (Joseph Prostko) Date: Fri, 12 Jun 2009 22:56:21 -0400 Subject: [Haiku-commits] r31015 - in haiku/trunk: headers/private/bluetooth src/servers/bluetooth In-Reply-To: <200906121814.n5CIEqYF024897@sheep.berlios.de> References: <200906121814.n5CIEqYF024897@sheep.berlios.de> Message-ID: <7e5795b0906121956n2dabe911nb36585132f48f50@mail.gmail.com> On Fri, Jun 12, 2009 at 2:14 PM, oruizdorantes at BerliOS wrote: > Author: oruizdorantes > Date: 2009-06-12 20:14:51 +0200 (Fri, 12 Jun 2009) > New Revision: 31015 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31015&view=rev I just ran an SVN up from yesterday and tried a build. I got the following errors on a cross-compile from Linux doing a GCC4 build (work-in-progress GCC 4.4). In file included from /home/joe/haiku/trunk/src/servers/bluetooth/BluetoothServer.h:26, from /home/joe/haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp:26: /home/joe/haiku/trunk/headers/private/bluetooth/PortListener.h: In destructor 'PortListener::~PortListener()': /home/joe/haiku/trunk/headers/private/bluetooth/PortListener.h:49: error: returning a value from a destructor /home/joe/haiku/trunk/headers/private/bluetooth/PortListener.h: In constructor 'BluetoothServer::BluetoothServer()': /home/joe/haiku/trunk/headers/private/bluetooth/PortListener.h:18: error: 'typedef status_t (* PortListener::port_listener_func)(struct hci_event_header*, long int, long unsigned int)' is private /home/joe/haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp:67: error: within this context From korli at mail.berlios.de Sat Jun 13 12:42:13 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 13 Jun 2009 12:42:13 +0200 Subject: [Haiku-commits] r31025 - in haiku/trunk: headers/private/bluetooth src/servers/bluetooth Message-ID: <200906131042.n5DAgDUm030168@sheep.berlios.de> Author: korli Date: 2009-06-13 12:42:11 +0200 (Sat, 13 Jun 2009) New Revision: 31025 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31025&view=rev Modified: haiku/trunk/headers/private/bluetooth/PortListener.h haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp Log: * fix the build by moving a typedef to public scope, and avoid returning a value in the destructor * some clean up Modified: haiku/trunk/headers/private/bluetooth/PortListener.h =================================================================== --- haiku/trunk/headers/private/bluetooth/PortListener.h 2009-06-13 02:35:19 UTC (rev 31024) +++ haiku/trunk/headers/private/bluetooth/PortListener.h 2009-06-13 10:42:11 UTC (rev 31025) @@ -14,16 +14,10 @@ size_t MAX_MESSAGE_DEEP = 16, uint32 PRIORITY = B_URGENT_DISPLAY_PRIORITY> class PortListener { - - typedef status_t (*port_listener_func)(TYPE*, int32, size_t); - - struct PortListenerInfo { - port_id* port; - port_listener_func func; - } fInformation; - public: - PortListener(const char* name, port_listener_func handler) + typedef status_t (*port_listener_func)(TYPE*, int32, size_t); + + PortListener(const char* name, port_listener_func handler) { fInformation.func = handler; fInformation.port = &fPort; @@ -35,8 +29,8 @@ } - ~PortListener() { - + ~PortListener() + { status_t status; close_port(fPort); @@ -45,27 +39,24 @@ delete fThreadName; delete fPortName; - - return status; } - status_t TriggerCode(int32 code) { - + status_t TriggerCode(int32 code) + { return write_port(fPort, code, NULL, 0); + } - } - - status_t InitCheck() { - + status_t InitCheck() + { // Create Port - fPort = find_port(fPortName); + fPort = find_port(fPortName); if (fPort == B_NAME_NOT_FOUND) { - fPort = create_port(MAX_MESSAGE_DEEP, fPortName); + fPort = create_port(MAX_MESSAGE_DEEP, fPortName); } - if (fPort < B_OK) + if (fPort < B_OK) return fPort; // Create Thread @@ -73,43 +64,49 @@ fThread = find_thread(fThreadName); if (fThread < B_OK) { #ifdef KERNEL_LAND - fThread = spawn_kernel_thread((thread_func)&PortListener::threadFunction, fThreadName, PRIORITY, &fInformation); #else - fThread = spawn_thread((thread_func)&PortListener::threadFunction, fThreadName, PRIORITY, &fInformation); + fThread = spawn_thread((thread_func)&PortListener::threadFunction, fThreadName, PRIORITY, &fInformation); #endif } - if (fThread < B_OK) + if (fThread < B_OK) return fThread; return B_OK; } - status_t Launch() { - + status_t Launch() + { status_t check = InitCheck(); - if (check < B_OK) + if (check < B_OK) return check; return resume_thread(fThread); } - status_t Stop() { - + status_t Stop() + { status_t status; - wait_for_thread(fThread, &status); return status; } - private: - port_id fPort; + + + private: + struct PortListenerInfo { + port_id* port; + port_listener_func func; + } fInformation; + + port_id fPort; thread_id fThread; char* fThreadName; char* fPortName; @@ -127,9 +124,9 @@ TYPE* buffer = (TYPE*)malloc(MAX_MESSAGE_SIZE); - while ((ssizePort = port_buffer_size(*port)) != B_BAD_PORT_ID) { + while ((ssizePort = port_buffer_size(*port)) != B_BAD_PORT_ID) { - if (ssizePort <= 0) { + if (ssizePort <= 0) { snooze(500*1000); continue; } @@ -139,7 +136,7 @@ continue; } - ssizeRead = read_port(*port, &code, (void*)buffer, ssizePort); + ssizeRead = read_port(*port, &code, (void*)buffer, ssizePort); if (ssizeRead != ssizePort) continue; @@ -152,7 +149,7 @@ free(buffer); - if (ssizePort == B_BAD_PORT_ID) // the port dissapeared + if (ssizePort == B_BAD_PORT_ID) // the port disappeared return ssizePort; return status; @@ -160,5 +157,5 @@ }; // PortListener - #endif // PORTLISTENER_H_ + Modified: haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp =================================================================== --- haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp 2009-06-13 02:35:19 UTC (rev 31024) +++ haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp 2009-06-13 10:42:11 UTC (rev 31025) @@ -63,8 +63,8 @@ fDeviceManager = new DeviceManager(); fLocalDevicesList.MakeEmpty(); - fEventListener2 = new BluetoothPortListener(BT_USERLAND_PORT_NAME, - (BluetoothPortListener::port_listener_func)&DispatchEvent); + fEventListener2 = new BluetoothPortListener(BT_USERLAND_PORT_NAME, + (BluetoothPortListener::port_listener_func)&DispatchEvent); } From korli at users.berlios.de Sat Jun 13 12:42:43 2009 From: korli at users.berlios.de (=?ISO-8859-1?B?Suly9G1lIER1dmFs?=) Date: Sat, 13 Jun 2009 12:42:43 +0200 Subject: [Haiku-commits] r31015 - in haiku/trunk: headers/private/bluetooth src/servers/bluetooth In-Reply-To: <7e5795b0906121956n2dabe911nb36585132f48f50@mail.gmail.com> References: <200906121814.n5CIEqYF024897@sheep.berlios.de> <7e5795b0906121956n2dabe911nb36585132f48f50@mail.gmail.com> Message-ID: 2009/6/13 Joseph Prostko : > On Fri, Jun 12, 2009 at 2:14 PM, oruizdorantes at > BerliOS wrote: >> Author: oruizdorantes >> Date: 2009-06-12 20:14:51 +0200 (Fri, 12 Jun 2009) >> New Revision: 31015 >> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31015&view=rev > > I just ran an SVN up from yesterday and tried a build. ?I got the > following errors on a cross-compile from Linux doing a GCC4 build > (work-in-progress GCC 4.4). Should be fine with r31025. Bye, J?r?me From mmlr at mail.berlios.de Sat Jun 13 13:35:58 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sat, 13 Jun 2009 13:35:58 +0200 Subject: [Haiku-commits] r31026 - haiku/trunk/src/add-ons/kernel/cpu/x86 Message-ID: <200906131135.n5DBZwK6003992@sheep.berlios.de> Author: mmlr Date: 2009-06-13 13:35:57 +0200 (Sat, 13 Jun 2009) New Revision: 31026 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31026&view=rev Modified: haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp Log: When clearing the MTRRs also set the default type to uncacheable. Otherwise on systems where the default is set to a cachable type and MTRRs are used to define the uncacheable areas, everything would become cacheable after clearing them. Modified: haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp 2009-06-13 10:42:11 UTC (rev 31025) +++ haiku/trunk/src/add-ons/kernel/cpu/x86/generic_x86.cpp 2009-06-13 11:35:57 UTC (rev 31026) @@ -101,8 +101,12 @@ // but turn on variable MTRR functionality + // we need to ensure that the default type is uncacheable, otherwise + // clearing the mtrrs could result in ranges that aren't supposed to be + // cacheable to become cacheable due to the default type + x86_write_msr(IA32_MSR_MTRR_DEFAULT_TYPE, - x86_read_msr(IA32_MSR_MTRR_DEFAULT_TYPE) | IA32_MTRR_ENABLE); + (x86_read_msr(IA32_MSR_MTRR_DEFAULT_TYPE) & ~0xff) | IA32_MTRR_ENABLE); } From mmlr at mail.berlios.de Sat Jun 13 13:40:06 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sat, 13 Jun 2009 13:40:06 +0200 Subject: [Haiku-commits] r31027 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200906131140.n5DBe6pu004512@sheep.berlios.de> Author: mmlr Date: 2009-06-13 13:40:05 +0200 (Sat, 13 Jun 2009) New Revision: 31027 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31027&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp Log: Make two runs of MTRR setting when setting memory ranges to write-back. At the first run only set up uncacheable MTRRs and in the second run set the write-back ones up. If this order is not followed, we could set too large ranges to cacheable first and then limit it back to uncacheable later. On systems with enough physical memory this would lead to a temporary situation in which areas become cacheable that must not be, resulting in system hangs or other unexpected behaviour. Fixes last part of #4018. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp 2009-06-13 11:35:57 UTC (rev 31026) +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp 2009-06-13 11:40:05 UTC (rev 31027) @@ -272,33 +272,48 @@ #ifdef TRACE_MTRR dprintf("solutions: "); - for (int i=0; i Author: mmlr Date: 2009-06-13 15:00:48 +0200 (Sat, 13 Jun 2009) New Revision: 31028 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31028&view=rev Modified: haiku/trunk/src/add-ons/mail_daemon/system_filters/notifier/filter.cpp Log: Do not notify about auto-read messages. For example when setting spam to be marked as read automatically I don't really want to get the notification alert. This has been laying around on my drive for a long time now... Modified: haiku/trunk/src/add-ons/mail_daemon/system_filters/notifier/filter.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/system_filters/notifier/filter.cpp 2009-06-13 11:40:05 UTC (rev 31027) +++ haiku/trunk/src/add-ons/mail_daemon/system_filters/notifier/filter.cpp 2009-06-13 13:00:48 UTC (rev 31028) @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -63,15 +64,20 @@ return B_OK; } -status_t NotifyFilter::ProcessMailMessage(BPositionIO**, BEntry*, BMessage*headers, BPath*, const char*) +status_t NotifyFilter::ProcessMailMessage(BPositionIO**, BEntry*, BMessage*headers, BPath*path, const char*) { if (callback == NULL) { callback = new NotifyCallback(strategy,_runner,this); _runner->RegisterProcessCallback(callback); } - if (!headers->FindBool("ENTIRE_MESSAGE")) - callback->num_messages ++; + if (!headers->FindBool("ENTIRE_MESSAGE")) { + BString status; + headers->FindString("STATUS", &status); + // do not notify about auto-read messages + if (status.Compare("Read") != 0) + callback->num_messages ++; + } return B_OK; } From stippi at mail.berlios.de Sat Jun 13 15:47:01 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 13 Jun 2009 15:47:01 +0200 Subject: [Haiku-commits] r31029 - in haiku/trunk: data/artwork/icons src/apps/poorman Message-ID: <200906131347.n5DDl14C021605@sheep.berlios.de> Author: stippi Date: 2009-06-13 15:46:59 +0200 (Sat, 13 Jun 2009) New Revision: 31029 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31029&view=rev Added: haiku/trunk/data/artwork/icons/App_Poorman Modified: haiku/trunk/src/apps/poorman/PoorMan.rdef Log: Added icon for PoorMan by zuMi. Thanks a lot and sorry for the delay! Added: haiku/trunk/data/artwork/icons/App_Poorman =================================================================== (Binary files differ) Property changes on: haiku/trunk/data/artwork/icons/App_Poorman ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: haiku/trunk/src/apps/poorman/PoorMan.rdef =================================================================== --- haiku/trunk/src/apps/poorman/PoorMan.rdef 2009-06-13 13:00:48 UTC (rev 31028) +++ haiku/trunk/src/apps/poorman/PoorMan.rdef 2009-06-13 13:46:59 UTC (rev 31029) @@ -1,6 +1,45 @@ +resource app_signature "application/x-vnd.haiku.PoorMan"; + +resource app_version +{ + major = 0, + middle = 1, + minor = 0, + variety = B_APPV_DEVELOPMENT, + internal = 0, + short_info = "PoorMan Web Server", + long_info = "PoorMan Web Server ? 2004-2009 Haiku, Inc." +}; + +resource app_flags B_EXCLUSIVE_LAUNCH; + resource file_types message; +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + +resource vector_icon { + $"6E63696606040059020006033B52123BE398BF0AC03E98EC4AFDFD43719100FF" + $"D4007DBF8F00FF9965000200060339B0453A1B90BF02A03EA2524B2E0E4637E9" + $"00FFEB907DFFD400FFFFC000020106033D20000000000000003D09C748800047" + $"6C7100C0E2FFC904569DFF3379B6020116033A00000000000000003A00004700" + $"004A600000FF33F2FF8005010C060CAAFEBC364E37502D563158BC77C7DB3856" + $"38563756385D345A3C60415A415D415A4D4E594E59595751445E4B443D374C0A" + $"122D562D563158315834553455374B374B3A4B3A4B3E4E3E4E414B414B3C473C" + $"47324732470A063E4E3A4B334B35473C47414B0A05334B354B31582D56314A0A" + $"04354B31583455374B06032B283B283B273C2B472E4302043B22C1B722B9CC22" + $"293429B70229BEED3B46B9CC46C1B7464D344DBEED4DB7020806334B41484347" + $"4543434335470A0443434148434745430604EA4148334B354743433D4A434306" + $"020E354743433D4A434302042E42B9E542B74242284828C19E28C4412E4EB742" + $"4EB9E54E344834C44134C19E100A00010030222001158400040A050101302220" + $"01178400040A0101022022200A0201032022200A0101042022200A0501053022" + $"2001178400040A0201052022200A01002022200A05010630222001178400040A" + $"0301062022200A05010730222001178400040A0101082022200A020109202220" + $"0A01010A2022200A05010B30222001178400040A04010B202220" +}; + +#else // HAIKU_TARGET_PLATFORM_HAIKU + resource large_icon array { $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" @@ -57,17 +96,4 @@ $"FFFFFFFF0000000011111111FFFFFFFF" }; -resource app_signature "application/x-vnd.haiku.PoorMan"; - -resource app_version -{ - major = 0, - middle = 1, - minor = 0, - variety = B_APPV_DEVELOPMENT, - internal = 0, - short_info = "PoorMan Web Server", - long_info = "Haiku recreation of the PoorMan Web Server." -}; - -resource app_flags B_EXCLUSIVE_LAUNCH; +#endif // HAIKU_TARGET_PLATFORM_HAIKU From stippi at mail.berlios.de Sat Jun 13 15:53:56 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 13 Jun 2009 15:53:56 +0200 Subject: [Haiku-commits] r31030 - haiku/trunk/data/artwork/icons Message-ID: <200906131353.n5DDruNO022321@sheep.berlios.de> Author: stippi Date: 2009-06-13 15:53:55 +0200 (Sat, 13 Jun 2009) New Revision: 31030 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31030&view=rev Added: haiku/trunk/data/artwork/icons/Alert_Idea Log: Added idea icon by zuMi, which was added to app_server resources before, it's used in idea alerts. Added: haiku/trunk/data/artwork/icons/Alert_Idea =================================================================== (Binary files differ) Property changes on: haiku/trunk/data/artwork/icons/Alert_Idea ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From stippi at mail.berlios.de Sat Jun 13 15:56:27 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 13 Jun 2009 15:56:27 +0200 Subject: [Haiku-commits] r31031 - haiku/trunk/data/artwork/icons Message-ID: <200906131356.n5DDuRCt022609@sheep.berlios.de> Author: stippi Date: 2009-06-13 15:56:25 +0200 (Sat, 13 Jun 2009) New Revision: 31031 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31031&view=rev Added: haiku/trunk/data/artwork/icons/App_BeHappy Log: Added BeHappy icon by zuMi. Thanks a lot and sorry for the delay! This is not yet added to the BeHappy package AFAIK. Added: haiku/trunk/data/artwork/icons/App_BeHappy =================================================================== (Binary files differ) Property changes on: haiku/trunk/data/artwork/icons/App_BeHappy ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From mattmadia at gmail.com Sat Jun 13 16:58:05 2009 From: mattmadia at gmail.com (Matt Madia) Date: Sat, 13 Jun 2009 14:58:05 +0000 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <200905270112.n4R1Cf1p031769@sheep.berlios.de> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> Message-ID: <1e42d8c50906130758h63d825f3r1b4dd8ed3ec04a74@mail.gmail.com> On Wed, May 27, 2009 at 1:12 AM, wrote: > @@ -416,7 +465,7 @@ > if $(TARGET_ARCH) != x86 { > Echo "No optional package OpenSSH available for $(TARGET_ARCH)" ; > } else { > - if ! $(HAIKU_IMAGE_HOST_NAME) { > + if ! $(HAIKU_IMAGE_HOST_NAME) && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) { > Exit "Optional package OpenSSH requires the HAIKU_IMAGE_HOST_NAME" > "variable to be set!" ; > } sorry for dragging up an older commit email... What's the reason for having OpenSSH test for && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) ? The usage case I was looking at is an end-user or build factory building official images with this command : `jam -q -sHAIKU_IGNORE_USER_BUILD_CONFIG=1 @alpha-raw` --mmadia From mmlr at mail.berlios.de Sat Jun 13 17:51:23 2009 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sat, 13 Jun 2009 17:51:23 +0200 Subject: [Haiku-commits] r31032 - haiku/trunk/src/add-ons/kernel/partitioning_systems/efi Message-ID: <200906131551.n5DFpNvm003042@sheep.berlios.de> Author: mmlr Date: 2009-06-13 17:51:19 +0200 (Sat, 13 Jun 2009) New Revision: 31032 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31032&view=rev Added: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/PartitionLocker.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/PartitionLocker.h Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/Jamfile haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h Log: Implement most of the logic for write support in the GPT partitioning system. Actual writing is not implemented though and some key functions aren't either. Completely untested so far. Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/Jamfile 2009-06-13 13:56:25 UTC (rev 31031) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/Jamfile 2009-06-13 15:51:19 UTC (rev 31032) @@ -6,4 +6,5 @@ KernelAddon efi_gpt : efi_gpt.cpp + PartitionLocker.cpp ; Copied: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/PartitionLocker.cpp (from rev 31031, haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.cpp) Copied: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/PartitionLocker.h (from rev 31031, haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionLocker.h) Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2009-06-13 13:56:25 UTC (rev 31031) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2009-06-13 15:51:19 UTC (rev 31032) @@ -1,4 +1,5 @@ /* + * Copyright 2009, Michael Lotz, mmlr at mlotz.ch. All rights reserved. * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -11,6 +12,7 @@ # include #else # include +# include "PartitionLocker.h" #endif #include @@ -53,18 +55,32 @@ class Header { public: Header(int fd, off_t block, uint32 blockSize); +#ifndef _BOOT_MODE + // constructor for empty header + Header(off_t block, uint32 blockSize); +#endif ~Header(); status_t InitCheck() const; bool IsPrimary() const { return fBlock == EFI_HEADER_LOCATION; } + uint64 FirstUsableBlock() const + { return fHeader.FirstUsableBlock(); } + uint64 LastUsableBlock() const + { return fHeader.LastUsableBlock(); } + uint32 EntryCount() const { return fHeader.EntryCount(); } - const efi_partition_entry &EntryAt(int32 index) const - { return *(const efi_partition_entry*) + efi_partition_entry &EntryAt(int32 index) const + { return *(efi_partition_entry *) (fEntries + fHeader.EntrySize() * index); } +#ifndef _BOOT_MODE + status_t WriteEntry(int fd, uint32 entryIndex); + status_t Write(int fd); +#endif + private: #ifdef TRACE_EFI_GPT const char *_PrintGUID(const guid_t &id); @@ -141,7 +157,16 @@ } -const char * +#ifndef _BOOT_MODE +static void +to_ucs2(const char *from, size_t fromLength, uint16 *to, size_t maxToLength) +{ + // TODO: implement +} +#endif // !_BOOT_MODE + + +static const char * get_partition_type(const guid_t &guid) { for (uint32 i = 0; i < sizeof(kTypeMap) / sizeof(kTypeMap[0]); i++) { @@ -153,6 +178,32 @@ } +#ifndef _BOOT_MODE +static const static_guid * +guid_for_partition_type(const char *type) +{ + for (uint32 i = 0; i < sizeof(kTypeMap) / sizeof(kTypeMap[0]); i++) { + if (strcmp(kTypeMap[i].type, type) == 0) + return &kTypeMap[i].guid; + } + + return NULL; +} + + +static off_t +block_align(partition_data *partition, off_t offset, bool upwards) +{ + if (upwards) { + return ((offset + partition->block_size - 1) / partition->block_size) + * partition->block_size; + } + + return (offset / partition->block_size) * partition->block_size; +} +#endif // !_BOOT_MODE + + // #pragma mark - @@ -224,6 +275,51 @@ } +#ifndef _BOOT_MODE +Header::Header(off_t block, uint32 blockSize) + : + fBlock(block), + fBlockSize(blockSize), + fStatus(B_NO_INIT), + fEntries(NULL) +{ + // initialize to an empty header + memcpy(fHeader.header, EFI_PARTITION_HEADER, sizeof(fHeader.header)); + fHeader.SetRevision(EFI_TABLE_REVISION); + fHeader.SetHeaderSize(sizeof(fHeader)); + fHeader.SetHeaderCRC(0); + fHeader.SetAbsoluteBlock(fBlock); + fHeader.SetAlternateBlock(0); // TODO + // TODO: set disk guid + fHeader.SetEntriesBlock(EFI_PARTITION_ENTRIES_BLOCK); + fHeader.SetEntryCount(EFI_PARTITION_ENTRY_COUNT); + fHeader.SetEntrySize(EFI_PARTITION_ENTRY_SIZE); + fHeader.SetEntriesCRC(0); + + size_t arraySize = _EntryArraySize(); + fEntries = new (std::nothrow) uint8[arraySize]; + if (fEntries == NULL) { + fStatus = B_NO_MEMORY; + return; + } + + memset(fEntries, 0, arraySize); + // TODO: initialize the entry guids + + fHeader.SetFirstUsableBlock(EFI_PARTITION_ENTRIES_BLOCK + + (arraySize + fBlockSize - 1) / fBlockSize); + fHeader.SetLastUsableBlock(0); // TODO + +#ifdef TRACE_EFI_GPT + _Dump(); + _DumpPartitions(); +#endif + + fStatus = B_OK; +} +#endif // !_BOOT_MODE + + Header::~Header() { delete[] fEntries; @@ -237,6 +333,24 @@ } +#ifndef _BOOT_MODE +status_t +Header::WriteEntry(int fd, uint32 entryIndex) +{ + // TODO: implement + return B_ERROR; +} + + +status_t +Header::Write(int fd) +{ + // TODO: implement + return B_ERROR; +} +#endif // !_BOOT_MODE + + bool Header::_ValidateCRC(uint8 *data, size_t size) const { @@ -348,6 +462,7 @@ partition->status = B_PARTITION_VALID; partition->flags |= B_PARTITION_PARTITIONING_SYSTEM | B_PARTITION_READ_ONLY; partition->content_size = partition->size; + partition->content_cookie = header; // scan all children @@ -381,9 +496,9 @@ child->offset = partition->offset + entry.StartBlock() * partition->block_size; - child->size = (entry.EndBlock() - entry.StartBlock()) - * partition->block_size; + child->size = entry.BlockCount() * partition->block_size; child->block_size = partition->block_size; + child->cookie = (void *)i; } return B_OK; @@ -391,13 +506,695 @@ static void -efi_gpt_free_identify_partition_cookie(partition_data *partition, void *_cookie) +efi_gpt_free_partition_content_cookie(partition_data *partition) { - delete (EFI::Header *)_cookie; + delete (EFI::Header *)partition->content_cookie; } #ifndef _BOOT_MODE +static uint32 +efi_gpt_get_supported_operations(partition_data *partition, uint32 mask) +{ + uint32 flags = B_DISK_SYSTEM_SUPPORTS_INITIALIZING + | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME + | B_DISK_SYSTEM_SUPPORTS_MOVING + | B_DISK_SYSTEM_SUPPORTS_RESIZING + | B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD; + // TODO: check for available entries and partitionable space and only + // add creating child support if both is valid + + return flags; +} + + +static uint32 +efi_gpt_get_supported_child_operations(partition_data *partition, + partition_data *child, uint32 mask) +{ + return B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD + | B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD + | B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE + | B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD; +} + + +static bool +efi_gpt_is_sub_system_for(partition_data *partition) +{ + // a GUID Partition Table doesn't usually live inside another partition + return false; +} + + +static bool +efi_gpt_validate_resize(partition_data *partition, off_t *size) +{ + off_t newSize = *size; + if (newSize == partition->size) + return true; + + if (newSize < 0) + newSize = 0; + else + newSize = block_align(partition, newSize, false); + + // growing + if (newSize > partition->size) { + *size = newSize; + return true; + } + + // shrinking, only so that no child would be truncated + off_t newEnd = partition->offset + newSize; + for (int32 i = 0; i < partition->child_count; i++) { + partition_data *child = get_child_partition(partition->id, i); + if (child == NULL) + continue; + + if (child->offset + child->size > newEnd) + newEnd = child->offset + child->size; + } + + newSize = block_align(partition, newEnd - partition->offset, true); + *size = newSize; + return true; +} + + +static bool +efi_gpt_validate_resize_child(partition_data *partition, partition_data *child, + off_t *size) +{ + off_t newSize = *size; + if (newSize == child->size) + return true; + + // shrinking + if (newSize < child->size) { + if (newSize < 0) + newSize = 0; + + *size = block_align(partition, newSize, false); + return true; + } + + // growing, but only so much that the child doesn't get bigger than + // the parent + if (child->offset + newSize > partition->offset + partition->size) + newSize = partition->offset + partition->size - child->offset; + + // make sure that the child doesn't overlap any sibling partitions + off_t newEnd = child->offset + newSize; + for (int32 i = 0; i < partition->child_count; i++) { + partition_data *other = get_child_partition(partition->id, i); + if (other == NULL || other->id == child->id + || other->offset < child->offset) + continue; + + if (newEnd > other->offset) + newEnd = other->offset; + } + + *size = block_align(partition, newEnd - child->offset, false); + return true; +} + + +static bool +efi_gpt_validate_move(partition_data *partition, off_t *start) +{ + // nothing to do + return true; +} + + +static bool +efi_gpt_validate_move_child(partition_data *partition, partition_data *child, + off_t *start) +{ + off_t newStart = *start; + if (newStart < 0) + newStart = 0; + + if (newStart + child->size > partition->size) + newStart = partition->size - child->size; + + newStart = block_align(partition, newStart, false); + if (newStart > child->offset) { + for (int32 i = 0; i < partition->child_count; i++) { + partition_data *other = get_child_partition(partition->id, i); + if (other == NULL || other->id == child->id + || other->offset < child->offset) + continue; + + if (other->offset < newStart + child->size) + newStart = other->offset - child->size; + } + + newStart = block_align(partition, newStart, false); + } else { + for (int32 i = 0; i < partition->child_count; i++) { + partition_data *other = get_child_partition(partition->id, i); + if (other == NULL || other->id == child->id + || other->offset > child->offset) + continue; + + if (other->offset + other->size > newStart) + newStart = other->offset + other->size; + } + + newStart = block_align(partition, newStart, true); + } + + *start = newStart; + return true; +} + + +static bool +efi_gpt_validate_set_content_name(partition_data *partition, char *name) +{ + // TODO: should validate that the utf-8 -> ucs-2 is valid + // TODO: should count actual utf-8 chars + if (strlen(name) > EFI_PARTITION_NAME_LENGTH) + name[EFI_PARTITION_NAME_LENGTH - 1] = 0; + return true; +} + + +static bool +efi_gpt_validate_set_type(partition_data *partition, const char *type) +{ + return guid_for_partition_type(type) != NULL; +} + + +static bool +efi_gpt_validate_initialize(partition_data *partition, char *name, + const char *parameters) +{ + if ((efi_gpt_get_supported_operations(partition, ~0) + & B_DISK_SYSTEM_SUPPORTS_INITIALIZING) == 0) + return false; + + // name and parameters are ignored + if (name != NULL) + name[0] = 0; + + return true; +} + + +static bool +efi_gpt_validate_create_child(partition_data *partition, off_t *start, + off_t *size, const char *type, const char *parameters, int32 *index) +{ + if ((efi_gpt_get_supported_operations(partition, ~0) + & B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD) == 0) + return false; + + if (guid_for_partition_type(type) == NULL) + return false; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + int32 entryIndex = -1; + for (uint32 i = 0; i < header->EntryCount(); i++) { + const efi_partition_entry &entry = header->EntryAt(i); + if (entry.partition_type == kEmptyGUID) { + entryIndex = i; + break; + } + } + + if (entryIndex < 0) + return false; + *index = entryIndex; + + // ensure that child lies between first and last usable block + off_t firstUsable = header->FirstUsableBlock() * partition->block_size; + if (*start < firstUsable) + *start = firstUsable; + + off_t lastUsable = header->LastUsableBlock() * partition->block_size; + if (*start + *size > lastUsable) { + if (*start > lastUsable) + return false; + + *size = lastUsable - *start; + } + + // ensure that we don't overlap any siblings + for (int32 i = 0; i < partition->child_count; i++) { + partition_data *other = get_child_partition(partition->id, i); + if (other == NULL) + continue; + + if (other->offset < *start && other->offset + other->size > *start) + *start = other->offset + other->size; + + if (other->offset > *start && other->offset < *start + *size) + *size = other->offset - *start; + } + + *start = block_align(partition, *size, true); + *size = block_align(partition, *size, false); + + // TODO: support parameters + return true; +} + + +static status_t +efi_gpt_get_partitionable_spaces(partition_data *partition, + partitionable_space_data *buffer, int32 count, int32 *actualCount) +{ + // TODO: implement + return B_ERROR; +} + + +static status_t +efi_gpt_get_next_supported_type(partition_data *partition, int32 *cookie, + char *type) +{ + // TODO: implement + return B_ERROR; +} + + +static status_t +efi_gpt_shadow_changed(partition_data *partition, partition_data *child, + uint32 operation) +{ + // TODO: implement + return B_ERROR; +} + + +static status_t +efi_gpt_repair(int fd, partition_id partition, bool checkOnly, disk_job_id job) +{ + // TODO: implement, validate CRCs and restore from backup area if corrupt + return B_ERROR; +} + + +static status_t +efi_gpt_resize(int fd, partition_id partitionID, off_t size, disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *partition = get_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + off_t validatedSize = size; + if (!efi_gpt_validate_resize(partition, &validatedSize)) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + partition->size = validatedSize; + partition->content_size = validatedSize; + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} + + +static status_t +efi_gpt_resize_child(int fd, partition_id partitionID, off_t size, + disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *child = get_partition(partitionID); + if (child == NULL) + return B_BAD_VALUE; + + partition_data *partition = get_parent_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + if (header == NULL) + return B_BAD_VALUE; + + uint32 entryIndex = (uint32)child->cookie; + if (entryIndex >= header->EntryCount()) + return B_BAD_VALUE; + + off_t validatedSize = size; + if (!efi_gpt_validate_resize_child(partition, child, &validatedSize)) + return B_BAD_VALUE; + + if (child->size == validatedSize) + return B_OK; + + update_disk_device_job_progress(job, 0.0); + + efi_partition_entry &entry = header->EntryAt(entryIndex); + entry.SetBlockCount(validatedSize / partition->block_size); + + status_t result = header->WriteEntry(fd, entryIndex); + if (result != B_OK) { + entry.SetBlockCount(child->size / partition->block_size); + return result; + } + + child->size = validatedSize; + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} + + +static status_t +efi_gpt_move(int fd, partition_id partition, off_t offset, disk_job_id job) +{ + // nothing to do here + return B_OK; +} + + +static status_t +efi_gpt_move_child(int fd, partition_id partitionID, partition_id childID, + off_t offset, disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *partition = get_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + partition_data *child = get_partition(childID); + if (child == NULL) + return B_BAD_VALUE; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + if (header == NULL) + return B_BAD_VALUE; + + uint32 entryIndex = (uint32)child->cookie; + if (entryIndex >= header->EntryCount()) + return B_BAD_VALUE; + + off_t validatedOffset = offset; + if (!efi_gpt_validate_move_child(partition, child, &validatedOffset)) + return B_BAD_VALUE; + + if (child->offset == validatedOffset) + return B_OK; + + // TODO: implement actual moving, need to move the partition content + // (the raw data) here and need to take overlap into account + return B_ERROR; + + update_disk_device_job_progress(job, 0.0); + + efi_partition_entry &entry = header->EntryAt(entryIndex); + uint64 blockCount = entry.BlockCount(); + entry.SetStartBlock((validatedOffset - partition->offset) + / partition->block_size); + entry.SetBlockCount(blockCount); + + status_t result = header->WriteEntry(fd, entryIndex); + if (result != B_OK) { + // fatal error: the data has been moved but the partition table could + // not be updated to reflect that change! + return result; + } + + child->offset = validatedOffset; + + update_disk_device_job_progress(job, 1.0); + partition_modified(childID); + return B_OK; +} + + +static status_t +efi_gpt_set_content_name(int fd, partition_id partitionID, const char *name, + disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *child = get_partition(partitionID); + if (child == NULL) + return B_BAD_VALUE; + + partition_data *partition = get_parent_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + if (header == NULL) + return B_BAD_VALUE; + + uint32 entryIndex = (uint32)child->cookie; + if (entryIndex >= header->EntryCount()) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + efi_partition_entry &entry = header->EntryAt(entryIndex); + to_ucs2(name, strlen(name), entry.name, EFI_PARTITION_NAME_LENGTH); + + status_t result = header->WriteEntry(fd, entryIndex); + if (result != B_OK) + return result; + + char newName[B_OS_NAME_LENGTH]; + to_utf8(entry.name, EFI_PARTITION_NAME_LENGTH, newName, sizeof(newName)); + child->name = strdup(newName); + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} + + +static status_t +efi_gpt_set_type(int fd, partition_id partitionID, const char *type, + disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *child = get_partition(partitionID); + if (child == NULL) + return B_BAD_VALUE; + + partition_data *partition = get_parent_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + if (header == NULL) + return B_BAD_VALUE; + + uint32 entryIndex = (uint32)child->cookie; + if (entryIndex >= header->EntryCount()) + return B_BAD_VALUE; + + const static_guid *newType = guid_for_partition_type(type); + if (newType == NULL) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + efi_partition_entry &entry = header->EntryAt(entryIndex); + memcpy(&entry.partition_type, newType, sizeof(entry.partition_type)); + + status_t result = header->WriteEntry(fd, entryIndex); + if (result != B_OK) + return result; + + child->type = strdup(type); + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} + + +static status_t +efi_gpt_initialize(int fd, partition_id partitionID, const char *name, + const char *parameters, off_t partitionSize, disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + partition_data *partition = get_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + EFI::Header header(EFI_HEADER_LOCATION, partition->block_size); + status_t result = header.InitCheck(); + if (result != B_OK) + return result; + + result = header.Write(fd); + if (result != B_OK) + return result; + + result = scan_partition(partitionID); + if (result != B_OK) + return result; + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} + + +static status_t +efi_gpt_create_child(int fd, partition_id partitionID, off_t offset, + off_t size, const char *type, const char *parameters, disk_job_id job, + partition_id *childID) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *partition = get_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + if (header == NULL) + return B_BAD_VALUE; + + off_t validatedOffset = offset; + off_t validatedSize = size; + uint32 entryIndex = 0; + + if (!efi_gpt_validate_create_child(partition, &validatedOffset, + &validatedSize, type, parameters, (int32 *)&entryIndex)) + return B_BAD_VALUE; + + const static_guid *newType = guid_for_partition_type(type); + if (newType == NULL) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + partition_data *child = create_child_partition(partition->id, entryIndex, + *childID); + if (child == NULL) + return B_ERROR; + + efi_partition_entry &entry = header->EntryAt(entryIndex); + memcpy(&entry.partition_type, newType, sizeof(entry.partition_type)); + entry.SetStartBlock((validatedOffset - partition->offset) + / partition->block_size); + entry.SetBlockCount(validatedSize / partition->block_size); + entry.SetAttributes(0); // TODO + + status_t result = header->WriteEntry(fd, entryIndex); + if (result != B_OK) { + delete_partition(child->id); + return result; + } + + *childID = child->id; + child->offset = validatedOffset; + child->size = validatedSize; + child->block_size = partition->block_size; + child->type = strdup(type); + child->parameters = strdup(parameters); + child->cookie = (void *)entryIndex; + + if (child->type == NULL || child->parameters == NULL) { + delete_partition(child->id); + return B_NO_MEMORY; + } + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} + + +static status_t +efi_gpt_delete_child(int fd, partition_id partitionID, partition_id childID, + disk_job_id job) +{ + if (fd < 0) + return B_ERROR; + + PartitionWriteLocker locker(partitionID); + if (!locker.IsLocked()) + return B_ERROR; + + partition_data *partition = get_partition(partitionID); + if (partition == NULL) + return B_BAD_VALUE; + + partition_data *child = get_partition(childID); + if (child == NULL) + return B_BAD_VALUE; + + EFI::Header *header = (EFI::Header *)partition->content_cookie; + if (header == NULL) + return B_BAD_VALUE; + + uint32 entryIndex = (uint32)child->cookie; + if (entryIndex >= header->EntryCount()) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + if (!delete_partition(childID)) + return B_ERROR; + + efi_partition_entry &entry = header->EntryAt(entryIndex); + entry.partition_type = kEmptyGUID; + + status_t result = header->WriteEntry(fd, entryIndex); + if (result != B_OK) + return result; + + update_disk_device_job_progress(job, 1.0); + partition_modified(partitionID); + return B_OK; +} +#endif // !_BOOT_MODE + + +#ifndef _BOOT_MODE static partition_module_info sEFIPartitionModule = { #else partition_module_info gEFIPartitionModule = { @@ -409,13 +1206,68 @@ }, "efi", // short_name EFI_PARTITION_NAME, // pretty_name - 0, // flags + 0 // flags + | B_DISK_SYSTEM_SUPPORTS_INITIALIZING + | B_DISK_SYSTEM_SUPPORTS_MOVING + | B_DISK_SYSTEM_SUPPORTS_RESIZING + | B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE + | B_DISK_SYSTEM_SUPPORTS_CONTENT_NAME + | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME + | B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD + | B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD + | B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD + | B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD + , // scanning efi_gpt_identify_partition, efi_gpt_scan_partition, - efi_gpt_free_identify_partition_cookie, - NULL, + NULL, // free_identify_partition_cookie + NULL, // free_partition_cookie + efi_gpt_free_partition_content_cookie, + +#ifndef _BOOT_MODE + // querying + efi_gpt_get_supported_operations, + efi_gpt_get_supported_child_operations, + NULL, // supports_initializing_child + efi_gpt_is_sub_system_for, + + efi_gpt_validate_resize, + efi_gpt_validate_resize_child, + efi_gpt_validate_move, + efi_gpt_validate_move_child, + NULL, // validate_set_name + efi_gpt_validate_set_content_name, + efi_gpt_validate_set_type, + NULL, // validate_set_parameters + NULL, // validate_set_content_parameters + efi_gpt_validate_initialize, + efi_gpt_validate_create_child, + efi_gpt_get_partitionable_spaces, + efi_gpt_get_next_supported_type, + NULL, // get_type_for_content_type + + // shadow partition modification + efi_gpt_shadow_changed, + + // writing + efi_gpt_repair, + efi_gpt_resize, + efi_gpt_resize_child, + efi_gpt_move, + efi_gpt_move_child, + NULL, // set_name + efi_gpt_set_content_name, + efi_gpt_set_type, + NULL, // set_parameters + NULL, // set_content_parameters + efi_gpt_initialize, + efi_gpt_create_child, + efi_gpt_delete_child +#else + NULL +#endif // _BOOT_MODE }; #ifndef _BOOT_MODE Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h 2009-06-13 13:56:25 UTC (rev 31031) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h 2009-06-13 15:51:19 UTC (rev 31032) @@ -31,36 +31,62 @@ // the rest of the block is reserved + void SetRevision(uint32 revision) + { revision = B_HOST_TO_LENDIAN_INT32(revision); } uint32 Revision() const { return B_LENDIAN_TO_HOST_INT32(revision); } + void SetHeaderSize(uint32 size) [... truncated: 83 lines follow ...] From humdingerb at mail.berlios.de Sat Jun 13 18:43:32 2009 From: humdingerb at mail.berlios.de (humdingerb at mail.berlios.de) Date: Sat, 13 Jun 2009 18:43:32 +0200 Subject: [Haiku-commits] r31033 - in haiku/trunk/docs/userguide: en en/applications en/preferences images/apps-images images/prefs-images Message-ID: <200906131643.n5DGhWMl017183@sheep.berlios.de> Author: humdingerb Date: 2009-06-13 18:43:13 +0200 (Sat, 13 Jun 2009) New Revision: 31033 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31033&view=rev Added: haiku/trunk/docs/userguide/en/applications/apps-charactermap.html haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_16.png haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_32.png haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_64.png haiku/trunk/docs/userguide/images/apps-images/charactermap.png Removed: haiku/trunk/docs/userguide/en/preferences/prefs-menu.html Modified: haiku/trunk/docs/userguide/en/applications.html haiku/trunk/docs/userguide/en/applications/apps-activitymonitor.html haiku/trunk/docs/userguide/en/applications/apps-cdplayer.html haiku/trunk/docs/userguide/en/applications/apps-codycam.html haiku/trunk/docs/userguide/en/keyboard-shortcuts.html haiku/trunk/docs/userguide/en/preferences.html haiku/trunk/docs/userguide/en/preferences/prefs-backgrounds.html haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html haiku/trunk/docs/userguide/en/preferences/prefs-media.html haiku/trunk/docs/userguide/en/preferences/prefs-mouse.html haiku/trunk/docs/userguide/images/apps-images/activitymonitor.png haiku/trunk/docs/userguide/images/apps-images/poorman-icon_16.png haiku/trunk/docs/userguide/images/apps-images/poorman-icon_32.png haiku/trunk/docs/userguide/images/apps-images/poorman-icon_64.png haiku/trunk/docs/userguide/images/prefs-images/fonts.png Log: * Added the drag&drop of images in Backgrounds preferences. * Updated ActivityMonitor with the interval setting panel and took a new screenshot. * Added documentation, icons, screenshot for CharacterMap (comments welcome, as I'm not excatly the target for this app, I guess). Added entry in Applications contents and adjusted links accordingly. * Removed Menu preferences as it's settings have been moved to other panels. Adjusted links to it accordingly. * Added zuMi's fine Poorman icon (Poor man, carries the weight of the planet.) Modified: haiku/trunk/docs/userguide/en/applications/apps-activitymonitor.html =================================================================== --- haiku/trunk/docs/userguide/en/applications/apps-activitymonitor.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/applications/apps-activitymonitor.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -43,15 +43,16 @@

You can track system resources by launching the ActivityMonitor and activating different items of interest.

-activitymonitor.png +activitymonitor.png

By right-clicking into the window, you can toggle the display of all kinds of resources:
-Used/Cached Memory, Swap Space, CPU Usage, Network Receive/Send, Page faults, Semaphores, Ports, Threads, Teams, Running Applications, Raw/Text Clipboard Size, Media Nodes

+Used/Cached Memory, Swap Space, CPU Usage, Network Receive/Send, Page faults, Semaphores, Ports, Threads, Teams, Running Applications, Raw/Text Clipboard Size, Media Nodes.

Below the graphics is a legend (hideable from the context menu). You can change their colors and that of the graph's background via drag&drop from any color picker, e.g. from Icon-O-Matic.

You can add more views from the File menu if it gets too crowded.

+

The Settings menu opens a panel where you can set the update interval.

Each view has it's own Replicator handle and can thus be arranged, for example, on the Desktop.

- + Modified: haiku/trunk/docs/userguide/en/applications/apps-cdplayer.html =================================================================== --- haiku/trunk/docs/userguide/en/applications/apps-cdplayer.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/applications/apps-cdplayer.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -30,7 +30,7 @@     Previous: BeZillaBrowser     - Next: CodyCam + Next: CharacterMap

@@ -60,7 +60,7 @@     Previous: BeZillaBrowser     - Next: CodyCam + Next: CharacterMap

--> Added: haiku/trunk/docs/userguide/en/applications/apps-charactermap.html =================================================================== --- haiku/trunk/docs/userguide/en/applications/apps-charactermap.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/applications/apps-charactermap.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -0,0 +1,65 @@ + + + + + + + + + CharacterMap + + + + + +
+

+ Applications +     + Previous: CDPlayer +     + Next: CodyCam +

+
+ +
+ +

charactermap-icon_64.pngCharacterMap

+ + + + +
Deskbar:Applications
Location:/boot/system/apps/CharacterMap
Settings:~/config/settings/CharacterMap settings
+ +

CharacterMap will show you the UTF-8 code of every character a font supports.

+charactermap.png +

To the left you have the standardized blocks, together with a handy filter function. Optionally, you can choose to also Show Private Blocks from the View menu. The right shows the actual characters in these blocks, using the font specified in the Font menu. Below that you can change the font size. And below that, the values of the character currently under the mouse pointer is displayed in hex, decimal and UTF-8 notation.

+

You can drag&drop a character directly from the character map into a text editor, or right-click on one to either Copy Character (ALT C) or Copy As Escaped Byte String (SHIFT ALT C). Resulting in, e.g. either or \xe2\x82\xac. + +

+ + + Modified: haiku/trunk/docs/userguide/en/applications/apps-codycam.html =================================================================== --- haiku/trunk/docs/userguide/en/applications/apps-codycam.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/applications/apps-codycam.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -28,7 +28,7 @@

Applications     - Previous: CDPlayer + Previous: CharacterMap     Next: DeskCalc

@@ -55,9 +55,9 @@

Applications     - Previous: BePDF + Previous: CharacterMap     - Next: CodyCam + Next: DeskCalc

--> Modified: haiku/trunk/docs/userguide/en/applications.html =================================================================== --- haiku/trunk/docs/userguide/en/applications.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/applications.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -71,6 +71,8 @@ A web browser based on Mozilla's source code. iconCDPlayer  A player for audio CDs. + iconCharacterMap  + An application that shows the Unicode character map. [still missing] iconCodyCam  A tool to regularly upload images from a webcam to a server. iconDeskCalc  Modified: haiku/trunk/docs/userguide/en/keyboard-shortcuts.html =================================================================== --- haiku/trunk/docs/userguide/en/keyboard-shortcuts.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/keyboard-shortcuts.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -37,7 +37,7 @@

By default, Haiku's option key, to invoke commands from menus for example, is not the usual CTRL key, but ALT instead. This has historical reasons, because the BeOS was inspired somewhat by MacOS. After you get used to it, it actually feels better as e.g. ALT C and ALT V is reached more conveniently on the keyboard and these commands seamlessly integrate into the bash shell of the Terminal, where CTRL C quits the running process.

-

In any case, you can switch to the maybe more familiar CTRL key in the Menu preferences. The user guide will always describes the default configuration with option key being ALT.

+

In any case, you can switch to the maybe more familiar CTRL key in the Keymap preferences. The user guide will always describes the default configuration with option key being ALT.

General shortcuts

Here's a table of many of the most commonly used shortcuts that are always available, even if there isn't a corresponding menu:

Modified: haiku/trunk/docs/userguide/en/preferences/prefs-backgrounds.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-backgrounds.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/preferences/prefs-backgrounds.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -48,7 +48,7 @@


backgrounds.png

The top drop-down menu specifies if your changes are applied to the current workspace, all workspaces, a specific folder or as default for every new folder.

-

Below that you can assign an image or select None if you want simply a colored background.

+

Below that you can assign an image or select None if you want simply a colored background. Images can also be drag&dropped onto the preview to the left.

If you are using an image, you have to decide on the placement:

Modified: haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -44,7 +44,7 @@ ~/config/settings/Font_settings - Stores the panel's window position.
Manual lets you specify the coordinates. You can drag the picture around in the preview to the left or enter X and Y manually.


-fonts.png +fonts.png

Haiku defines three standard fonts for different purposes. You set plain, bold and fixed font types and sizes that will be used throughout the system.

Modified: haiku/trunk/docs/userguide/en/preferences/prefs-media.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-media.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/preferences/prefs-media.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -30,7 +30,7 @@     Previous: Keymap     - Next: Menu + Next: Mouse

@@ -54,7 +54,7 @@     Previous: Keymap     - Next: Menu + Next: Mouse

Deleted: haiku/trunk/docs/userguide/en/preferences/prefs-menu.html Modified: haiku/trunk/docs/userguide/en/preferences/prefs-mouse.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-mouse.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/preferences/prefs-mouse.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -28,7 +28,7 @@

Preferences     - Previous: Menu + Previous: Media     Next: Network

@@ -66,7 +66,7 @@

Preferences     - Previous: Menu + Previous: Media     Next: Network

Modified: haiku/trunk/docs/userguide/en/preferences.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences.html 2009-06-13 15:51:19 UTC (rev 31032) +++ haiku/trunk/docs/userguide/en/preferences.html 2009-06-13 16:43:13 UTC (rev 31033) @@ -57,8 +57,6 @@ - - Modified: haiku/trunk/docs/userguide/images/apps-images/activitymonitor.png =================================================================== (Binary files differ) Added: haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_16.png =================================================================== (Binary files differ) Property changes on: haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_16.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_32.png =================================================================== (Binary files differ) Property changes on: haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_32.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_64.png =================================================================== (Binary files differ) Property changes on: haiku/trunk/docs/userguide/images/apps-images/charactermap-icon_64.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: haiku/trunk/docs/userguide/images/apps-images/charactermap.png =================================================================== (Binary files differ) Property changes on: haiku/trunk/docs/userguide/images/apps-images/charactermap.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: haiku/trunk/docs/userguide/images/apps-images/poorman-icon_16.png =================================================================== (Binary files differ) Modified: haiku/trunk/docs/userguide/images/apps-images/poorman-icon_32.png =================================================================== (Binary files differ) Modified: haiku/trunk/docs/userguide/images/apps-images/poorman-icon_64.png =================================================================== (Binary files differ) Modified: haiku/trunk/docs/userguide/images/prefs-images/fonts.png =================================================================== (Binary files differ) From humdingerb at mail.berlios.de Sat Jun 13 18:48:13 2009 From: humdingerb at mail.berlios.de (humdingerb at mail.berlios.de) Date: Sat, 13 Jun 2009 18:48:13 +0200 Subject: [Haiku-commits] r31034 - haiku/trunk/docs/userguide/en/preferences Message-ID: <200906131648.n5DGmDX3020288@sheep.berlios.de> Author: humdingerb Date: 2009-06-13 18:48:12 +0200 (Sat, 13 Jun 2009) New Revision: 31034 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31034&view=rev Modified: haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html Log: Forgot to mention the super-special-extra setting for the menu font... Modified: haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html 2009-06-13 16:43:13 UTC (rev 31033) +++ haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html 2009-06-13 16:48:12 UTC (rev 31034) @@ -45,7 +45,7 @@
Defaults resets everything to default values.
Set the mapping of your keyboard.
iconMedia  Audio and video settings like in/output devices and the system's audio mixer.
iconMenu Configure the behavior of menus and the command key (CTRL/ALT).
iconMouse  Configure your mouse.
iconNetwork 


fonts.png -

Haiku defines three standard fonts for different purposes. You set plain, bold and fixed font types and sizes that will be used throughout the system.

+

Haiku defines three standard fonts for different purposes. You set plain, bold and fixed font types and sizes that will be used throughout the system. Besides these, there's also a separate setting for the font used in menus.

From stippi at mail.berlios.de Sat Jun 13 19:07:11 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 13 Jun 2009 19:07:11 +0200 Subject: [Haiku-commits] r31035 - haiku/trunk/src/apps/mediaplayer Message-ID: <200906131707.n5DH7BHf006853@sheep.berlios.de> Author: stippi Date: 2009-06-13 19:06:58 +0200 (Sat, 13 Jun 2009) New Revision: 31035 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31035&view=rev Modified: haiku/trunk/src/apps/mediaplayer/MainApp.cpp Log: When the media server is not running, display an alert and offer to start it. Modified: haiku/trunk/src/apps/mediaplayer/MainApp.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/MainApp.cpp 2009-06-13 16:48:12 UTC (rev 31034) +++ haiku/trunk/src/apps/mediaplayer/MainApp.cpp 2009-06-13 17:06:58 UTC (rev 31035) @@ -124,14 +124,6 @@ void MainApp::ReadyToRun() { - // make sure we have at least one window open - FirstWindow(); - - // setup the settings window now, we need to have it - fSettingsWindow = new SettingsWindow(BRect(150, 150, 450, 520)); - fSettingsWindow->Hide(); - fSettingsWindow->Show(); - // Now tell the application roster, that we're interested // in getting notifications of apps being launched or quit. // In this way we are going to detect a media_server restart. @@ -139,8 +131,32 @@ B_REQUEST_LAUNCHED | B_REQUEST_QUIT); // we will keep track of the status of media_server // and media_addon_server - fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); + fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig); + + if (!fMediaServerRunning || !fMediaAddOnServerRunning) { + BAlert* alert = new BAlert("start_media_server", + "It appears the Media Server is not running.\n" + "Would you like to start it ?", "Quit", "Start Media Server", NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT); + if (alert->Go() == 0) { + PostMessage(B_QUIT_REQUESTED); + return; + } + + launch_media_server(); + + fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); + fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig); + } + + // make sure we have at least one window open + FirstWindow(); + + // setup the settings window now, we need to have it + fSettingsWindow = new SettingsWindow(BRect(150, 150, 450, 520)); + fSettingsWindow->Hide(); + fSettingsWindow->Show(); } From revol at free.fr Sat Jun 13 20:55:09 2009 From: revol at free.fr (=?utf-8?q?Fran=C3=A7ois?= Revol) Date: Sat, 13 Jun 2009 20:55:09 +0200 CEST Subject: [Haiku-commits] r31031 - haiku/trunk/data/artwork/icons In-Reply-To: <200906131356.n5DDuRCt022609@sheep.berlios.de> Message-ID: <6662139254-BeMail@laptop> > Log: > Added BeHappy icon by zuMi. Thanks a lot and sorry for the delay! > This is not > yet added to the BeHappy package AFAIK. > Cool, I just added it to the BeHappy svn on osdrawer. Fran?ois. From ingo_weinhold at gmx.de Sat Jun 13 20:55:19 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 13 Jun 2009 20:55:19 +0200 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <1e42d8c50906130758h63d825f3r1b4dd8ed3ec04a74@mail.gmail.com> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> <1e42d8c50906130758h63d825f3r1b4dd8ed3ec04a74@mail.gmail.com> Message-ID: <20090613205519.426.2@knochen-vm.localdomain> On 2009-06-13 at 16:58:05 [+0200], Matt Madia wrote: > On Wed, May 27, 2009 at 1:12 AM, wrote: > > @@ -416,7 +465,7 @@ > > if $(TARGET_ARCH) != x86 { > > Echo "No optional package OpenSSH available for > > $(TARGET_ARCH)" ; > > } else { > > - if ! $(HAIKU_IMAGE_HOST_NAME) { > > + if ! $(HAIKU_IMAGE_HOST_NAME) && ! > > $(HAIKU_IGNORE_USER_BUILD_CONFIG) { > > Exit "Optional package OpenSSH requires the > > HAIKU_IMAGE_HOST_NAME" > > "variable to be set!" ; > > } > > sorry for dragging up an older commit email... > > What's the reason for having OpenSSH test for > && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) ? HAIKU_IGNORE_USER_BUILD_CONFIG was mainly intended for the "alternative" part of the hybrid build. And in that case HAIKU_IMAGE_HOST_NAME won't be set, so this check would always fail. > The usage case I was looking at is an end-user or build factory > building official images with this command : > `jam -q -sHAIKU_IGNORE_USER_BUILD_CONFIG=1 @alpha-raw` Since the build profile explicitly sets the host name variable, there shouldn't be any problem. Or do I miss something? CU, Ingo From oruizdorantes at mail.berlios.de Sat Jun 13 21:17:11 2009 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Sat, 13 Jun 2009 21:17:11 +0200 Subject: [Haiku-commits] r31036 - in haiku/trunk: headers/os/bluetooth/HCI src/add-ons/kernel/drivers/bluetooth/h2/h2generic src/servers/bluetooth Message-ID: <200906131917.n5DJHBFQ006681@sheep.berlios.de> Author: oruizdorantes Date: 2009-06-13 21:17:10 +0200 (Sat, 13 Jun 2009) New Revision: 31036 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31036&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp haiku/trunk/src/servers/bluetooth/BluetoothServer.h haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp Log: - Long events were locking the bluetooth server, as events can be more than 256 counting with the header. - Add debug more information in H2 driver and Command Status event - Change name of port for posting events(former was too long) Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2009-06-13 17:06:58 UTC (rev 31035) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2009-06-13 19:17:10 UTC (rev 31036) @@ -75,7 +75,7 @@ #define BT_IOCTLS_OFFSET 3000 enum { - ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, + ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, //12999 GET_STATS, GET_NOTIFICATION_PORT, GET_HCI_ID, @@ -89,7 +89,7 @@ /* Port drivers can use to send information (1 for all for at moment refer to ioctl GET_NOTIFICATION_PORT)*/ -#define BT_USERLAND_PORT_NAME "bluetooth kernel-user Land" +#define BT_USERLAND_PORT_NAME "Kernel-User Event" #define BLUETOOTH_CONNECTION_PORT "bluetooth connection port" #define BLUETOOTH_CONNECTION_SCHED_PORT "bluetooth con sched port" Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2009-06-13 17:06:58 UTC (rev 31035) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2009-06-13 19:17:10 UTC (rev 31036) @@ -164,6 +164,8 @@ //bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option status_t error; + debugf("cookie@%p status=%ld len=%ld\n", cookie, status, actual_len); + if (bdev == NULL) return; Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c 2009-06-13 17:06:58 UTC (rev 31035) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c 2009-06-13 19:17:10 UTC (rev 31036) @@ -14,7 +14,7 @@ #include "h2transactions.h" #include "snet_buffer.h" -//#define BT_DEBUG_THIS_MODULE +#define BT_DEBUG_THIS_MODULE #include @@ -93,14 +93,14 @@ if (type == BT_EVENT) { snet_buffer* snbuf = (snet_buffer*)buf; - flowf("to btDataCore\n"); btCoreData->PostEvent(bdev->ndev, snb_get(snbuf), (size_t)snb_size(snbuf)); snb_park(&bdev->snetBufferRecycleTrash, snbuf); + debugf("to btDataCore len=%d\n", snb_size(snbuf)); } else { net_buffer* nbuf = (net_buffer*) buf; /* No need to free the buffer at allocation is gonna be reused */ - flowf("to net_device\n"); btDevices->receive_data(bdev->ndev, &nbuf); + flowf("to net_device\n"); } return err; Modified: haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp =================================================================== --- haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp 2009-06-13 17:06:58 UTC (rev 31035) +++ haiku/trunk/src/servers/bluetooth/BluetoothServer.cpp 2009-06-13 19:17:10 UTC (rev 31036) @@ -32,14 +32,16 @@ { // we only handle events if (GET_PORTCODE_TYPE(code)!= BT_EVENT) { - Output::Instance()->Post("Wrong type frame code", BLACKBOARD_GENERAL); + Output::Instance()->Post("Wrong type frame code", BLACKBOARD_KIT); return B_OK; } // fetch the LocalDevice who belongs this event - LocalDeviceImpl* lDeviceImplementation = ((BluetoothServer*)be_app)->LocateLocalDeviceImpl(GET_PORTCODE_HID(code)); + LocalDeviceImpl* lDeviceImplementation = ((BluetoothServer*)be_app)-> + LocateLocalDeviceImpl(GET_PORTCODE_HID(code)); + if (lDeviceImplementation == NULL) { - Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_GENERAL); + Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_KIT); return B_OK; } Modified: haiku/trunk/src/servers/bluetooth/BluetoothServer.h =================================================================== --- haiku/trunk/src/servers/bluetooth/BluetoothServer.h 2009-06-13 17:06:58 UTC (rev 31035) +++ haiku/trunk/src/servers/bluetooth/BluetoothServer.h 2009-06-13 19:17:10 UTC (rev 31036) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BLUETOOTH_SERVER_APP_H #define _BLUETOOTH_SERVER_APP_H @@ -38,7 +35,10 @@ #define BLACKBOARD_LD(X) (BLACKBOARD_END+X-HCI_DEVICE_INDEX_OFFSET) typedef BObjectList LocalDevicesList; -typedef PortListener BluetoothPortListener; +typedef PortListener BluetoothPortListener; class BluetoothServer : public BApplication { Modified: haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp =================================================================== --- haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp 2009-06-13 17:06:58 UTC (rev 31035) +++ haiku/trunk/src/servers/bluetooth/LocalDeviceImpl.cpp 2009-06-13 19:17:10 UTC (rev 31036) @@ -481,8 +481,8 @@ // Handle command complete information request->FindInt16("opcodeExpected", index, &opcodeExpected); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for %s\n",__FUNCTION__, - event->ncmd,GetCommand(opcodeExpected)); + Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) %x for %s\n",__FUNCTION__, + event->ncmd, event->status, GetCommand(event->opcode)); if (request->IsSourceWaiting() == false) Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT); From oliver.ruiz.dorantes at gmail.com Sat Jun 13 21:21:51 2009 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Sat, 13 Jun 2009 21:21:51 +0200 Subject: [Haiku-commits] r31015 - in haiku/trunk: headers/private/bluetooth src/servers/bluetooth In-Reply-To: References: <200906121814.n5CIEqYF024897@sheep.berlios.de> <7e5795b0906121956n2dabe911nb36585132f48f50@mail.gmail.com> Message-ID: 2009/6/13 J?r?me Duval > 2009/6/13 Joseph Prostko > >: > > On Fri, Jun 12, 2009 at 2:14 PM, oruizdorantes at > > BerliOS wrote: > >> Author: oruizdorantes > >> Date: 2009-06-12 20:14:51 +0200 (Fri, 12 Jun 2009) > >> New Revision: 31015 > >> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31015&view=rev > > > > I just ran an SVN up from yesterday and tried a build. I got the > > following errors on a cross-compile from Linux doing a GCC4 build > > (work-in-progress GCC 4.4). > > Should be fine with r31025. > > Bye, > J?r?me > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Oliver, http://urnenfeld.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From oliver.ruiz.dorantes at gmail.com Sat Jun 13 21:22:30 2009 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Sat, 13 Jun 2009 21:22:30 +0200 Subject: [Haiku-commits] r31015 - in haiku/trunk: headers/private/bluetooth src/servers/bluetooth In-Reply-To: References: <200906121814.n5CIEqYF024897@sheep.berlios.de> <7e5795b0906121956n2dabe911nb36585132f48f50@mail.gmail.com> Message-ID: Thanks J?r?me -------------- next part -------------- An HTML attachment was scrubbed... URL: From superstippi at gmx.de Sat Jun 13 21:43:05 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 13 Jun 2009 21:43:05 +0200 Subject: [Haiku-commits] r31031 - haiku/trunk/data/artwork/icons In-Reply-To: <6662139254-BeMail@laptop> References: <6662139254-BeMail@laptop> Message-ID: <20090613214305.15000.1@bepc.1244911975.fake> On 2009-06-13 at 20:55:09 [+0200], Fran?ois Revol wrote: > > Log: > > Added BeHappy icon by zuMi. Thanks a lot and sorry for the delay! This > > is not > > yet added to the BeHappy package AFAIK. > > > > Cool, > I just added it to the BeHappy svn on osdrawer. Thanks! Best regards, -Stephan From mattmadia at gmail.com Sat Jun 13 22:20:49 2009 From: mattmadia at gmail.com (Matt Madia) Date: Sat, 13 Jun 2009 20:20:49 +0000 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <20090613205519.426.2@knochen-vm.localdomain> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> <1e42d8c50906130758h63d825f3r1b4dd8ed3ec04a74@mail.gmail.com> <20090613205519.426.2@knochen-vm.localdomain> Message-ID: <1e42d8c50906131320w70b83884ob53ea03df237f32d@mail.gmail.com> On Sat, Jun 13, 2009 at 6:55 PM, Ingo Weinhold wrote: > > On 2009-06-13 at 16:58:05 [+0200], Matt Madia wrote: >> On Wed, May 27, 2009 at 1:12 AM, wrote: >> > @@ -416,7 +465,7 @@ >> > if $(TARGET_ARCH) != x86 { >> > Echo "No optional package OpenSSH available for >> > $(TARGET_ARCH)" ; >> > } else { >> > - if ! $(HAIKU_IMAGE_HOST_NAME) { >> > + if ! $(HAIKU_IMAGE_HOST_NAME) && ! >> > $(HAIKU_IGNORE_USER_BUILD_CONFIG) { >> > Exit "Optional package OpenSSH requires the >> > HAIKU_IMAGE_HOST_NAME" >> > "variable to be set!" ; >> > } >> >> sorry for dragging up an older commit email... >> >> What's the reason for having OpenSSH test for >> && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) ? > > HAIKU_IGNORE_USER_BUILD_CONFIG was mainly intended for the "alternative" > part of the hybrid build. And in that case HAIKU_IMAGE_HOST_NAME won't be > set, so this check would always fail. >> The usage case I was looking at is an end-user or build factory >> building official images with this command : >> `jam -q -sHAIKU_IGNORE_USER_BUILD_CONFIG=1 @alpha-raw` > > Since the build profile explicitly sets the host name variable, there > shouldn't be any problem. Or do I miss something? > With the above jam command, OpenSSH will be skipped due to this test in OptionalPackages if ! $(HAIKU_IMAGE_HOST_NAME) && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) { Oddly, OpenSSH is the only package that checks for !$(HAIKU_IGNORE_USER_BUILD_CONFIG) So basically, i'm wondering if the 2nd part of the above if statement could be removed. From anevilyak at mail.berlios.de Sun Jun 14 00:07:31 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 14 Jun 2009 00:07:31 +0200 Subject: [Haiku-commits] r31037 - haiku/trunk/data/common/boot/post_install Message-ID: <200906132207.n5DM7Vm3027396@sheep.berlios.de> Author: anevilyak Date: 2009-06-14 00:07:31 +0200 (Sun, 14 Jun 2009) New Revision: 31037 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31037&view=rev Modified: haiku/trunk/data/common/boot/post_install/mime_update.sh Log: Update fallback path used if finddir fails to correspond to the new directory structure. Resolves ticket #4019. Modified: haiku/trunk/data/common/boot/post_install/mime_update.sh =================================================================== --- haiku/trunk/data/common/boot/post_install/mime_update.sh 2009-06-13 19:17:10 UTC (rev 31036) +++ haiku/trunk/data/common/boot/post_install/mime_update.sh 2009-06-13 22:07:31 UTC (rev 31037) @@ -2,7 +2,7 @@ # Make sure all apps have a MIME DB entry. -SYSTEM=$(/bin/finddir B_SYSTEM_DIRECTORY 2>/dev/null || echo "/boot/beos") +SYSTEM=$(/bin/finddir B_SYSTEM_DIRECTORY 2>/dev/null || echo "/boot/system") mimeset -apps -f "$SYSTEM/apps" mimeset -f "$SYSTEM/documentation" From ingo_weinhold at gmx.de Sat Jun 13 23:09:47 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 13 Jun 2009 23:09:47 +0200 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <1e42d8c50906131320w70b83884ob53ea03df237f32d@mail.gmail.com> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> <1e42d8c50906130758h63d825f3r1b4dd8ed3ec04a74@mail.gmail.com> <20090613205519.426.2@knochen-vm.localdomain> <1e42d8c50906131320w70b83884ob53ea03df237f32d@mail.gmail.com> Message-ID: <20090613230947.407.1@knochen-vm.localdomain> On 2009-06-13 at 22:20:49 [+0200], Matt Madia wrote: > On Sat, Jun 13, 2009 at 6:55 PM, Ingo Weinhold wrote: > > On 2009-06-13 at 16:58:05 [+0200], Matt Madia wrote: > >> The usage case I was looking at is an end-user or build factory > >> building official images with this command : > >> `jam -q -sHAIKU_IGNORE_USER_BUILD_CONFIG=1 @alpha-raw` > > > > Since the build profile explicitly sets the host name variable, there > > shouldn't be any problem. Or do I miss something? > > > With the above jam command, OpenSSH will be skipped due to this test > in OptionalPackages > if ! $(HAIKU_IMAGE_HOST_NAME) && ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) { If OpenSSH is skipped, then it shouldn't be because of this test. If you have a look at the complete "if" block, you'll see that it this is only the error case that HAIKU_IMAGE_HOST_NAME has not been specified although the OpenSSL optional package has been added. The "&& ! $(HAIKU_IGNORE_USER_BUILD_CONFIG)" part just disables the check, when HAIKU_IGNORE_USER_BUILD_CONFIG is set. > Oddly, OpenSSH is the only package that checks for > !$(HAIKU_IGNORE_USER_BUILD_CONFIG) > > So basically, i'm wondering if the 2nd part of the above if statement > could be removed. Nope, besides that I think it is not related it would break the hybrid build. CU, Ingo From anevilyak at mail.berlios.de Sun Jun 14 02:37:09 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 14 Jun 2009 02:37:09 +0200 Subject: [Haiku-commits] r31038 - haiku/trunk/src/preferences/media Message-ID: <200906140037.n5E0b9gQ020642@sheep.berlios.de> Author: anevilyak Date: 2009-06-14 02:37:07 +0200 (Sun, 14 Jun 2009) New Revision: 31038 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31038&view=rev Modified: haiku/trunk/src/preferences/media/MediaViews.cpp haiku/trunk/src/preferences/media/MediaViews.h haiku/trunk/src/preferences/media/MediaWindow.cpp Log: The Media preflet was using a mix of old and layout style primitives to set itself up. As a consequence resizing basically didn't work correctly at all. Fixes ticket #3427. Modified: haiku/trunk/src/preferences/media/MediaViews.cpp =================================================================== --- haiku/trunk/src/preferences/media/MediaViews.cpp 2009-06-13 22:07:31 UTC (rev 31037) +++ haiku/trunk/src/preferences/media/MediaViews.cpp 2009-06-14 00:37:07 UTC (rev 31038) @@ -31,8 +31,8 @@ #include "MediaViews.h" -BarView::BarView(BRect frame) - : BView (frame, "barView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW ), +BarView::BarView() + : BView ("barView", B_WILL_DRAW ), fDisplay(true) { } @@ -56,24 +56,18 @@ } -SettingsView::SettingsView (BRect frame, bool isVideo) - : BView (frame, "SettingsView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ), +SettingsView::SettingsView (bool isVideo) + : BView ("SettingsView", B_WILL_DRAW | B_SUPPORTS_LAYOUT), fIsVideo(isVideo) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - BRect rect(frame); - rect.left += 10; - rect.top += 12; - rect.right -=21; - rect.bottom = rect.top + 104; - BBox *defaultsBox = new BBox(rect, "defaults"); + BBox *defaultsBox = new BBox("defaults"); defaultsBox->SetLabel(fIsVideo ? "Default Nodes" : "Defaults"); // create the default box BGroupLayout* defaultBoxLayout = new BGroupLayout(B_VERTICAL, 5); - float inset = defaultsBox->Frame().left - defaultsBox->InnerFrame().left; - defaultBoxLayout->SetInsets(inset, defaultsBox->TopBorderOffset() * 2, inset, inset); + defaultBoxLayout->SetInsets(10,10,10,10); defaultsBox->SetLayout(defaultBoxLayout); defaultBoxLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5)); @@ -82,19 +76,17 @@ defaultsBox->GetLayout()->AddView(inputField); defaultsBox->GetLayout()->AddView(outputField); - BRect defaultRect(20, 22, 250, 40); float divider = StringWidth(fIsVideo ? "Video Output:" : "Audio Output:") + 5; fMenu1 = new BPopUpMenu(""); fMenu1->SetLabelFromMarked(true); - BMenuField *menuField1 = new BMenuField(defaultRect, "menuField1", - fIsVideo ? "Video Input:" : "Audio Input:", fMenu1); + BMenuField *menuField1 = new BMenuField("menuField1", + fIsVideo ? "Video Input:" : "Audio Input:", fMenu1, NULL); menuField1->SetDivider(divider); - defaultRect.OffsetBy(0, 26); fMenu2 = new BPopUpMenu(""); fMenu2->SetLabelFromMarked(true); - BMenuField *menuField2 = new BMenuField(defaultRect, "menuField2", - fIsVideo ? "Video Output:" : "Audio Output:", fMenu2); + BMenuField *menuField2 = new BMenuField("menuField2", + fIsVideo ? "Video Output:" : "Audio Output:", fMenu2, NULL); menuField2->SetDivider(divider); inputField->GroupLayout()->AddView(menuField1); @@ -102,48 +94,37 @@ BMenuField *menuField3 = NULL; if (!fIsVideo) { - defaultRect.OffsetBy(186, 0); - defaultRect.right -= 30; fMenu3 = new BPopUpMenu(""); fMenu3->SetLabelFromMarked(true); - menuField3 = new BMenuField(defaultRect, "menuField3", - "Channel:", fMenu3); + menuField3 = new BMenuField("menuField3", + "Channel:", fMenu3, NULL); outputField->GroupLayout()->AddView(menuField3); menuField3->SetDivider(StringWidth("Channel:")+5); - defaultRect.right += 30; - defaultRect.OffsetBy(-186, 0); } - defaultRect.OffsetBy(0, 32); - defaultRect.right += 100; rgb_color red_color = {222, 32, 33}; - fRestartView = new BStringView(defaultRect, "restartStringView", "Restart the Media Server to apply changes.", - B_FOLLOW_ALL, B_WILL_DRAW); + fRestartView = new BStringView("restartStringView", + "Restart the Media Server to apply changes."); fRestartView->SetHighColor(red_color); defaultsBox->AddChild(fRestartView); fRestartView->Hide(); // create the realtime box - rect.top = rect.bottom + 10; - rect.bottom = rect.top + 162; - BBox *realtimeBox = new BBox(rect, "realtime"); + BBox *realtimeBox = new BBox("realtime"); realtimeBox->SetLabel("Real-Time"); BMessage *message = new BMessage(ML_ENABLE_REAL_TIME); message->AddBool("isVideo", fIsVideo); - BRect rect2(22,20, frame.Width() - 22, 40); - fRealtimeCheckBox = new BCheckBox(rect2, "realtimeCheckBox", - fIsVideo ? "Enable Real-Time Video" : "Enable Real-Time Audio", message); + fRealtimeCheckBox = new BCheckBox("realtimeCheckBox", + fIsVideo ? "Enable Real-Time Video" : "Enable Real-Time Audio", + message); uint32 flags; BMediaRoster::Roster()->GetRealtimeFlags(&flags); if (flags & (fIsVideo ? B_MEDIA_REALTIME_VIDEO : B_MEDIA_REALTIME_AUDIO)) fRealtimeCheckBox->SetValue(B_CONTROL_ON); - rect2.top += 26; - rect2.bottom = rect.Height() - 5; - BRect textRect(3, 3, rect2.Width() - 3, rect2.Height() - 3); - BTextView *textView = new BTextView(rect2, "stringView", textRect, B_FOLLOW_ALL, B_WILL_DRAW); + BTextView *textView = new BTextView("stringView"); textView->Insert(fIsVideo ? "Enabling Real-Time Video allows system to perform video operations as fast and smoothly as possible. It achieves optimum performance by using more RAM." "\n\nOnly enable this feature if you need the lowest latency possible." : "Enabling Real-time Audio allows system to record and play audio as fast as possible. It achieves this performance by using more CPU and RAM." @@ -153,8 +134,7 @@ textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BGroupLayout* realtimeBoxLayout = new BGroupLayout(B_VERTICAL, 5); - inset = realtimeBox->Frame().left - realtimeBox->InnerFrame().left; - realtimeBoxLayout->SetInsets(inset, defaultsBox->TopBorderOffset() * 2, inset, inset); + realtimeBoxLayout->SetInsets(10,10,10,10); realtimeBox->SetLayout(realtimeBoxLayout); realtimeBoxLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5)); @@ -163,19 +143,11 @@ // create the bottom line: volumen in deskbar checkbox and restart button BGroupView* bottomView = new BGroupView(B_HORIZONTAL); - rect.top = rect.bottom + 11; - rect.bottom = rect.top + 20; - rect.left = rect.right - StringWidth("Restart Media Services") - 20; - BButton *restartButton = new BButton(rect, "restartButton", + BButton *restartButton = new BButton("restartButton", "Restart Media Services", new BMessage(ML_RESTART_MEDIA_SERVER)); if (!fIsVideo) { - rect.right = rect.left - 10; - rect.top += 4; - rect.left = frame.left + 33; - if (StringWidth("Show Volume Control on Deskbar") > rect.Width() - 30) - rect.left -= 10; - fVolumeCheckBox = new BCheckBox(rect, "volumeCheckBox", + fVolumeCheckBox = new BCheckBox("volumeCheckBox", "Show Volume Control on Deskbar", new BMessage(ML_SHOW_VOLUME_CONTROL)); bottomView->GroupLayout()->AddView(fVolumeCheckBox); if (BDeskbar().HasItem("MediaReplicant")) Modified: haiku/trunk/src/preferences/media/MediaViews.h =================================================================== --- haiku/trunk/src/preferences/media/MediaViews.h 2009-06-13 22:07:31 UTC (rev 31037) +++ haiku/trunk/src/preferences/media/MediaViews.h 2009-06-14 00:37:07 UTC (rev 31038) @@ -30,7 +30,7 @@ class BarView : public BView { public: - BarView(BRect frame); + BarView(); virtual void Draw(BRect updateRect); bool fDisplay; }; @@ -58,7 +58,7 @@ class SettingsView : public BView { public: - SettingsView(BRect frame, bool isVideo); + SettingsView(bool isVideo); void AddNodes(BList &list, bool isInput); void SetDefault(dormant_node_info &info, bool isInput, int32 outputID = -1); BCheckBox *fRealtimeCheckBox; Modified: haiku/trunk/src/preferences/media/MediaWindow.cpp =================================================================== --- haiku/trunk/src/preferences/media/MediaWindow.cpp 2009-06-13 22:07:31 UTC (rev 31037) +++ haiku/trunk/src/preferences/media/MediaWindow.cpp 2009-06-14 00:37:07 UTC (rev 31038) @@ -35,7 +35,7 @@ // MediaWindow - Constructor MediaWindow::MediaWindow(BRect frame) -: BWindow (frame, "Media", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS), +: BWindow (frame, "Media", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fCurrentNode(NULL), fParamWeb(NULL), fAlert(NULL), @@ -172,59 +172,36 @@ fIcons.AddItem(icon); const float scrollWidth = 9 * be_plain_font->Size() + 30; - const float contentWidth = 34 * be_plain_font->Size(); - float totalWidthFont = scrollWidth + contentWidth + 14 * 3; - const float totalWidth = (605.0 > totalWidthFont) ? - 605.0 : totalWidthFont; - BRect bounds = Bounds(); // the whole view - // Create the OutlineView - font_height titleHeightStruct; - be_bold_font->GetHeight(&titleHeightStruct); - float titleHeight = titleHeightStruct.ascent + titleHeightStruct.descent - + titleHeightStruct.leading + 1; - - BRect menuRect(bounds.left + 14, bounds.top + 14, scrollWidth, - bounds.bottom - 14); - BRect titleRect(menuRect.right + 14, menuRect.top, - totalWidth - 10, menuRect.top + titleHeight); - BRect availableRect(menuRect.right + 15, titleRect.bottom + 12, - totalWidth - 14, bounds.bottom - 16); - BRect barRect(titleRect.left, titleRect.bottom + 10, - titleRect.right - 2, titleRect.bottom + 11); - - fListView = new BListView(menuRect, "media_list_view", - B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); + fListView = new BListView("media_list_view"); fListView->SetSelectionMessage(new BMessage(ML_SELECTED_NODE)); // Add ScrollView to Media Menu BScrollView *scrollView = new BScrollView("listscroller", - fListView, B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM, 0, false, false, - B_FANCY_BORDER); + fListView, 0, false, false, B_FANCY_BORDER); scrollView->SetExplicitMinSize(BSize(scrollWidth, B_SIZE_UNSET)); scrollView->SetExplicitMaxSize(BSize(scrollWidth, B_SIZE_UNSET)); // Create the Views - fBox = new BBox(bounds, "background", B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); + fBox = new BBox("background", B_WILL_DRAW | B_FRAME_EVENTS, + B_PLAIN_BORDER); SetLayout(new BGroupLayout(B_HORIZONTAL)); GetLayout()->AddView(fBox); // StringViews rgb_color titleFontColor = { 0,0,0,0 }; - fTitleView = new BStringView(titleRect, "AudioSettings", - "Audio Settings", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + fTitleView = new BStringView("AudioSettings", + "Audio Settings", B_WILL_DRAW); fTitleView->SetFont(be_bold_font); fTitleView->SetHighColor(titleFontColor); - fContentView = new BBox(availableRect, "contentView", - B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER); + fContentView = new BBox("contentView", B_WILL_DRAW | B_FRAME_EVENTS, + B_NO_BORDER); - BRect settingsRect(0, 0, availableRect.Width(), availableRect.Height()); - fAudioView = new SettingsView(settingsRect, false); - fVideoView = new SettingsView(settingsRect, true); + fAudioView = new SettingsView(false); + fVideoView = new SettingsView(true); - fBar = new BarView(barRect); + fBar = new BarView(); BGroupView* titleGroupView = new BGroupView(B_HORIZONTAL); titleGroupView->GroupLayout()->AddView(fTitleView); titleGroupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); @@ -252,11 +229,6 @@ if (IsHidden()) Show(); } - - // Set window limits - ResizeTo(totalWidth + 14, bounds.Height()); - SetZoomLimits(totalWidth + 14, bounds.Height()); - SetSizeLimits(totalWidth + 14, 100000, bounds.Height(), 100000); } @@ -705,7 +677,7 @@ { MediaAlert *alert = static_cast(cookie); PRINT(("stage : %i\n", stage)); - char *string = "Unknown stage"; + const char *string = "Unknown stage"; switch (stage) { case 10: string = "Stopping Media Server" B_UTF8_ELLIPSIS; From mattmadia at gmail.com Sun Jun 14 03:05:47 2009 From: mattmadia at gmail.com (Matt Madia) Date: Sun, 14 Jun 2009 01:05:47 +0000 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <20090613230947.407.1@knochen-vm.localdomain> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> <1e42d8c50906130758h63d825f3r1b4dd8ed3ec04a74@mail.gmail.com> <20090613205519.426.2@knochen-vm.localdomain> <1e42d8c50906131320w70b83884ob53ea03df237f32d@mail.gmail.com> <20090613230947.407.1@knochen-vm.localdomain> Message-ID: <1e42d8c50906131805n5ff9c2a8gb4223271d60303ff@mail.gmail.com> On Sat, Jun 13, 2009 at 9:09 PM, Ingo Weinhold wrote: > The "&& ! $(HAIKU_IGNORE_USER_BUILD_CONFIG)" > part just disables the check, when HAIKU_IGNORE_USER_BUILD_CONFIG is set. *cough* whoops. ...Seems i mis-read that statement. My apologies. In hindsight, i might've looked for /boot/common/openssh as the binary instead of "ssh" --mmadia From anevilyak at gmail.com Sun Jun 14 07:45:39 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 14 Jun 2009 00:45:39 -0500 Subject: [Haiku-commits] r31038 - haiku/trunk/src/preferences/media In-Reply-To: <200906140037.n5E0b9gQ020642@sheep.berlios.de> References: <200906140037.n5E0b9gQ020642@sheep.berlios.de> Message-ID: On Sat, Jun 13, 2009 at 7:37 PM, anevilyak at BerliOS wrote: > Author: anevilyak > Date: 2009-06-14 02:37:07 +0200 (Sun, 14 Jun 2009) > New Revision: 31038 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31038&view=rev > > Log: > The Media preflet was using a mix of old and layout style primitives to set itself up. As a consequence resizing basically didn't work correctly at all. Fixes ticket #3427. > These changes do expose a peculiarity I've thus far been unable to track down the cause of: if I switch to the config view of my audio chip, the resulting view has far more controls than can fit in the default window width, and thus has a scroll bar. This is fine. However, if I then resize the window wide enough such that said scroll bar is no longer necessary, I can then no longer size the window any smaller than that (ergo small enough to make the scrollbar reappear). I have yet to find where in any of the code this clamping effect comes from. Anyone who knows the layout kit and such better have any ideas? Regards, Rene From superstippi at gmx.de Sun Jun 14 09:10:58 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 14 Jun 2009 09:10:58 +0200 Subject: [Haiku-commits] r31038 - haiku/trunk/src/preferences/media In-Reply-To: References: <200906140037.n5E0b9gQ020642@sheep.berlios.de> Message-ID: <20090614091058.338.1@bepc.1244963125.fake> On 2009-06-14 at 07:45:39 [+0200], Rene Gollent wrote: > On Sat, Jun 13, 2009 at 7:37 PM, anevilyak at > BerliOS wrote: > > Author: anevilyak > > Date: 2009-06-14 02:37:07 +0200 (Sun, 14 Jun 2009) New Revision: 31038 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31038&view=rev > > > > Log: > > The Media preflet was using a mix of old and layout style primitives to > > set itself up. As a consequence resizing basically didn't work > > correctly at all. Fixes ticket #3427. > > > > These changes do expose a peculiarity I've thus far been unable to track > down the cause of: if I switch to the config view of my audio chip, the > resulting view has far more controls than can fit in the default window > width, and thus has a scroll bar. This is fine. However, if I then resize > the window wide enough such that said scroll bar is no longer necessary, > I can then no longer size the window any smaller than that (ergo small > enough to make the scrollbar reappear). I have yet to find where in any > of the code this clamping effect comes from. Anyone who knows the layout > kit and such better have any ideas? If you still have an old style view, it may reset the MinSize() to the current size always. MinSize() is implemented in BView to ask GetPreferredSize(), and some controls return the current Bounds() there. Best regards, -Stephan From bonefish at mail.berlios.de Sun Jun 14 12:57:13 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 12:57:13 +0200 Subject: [Haiku-commits] r31039 - haiku/trunk/src/kits/tracker Message-ID: <200906141057.n5EAvDIe003245@sheep.berlios.de> Author: bonefish Date: 2009-06-14 12:57:09 +0200 (Sun, 14 Jun 2009) New Revision: 31039 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31039&view=rev Modified: haiku/trunk/src/kits/tracker/FilePanel.cpp haiku/trunk/src/kits/tracker/Tracker.cpp Log: * Use public functionality instead of private BeOS syscalls. * Automatic whitespace cleanup. Modified: haiku/trunk/src/kits/tracker/FilePanel.cpp =================================================================== --- haiku/trunk/src/kits/tracker/FilePanel.cpp 2009-06-14 00:37:07 UTC (rev 31038) +++ haiku/trunk/src/kits/tracker/FilePanel.cpp 2009-06-14 10:57:09 UTC (rev 31039) @@ -34,6 +34,8 @@ // Implementation for the public FilePanel object. +#include + #include #include #include @@ -50,7 +52,6 @@ #ifndef _IMPEXP_TRACKER # define _IMPEXP_TRACKER #endif -extern "C" _IMPEXP_ROOT int _kset_fd_limit_(int num); // these two calls are deprecated extern _IMPEXP_TRACKER void run_open_panel(); @@ -80,9 +81,13 @@ { // boost file descriptor limit so file panels in other apps don't have // problems - _kset_fd_limit_ (512); + struct rlimit rl; + rl.rlim_cur = 512; + rl.rlim_max = RLIM_SAVED_MAX; + setrlimit(RLIMIT_NOFILE, &rl); + BEntry startDir(ref); - fWindow = new TFilePanel(mode, target, &startDir, nodeFlavors, + fWindow = new TFilePanel(mode, target, &startDir, nodeFlavors, multipleSelection, message, filter, 0, B_DOCUMENT_WINDOW_LOOK, modal ? B_MODAL_APP_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL, hideWhenDone); @@ -109,14 +114,14 @@ // just pull it to us uint32 workspace = 1UL << (uint32)current_workspace(); uint32 windowWorkspaces = fWindow->Workspaces(); - if (!(windowWorkspaces & workspace)) + if (!(windowWorkspaces & workspace)) // window in a different workspace, reopen in current fWindow->SetWorkspaces(workspace); - if (!IsShowing()) + if (!IsShowing()) fWindow->Show(); - fWindow->Activate(); + fWindow->Activate(); } void @@ -198,7 +203,7 @@ AutoLock lock(fWindow); if (!lock) return; - + static_cast(fWindow)->Refresh(); } @@ -228,7 +233,7 @@ AutoLock lock(fWindow); if (!lock) return; - + static_cast(fWindow)->SetButtonLabel(button, text); } @@ -267,7 +272,7 @@ { entry_ref ref; status_t err = get_ref_for_path(path, &ref); - if (err < B_OK) + if (err < B_OK) return; AutoLock lock(fWindow); @@ -317,7 +322,7 @@ AutoLock lock(fWindow); if (!lock) return B_ERROR; - + return static_cast(fWindow)->GetNextEntryRef(ref); } @@ -329,8 +334,8 @@ AutoLock lock(fWindow); if (!lock) return; - - static_cast(fWindow)->SetHideWhenDone(on); + + static_cast(fWindow)->SetHideWhenDone(on); } bool Modified: haiku/trunk/src/kits/tracker/Tracker.cpp =================================================================== --- haiku/trunk/src/kits/tracker/Tracker.cpp 2009-06-14 00:37:07 UTC (rev 31038) +++ haiku/trunk/src/kits/tracker/Tracker.cpp 2009-06-14 10:57:09 UTC (rev 31039) @@ -32,8 +32,10 @@ All rights reserved. */ +#include #include #include +#include #include #include @@ -90,9 +92,6 @@ #ifndef _IMPEXP_ROOT # define _IMPEXP_ROOT #endif -extern "C" _IMPEXP_ROOT int _kset_fd_limit_(int num); -extern "C" _IMPEXP_ROOT int _kset_mon_limit_(int num); - // from priv_syscalls.h const int32 DEFAULT_MON_NUM = 4096; // copied from fsil.c @@ -109,14 +108,14 @@ NodePreloader *gPreloader = NULL; -void +void InitIconPreloader() { static int32 lock = 0; if (atomic_add(&lock, 1) != 0) { // Just wait for the icon cache to be instantiated - int32 tries = 20; + int32 tries = 20; while (IconCache::sIconCache == NULL && tries-- > 0) snooze(10000); return; @@ -166,7 +165,7 @@ } if (!fs_stat_dev(model->NodeRef()->device,&info)) return info.flags; - + return B_FS_HAS_ATTR; } @@ -176,7 +175,7 @@ { BPath path; status_t err = find_directory(B_COMMON_VAR_DIRECTORY, &path); - + if (err != B_OK){ PRINT(("var err = %s\n", strerror(err))); return; @@ -188,7 +187,7 @@ // make var dir invisible info.fInvisible = true; info.fInitedDirectory = -1; - + if (varDirectory.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &info, sizeof(info)) == sizeof(info)) varDirectory.RemoveAttr(kAttrPoseInfoForeign); @@ -203,17 +202,19 @@ : BApplication(kTrackerSignature), fSettingsWindow(NULL) { - // set the cwd to /boot/home, anything that's launched - // from Tracker will automatically inherit this + // set the cwd to /boot/home, anything that's launched + // from Tracker will automatically inherit this BPath homePath; - + if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK) chdir(homePath.Path()); - - _kset_fd_limit_(512); - // ask for a bunch more file descriptors so that nested copying - // works well - + + // ask for a bunch more file descriptors so that nested copying works well + struct rlimit rl; + rl.rlim_cur = 512; + rl.rlim_max = RLIM_SAVED_MAX; + setrlimit(RLIMIT_NOFILE, &rl); + fNodeMonitorCount = DEFAULT_MON_NUM; #ifdef CHECK_OPEN_MODEL_LEAKS @@ -261,7 +262,7 @@ gStatusWindow->AttemptToQuit(); // try quitting the copy/move/empty trash threads - + BVolume bootVolume; DEBUG_ONLY(status_t err =) BVolumeRoster().GetBootVolume(&bootVolume); ASSERT(err == B_OK); @@ -311,8 +312,8 @@ message.AddInt8(path.Path(), flags); } } - } - window->Unlock(); + } + window->Unlock(); } } lock.Unlock(); @@ -351,15 +352,15 @@ fAutoMounter->Lock(); fAutoMounter->QuitRequested(); // automounter does some stuff in QuitRequested fAutoMounter->Quit(); // but we really don't care if it is cooperating or not - + fClipboardRefsWatcher->Lock(); fClipboardRefsWatcher->Quit(); - + fTrashWatcher->Lock(); fTrashWatcher->Quit(); WellKnowEntryList::Quit(); - + delete gPreloader; delete fTaskLoop; delete IconCache::sIconCache; @@ -397,7 +398,7 @@ CloseWindowAndChildren(itemNode); break; } - + case kCloseAllWindows: CloseAllWindows(); break; @@ -451,7 +452,7 @@ // show the addprinter window run_add_printer_panel(); break; - + case kMakeActivePrinter: // get the current selection SetDefaultPrinter(message); @@ -642,7 +643,7 @@ }; -bool +bool TTracker::LaunchAndCloseParentIfOK(const entry_ref *launchThis, const node_ref *closeThis, const BMessage *messageToBundle) { @@ -651,7 +652,7 @@ refsReceived = *messageToBundle; refsReceived.what = B_REFS_RECEIVED; } - refsReceived.AddRef("refs", launchThis); + refsReceived.AddRef("refs", launchThis); // synchronous launch, we are already in our own thread if (TrackerLaunch(&refsReceived, false) == B_OK) { // if launched fine, close parent window in a bit @@ -691,7 +692,7 @@ alert->Go(); return result; } - } else + } else model = new Model(&entry); result = model->InitCheck(); @@ -850,7 +851,7 @@ for (int32 index = 1; index < argc; index++) { BEntry entry; if (entry.SetTo(&workingDirectory, argv[index]) == B_OK - && entry.GetRef(&ref) == B_OK) + && entry.GetRef(&ref) == B_OK) OpenRef(&ref); else if (get_ref_for_path(argv[index], &ref) == B_OK) OpenRef(&ref); @@ -870,13 +871,13 @@ window = FindContainerWindow(model->NodeRef()); bool someWindowActivated = false; - - uint32 workspace = (uint32)(1 << current_workspace()); + + uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; - + while (window) { // At least one window open, just pull to front - // make sure we don't jerk workspaces around + // make sure we don't jerk workspaces around uint32 windowWorkspaces = window->Workspaces(); if (windowWorkspaces & workspace) { window->Activate(); @@ -884,13 +885,13 @@ } window = FindContainerWindow(model->NodeRef(), ++windowCount); } - + if (someWindowActivated) { delete model; - return; + return; } // If no window was actiated, (none in the current workspace // we open a new one. - + if (openSelector == kRunOpenWithWindow) { BMessage *refList = NULL; if (!originalRefsList) { @@ -914,12 +915,12 @@ } else // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); - + if (model) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); - + if (stateMessage) restoreStateMessage.AddMessage("state", stateMessage); @@ -941,7 +942,7 @@ entry_ref ref; message->FindRef("refs", index, &ref); BEntry entry(&ref, true); - if (entry.InitCheck() == B_OK && entry.Exists()) + if (entry.InitCheck() == B_OK && entry.Exists()) (new FindWindow(&ref, editOnlyIfTemplate))->Show(); } } @@ -1000,7 +1001,7 @@ TTracker::FindContainerWindow(const node_ref *node, int32 number) const { ASSERT(fWindowList.IsLocked()); - + int32 count = fWindowList.CountItems(); int32 windowsFound = 0; @@ -1008,7 +1009,7 @@ for (int32 index = 0; index < count; index++) { BContainerWindow *window = dynamic_cast (fWindowList.ItemAt(index)); - + if (window && window->IsShowing(node) && number == windowsFound++) return window; } @@ -1020,7 +1021,7 @@ TTracker::FindContainerWindow(const entry_ref *entry, int32 number) const { ASSERT(fWindowList.IsLocked()); - + int32 count = fWindowList.CountItems(); int32 windowsFound = 0; @@ -1036,7 +1037,7 @@ } -bool +bool TTracker::EntryHasWindowOpen(const entry_ref *entry) { AutoLock lock(&fWindowList); @@ -1049,15 +1050,15 @@ { BEntry entry(ref); BEntry parent; - + if (entry.GetParent(&parent) != B_OK) return NULL; - + entry_ref parentRef; parent.GetRef(&parentRef); ASSERT(fWindowList.IsLocked()); - + int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { BContainerWindow *window = dynamic_cast @@ -1073,7 +1074,7 @@ TTracker::FindInfoWindow(const node_ref* node) const { ASSERT(fWindowList.IsLocked()); - + int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { BInfoWindow *window = dynamic_cast @@ -1085,7 +1086,7 @@ } -bool +bool TTracker::QueryActiveForDevice(dev_t device) { AutoLock lock(&fWindowList); @@ -1103,7 +1104,7 @@ } -void +void TTracker::CloseActiveQueryWindows(dev_t device) { // used when trying to unmount a volume - an active query would prevent that from @@ -1143,8 +1144,8 @@ if (window) { AutoLock lock(window); BDeskWindow *deskWindow = dynamic_cast(window); - - if (deskWindow) + + if (deskWindow) deskWindow->SaveDesktopPoseLocations(); else window->PoseView()->SavePoseLocations(); @@ -1174,7 +1175,7 @@ if ((*window->TargetModel()->NodeRef() == *node) || dir.Contains(&wind_entry)) { - + // ToDo: // get rid of the Remove here, BContainerWindow::Quit does it fWindowList.RemoveItemAt(index); @@ -1203,11 +1204,11 @@ BWindow *window = fWindowList.ItemAt(index); if (window->Workspaces() & currentWorkspace) // avoid the desktop - if (!dynamic_cast(window) + if (!dynamic_cast(window) && !dynamic_cast(window)) window->PostMessage(B_QUIT_REQUESTED); - } -} + } +} void @@ -1235,7 +1236,7 @@ // ToDo: // get rid of the Remove here, BContainerWindow::Quit does it fWindowList.RemoveItemAt(index); - } + } } @@ -1325,7 +1326,7 @@ InstallDefaultTemplates(); InstallIndices(); InstallTemporaryBackgroundImages(); - + HideVarDir(); fTrashWatcher = new BTrashWatcher(); @@ -1333,13 +1334,13 @@ fClipboardRefsWatcher = new BClipboardRefsWatcher(); fClipboardRefsWatcher->Run(); - + fAutoMounter = new AutoMounter(); fAutoMounter->Run(); - + fTaskLoop = new StandAloneTaskLoop(true); - // open desktop window + // open desktop window BContainerWindow *deskWindow = NULL; BVolume bootVolume; BVolumeRoster().GetBootVolume(&bootVolume); @@ -1389,9 +1390,9 @@ TTracker::MimeTypes() const { return fMimeTypeList; -} +} -void +void TTracker::SelectChildInParentSoon(const entry_ref *parent, const node_ref *child) { @@ -1400,7 +1401,7 @@ 100000, 200000, 5000000); } -void +void TTracker::CloseParentWaitingForChildSoon(const entry_ref *child, const node_ref *parent) { @@ -1409,7 +1410,7 @@ 200000, 100000, 5000000); } -void +void TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose) { fTaskLoop->RunLater(NewMemberFunctionObject @@ -1417,7 +1418,7 @@ 100000); } -void +void TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose) { AutoLock lock(&fWindowList); @@ -1428,12 +1429,12 @@ } } -bool +bool TTracker::CloseParentWaitingForChild(const entry_ref *child, const node_ref *parent) { AutoLock lock(&fWindowList); - + BContainerWindow *parentWindow = FindContainerWindow(parent); if (!parentWindow) // parent window already closed, give up @@ -1452,10 +1453,10 @@ if (!window->IsHidden()) return CloseParentWindowCommon(parentWindow); } - return false; + return false; } -void +void TTracker::CloseParent(node_ref parent) { AutoLock lock(&fWindowList); @@ -1482,11 +1483,11 @@ } } -bool +bool TTracker::CloseParentWindowCommon(BContainerWindow *window) { ASSERT(fWindowList.IsLocked()); - + if (dynamic_cast(window)) // don't close the destop return false; @@ -1495,18 +1496,18 @@ return true; } -bool +bool TTracker::SelectChildInParent(const entry_ref *parent, const node_ref *child) { AutoLock lock(&fWindowList); - + BContainerWindow *window = FindContainerWindow(parent); - if (!window) + if (!window) // parent window already closed, give up return false; AutoLock windowLock(window); - + if (windowLock.IsLocked()) { BPoseView *view = window->PoseView(); int32 index; @@ -1516,18 +1517,24 @@ return true; } } - return false; + return false; } const int32 kNodeMonitorBumpValue = 512; -status_t +status_t TTracker::NeedMoreNodeMonitors() { fNodeMonitorCount += kNodeMonitorBumpValue; PRINT(("bumping nodeMonitorCount to %d\n", fNodeMonitorCount)); - return _kset_mon_limit_(fNodeMonitorCount); + struct rlimit rl; + rl.rlim_cur = fNodeMonitorCount; + rl.rlim_max = RLIM_SAVED_MAX; + if (setrlimit(RLIMIT_NOVMON, &rl) < 0) + return errno; + return B_OK; + } status_t @@ -1570,7 +1577,7 @@ } -bool +bool TTracker::InTrashNode(const entry_ref *node) const { return FSInTrashDir(node); @@ -1588,5 +1595,5 @@ TTracker::IsTrashNode(const node_ref *node) const { return fTrashWatcher->IsTrashNode(node); -} +} From bonefish at mail.berlios.de Sun Jun 14 12:58:56 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 12:58:56 +0200 Subject: [Haiku-commits] r31040 - haiku/trunk/src/system/kernel Message-ID: <200906141058.n5EAwuTj004491@sheep.berlios.de> Author: bonefish Date: 2009-06-14 12:58:54 +0200 (Sun, 14 Jun 2009) New Revision: 31040 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31040&view=rev Modified: haiku/trunk/src/system/kernel/thread.cpp Log: Also set user_thread to NULL. It shouldn't make a difference, though. Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2009-06-14 10:57:09 UTC (rev 31039) +++ haiku/trunk/src/system/kernel/thread.cpp 2009-06-14 10:58:54 UTC (rev 31040) @@ -284,6 +284,7 @@ thread->select_infos = NULL; thread->post_interrupt_callback = NULL; thread->post_interrupt_data = NULL; + thread->user_thread = NULL; sprintf(temp, "thread_%ld_retcode_sem", thread->id); thread->exit.sem = create_sem(0, temp); From bonefish at mail.berlios.de Sun Jun 14 13:03:43 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 13:03:43 +0200 Subject: [Haiku-commits] r31041 - haiku/trunk/headers/os/kernel Message-ID: <200906141103.n5EB3h9L007830@sheep.berlios.de> Author: bonefish Date: 2009-06-14 13:03:39 +0200 (Sun, 14 Jun 2009) New Revision: 31041 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31041&view=rev Modified: haiku/trunk/headers/os/kernel/debugger.h Log: Updated comment to reality. Modified: haiku/trunk/headers/os/kernel/debugger.h =================================================================== --- haiku/trunk/headers/os/kernel/debugger.h 2009-06-14 10:58:54 UTC (rev 31040) +++ haiku/trunk/headers/os/kernel/debugger.h 2009-06-14 11:03:39 UTC (rev 31041) @@ -48,9 +48,9 @@ // team debugging flags enum { // event mask: If a flag is set, any of the team's threads will stop when - // the respective event occurs. All flags are enabled by default. Always - // enabled are debugger() calls and hardware exceptions, as well as the - // deletion of the debugged team. + // the respective event occurs. None of the flags are enabled by default. + // Always enabled are debugger() calls and hardware exceptions, as well as + // the deletion of the debugged team. B_TEAM_DEBUG_SIGNALS = 0x00010000, B_TEAM_DEBUG_PRE_SYSCALL = 0x00020000, B_TEAM_DEBUG_POST_SYSCALL = 0x00040000, From stippi at mail.berlios.de Sun Jun 14 13:07:56 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 14 Jun 2009 13:07:56 +0200 Subject: [Haiku-commits] r31042 - haiku/trunk/src/apps/installer Message-ID: <200906141107.n5EB7ukx012222@sheep.berlios.de> Author: stippi Date: 2009-06-14 13:07:52 +0200 (Sun, 14 Jun 2009) New Revision: 31042 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31042&view=rev Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp haiku/trunk/src/apps/installer/CopyEngine.h haiku/trunk/src/apps/installer/InstallerWindow.cpp haiku/trunk/src/apps/installer/WorkerThread.cpp Log: * Fixed problems when installing onto non-empty target volumes. The 'system' folder will be a clean copy of the source volume. Other folders will be merged (as before), but in case a folder is in the way of a link or file from the source volume, it will now be purged. * Clarified the alert for non-empty target volumes, so it is very clear what happens. (Maybe there ought to the be option to only copy the system folder, though.) * Fixed a problem with copying attributes in certain cases. * Fixed the main GUI not resetting state properly after encountering an error during the copy process. Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.cpp 2009-06-14 11:03:39 UTC (rev 31041) +++ haiku/trunk/src/apps/installer/CopyEngine.cpp 2009-06-14 11:07:52 UTC (rev 31042) @@ -263,8 +263,11 @@ return ret; ret = create_directory(_destination, 0777); - if (ret < B_OK && ret != B_FILE_EXISTS) + if (ret < B_OK && ret != B_FILE_EXISTS) { + fprintf(stderr, "Could not create '%s': %s\n", _destination, + strerror(ret)); return ret; + } BDirectory destination(_destination); ret = destination.InitCheck(); @@ -301,10 +304,24 @@ // handle recursive directory copy if (copy.Exists()) { - // Do not overwrite attributes on folders that exist. - // This should work better when the install target already - // contains a Haiku installation. - copyAttributes = false; + ret = B_OK; + if (copy.IsDirectory()) { + if (_ShouldClobberFolder(name, statInfo, level)) + ret = _RemoveFolder(copy); + else { + // Do not overwrite attributes on folders that exist. + // This should work better when the install target + // already contains a Haiku installation. + copyAttributes = false; + } + } else + ret = copy.Remove(); + + if (ret != B_OK) { + fprintf(stderr, "Failed to make room for folder '%s': " + "%s\n", name, strerror(ret)); + return ret; + } } BPath srcFolder; @@ -329,35 +346,52 @@ // We are supposed to quit return B_CANCELED; } - } else if (S_ISLNK(statInfo.st_mode)) { - // copy symbolic links - BSymLink srcLink(&entry); - if (ret < B_OK) - return ret; - - char linkPath[B_PATH_NAME_LENGTH]; - ssize_t read = srcLink.ReadLink(linkPath, B_PATH_NAME_LENGTH - 1); - if (read < 0) - return (status_t)read; - - // just in case it already exists... - copy.Remove(); - - BSymLink dstLink; - ret = destination.CreateSymLink(name, linkPath, &dstLink); - if (ret < B_OK) - return ret; } else { - // copy file data - // NOTE: Do not pass the locker, we simply keep holding the lock! - ret = CopyFile(entry, copy); - if (ret < B_OK) - return ret; + if (copy.Exists()) { + if (copy.IsDirectory()) + ret = _RemoveFolder(copy); + else + ret = copy.Remove(); + if (ret != B_OK) { + fprintf(stderr, "Failed to make room for entry '%s': " + "%s\n", name, strerror(ret)); + return ret; + } + } + if (S_ISLNK(statInfo.st_mode)) { + // copy symbolic links + BSymLink srcLink(&entry); + if (ret < B_OK) + return ret; + + char linkPath[B_PATH_NAME_LENGTH]; + ssize_t read = srcLink.ReadLink(linkPath, B_PATH_NAME_LENGTH - 1); + if (read < 0) + return (status_t)read; + + // just in case it already exists... + copy.Remove(); + + BSymLink dstLink; + ret = destination.CreateSymLink(name, linkPath, &dstLink); + if (ret < B_OK) + return ret; + } else { + // copy file data + // NOTE: Do not pass the locker, we simply keep holding the lock! + ret = CopyFile(entry, copy); + if (ret < B_OK) + return ret; + } } if (!copyAttributes) continue; + ret = copy.SetTo(&destination, name); + if (ret != B_OK) + return ret; + // copy attributes BNode sourceNode(&entry); BNode targetNode(©); @@ -396,6 +430,30 @@ } +status_t +CopyEngine::_RemoveFolder(BEntry& entry) +{ + BDirectory directory(&entry); + status_t ret = directory.InitCheck(); + if (ret != B_OK) + return ret; + + BEntry subEntry; + while (directory.GetNextEntry(&subEntry) == B_OK) { + if (subEntry.IsDirectory()) { + ret = _RemoveFolder(subEntry); + if (ret != B_OK) + return ret; + } else { + ret = subEntry.Remove(); + if (ret != B_OK) + return ret; + } + } + return entry.Remove(); +} + + void CopyEngine::_UpdateProgress() { @@ -430,6 +488,24 @@ } +bool +CopyEngine::_ShouldClobberFolder(const char* name, const struct stat& statInfo, + int32 level) const +{ + if (level == 1 && S_ISDIR(statInfo.st_mode)) { + if (strcmp("system", name) == 0) { + printf("clobbering '%s'.\n", name); + return true; + } +// if (strcmp("develop", name) == 0) { +// printf("clobbering '%s'.\n", name); +// return true; +// } + } + return false; +} + + int32 CopyEngine::_WriteThreadEntry(void* cookie) { Modified: haiku/trunk/src/apps/installer/CopyEngine.h =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.h 2009-06-14 11:03:39 UTC (rev 31041) +++ haiku/trunk/src/apps/installer/CopyEngine.h 2009-06-14 11:07:52 UTC (rev 31042) @@ -48,6 +48,12 @@ const struct stat& statInfo, int32 level) const; + bool _ShouldClobberFolder(const char* name, + const struct stat& statInfo, + int32 level) const; + + status_t _RemoveFolder(BEntry& entry); + void _UpdateProgress(); static int32 _WriteThreadEntry(void* cookie); Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp =================================================================== --- haiku/trunk/src/apps/installer/InstallerWindow.cpp 2009-06-14 11:03:39 UTC (rev 31041) +++ haiku/trunk/src/apps/installer/InstallerWindow.cpp 2009-06-14 11:07:52 UTC (rev 31042) @@ -373,15 +373,12 @@ (new BAlert("error", errorMessage, "Ok"))->Go(); } - fInstallStatus = kReadyForInstall; - fBeginButton->SetEnabled(true); _DisableInterface(false); fProgressLayoutItem->SetVisible(false); fPkgSwitchLayoutItem->SetVisible(true); _ShowOptionalPackages(); - - fBeginButton->SetLabel("Begin"); + _UpdateControls(); break; } case START_SCAN: Modified: haiku/trunk/src/apps/installer/WorkerThread.cpp =================================================================== --- haiku/trunk/src/apps/installer/WorkerThread.cpp 2009-06-14 11:03:39 UTC (rev 31041) +++ haiku/trunk/src/apps/installer/WorkerThread.cpp 2009-06-14 11:07:52 UTC (rev 31042) @@ -234,14 +234,14 @@ void -WorkerThread::_PerformInstall(BMenu *srcMenu, BMenu *targetMenu) +WorkerThread::_PerformInstall(BMenu* srcMenu, BMenu* targetMenu) { CALLED(); BPath targetDirectory, srcDirectory; BDirectory targetDir; BDiskDevice device; - BPartition *partition; + BPartition* partition; BVolume targetVolume; status_t err = B_OK; int32 entries = 0; @@ -250,8 +250,8 @@ BMessenger messenger(fWindow); CopyEngine engine(messenger, new BMessage(MSG_STATUS_MESSAGE)); - PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked(); - PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked(); + PartitionMenuItem* targetItem = (PartitionMenuItem*)targetMenu->FindMarked(); + PartitionMenuItem* srcItem = (PartitionMenuItem*)srcMenu->FindMarked(); if (!srcItem || !targetItem) { ERR("bad menu items\n"); goto error; @@ -381,7 +381,12 @@ } if (entries != 0 && ((new BAlert("", "The target volume is not empty. Are you sure you " - "want to install anyway?", "Install Anyway", "Cancel", 0, + "want to install anyway?\n\nNote: The 'system' folder will be a " + "clean copy from the source volume, all other folders will be " + "merged, whereas files and links that exist on both the source " + "and target volume will be overwritten with the source volume " + "version.", + "Install Anyway", "Cancel", 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { err = B_CANCELED; goto error; From bonefish at mail.berlios.de Sun Jun 14 13:10:41 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 13:10:41 +0200 Subject: [Haiku-commits] r31043 - haiku/trunk/src/system/libroot/os/arch/x86 Message-ID: <200906141110.n5EBAfaI015631@sheep.berlios.de> Author: bonefish Date: 2009-06-14 13:10:36 +0200 (Sun, 14 Jun 2009) New Revision: 31043 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31043&view=rev Modified: haiku/trunk/src/system/libroot/os/arch/x86/Jamfile haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c Log: Don't build compatibility.c for non-gcc2 anymore. Modified: haiku/trunk/src/system/libroot/os/arch/x86/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/os/arch/x86/Jamfile 2009-06-14 11:07:52 UTC (rev 31042) +++ haiku/trunk/src/system/libroot/os/arch/x86/Jamfile 2009-06-14 11:10:36 UTC (rev 31043) @@ -5,14 +5,22 @@ # time.c! UsePrivateSystemHeaders ; +local compatibilitySources ; +if $(HAIKU_GCC_VERSION[1]) = 2 { + compatibilitySources = + compatibility.c + ; +} + MergeObject os_arch_$(TARGET_ARCH).o : atomic.S byteorder.S - compatibility.c get_stack_frame.S system_info.c system_time_asm.S thread.c time.c tls.c + + $(compatibilitySources) ; Modified: haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c =================================================================== --- haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c 2009-06-14 11:07:52 UTC (rev 31042) +++ haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c 2009-06-14 11:10:36 UTC (rev 31043) @@ -3,23 +3,18 @@ * Distributed under the terms of the MIT License. */ -// TODO: temporary measurement to fix the build with GCC 4 - in the end, these -// private syscalls shouldn't be used anywhere in the Haiku tree, at the very -// least they should only be used when compiling for GCC 2.95.3, though. -#if __GNUC__ < 30 - //! This file includes some known R5 syscalls +#include +#include +#include + #include #include #include -#include -#include -#include - int _kset_mon_limit_(int num); int _kset_fd_limit_(int num); int _klock_node_(int fd); @@ -103,6 +98,3 @@ return fs_stat_dev(device, info); } - - -#endif // __GNUC__ < 3 From bonefish at mail.berlios.de Sun Jun 14 13:55:30 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 13:55:30 +0200 Subject: [Haiku-commits] r31044 - in haiku/trunk/src/apps: processcontroller pulse showimage Message-ID: <200906141155.n5EBtUuR027337@sheep.berlios.de> Author: bonefish Date: 2009-06-14 13:55:24 +0200 (Sun, 14 Jun 2009) New Revision: 31044 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31044&view=rev Modified: haiku/trunk/src/apps/processcontroller/Jamfile haiku/trunk/src/apps/processcontroller/PCWorld.h haiku/trunk/src/apps/processcontroller/ProcessController.cpp haiku/trunk/src/apps/pulse/CPUButton.cpp haiku/trunk/src/apps/pulse/Jamfile haiku/trunk/src/apps/pulse/PulseApp.cpp haiku/trunk/src/apps/pulse/PulseView.cpp haiku/trunk/src/apps/pulse/PulseView.h haiku/trunk/src/apps/showimage/Filter.cpp haiku/trunk/src/apps/showimage/Jamfile Log: Don't use private BeOS syscalls. Modified: haiku/trunk/src/apps/processcontroller/Jamfile =================================================================== --- haiku/trunk/src/apps/processcontroller/Jamfile 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/processcontroller/Jamfile 2009-06-14 11:55:24 UTC (rev 31044) @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src apps processcontroller ; -SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateSystemHeaders ; Application ProcessController : AutoIcon.cpp Modified: haiku/trunk/src/apps/processcontroller/PCWorld.h =================================================================== --- haiku/trunk/src/apps/processcontroller/PCWorld.h 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/processcontroller/PCWorld.h 2009-06-14 11:55:24 UTC (rev 31044) @@ -1,20 +1,20 @@ /* ProcessController ? 2000, Georges-Edouard Berenger, All Rights Reserved. - Copyright (C) 2004 beunited.org + Copyright (C) 2004 beunited.org - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PCWORLD_H_ #define _PCWORLD_H_ @@ -42,7 +42,5 @@ extern thread_id id; -extern "C" int _kget_cpu_state_(int cpu); -extern "C" int _kset_cpu_state_(int cpu, int enabled); #endif // _PCWORLD_H_ Modified: haiku/trunk/src/apps/processcontroller/ProcessController.cpp =================================================================== --- haiku/trunk/src/apps/processcontroller/ProcessController.cpp 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/processcontroller/ProcessController.cpp 2009-06-14 11:55:24 UTC (rev 31044) @@ -21,18 +21,9 @@ #include "ProcessController.h" -#include "AutoIcon.h" -#include "Colors.h" -#include "IconMenuItem.h" -#include "MemoryBarMenu.h" -#include "MemoryBarMenuItem.h" -#include "PCWorld.h" -#include "Preferences.h" -#include "QuitMenu.h" -#include "TeamBarMenu.h" -#include "TeamBarMenuItem.h" -#include "ThreadBarMenu.h" -#include "Utilities.h" +#include +#include +#include #include #include @@ -49,10 +40,22 @@ #include #include -#include -#include -#include +#include +#include "AutoIcon.h" +#include "Colors.h" +#include "IconMenuItem.h" +#include "MemoryBarMenu.h" +#include "MemoryBarMenuItem.h" +#include "PCWorld.h" +#include "Preferences.h" +#include "QuitMenu.h" +#include "TeamBarMenu.h" +#include "TeamBarMenuItem.h" +#include "ThreadBarMenu.h" +#include "Utilities.h" + + const char* kDeskbarItemName = "ProcessController"; const char* kClassName = "ProcessController"; @@ -340,7 +343,7 @@ if (message->FindInt32 ("cpu", &cpu) == B_OK) { bool last = true; for (int p = 0; p < gCPUcount; p++) { - if (p != cpu && _kget_cpu_state_(p)) { + if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } @@ -350,7 +353,7 @@ "That's no Fun!", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->Go(); } else - _kset_cpu_state_(cpu, !_kget_cpu_state_(cpu)); + _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } @@ -674,7 +677,7 @@ BMessage* m = new BMessage ('CPU '); m->AddInt32 ("cpu", i); item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m); - if (_kget_cpu_state_(i)) + if (_kern_cpu_enabled(i)) item->SetMarked (true); item->SetTarget(gPCView); addtopbottom(item); Modified: haiku/trunk/src/apps/pulse/CPUButton.cpp =================================================================== --- haiku/trunk/src/apps/pulse/CPUButton.cpp 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/pulse/CPUButton.cpp 2009-06-14 11:55:24 UTC (rev 31044) @@ -10,11 +10,16 @@ #include "CPUButton.h" + +#include + +#include + +#include + #include "PulseApp.h" #include "PulseView.h" #include "Common.h" -#include -#include CPUButton::CPUButton(BRect rect, const char *name, const char *label, BMessage *message) @@ -173,13 +178,13 @@ CPUButton::Invoke(BMessage *message) { if (!LastEnabledCPU(fCPU)) { - _kset_cpu_state_(fCPU, Value()); + _kern_set_cpu_enabled(fCPU, Value()); } else { BAlert *alert = new BAlert(NULL, "You can't disable the last active CPU.", "OK"); alert->Go(NULL); SetValue(!Value()); } - + return B_OK; } @@ -216,7 +221,7 @@ } case PV_REPLICANT_PULSE: { // Make sure we're consistent with our CPU - if (_kget_cpu_state_(fCPU) != Value() && !IsTracking()) + if (_kern_cpu_enabled(fCPU) != Value() && !IsTracking()) SetValue(!Value()); break; } Modified: haiku/trunk/src/apps/pulse/Jamfile =================================================================== --- haiku/trunk/src/apps/pulse/Jamfile 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/pulse/Jamfile 2009-06-14 11:55:24 UTC (rev 31044) @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src apps pulse ; -SetSubDirSupportedPlatformsBeOSCompatible ; - +UsePrivateSystemHeaders ; UsePrivateHeaders shared ; if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { UseHeaders [ FDirName $(HAIKU_TOP) headers os kernel ] : true ; @@ -22,8 +21,8 @@ ProgressBar.cpp PulseApp.cpp PulseView.cpp - PulseWindow.cpp + PulseWindow.cpp - : be - : Pulse.rdef + : be + : Pulse.rdef ; Modified: haiku/trunk/src/apps/pulse/PulseApp.cpp =================================================================== --- haiku/trunk/src/apps/pulse/PulseApp.cpp 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/pulse/PulseApp.cpp 2009-06-14 11:55:24 UTC (rev 31044) @@ -12,20 +12,23 @@ #include "PulseApp.h" -#include "Common.h" -#include "PulseWindow.h" -#include "DeskbarPulseView.h" -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include + +#include "Common.h" +#include "PulseWindow.h" +#include "DeskbarPulseView.h" + + PulseApp::PulseApp(int argc, char **argv) : BApplication(APP_SIGNATURE) { @@ -60,7 +63,7 @@ uint32 rgb = strtoul(optarg, NULL, 0); rgb = rgb << 8; rgb |= 0x000000ff; - + switch (option_index) { case 2: framecolor = rgb; @@ -90,7 +93,7 @@ break; } } - + if (deskbar) { prefs->window_mode = DESKBAR_MODE; if (activecolor != 0) @@ -171,7 +174,7 @@ for (int x = 0; x < sys_info.cpu_count; x++) { if (x == my_cpu) continue; - if (_kget_cpu_state_(x) == 1) + if (_kern_cpu_enabled(x) == 1) return false; } return true; @@ -211,7 +214,7 @@ delete deskbar; return false; } - + // Must be 16 pixels high, the width is retrieved from the Prefs class int width = pulseapp->prefs->deskbar_icon_width; int min_width = GetMinimumViewWidth(); @@ -219,7 +222,7 @@ pulseapp->prefs->deskbar_icon_width = min_width; width = min_width; } - + BRect rect(0, 0, width - 1, 15); DeskbarPulseView *replicant = new DeskbarPulseView(rect); status_t err = deskbar->AddItem(replicant); Modified: haiku/trunk/src/apps/pulse/PulseView.cpp =================================================================== --- haiku/trunk/src/apps/pulse/PulseView.cpp 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/pulse/PulseView.cpp 2009-06-14 11:55:24 UTC (rev 31044) @@ -9,13 +9,19 @@ //**************************************************************************************** #include "PulseView.h" -#include "Common.h" -#include "PulseApp.h" -#include + #include #include #include +#include + +#include + +#include "Common.h" +#include "PulseApp.h" + + PulseView::PulseView(BRect rect, const char *name) : BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS) { @@ -33,7 +39,7 @@ PulseView::PulseView(BMessage *message) : BView(message) { SetResizingMode(B_FOLLOW_ALL_SIDES); SetFlags(B_WILL_DRAW | B_PULSE_NEEDED); - + popupmenu = NULL; cpu_menu_items = NULL; Init(); @@ -46,14 +52,14 @@ mode2 = new BMenuItem("", NULL, 0, 0); preferences = new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(PV_PREFERENCES), 0, 0); about = new BMenuItem("About Pulse" B_UTF8_ELLIPSIS, new BMessage(PV_ABOUT), 0, 0); - + popupmenu->AddItem(mode1); popupmenu->AddItem(mode2); popupmenu->AddSeparatorItem(); - + system_info sys_info; get_system_info(&sys_info); - + // Only add menu items to control CPUs on an SMP machine if (sys_info.cpu_count >= 2) { cpu_menu_items = new BMenuItem *[sys_info.cpu_count]; @@ -67,7 +73,7 @@ } popupmenu->AddSeparatorItem(); } - + popupmenu->AddItem(preferences); popupmenu->AddItem(about); } @@ -77,7 +83,7 @@ uint32 buttons; MakeFocus(true); GetMouse(&cursor, &buttons, true); - + if (buttons & B_SECONDARY_MOUSE_BUTTON) { ConvertToScreen(&point); // Use the asynchronous version so we don't interfere with @@ -98,11 +104,11 @@ if (cpu_time < 0) cpu_time = 0; if (cpu_time > 1) cpu_time = 1; cpu_times[x] = cpu_time; - + if (sys_info.cpu_count >= 2) { - if (!_kget_cpu_state_(x) && cpu_menu_items[x]->IsMarked()) + if (!_kern_cpu_enabled(x) && cpu_menu_items[x]->IsMarked()) cpu_menu_items[x]->SetMarked(false); - if (_kget_cpu_state_(x) && !cpu_menu_items[x]->IsMarked()) + if (_kern_cpu_enabled(x) && !cpu_menu_items[x]->IsMarked()) cpu_menu_items[x]->SetMarked(true); } } @@ -111,9 +117,9 @@ void PulseView::ChangeCPUState(BMessage *message) { int which = message->FindInt32("which"); - + if (!LastEnabledCPU(which)) { - _kset_cpu_state_(which, (int)!cpu_menu_items[which]->IsMarked()); + _kern_set_cpu_enabled(which, (int)!cpu_menu_items[which]->IsMarked()); } else { BAlert *alert = new BAlert(NULL, "You can't disable the last active CPU.", "OK"); alert->Go(NULL); Modified: haiku/trunk/src/apps/pulse/PulseView.h =================================================================== --- haiku/trunk/src/apps/pulse/PulseView.h 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/pulse/PulseView.h 2009-06-14 11:55:24 UTC (rev 31044) @@ -15,8 +15,6 @@ #include #include -extern "C" int _kget_cpu_state_(int cpu); -extern "C" int _kset_cpu_state_(int cpu, int enabled); class PulseView : public BView { public: @@ -25,15 +23,15 @@ ~PulseView(); virtual void MouseDown(BPoint point); void ChangeCPUState(BMessage *message); - + protected: void Init(); void Update(); - + BPopUpMenu *popupmenu; BMenuItem *mode1, *mode2, *preferences, *about; BMenuItem **cpu_menu_items; - + double cpu_times[B_MAX_CPU_COUNT]; bigtime_t prev_active[B_MAX_CPU_COUNT]; bigtime_t prev_time; Modified: haiku/trunk/src/apps/showimage/Filter.cpp =================================================================== --- haiku/trunk/src/apps/showimage/Filter.cpp 2009-06-14 11:10:36 UTC (rev 31043) +++ haiku/trunk/src/apps/showimage/Filter.cpp 2009-06-14 11:55:24 UTC (rev 31044) @@ -15,11 +15,11 @@ #include #include +#include + #include "Filter.h" -extern "C" int _kget_cpu_state_(int cpu); - // Implementation of FilterThread FilterThread::FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread) : fFilter(filter) @@ -44,7 +44,7 @@ fFilter->FilterThreadDone(); } -status_t +status_t FilterThread::worker_thread(void* data) { FilterThread* thread = (FilterThread*)data; @@ -87,12 +87,12 @@ , fDestImage(NULL) { fCPUCount = NumberOfActiveCPUs(); - + fWaitForThreads = create_sem(0, "wait_for_threads"); - + #if TIME_FILTER fStopWatch = NULL; - #endif + #endif } Filter::~Filter() @@ -123,19 +123,19 @@ Filter::Start(bool async) { if (fStarted || fSrcImage == NULL) return; - + #if TIME_FILTER fStopWatch = new BStopWatch("Filter Time"); #endif - + fN = NumberOfThreads(); fNumberOfThreads = fN; - fIsRunning = true; + fIsRunning = true; fStarted = true; // start first filter thread new FilterThread(this, 0, fN, !async); - + if (!async) { Wait(); } @@ -238,7 +238,7 @@ count = info.cpu_count; int32 cpuCount = 0; for (int i = 0; i < count; i ++) { - if (_kget_cpu_state_(i)) + if (_kern_cpu_enabled(i)) cpuCount++; } if (cpuCount == 0) @@ -271,19 +271,19 @@ BRect dest(0, 0, fRect.IntegerWidth(), fRect.IntegerHeight()); BBitmap* destImage = new BBitmap(dest, fDither ? B_CMAP8 : srcImage->ColorSpace()); - + if (!IsBitmapValid(destImage)) { delete destImage; return NULL; } - - if (fDither) + + if (fDither) { BRect dest_rect(0, 0, fRect.IntegerWidth(), fRect.IntegerHeight()); fScaledImage = new BBitmap(dest_rect, srcImage->ColorSpace()); if (!IsBitmapValid(fScaledImage)) { delete destImage; - delete fScaledImage; + delete fScaledImage; fScaledImage = NULL; return NULL; } @@ -330,17 +330,17 @@ src = GetSrcImage(); dest = fScaledImage; - + srcW = src->Bounds().IntegerWidth(); srcH = src->Bounds().IntegerHeight(); destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); destBits = (uchar*)dest->Bits(); srcBPR = src->BytesPerRow(); destBPR = dest->BytesPerRow(); - + columnData = new ColumnData[destW]; cd = columnData; for (i = 0; i < destW; i ++, cd++) { @@ -351,7 +351,7 @@ } destDataRow = destBits + fromRow * destBPR; - + for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { float row; intType srcRow; @@ -368,7 +368,7 @@ srcData = srcBits + srcRow * srcBPR; destData = destDataRow; - + if (y < destH) { float a0, a1; const uchar *a, *b, *c, *d; @@ -378,10 +378,10 @@ b = a + kBPP; c = a + srcBPR; d = c + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = static_cast( (a[0] * a0 + b[0] * a1) * alpha0 + (c[0] * a0 + d[0] * a1) * alpha1); @@ -395,11 +395,11 @@ (a[3] * a0 + b[3] * a1) * alpha0 + (c[3] * a0 + d[3] * a1) * alpha1); } - + // right column a = srcData + srcW * kBPP; c = a + srcBPR; - + destData[0] = static_cast(a[0] * alpha0 + c[0] * alpha1); destData[1] = static_cast(a[1] * alpha0 + c[1] * alpha1); destData[2] = static_cast(a[2] * alpha0 + c[2] * alpha1); @@ -410,16 +410,16 @@ for (x = 0; x < destW; x ++, destData += kBPP) { a = srcData + columnData[x].srcColumn * kBPP; b = a + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = static_cast(a[0] * a0 + b[0] * a1); destData[1] = static_cast(a[1] * a0 + b[1] * a1); destData[2] = static_cast(a[2] * a0 + b[2] * a1); destData[3] = static_cast(a[3] * a0 + b[3] * a1); } - + // bottom, right pixel a = srcData + srcW * kBPP; @@ -428,9 +428,9 @@ destData[2] = a[2]; destData[3] = a[3]; } - + } - + delete[] columnData; } @@ -464,22 +464,22 @@ src = GetSrcImage(); dest = fScaledImage; - + srcW = src->Bounds().IntegerWidth(); srcH = src->Bounds().IntegerHeight(); destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); destBits = (uchar*)dest->Bits(); srcBPR = src->BytesPerRow(); destBPR = dest->BytesPerRow(); - - fixed_point fpSrcW = to_fixed_point(srcW); + + fixed_point fpSrcW = to_fixed_point(srcW); fixed_point fpDestW = to_fixed_point(destW); fixed_point fpSrcH = to_fixed_point(srcH); fixed_point fpDestH = to_fixed_point(destH); - + columnData = new ColumnDataFP[destW]; cd = columnData; for (i = 0; i < destW; i ++, cd++) { @@ -490,7 +490,7 @@ } destDataRow = destBits + fromRow * destBPR; - + for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { fixed_point row; intType srcRow; @@ -514,7 +514,7 @@ (c[i] * a0 + d[i] * a1) * alpha1)) #define V2(i) from_fixed_point(a[i] * alpha0 + c[i] * alpha1); #define H2(i) from_fixed_point(a[i] * a0 + b[i] * a1); - + if (y < destH) { fixed_point a0, a1; const uchar *a, *b, *c, *d; @@ -524,20 +524,20 @@ b = a + kBPP; c = a + srcBPR; d = c + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = I4(0); destData[1] = I4(1); destData[2] = I4(2); destData[3] = I4(3); } - + // right column a = srcData + srcW * kBPP; c = a + srcBPR; - + destData[0] = V2(0); destData[1] = V2(1); destData[2] = V2(2); @@ -548,16 +548,16 @@ for (x = 0; x < destW; x ++, destData += kBPP) { a = srcData + columnData[x].srcColumn * kBPP; b = a + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = H2(0); destData[1] = H2(1); destData[2] = H2(2); destData[3] = H2(3); } - + // bottom, right pixel a = srcData + srcW * kBPP; @@ -566,9 +566,9 @@ destData[2] = a[2]; destData[3] = a[3]; } - + } - + delete[] columnData; } @@ -578,15 +578,15 @@ sum[0] = a0X * src[0]; sum[1] = a0X * src[1]; sum[2] = a0X * src[2]; - + src += kBPP; - + for (int32 x = fromX+1; x < toX; x ++, src += kBPP) { sum[0] += src[0]; sum[1] += src[1]; sum[2] += src[2]; } - + if (toX <= srcW) { sum[0] += a1X * src[0]; sum[1] += a1X * src[1]; @@ -620,19 +620,19 @@ src = GetSrcImage(); dest = fScaledImage; - + srcW = src->Bounds().IntegerWidth(); srcH = src->Bounds().IntegerHeight(); destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); destBits = (uchar*)dest->Bits(); srcBPR = src->BytesPerRow(); destBPR = dest->BytesPerRow(); - + destDataRow = destBits + fromRow * destBPR; - + const float deltaX = (srcW + 1.0) / (destW + 1.0); const float deltaY = (srcH + 1.0) / (destH + 1.0); const float deltaXY = deltaX * deltaY; @@ -642,61 +642,61 @@ for (x = 0; x <= destW; x ++, cd ++) { const float fFromX = x * deltaX; const float fToX = fFromX + deltaX; - + cd->from = (intType)fFromX; cd->to = (intType)fToX; - + cd->alpha0 = 1.0 - (fFromX - cd->from); - cd->alpha1 = fToX - cd->to; + cd->alpha1 = fToX - cd->to; } - + for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { const float fFromY = y * deltaY; const float fToY = fFromY + deltaY; - + const intType fromY = (intType)fFromY; const intType toY = (intType)fToY; - + const float a0Y = 1.0 - (fFromY - fromY); - const float a1Y = fToY - toY; - + const float a1Y = fToY - toY; + const uchar* srcDataRow = srcBits + fromY * srcBPR; destData = destDataRow; - + cd = columnData; for (x = 0; x <= destW; x ++, destData += kBPP, cd ++) { const intType fromX = cd->from; const intType toX = cd->to; - + const float a0X = cd->alpha0; const float a1X = cd->alpha1; srcData = srcDataRow + fromX * kBPP; - + float totalSum[3]; float sum[3]; - + RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] = a0Y * sum[0]; totalSum[1] = a0Y * sum[1]; totalSum[2] = a0Y * sum[2]; - + srcData += srcBPR; - + for (int32 r = fromY+1; r < toY; r ++, srcData += srcBPR) { RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] += sum[0]; totalSum[1] += sum[1]; totalSum[2] += sum[2]; } - + if (toY <= srcH) { RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] += a1Y * sum[0]; totalSum[1] += a1Y * sum[1]; totalSum[2] += a1Y * sum[2]; } - + destData[0] = static_cast(totalSum[0] / deltaXY); destData[1] = static_cast(totalSum[1] / deltaXY); destData[2] = static_cast(totalSum[2] / deltaXY); @@ -715,7 +715,7 @@ intType error[3]; } DitheringColumnData; -uchar +uchar Scaler::Limit(intType value) { if (value < 0) { @@ -749,7 +749,7 @@ DitheringColumnData* cd; BScreen screen; intType error[3], err[3]; - + src = fScaledImage; dest = GetDestImage(); @@ -757,20 +757,20 @@ ASSERT(dest->ColorSpace() == B_CMAP8); ASSERT(src->Bounds().IntegerWidth() == dest->Bounds().IntegerWidth()); ASSERT(src->Bounds().IntegerHeight() == dest->Bounds().IntegerHeight()); - + destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); srcBPR = src->BytesPerRow(); destBits = (uchar*)dest->Bits(); destBPR = dest->BytesPerRow(); - + // Allocate space for sentinel at left and right bounds, // so that columnData[-1] and columnData[destW+1] can be safely accessed columnData0 = new DitheringColumnData[destW+3]; columnData = columnData0 + 1; - + // clear error cd = columnData; for (x = destW; x >= 0; x --, cd ++) { @@ -787,38 +787,38 @@ for (x = 0; x <= destW; x ++, srcData += kBPP, destData += 1) { rgb_color color, actualColor; uint8 index; - + color.red = Limit(srcData[2] + error[0] / 16); color.green = Limit(srcData[1] + error[1] / 16); color.blue = Limit(srcData[0] + error[2] / 16); - + index = screen.IndexForColor(color); actualColor = screen.ColorForIndex(index); - + *destData = index; - + err[0] = color.red - actualColor.red; err[1] = color.green -actualColor.green; err[2] = color.blue -actualColor.blue; - + // distribute error // get error for next pixel cd = &columnData[x+1]; error[0] = cd->error[0] + 7 * err[0]; error[1] = cd->error[1] + 7 * err[1]; error[2] = cd->error[2] + 7 * err[2]; - + // set error for right pixel below current pixel cd->error[0] = err[0]; cd->error[1] = err[1]; cd->error[2] = err[2]; - + // add error for pixel below current pixel cd --; cd->error[0] += 5 * err[0]; cd->error[1] += 5 * err[1]; cd->error[2] += 5 * err[2]; - + // add error for left pixel below current pixel cd --; cd->error[0] += 3 * err[0]; @@ -837,38 +837,38 @@ for (x = 0; x <= destW; x ++, srcData -= kBPP, destData -= 1) { rgb_color color, actualColor; uint8 index; - + color.red = Limit(srcData[2] + error[0] / 16); color.green = Limit(srcData[1] + error[1] / 16); color.blue = Limit(srcData[0] + error[2] / 16); - + index = screen.IndexForColor(color); actualColor = screen.ColorForIndex(index); - + *destData = index; - + err[0] = color.red - actualColor.red; err[1] = color.green -actualColor.green; err[2] = color.blue -actualColor.blue; - + // distribute error // get error for next pixel cd = &columnData[x-1]; error[0] = cd->error[0] + 7 * err[0]; error[1] = cd->error[1] + 7 * err[1]; error[2] = cd->error[2] + 7 * err[2]; - + // set error for left pixel below current pixel cd->error[0] = err[0]; cd->error[1] = err[1]; cd->error[2] = err[2]; - + // add error for pixel below current pixel cd ++; cd->error[0] += 5 * err[0]; cd->error[1] += 5 * err[1]; cd->error[2] += 5 * err[2]; - + // add error for right pixel below current pixel cd ++; cd->error[0] += 3 * err[0]; @@ -888,7 +888,7 @@ void Scaler::Run(int32 i, int32 n) -{ +{ int32 from, to, height, imageHeight; imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1; height = imageHeight / n; @@ -930,28 +930,28 @@ color_space cs; BBitmap* bm; BRect rect; [... truncated: 68 lines follow ...] From bonefish at mail.berlios.de Sun Jun 14 14:14:12 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 14:14:12 +0200 Subject: [Haiku-commits] r31045 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch headers/private/kernel/arch/x86 headers/private/system src/system/kernel/arch/m68k src/system/kernel/arch/ppc src/system/kernel/arch/x86 src/system/kernel/debug Message-ID: <200906141214.n5ECECxm029445@sheep.berlios.de> Author: bonefish Date: 2009-06-14 14:14:06 +0200 (Sun, 14 Jun 2009) New Revision: 31045 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31045&view=rev Modified: haiku/trunk/headers/private/kernel/arch/user_debugger.h haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h haiku/trunk/headers/private/kernel/user_debugger.h haiku/trunk/headers/private/system/syscalls.h haiku/trunk/src/system/kernel/arch/m68k/arch_user_debugger.cpp haiku/trunk/src/system/kernel/arch/ppc/arch_user_debugger.cpp haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp haiku/trunk/src/system/kernel/debug/user_debugger.cpp Log: User debugger support: * Generalized address checks. The debugger can now also read the commpage. * Added new syscall _kern_get_thread_cpu_state() to get the CPU state of a not running thread. Introduced arch_get_thread_debug_cpu_state() for that purpose, which is only implemented for x86 ATM (uses the new i386_get_thread_user_iframe()). * Don't allow a debugger to change a thread's "esp" anymore. That's the esp register in the kernel. "user_esp" can still be changed. * Generally set RF (resume flag) in eflags in interrupt handlers, not only after a instruction breakpoint debug exception. This should prevent breakpoints from being triggered more than once (e.g. when the breakpoint is on an instruction that can cause a page fault). I still saw those with bdb in VMware, but that might be a VMware bug. Modified: haiku/trunk/headers/private/kernel/arch/user_debugger.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/user_debugger.h 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/headers/private/kernel/arch/user_debugger.h 2009-06-14 12:14:06 UTC (rev 31045) @@ -17,6 +17,7 @@ struct arch_team_debug_info; struct arch_thread_debug_info; +struct thread; void arch_clear_team_debug_info(struct arch_team_debug_info *info); void arch_destroy_team_debug_info(struct arch_team_debug_info *info); @@ -27,6 +28,8 @@ void arch_set_debug_cpu_state(const struct debug_cpu_state *cpuState); void arch_get_debug_cpu_state(struct debug_cpu_state *cpuState); +status_t arch_get_thread_debug_cpu_state(struct thread *thread, + struct debug_cpu_state *cpuState); status_t arch_set_breakpoint(void *address); status_t arch_clear_breakpoint(void *address); Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_thread.h 2009-06-14 12:14:06 UTC (rev 31045) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, The Haiku Team. All rights reserved. + * Copyright 2002-2009, The Haiku Team. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2002, Travis Geiselbrecht. All rights reserved. @@ -18,6 +18,8 @@ struct iframe *i386_get_user_iframe(void); struct iframe *i386_get_current_iframe(void); +struct iframe *i386_get_thread_user_iframe(struct thread *thread); + void *x86_next_page_directory(struct thread *from, struct thread *to); void x86_restart_syscall(struct iframe* frame); Modified: haiku/trunk/headers/private/kernel/user_debugger.h =================================================================== --- haiku/trunk/headers/private/kernel/user_debugger.h 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/headers/private/kernel/user_debugger.h 2009-06-14 12:14:06 UTC (rev 31045) @@ -240,6 +240,8 @@ port_id _user_install_team_debugger(team_id team, port_id debuggerPort); status_t _user_remove_team_debugger(team_id team); status_t _user_debug_thread(thread_id thread); +status_t _user_get_thread_cpu_state(thread_id thread, + struct debug_cpu_state *cpuState); void _user_wait_for_debugger(void); status_t _user_set_debugger_breakpoint(void *address, uint32 type, Modified: haiku/trunk/headers/private/system/syscalls.h =================================================================== --- haiku/trunk/headers/private/system/syscalls.h 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/headers/private/system/syscalls.h 2009-06-14 12:14:06 UTC (rev 31045) @@ -19,6 +19,7 @@ extern "C" { #endif +struct debug_cpu_state; struct dirent; struct Elf32_Sym; struct fd_info; @@ -384,6 +385,8 @@ port_id debuggerPort); extern status_t _kern_remove_team_debugger(team_id team); extern status_t _kern_debug_thread(thread_id thread); +extern status_t _kern_get_thread_cpu_state(thread_id threadID, + struct debug_cpu_state *userCPUState); extern void _kern_wait_for_debugger(void); extern status_t _kern_set_debugger_breakpoint(void *address, uint32 type, Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_user_debugger.cpp 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_user_debugger.cpp 2009-06-14 12:14:06 UTC (rev 31045) @@ -45,14 +45,14 @@ { if (struct iframe* frame = m68k_get_user_iframe()) { struct thread* thread = thread_get_current_thread(); - + // set/clear T1 in SR depending on if single stepping is desired // T1 T0 // 0 0 no tracing // 0 1 trace on flow // 1 0 single step // 1 1 undef - // note 060 and 020(?) only have T1 bit, + // note 060 and 020(?) only have T1 bit, // but this should be compatible as well. if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP) { frame->cpu.sr &= ~(M68K_SR_T_MASK); @@ -77,6 +77,14 @@ status_t +arch_get_thread_debug_cpu_state(struct thread *thread, + struct debug_cpu_state *cpuState) +{ + return B_UNSUPPORTED; +} + + +status_t arch_set_breakpoint(void *address) { return B_ERROR; Modified: haiku/trunk/src/system/kernel/arch/ppc/arch_user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/ppc/arch_user_debugger.cpp 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/src/system/kernel/arch/ppc/arch_user_debugger.cpp 2009-06-14 12:14:06 UTC (rev 31045) @@ -55,6 +55,14 @@ status_t +arch_get_thread_debug_cpu_state(struct thread *thread, + struct debug_cpu_state *cpuState) +{ + return B_UNSUPPORTED; +} + + +status_t arch_set_breakpoint(void *address) { return B_ERROR; Modified: haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2009-06-14 12:14:06 UTC (rev 31045) @@ -253,6 +253,11 @@ movl %esp, %ebp // frame pointer is the iframe + // Set the RF (resume flag) in EFLAGS. This prevents an instruction + // breakpoint on the instruction we're returning to to trigger a debug + // exception. + orl $0x10000, IFRAME_flags(%ebp); + testl $0x20000, IFRAME_flags(%ebp) // VM86 mode jnz int_bottom_vm86 cmp $USER_CODE_SEG, IFRAME_cs(%ebp) // user mode Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2009-06-14 12:14:06 UTC (rev 31045) @@ -90,10 +90,8 @@ static struct iframe * -find_previous_iframe(addr_t frame) +find_previous_iframe(struct thread *thread, addr_t frame) { - struct thread *thread = thread_get_current_thread(); - // iterate backwards through the stack frames, until we hit an iframe while (frame >= thread->kernel_stack_base && frame < thread->kernel_stack_top) { @@ -117,7 +115,7 @@ if (frame == NULL) return NULL; - return find_previous_iframe(frame->ebp); + return find_previous_iframe(thread_get_current_thread(), frame->ebp); } @@ -130,7 +128,7 @@ static struct iframe* get_current_iframe(void) { - return find_previous_iframe(x86_read_ebp()); + return find_previous_iframe(thread_get_current_thread(), x86_read_ebp()); } @@ -156,12 +154,38 @@ } +/*! \brief Like i386_get_user_iframe(), just for the given thread. + The thread must not be running and the threads spinlock must be held. +*/ struct iframe * +i386_get_thread_user_iframe(struct thread *thread) +{ + if (thread->state == B_THREAD_RUNNING) + return NULL; + + // read %ebp from the thread's stack stored by a pushad + addr_t ebp = thread->arch_info.current_stack.esp[2]; + + // find the user iframe + struct iframe *frame = find_previous_iframe(thread, ebp); + + while (frame != NULL) { + if (IFRAME_IS_USER(frame)) + return frame; + frame = get_previous_iframe(frame); + } + + return NULL; +} + + +struct iframe * i386_get_current_iframe(void) { return get_current_iframe(); } + void * x86_next_page_directory(struct thread *from, struct thread *to) { Modified: haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp 2009-06-14 12:14:06 UTC (rev 31045) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Ingo Weinhold, bonefish at users.sf.net. + * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold at gmx.de. * Distributed under the terms of the MIT License. */ @@ -60,6 +60,31 @@ static bool sQEmuSingleStepHack = false; +static void +get_iframe_registers(struct iframe *frame, struct debug_cpu_state *cpuState) +{ + cpuState->gs = frame->gs; + cpuState->fs = frame->fs; + cpuState->es = frame->es; + cpuState->ds = frame->ds; + cpuState->edi = frame->edi; + cpuState->esi = frame->esi; + cpuState->ebp = frame->ebp; + cpuState->esp = frame->esp; + cpuState->ebx = frame->ebx; + cpuState->edx = frame->orig_edx; + cpuState->ecx = frame->ecx; + cpuState->eax = frame->orig_eax; + cpuState->vector = frame->vector; + cpuState->error_code = frame->error_code; + cpuState->eip = frame->eip; + cpuState->cs = frame->cs; + cpuState->eflags = frame->flags; + cpuState->user_esp = frame->user_esp; + cpuState->user_ss = frame->user_ss; +} + + static inline void install_breakpoints(const arch_team_debug_info &teamInfo) { @@ -562,7 +587,7 @@ frame->edi = cpuState->edi; frame->esi = cpuState->esi; frame->ebp = cpuState->ebp; - frame->esp = cpuState->esp; +// frame->esp = cpuState->esp; frame->ebx = cpuState->ebx; frame->edx = cpuState->edx; frame->ecx = cpuState->ecx; @@ -586,31 +611,31 @@ i386_fnsave(cpuState->extended_regs); // For this to be correct the calling function must not use these // registers (not even indirectly). - - cpuState->gs = frame->gs; - cpuState->fs = frame->fs; - cpuState->es = frame->es; - cpuState->ds = frame->ds; - cpuState->edi = frame->edi; - cpuState->esi = frame->esi; - cpuState->ebp = frame->ebp; - cpuState->esp = frame->esp; - cpuState->ebx = frame->ebx; - cpuState->edx = frame->orig_edx; - cpuState->ecx = frame->ecx; - cpuState->eax = frame->orig_eax; - cpuState->vector = frame->vector; - cpuState->error_code = frame->error_code; - cpuState->eip = frame->eip; - cpuState->cs = frame->cs; - cpuState->eflags = frame->flags; - cpuState->user_esp = frame->user_esp; - cpuState->user_ss = frame->user_ss; + get_iframe_registers(frame, cpuState); } } +/*! \brief Returns the CPU state for the given thread. + The thread must not be running and the threads spinlock must be held. +*/ status_t +arch_get_thread_debug_cpu_state(struct thread *thread, + struct debug_cpu_state *cpuState) +{ + struct iframe *frame = i386_get_thread_user_iframe(thread); + if (frame == NULL) + return B_BAD_VALUE; + + get_iframe_registers(frame, cpuState); + memcpy(cpuState->extended_regs, thread->arch_info.fpu_state, + sizeof(cpuState->extended_regs)); + + return B_OK; +} + + +status_t arch_set_breakpoint(void *address) { return set_breakpoint(address, X86_INSTRUCTION_BREAKPOINT, @@ -801,15 +826,9 @@ bool watchpoint = true; for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { if (dr6 & (1 << sDR6B[i])) { - // If it is an instruction breakpoint, we need to set RF in - // EFLAGS to prevent triggering the same exception - // again (breakpoint instructions are triggered *before* - // executing the instruction). uint32 type = (dr7 >> sDR7RW[i]) & 0x3; - if (type == X86_INSTRUCTION_BREAKPOINT) { - frame->flags |= (1 << X86_EFLAGS_RF); + if (type == X86_INSTRUCTION_BREAKPOINT) watchpoint = false; - } } } Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-14 11:55:24 UTC (rev 31044) +++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-14 12:14:06 UTC (rev 31045) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold at gmx.de. * Distributed under the terms of the MIT License. */ @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -1412,6 +1413,26 @@ } +/*! \brief Returns whether the given address can be accessed in principle. + No check whether there's an actually accessible area is performed, though. +*/ +static bool +can_access_address(const void* address, bool write) +{ + // user addresses are always fine + if (IS_USER_ADDRESS(address)) + return true; + + // a commpage address can at least be read + if ((addr_t)address >= USER_COMMPAGE_ADDR + && (addr_t)address < USER_COMMPAGE_ADDR + COMMPAGE_SIZE) { + return !write; + } + + return false; +} + + /** \brief Reads data from user memory. * * Tries to read \a size bytes of data from user memory address \a address @@ -1435,7 +1456,7 @@ char *buffer = (char*)_buffer; // check the parameters - if (!IS_USER_ADDRESS(address)) + if (!can_access_address(address, false)) return B_BAD_ADDRESS; if (size <= 0) return B_BAD_VALUE; @@ -1446,7 +1467,7 @@ bytesRead = 0; while (size > 0) { // check whether we're still in user address space - if (!IS_USER_ADDRESS(address)) { + if (!can_access_address(address, false)) { error = B_BAD_ADDRESS; break; } @@ -1486,7 +1507,7 @@ const char *buffer = (const char*)_buffer; // check the parameters - if (!IS_USER_ADDRESS(address)) + if (!can_access_address(address, true)) return B_BAD_ADDRESS; if (size <= 0) return B_BAD_VALUE; @@ -1497,7 +1518,7 @@ bytesWritten = 0; while (size > 0) { // check whether we're still in user address space - if (!IS_USER_ADDRESS(address)) { + if (!can_access_address(address, true)) { error = B_BAD_ADDRESS; break; } @@ -1589,7 +1610,7 @@ else if (thread->debug_info.flags & B_THREAD_DEBUG_STOPPED) threadDebugPort = thread->debug_info.debug_port; else - result = B_BAD_VALUE; + result = B_BAD_THREAD_STATE; } else result = B_BAD_THREAD_ID; @@ -1677,7 +1698,7 @@ status_t result = B_OK; // check the parameters - if (!IS_USER_ADDRESS(address)) + if (!can_access_address(address, false)) result = B_BAD_ADDRESS; else if (size <= 0 || size > B_MAX_READ_WRITE_MEMORY_SIZE) result = B_BAD_VALUE; @@ -1713,7 +1734,7 @@ status_t result = B_OK; // check the parameters - if (!IS_USER_ADDRESS(address)) + if (!can_access_address(address, true)) result = B_BAD_ADDRESS; else if (size <= 0 || size > realSize) result = B_BAD_VALUE; @@ -1897,7 +1918,7 @@ // check the address status_t result = B_OK; - if (address == NULL || !IS_USER_ADDRESS(address)) + if (address == NULL || !can_access_address(address, false)) result = B_BAD_ADDRESS; // set the breakpoint @@ -1925,7 +1946,7 @@ // check the address status_t result = B_OK; - if (address == NULL || !IS_USER_ADDRESS(address)) + if (address == NULL || !can_access_address(address, false)) result = B_BAD_ADDRESS; // clear the breakpoint @@ -1952,7 +1973,7 @@ // check the address and size status_t result = B_OK; - if (address == NULL || !IS_USER_ADDRESS(address)) + if (address == NULL || !can_access_address(address, false)) result = B_BAD_ADDRESS; if (length < 0) result = B_BAD_VALUE; @@ -1982,7 +2003,7 @@ // check the address status_t result = B_OK; - if (address == NULL || !IS_USER_ADDRESS(address)) + if (address == NULL || !can_access_address(address, false)) result = B_BAD_ADDRESS; // clear the watchpoint @@ -2928,6 +2949,49 @@ } +status_t +_user_get_thread_cpu_state(thread_id threadID, + struct debug_cpu_state *userCPUState) +{ + TRACE(("[%ld] _user_get_thread_cpu_state(%ld, %p)\n", find_thread(NULL), + threadID, userCPUState)); + + if (userCPUState == NULL || !IS_USER_ADDRESS(userCPUState)) + return B_BAD_ADDRESS; + + InterruptsSpinLocker locker(gThreadSpinlock); + + // get and check the thread + struct thread *thread = thread_get_thread_struct_locked(threadID); + if (thread == NULL) { + // thread doesn't exist any longer + return B_BAD_THREAD_ID; + } else if (thread->team == team_get_kernel_team()) { + // we can't debug the kernel team + return B_NOT_ALLOWED; + } else if (thread->debug_info.flags & B_THREAD_DEBUG_DYING) { + // the thread is already dying + return B_BAD_THREAD_ID; + } else if (thread->debug_info.flags & B_THREAD_DEBUG_NUB_THREAD) { + // don't play with the nub thread + return B_NOT_ALLOWED; + } else if (thread->state == B_THREAD_RUNNING) { + // thread is running -- no way to get its CPU state + return B_BAD_THREAD_STATE; + } + + // get the CPU state + debug_cpu_state cpuState; + status_t error = arch_get_thread_debug_cpu_state(thread, &cpuState); + if (error != B_OK) + return error; + + locker.Unlock(); + + return user_memcpy(userCPUState, &cpuState, sizeof(cpuState)); +} + + void _user_wait_for_debugger(void) { @@ -2942,7 +3006,7 @@ bool watchpoint) { // check the address and size - if (address == NULL || !IS_USER_ADDRESS(address)) + if (address == NULL || !can_access_address(address, false)) return B_BAD_ADDRESS; if (watchpoint && length < 0) return B_BAD_VALUE; @@ -2975,7 +3039,7 @@ _user_clear_debugger_breakpoint(void *address, bool watchpoint) { // check the address - if (address == NULL || !IS_USER_ADDRESS(address)) + if (address == NULL || !can_access_address(address, false)) return B_BAD_ADDRESS; // check whether a debugger is installed already From stippi at mail.berlios.de Sun Jun 14 14:16:19 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 14 Jun 2009 14:16:19 +0200 Subject: [Haiku-commits] r31046 - haiku/trunk/src/apps/installer Message-ID: <200906141216.n5ECGJ2q029616@sheep.berlios.de> Author: stippi Date: 2009-06-14 14:16:18 +0200 (Sun, 14 Jun 2009) New Revision: 31046 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31046&view=rev Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp Log: Increase the file handle limit. Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.cpp 2009-06-14 12:14:06 UTC (rev 31045) +++ haiku/trunk/src/apps/installer/CopyEngine.cpp 2009-06-14 12:16:18 UTC (rev 31046) @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,12 @@ if (fWriterThread >= B_OK) resume_thread(fWriterThread); + + // ask for a bunch more file descriptors so that nested copying works well + struct rlimit rl; + rl.rlim_cur = 512; + rl.rlim_max = RLIM_SAVED_MAX; + setrlimit(RLIMIT_NOFILE, &rl); } From bonefish at mail.berlios.de Sun Jun 14 14:53:33 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 14:53:33 +0200 Subject: [Haiku-commits] r31047 - in haiku/trunk/src/apps: . debugger Message-ID: <200906141253.n5ECrX5o032235@sheep.berlios.de> Author: bonefish Date: 2009-06-14 14:53:29 +0200 (Sun, 14 Jun 2009) New Revision: 31047 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31047&view=rev Added: haiku/trunk/src/apps/debugger/ haiku/trunk/src/apps/debugger/Array.h haiku/trunk/src/apps/debugger/AttributeValue.cpp haiku/trunk/src/apps/debugger/AttributeValue.h haiku/trunk/src/apps/debugger/DataReader.h haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/DebugInfoEntries.h haiku/trunk/src/apps/debugger/DebugInfoEntry.cpp haiku/trunk/src/apps/debugger/DebugInfoEntry.h haiku/trunk/src/apps/debugger/DwarfManager.cpp haiku/trunk/src/apps/debugger/DwarfManager.h haiku/trunk/src/apps/debugger/ElfFile.cpp haiku/trunk/src/apps/debugger/ElfFile.h haiku/trunk/src/apps/debugger/HaikuTypes.h haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/SourceLanguageInfo.cpp haiku/trunk/src/apps/debugger/SourceLanguageInfo.h haiku/trunk/src/apps/debugger/arch_elf.h haiku/trunk/src/apps/debugger/attribute_classes.cpp haiku/trunk/src/apps/debugger/attribute_classes.h haiku/trunk/src/apps/debugger/debugger.cpp haiku/trunk/src/apps/debugger/dwarf.h haiku/trunk/src/apps/debugger/tag_names.cpp haiku/trunk/src/apps/debugger/tag_names.h haiku/trunk/src/apps/debugger/types.h Modified: haiku/trunk/src/apps/Jamfile Log: The very beginnings of a debugger. Currently consisting only of the beginnings of a DWARF 3 reader. It can read the .debug_info section and create objects for the entries, but most attributes are ignored yet. Modified: haiku/trunk/src/apps/Jamfile =================================================================== --- haiku/trunk/src/apps/Jamfile 2009-06-14 12:16:18 UTC (rev 31046) +++ haiku/trunk/src/apps/Jamfile 2009-06-14 12:53:29 UTC (rev 31047) @@ -12,6 +12,7 @@ HaikuSubInclude codycam ; HaikuSubInclude cortex ; HaikuSubInclude debuganalyzer ; +HaikuSubInclude debugger ; HaikuSubInclude deskbar ; HaikuSubInclude deskcalc ; HaikuSubInclude diskprobe ; Added: haiku/trunk/src/apps/debugger/Array.h =================================================================== --- haiku/trunk/src/apps/debugger/Array.h 2009-06-14 12:16:18 UTC (rev 31046) +++ haiku/trunk/src/apps/debugger/Array.h 2009-06-14 12:53:29 UTC (rev 31047) @@ -0,0 +1,193 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef ARRAY_H +#define ARRAY_H + +#include +#include +#include + + +template +class Array { +public: + inline Array(); + ~Array(); + + inline int Size() const { return fSize; } + inline int Count() const { return fSize; } + inline bool IsEmpty() const { return fSize == 0; } + inline Element* Elements() const { return fElements; } + + inline bool Add(const Element& element); + inline bool Insert(const Element& element, int index); + inline bool Remove(int index); + + inline Element& ElementAt(int index); + inline const Element& ElementAt(int index) const; + + inline Element& operator[](int index); + inline const Element& operator[](int index) const; + +private: + static const int kMinCapacity = 8; + + bool _Resize(int index, int delta); + +private: + Element* fElements; + int fSize; + int fCapacity; +}; + + +template +Array::Array() + : + fElements(NULL), + fSize(0), + fCapacity(0) +{ +} + + +template +Array::~Array() +{ + free(fElements); +} + + +template +bool +Array::Add(const Element& element) +{ + if (fSize == fCapacity) { + if (!_Resize(fSize, 1)) + return false; + } + + fElements[fSize] = element; + fSize++; + return true; +} + + +template +bool +Array::Insert(const Element& element, int index) +{ + if (index < 0 || index > fSize) + index = fSize; + + if (fSize == fCapacity) { + if (!_Resize(index, 1)) + return false; + } else if (index < fSize) { + memmove(fElements + index + 1, fElements + index, + sizeof(Element) * (fSize - index)); + } + + fElements[index] = element; + fSize++; + return false; +} + + +template +bool +Array::Remove(int index) +{ + if (index < 0 || index >= fSize) { + char buffer[128]; + snprintf(buffer, sizeof(buffer), "Array::Remove(): index: %d, size: %d", + index, fSize); + return false; + } + + if (fSize <= fCapacity / 2 && fCapacity > kMinCapacity) { + _Resize(index, -1); + } else if (index < fSize) { + memmove(fElements + index, fElements + index + 1, + sizeof(Element) * (fSize - index - 1)); + } + + fSize--; + return true; +} + + +template +Element& +Array::ElementAt(int index) +{ + return fElements[index]; +} + + +template +const Element& +Array::ElementAt(int index) const +{ + return fElements[index]; +} + + +template +Element& +Array::operator[](int index) +{ + return fElements[index]; +} + + +template +const Element& +Array::operator[](int index) const +{ + return fElements[index]; +} + + +template +bool +Array::_Resize(int index, int delta) +{ + // determine new capacity + int newSize = fSize + delta; + int newCapacity = kMinCapacity; + while (newCapacity < newSize) + newCapacity *= 2; + + if (newCapacity == fCapacity) + return true; + + // allocate new array + Element* elements = (Element*)malloc(newCapacity * sizeof(Element)); + if (elements == NULL) + return false; + + if (index > 0) + memcpy(elements, fElements, index * sizeof(Element)); + if (index < fSize) { + if (delta > 0) { + // leave a gap of delta elements + memcpy(elements + index + delta, fElements + index, + (fSize - index) * sizeof(Element)); + } else if (index < fSize + delta) { + // drop -delta elements + memcpy(elements + index, fElements + index - delta, + (fSize - index + delta) * sizeof(Element)); + } + } + + free(fElements); + fElements = elements; + fCapacity = newCapacity; + return true; +} + + +#endif // ARRAY_H Added: haiku/trunk/src/apps/debugger/AttributeValue.cpp =================================================================== --- haiku/trunk/src/apps/debugger/AttributeValue.cpp 2009-06-14 12:16:18 UTC (rev 31046) +++ haiku/trunk/src/apps/debugger/AttributeValue.cpp 2009-06-14 12:53:29 UTC (rev 31047) @@ -0,0 +1,48 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "AttributeValue.h" + +#include + +#include "attribute_classes.h" + + +const char* +AttributeValue::ToString(char* buffer, size_t size) +{ + switch (attributeClass) { + case ATTRIBUTE_CLASS_ADDRESS: + snprintf(buffer, size, "%#lx", address); + return buffer; + case ATTRIBUTE_CLASS_BLOCK: + snprintf(buffer, size, "(%p, %#lx)", block.data, block.length); + return buffer; + case ATTRIBUTE_CLASS_CONSTANT: + snprintf(buffer, size, "%#llx", constant); + return buffer; + case ATTRIBUTE_CLASS_FLAG: + snprintf(buffer, size, "%s", flag ? "true" : "false"); + return buffer; + case ATTRIBUTE_CLASS_LINEPTR: + case ATTRIBUTE_CLASS_LOCLISTPTR: + case ATTRIBUTE_CLASS_MACPTR: + case ATTRIBUTE_CLASS_RANGELISTPTR: + snprintf(buffer, size, "%#lx", pointer); + return buffer; + case ATTRIBUTE_CLASS_REFERENCE: + snprintf(buffer, size, "%p", reference); + return buffer; + case ATTRIBUTE_CLASS_STRING: + snprintf(buffer, size, "\"%s\"", string); + return buffer; + + default: + case ATTRIBUTE_CLASS_UNKNOWN: + return ""; + } + + return buffer; +} Added: haiku/trunk/src/apps/debugger/AttributeValue.h =================================================================== --- haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-14 12:16:18 UTC (rev 31046) +++ haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-14 12:53:29 UTC (rev 31047) @@ -0,0 +1,69 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef ATTRIBUTE_VALUE_H +#define ATTRIBUTE_VALUE_H + +#include "attribute_classes.h" +#include "types.h" + + +class DebugInfoEntry; + + +struct AttributeValue { + union { + dwarf_addr_t address; + struct { + const void* data; + dwarf_size_t length; + } block; + uint64 constant; + bool flag; + dwarf_off_t pointer; + DebugInfoEntry* reference; + const char* string; + }; + + uint16 attributeForm; + uint8 attributeClass; + bool isSigned; + + const char* ToString(char* buffer, size_t size); +}; + + +struct DynamicAttributeValue { + union { + uint64 constant; + DebugInfoEntry* reference; + struct { + const void* data; + dwarf_size_t length; + } block; + }; + uint8 attributeClass; + + void SetTo(uint64 constant) + { + this->constant = constant; + attributeClass = ATTRIBUTE_CLASS_CONSTANT; + } + + void SetTo(DebugInfoEntry* reference) + { + this->reference = reference; + attributeClass = ATTRIBUTE_CLASS_REFERENCE; + } + + void SetTo(const void* data, dwarf_size_t length) + { + block.data = data; + block.length = length; + attributeClass = ATTRIBUTE_CLASS_BLOCK; + } +}; + + +#endif // ATTRIBUTE_VALUE_H Added: haiku/trunk/src/apps/debugger/DataReader.h =================================================================== --- haiku/trunk/src/apps/debugger/DataReader.h 2009-06-14 12:16:18 UTC (rev 31046) +++ haiku/trunk/src/apps/debugger/DataReader.h 2009-06-14 12:53:29 UTC (rev 31047) @@ -0,0 +1,163 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef DATA_READER_H +#define DATA_READER_H + +#include + + +class DataReader { +public: + DataReader() + : + fData(NULL), + fSize(0), + fInitialSize(0), + fOverflow(false) + { + } + + DataReader(const void* data, off_t size) + { + SetTo(data, size); + } + + void SetTo(const void* data, off_t size) + { + fData = (const uint8*)data; + fInitialSize = fSize = size; + fOverflow = false; + } + + bool HasData() const + { + return fSize > 0; + } + + bool HasOverflow() const + { + return fOverflow; + } + + const void* Data() const + { + return fData; + } + + off_t BytesRemaining() const + { + return fSize; + } + + off_t Offset() const + { + return fInitialSize - fSize; + } + + void SeekAbsolute(off_t offset) + { + if (offset < 0) + offset = 0; + else if (offset > fInitialSize) + offset = fInitialSize; + + fData += offset - Offset(); + fSize = fInitialSize - offset; + } + + template + Type Read(const Type& defaultValue) + { + if (fSize < sizeof(Type)) { + fOverflow = true; + fSize = 0; + return defaultValue; + } + + Type data; + memcpy(&data, fData, sizeof(Type)); + + fData += sizeof(Type); + fSize -= sizeof(Type); + + return data; + } + + uint64 ReadUnsignedLEB128(uint64 defaultValue) + { + uint64 result = 0; + int shift = 0; + while (true) { + uint8 byte = Read(0); + result |= uint64(byte & 0x7f) << shift; + if ((byte & 0x80) == 0) + break; + shift += 7; + } + + return fOverflow ? defaultValue : result; + } + + int64 ReadSignedLEB128(int64 defaultValue) + { + int64 result = 0; + int shift = 0; + while (true) { + uint8 byte = Read(0); + result |= uint64(byte & 0x7f) << shift; + shift += 7; + + if ((byte & 0x80) == 0) { + // sign extend + if ((byte & 0x40) != 0 && shift < 64) + result |= -((uint64)1 << shift); + break; + } + } + + return fOverflow ? defaultValue : result; + } + + const char* ReadString() + { + const char* string = (const char*)fData; + while (fSize > 0) { + fData++; + fSize--; + + if (fData[-1] == 0) + return string; + } + + fOverflow = true; + return NULL; + } + + bool Skip(off_t bytes) + { + if (bytes < 0) + return false; + + if (bytes > fSize) { + fSize = 0; + fOverflow = true; + return false; + } + + fData += bytes; + fSize -= bytes; + + return true; + } + +private: + const uint8* fData; + off_t fSize; + off_t fInitialSize; + bool fOverflow; +}; + + +#endif // DATA_READER_H Added: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 12:16:18 UTC (rev 31046) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 12:53:29 UTC (rev 31047) @@ -0,0 +1,1483 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "DebugInfoEntries.h" + +#include + +#include "AttributeValue.h" +#include "dwarf.h" +#include "SourceLanguageInfo.h" + + +// #pragma mark - DIECompileUnitBase + + +DIECompileUnitBase::DIECompileUnitBase() + : + fName(NULL), + fCompilationDir(NULL), + fLowPC(0), + fHighPC(0), + fStatementListOffset(0), + fMacroInfoOffset(0), + // TODO: Is 0 a good invalid offset? + fBaseTypesUnit(NULL), + fLanguage(0), + fIdentifierCase(0), + fUseUTF8(true) +{ +} + + +status_t +DIECompileUnitBase::InitAfterAttributes(DebugInfoEntryInitInfo& info) +{ + switch (fLanguage) { + case 0: + info.languageInfo = &kUnknownLanguageInfo; + return B_OK; + case DW_LANG_C89: + info.languageInfo = &kC89LanguageInfo; + return B_OK; + case DW_LANG_C: + info.languageInfo = &kCLanguageInfo; + return B_OK; + case DW_LANG_C_plus_plus: + info.languageInfo = &kCPlusPlusLanguageInfo; + return B_OK; + case DW_LANG_C99: + info.languageInfo = &kC99LanguageInfo; + return B_OK; + default: + info.languageInfo = &kUnsupportedLanguageInfo; + return B_OK; + } +} + + +const char* +DIECompileUnitBase::Name() const +{ + return fName; +} + + +status_t +DIECompileUnitBase::AddChild(DebugInfoEntry* child) +{ + if (child->IsType()) + fTypes.Add(child); + else + fOtherChildren.Add(child); + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_name(uint16 attributeName, + const AttributeValue& value) +{ + fName = value.string; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_comp_dir(uint16 attributeName, + const AttributeValue& value) +{ + fCompilationDir = value.string; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_low_pc(uint16 attributeName, + const AttributeValue& value) +{ + fLowPC = value.address; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_high_pc(uint16 attributeName, + const AttributeValue& value) +{ + fHighPC = value.address; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_producer(uint16 attributeName, + const AttributeValue& value) +{ + // not interesting + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_stmt_list(uint16 attributeName, + const AttributeValue& value) +{ + fStatementListOffset = value.pointer; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_macro_info(uint16 attributeName, + const AttributeValue& value) +{ + fMacroInfoOffset = value.pointer; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_base_types(uint16 attributeName, + const AttributeValue& value) +{ + fBaseTypesUnit = dynamic_cast(value.reference); + return fBaseTypesUnit != NULL ? B_OK : B_BAD_DATA; +} + + +status_t +DIECompileUnitBase::AddAttribute_language(uint16 attributeName, + const AttributeValue& value) +{ + fLanguage = value.constant; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_identifier_case(uint16 attributeName, + const AttributeValue& value) +{ + fIdentifierCase = value.constant; + return B_OK; +} + + +status_t +DIECompileUnitBase::AddAttribute_use_UTF8(uint16 attributeName, + const AttributeValue& value) +{ + fUseUTF8 = value.flag; + return B_OK; +} + + +// #pragma mark - DIEType + + +DIEType::DIEType() + : + fName(NULL) +{ + fAllocated.SetTo((uint64)0); + fAssociated.SetTo((uint64)0); +} + + +bool +DIEType::IsType() const +{ + return true; +} + + +const char* +DIEType::Name() const +{ + return fName; +} + + +status_t +DIEType::AddAttribute_name(uint16 attributeName, + const AttributeValue& value) +{ + fName = value.string; + return B_OK; +} + + +status_t +DIEType::AddAttribute_allocated(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fAllocated, value); +} + + +status_t +DIEType::AddAttribute_associated(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fAssociated, value); +} + + +// #pragma mark - DIEModifiedType + + +DIEModifiedType::DIEModifiedType() + : + fType(NULL) +{ +} + + +status_t +DIEModifiedType::AddAttribute_type(uint16 attributeName, + const AttributeValue& value) +{ + fType = dynamic_cast(value.reference); + return B_OK; +} + + +// #pragma mark - DIEAddressingType + + +DIEAddressingType::DIEAddressingType() + : + fAddressClass(0) +{ +} + + +status_t +DIEAddressingType::AddAttribute_address_class(uint16 attributeName, + const AttributeValue& value) +{ +// TODO: How is the address class handled? + fAddressClass = value.constant; + return B_OK; +} + + +// #pragma mark - DIEDeclaredType + + +DIEDeclaredType::DIEDeclaredType() +{ +} + + +// #pragma mark - DIEDerivedType + + +DIEDerivedType::DIEDerivedType() + : + fType(NULL) +{ +} + + +status_t +DIEDerivedType::AddAttribute_type(uint16 attributeName, + const AttributeValue& value) +{ + fType = dynamic_cast(value.reference); + return B_OK; +} + + + + +// #pragma mark - DIECompoundType + + +DIECompoundType::DIECompoundType() +{ +} + + +// #pragma mark - DIEClassBaseType + + +DIEClassBaseType::DIEClassBaseType() +{ +} + + +// #pragma mark - DIEArrayType + + +DIEArrayType::DIEArrayType() + : + fBitStride(0), + fByteSize(0), + fOrdering(DW_ORD_row_major) +{ +} + + +uint16 +DIEArrayType::Tag() const +{ + return DW_TAG_array_type; +} + + +status_t +DIEArrayType::InitAfterHierarchy(DebugInfoEntryInitInfo& info) +{ + fOrdering = info.languageInfo->arrayOrdering; + return B_OK; +} + + +status_t +DIEArrayType::AddChild(DebugInfoEntry* child) +{ + // a dimension child must be of subrange or enumeration type + uint16 tag = child->Tag(); + if (tag == DW_TAG_subrange_type || tag == DW_TAG_enumeration_type) { + fDimensions.Add(child); + return B_OK; + } + + return DIEDerivedType::AddChild(child); +} + + +status_t +DIEArrayType::AddAttribute_ordering(uint16 attributeName, + const AttributeValue& value) +{ + fOrdering = value.constant; + return B_OK; +} + + +status_t +DIEArrayType::AddAttribute_bit_stride(uint16 attributeName, + const AttributeValue& value) +{ + fBitStride = value.constant; + return B_OK; +} + + +status_t +DIEArrayType::AddAttribute_stride_size(uint16 attributeName, + const AttributeValue& value) +{ + fBitStride = value.constant; + return B_OK; +} + + +status_t +DIEArrayType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + fByteSize = value.constant; + return B_OK; +} + + +// #pragma mark - DIEClassType + + +DIEClassType::DIEClassType() +{ +} + + +uint16 +DIEClassType::Tag() const +{ + return DW_TAG_class_type; +} + + +// #pragma mark - DIEEntryPoint + + +DIEEntryPoint::DIEEntryPoint() +{ +} + + +uint16 +DIEEntryPoint::Tag() const +{ + return DW_TAG_entry_point; +} + + +// #pragma mark - DIEEnumerationType + + +DIEEnumerationType::DIEEnumerationType() +{ +} + + +uint16 +DIEEnumerationType::Tag() const +{ + return DW_TAG_enumeration_type; +} + + +// #pragma mark - DIEFormalParameter + + +DIEFormalParameter::DIEFormalParameter() +{ +} + + +uint16 +DIEFormalParameter::Tag() const +{ + return DW_TAG_formal_parameter; +} + + +// #pragma mark - DIEImportedDeclaration + + +DIEImportedDeclaration::DIEImportedDeclaration() +{ +} + + +uint16 +DIEImportedDeclaration::Tag() const +{ + return DW_TAG_imported_declaration; +} + + +// #pragma mark - DIELabel + + +DIELabel::DIELabel() +{ +} + + +uint16 +DIELabel::Tag() const +{ + return DW_TAG_label; +} + + +// #pragma mark - DIELexicalBlock + + +DIELexicalBlock::DIELexicalBlock() +{ +} [... truncated: 4738 lines follow ...] From bonefish at mail.berlios.de Sun Jun 14 15:11:51 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 15:11:51 +0200 Subject: [Haiku-commits] r31048 - haiku/trunk/src/apps/debugger Message-ID: <200906141311.n5EDBpAr000569@sheep.berlios.de> Author: bonefish Date: 2009-06-14 15:11:42 +0200 (Sun, 14 Jun 2009) New Revision: 31048 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31048&view=rev Removed: haiku/trunk/src/apps/debugger/arch_elf.h Log: Slipped in by accident. Deleted: haiku/trunk/src/apps/debugger/arch_elf.h From bonefish at mail.berlios.de Sun Jun 14 16:02:58 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 16:02:58 +0200 Subject: [Haiku-commits] r31049 - haiku/trunk/src/apps/debugger Message-ID: <200906141402.n5EE2wwn006641@sheep.berlios.de> Author: bonefish Date: 2009-06-14 16:02:50 +0200 (Sun, 14 Jun 2009) New Revision: 31049 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31049&view=rev Modified: haiku/trunk/src/apps/debugger/AttributeValue.h haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/DebugInfoEntries.h Log: Support DW_AT_decl_{file,line,column} attributes for types. Modified: haiku/trunk/src/apps/debugger/AttributeValue.h =================================================================== --- haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-14 13:11:42 UTC (rev 31048) +++ haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-14 14:02:50 UTC (rev 31049) @@ -66,4 +66,33 @@ }; +struct DeclarationLocation { + uint32 file; + uint32 line; + uint32 column; + + DeclarationLocation() + : + file(0), + line(0), + column(0) + { + } + + void SetFile(uint32 file) + { + this->file = file; + } + + void SetLine(uint32 line) + { + this->line = line; + } + + void SetColumn(uint32 column) + { + this->column = column; + } +}; + #endif // ATTRIBUTE_VALUE_H Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 13:11:42 UTC (rev 31048) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 14:02:50 UTC (rev 31049) @@ -273,6 +273,33 @@ } +status_t +DIEDeclaredType::AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetFile(value.constant); + return B_OK; +} + + +status_t +DIEDeclaredType::AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetLine(value.constant); + return B_OK; +} + + +status_t +DIEDeclaredType::AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetColumn(value.constant); + return B_OK; +} + + // #pragma mark - DIEDerivedType @@ -1128,6 +1155,33 @@ } +status_t +DIEVolatileType::AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetFile(value.constant); + return B_OK; +} + + +status_t +DIEVolatileType::AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetLine(value.constant); + return B_OK; +} + + +status_t +DIEVolatileType::AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetColumn(value.constant); + return B_OK; +} + + // #pragma mark - DIEDwarfProcedure @@ -1218,6 +1272,33 @@ } +status_t +DIEUnspecifiedType::AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetFile(value.constant); + return B_OK; +} + + +status_t +DIEUnspecifiedType::AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetLine(value.constant); + return B_OK; +} + + +status_t +DIEUnspecifiedType::AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetColumn(value.constant); + return B_OK; +} + + // #pragma mark - DIEPartialUnit @@ -1289,6 +1370,33 @@ } +status_t +DIESharedType::AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetFile(value.constant); + return B_OK; +} + + +status_t +DIESharedType::AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetLine(value.constant); + return B_OK; +} + + +status_t +DIESharedType::AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value) +{ + fDeclarationLocation.SetColumn(value.constant); + return B_OK; +} + + // #pragma mark - DebugInfoEntryFactory Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.h =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-14 13:11:42 UTC (rev 31048) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-14 14:02:50 UTC (rev 31049) @@ -246,8 +246,14 @@ public: DIEDeclaredType(); + virtual status_t AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value); + // TODO: -// DECL // DW_AT_accessibility // !file, !pointer to member // DW_AT_declaration // !file // DW_AT_abstract_origin // !interface @@ -255,6 +261,7 @@ // DW_AT_visibility // !interface protected: + DeclarationLocation fDeclarationLocation; }; @@ -759,8 +766,15 @@ virtual uint16 Tag() const; -// TODO: -// DECL + virtual status_t AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value); + +private: + DeclarationLocation fDeclarationLocation; }; @@ -810,9 +824,18 @@ virtual uint16 Tag() const; + virtual status_t AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value); + // TODO: -// DECL // DW_AT_description + +private: + DeclarationLocation fDeclarationLocation; }; @@ -852,12 +875,16 @@ virtual status_t AddAttribute_count(uint16 attributeName, const AttributeValue& value); + virtual status_t AddAttribute_decl_file(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_line(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_decl_column(uint16 attributeName, + const AttributeValue& value); -// TODO: -// DECL - private: uint64 fBlockSize; + DeclarationLocation fDeclarationLocation; }; From bonefish at mail.berlios.de Sun Jun 14 16:17:40 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 16:17:40 +0200 Subject: [Haiku-commits] r31050 - haiku/trunk/src/apps/debugger Message-ID: <200906141417.n5EEHei7008840@sheep.berlios.de> Author: bonefish Date: 2009-06-14 16:17:37 +0200 (Sun, 14 Jun 2009) New Revision: 31050 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31050&view=rev Modified: haiku/trunk/src/apps/debugger/AttributeValue.h Log: Some default value doesn't harm. Modified: haiku/trunk/src/apps/debugger/AttributeValue.h =================================================================== --- haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-14 14:02:50 UTC (rev 31049) +++ haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-14 14:17:37 UTC (rev 31050) @@ -45,6 +45,13 @@ }; uint8 attributeClass; + DynamicAttributeValue() + : + attributeClass(ATTRIBUTE_CLASS_CONSTANT) + { + this->constant = 0; + } + void SetTo(uint64 constant) { this->constant = constant; From bonefish at mail.berlios.de Sun Jun 14 16:19:07 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 16:19:07 +0200 Subject: [Haiku-commits] r31051 - haiku/trunk/src/apps/debugger Message-ID: <200906141419.n5EEJ7DP009346@sheep.berlios.de> Author: bonefish Date: 2009-06-14 16:18:55 +0200 (Sun, 14 Jun 2009) New Revision: 31051 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31051&view=rev Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/DebugInfoEntries.h Log: Support for DW_AT_{accessibility,declaration,abstract_origin} attributes for types. Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 14:17:37 UTC (rev 31050) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 14:18:55 UTC (rev 31051) @@ -269,6 +269,10 @@ DIEDeclaredType::DIEDeclaredType() + : + fAbstractOrigin(NULL), + fAccessibility(0), + fDeclaration(false) { } @@ -300,6 +304,33 @@ } +status_t +DIEDeclaredType::AddAttribute_accessibility(uint16 attributeName, + const AttributeValue& value) +{ + fAccessibility = value.constant; + return B_OK; +} + + +status_t +DIEDeclaredType::AddAttribute_declaration(uint16 attributeName, + const AttributeValue& value) +{ + fDeclaration = value.flag; + return B_OK; +} + + +status_t +DIEDeclaredType::AddAttribute_abstract_origin(uint16 attributeName, + const AttributeValue& value) +{ + fAbstractOrigin = value.reference; + return B_OK; +} + + // #pragma mark - DIEDerivedType Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.h =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-14 14:17:37 UTC (rev 31050) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-14 14:18:55 UTC (rev 31051) @@ -252,16 +252,26 @@ const AttributeValue& value); virtual status_t AddAttribute_decl_column(uint16 attributeName, const AttributeValue& value); + virtual status_t AddAttribute_accessibility(uint16 attributeName, + const AttributeValue& value); + // TODO: !file, !pointer to member + virtual status_t AddAttribute_declaration(uint16 attributeName, + const AttributeValue& value); + // TODO: !file + virtual status_t AddAttribute_abstract_origin( + uint16 attributeName, + const AttributeValue& value); + // TODO: !interface // TODO: -// DW_AT_accessibility // !file, !pointer to member -// DW_AT_declaration // !file -// DW_AT_abstract_origin // !interface // DW_AT_description // !interface // DW_AT_visibility // !interface protected: DeclarationLocation fDeclarationLocation; + DebugInfoEntry* fAbstractOrigin; + uint8 fAccessibility; + bool fDeclaration; }; @@ -272,9 +282,6 @@ virtual status_t AddAttribute_type(uint16 attributeName, const AttributeValue& value); -// TODO: -// DW_AT_type - protected: DIEType* fType; }; From bonefish at mail.berlios.de Sun Jun 14 19:16:17 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 14 Jun 2009 19:16:17 +0200 Subject: [Haiku-commits] r31052 - haiku/trunk/src/apps/debugger Message-ID: <200906141716.n5EHGHZB005111@sheep.berlios.de> Author: bonefish Date: 2009-06-14 19:16:08 +0200 (Sun, 14 Jun 2009) New Revision: 31052 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31052&view=rev Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/DebugInfoEntries.h Log: * Support for DW_AT_byte_size in DIECompoundType. * Fixed several instances of attributes with dynamic values not being handled correctly. Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 14:18:55 UTC (rev 31051) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-14 17:16:08 UTC (rev 31052) @@ -360,6 +360,14 @@ } +status_t +DIECompoundType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteSize, value); +} + + // #pragma mark - DIEClassBaseType @@ -373,8 +381,6 @@ DIEArrayType::DIEArrayType() : - fBitStride(0), - fByteSize(0), fOrdering(DW_ORD_row_major) { } @@ -422,8 +428,7 @@ DIEArrayType::AddAttribute_bit_stride(uint16 attributeName, const AttributeValue& value) { - fBitStride = value.constant; - return B_OK; + return SetDynamicAttributeValue(fBitStride, value); } @@ -431,8 +436,7 @@ DIEArrayType::AddAttribute_stride_size(uint16 attributeName, const AttributeValue& value) { - fBitStride = value.constant; - return B_OK; + return SetDynamicAttributeValue(fBitStride, value); } @@ -440,8 +444,7 @@ DIEArrayType::AddAttribute_byte_size(uint16 attributeName, const AttributeValue& value) { - fByteSize = value.constant; - return B_OK; + return SetDynamicAttributeValue(fByteSize, value); } @@ -871,10 +874,7 @@ DIEBaseType::DIEBaseType() : fEncoding(0), - fEndianity(0), - fByteSize(0), - fBitSize(0), - fBitOffset(0) + fEndianity(0) { } @@ -899,8 +899,7 @@ DIEBaseType::AddAttribute_byte_size(uint16 attributeName, const AttributeValue& value) { - fByteSize = value.constant; - return B_OK; + return SetDynamicAttributeValue(fByteSize, value); } @@ -908,8 +907,7 @@ DIEBaseType::AddAttribute_bit_size(uint16 attributeName, const AttributeValue& value) { - fBitSize = value.constant; - return B_OK; + return SetDynamicAttributeValue(fBitSize, value); } @@ -917,8 +915,7 @@ DIEBaseType::AddAttribute_bit_offset(uint16 attributeName, const AttributeValue& value) { - fBitOffset = value.constant; - return B_OK; + return SetDynamicAttributeValue(fBitOffset, value); } @@ -1379,9 +1376,8 @@ DIESharedType::DIESharedType() - : - fBlockSize(DWARF_ADDRESS_MAX) { + fBlockSize.SetTo(DWARF_ADDRESS_MAX); } @@ -1396,8 +1392,7 @@ DIESharedType::AddAttribute_count(uint16 attributeName, const AttributeValue& value) { - fBlockSize = value.constant; - return B_OK; + return SetDynamicAttributeValue(fBlockSize, value); } Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.h =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-14 14:18:55 UTC (rev 31051) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-14 17:16:08 UTC (rev 31052) @@ -291,11 +291,15 @@ public: DIECompoundType(); + virtual status_t AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value); + // TODO: !interface + // TODO: -// DW_AT_byte_size // !interface // DW_AT_specification // !interface protected: + DynamicAttributeValue fByteSize; }; @@ -335,10 +339,10 @@ // DW_AT_specification private: - uint64 fBitStride; - dwarf_addr_t fByteSize; + DynamicAttributeValue fBitStride; + DynamicAttributeValue fByteSize; + DebugInfoEntryList fDimensions; uint8 fOrdering; - DebugInfoEntryList fDimensions; }; @@ -628,11 +632,11 @@ // DW_AT_small private: + DynamicAttributeValue fByteSize; + DynamicAttributeValue fBitOffset; + DynamicAttributeValue fBitSize; uint8 fEncoding; uint8 fEndianity; - uint16 fByteSize; - uint16 fBitSize; - uint16 fBitOffset; }; @@ -890,7 +894,7 @@ const AttributeValue& value); private: - uint64 fBlockSize; + DynamicAttributeValue fBlockSize; DeclarationLocation fDeclarationLocation; }; From revol at free.fr Sun Jun 14 20:07:28 2009 From: revol at free.fr (=?utf-8?q?Fran=C3=A7ois?= Revol) Date: Sun, 14 Jun 2009 20:07:28 +0200 CEST Subject: [Haiku-commits] r31047 - in haiku/trunk/src/apps: . debugger In-Reply-To: <200906141253.n5ECrX5o032235@sheep.berlios.de> Message-ID: <813423872-BeMail@laptop> > Log: > The very beginnings of a debugger. Currently consisting only of the > beginnings > of a DWARF 3 reader. It can read the .debug_info section and create > objects > for > the entries, but most attributes are ignored yet. Wouldn't a gdb based GUI be faster to write ? IIRC there is a library that can be used. It should be GPLed but that shouldn't matter much anyway... Fran?ois. From superstippi at gmx.de Sun Jun 14 20:30:38 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 14 Jun 2009 20:30:38 +0200 Subject: [Haiku-commits] r31047 - in haiku/trunk/src/apps: . debugger In-Reply-To: <813423872-BeMail@laptop> References: <813423872-BeMail@laptop> Message-ID: <20090614203038.9312.7@bepc.1244973970.fake> On 2009-06-14 at 20:07:28 [+0200], Fran?ois Revol wrote: > > Log: > > The very beginnings of a debugger. Currently consisting only of the > > beginnings > > of a DWARF 3 reader. It can read the .debug_info section and create > > objects > > for > > the entries, but most attributes are ignored yet. > > Wouldn't a gdb based GUI be faster to write ? > IIRC there is a library that can be used. > It should be GPLed but that shouldn't matter much anyway... But Ingo is the one who ported our GDB. So he is probably aware of it. :-} In any case, have you used some GDB based debuggers? I trust Ingo has enough technical reasons to do this, but even as a user, I could see where this is comming from, because both KDevelop and QtCreator are no fun to do debugging on in my experience. Even when GDB does run for a while without crashing. Best regards, -Stephan From revol at free.fr Sun Jun 14 20:33:27 2009 From: revol at free.fr (=?utf-8?q?Fran=C3=A7ois?= Revol) Date: Sun, 14 Jun 2009 20:33:27 +0200 CEST Subject: [Haiku-commits] r31047 - in haiku/trunk/src/apps: . debugger In-Reply-To: <20090614203038.9312.7@bepc.1244973970.fake> Message-ID: <2372987327-BeMail@laptop> > > Wouldn't a gdb based GUI be faster to write ? > > IIRC there is a library that can be used. > > It should be GPLed but that shouldn't matter much anyway... > > But Ingo is the one who ported our GDB. So he is probably aware of > it. :-} Maybe he didn't look at the library API. > > In any case, have you used some GDB based debuggers? I trust Ingo has Not really, no. I do miss bdb :) > enough technical reasons to do this, but even as a user, I could see > where > this is comming from, because both KDevelop and QtCreator are no fun > to do > debugging on in my experience. Even when GDB does run for a while > without > crashing. I just scratched the surface with gdb, it's quite powerful but I never read the manual. Fran?ois. From oruizdorantes at mail.berlios.de Sun Jun 14 21:51:30 2009 From: oruizdorantes at mail.berlios.de (oruizdorantes at BerliOS) Date: Sun, 14 Jun 2009 21:51:30 +0200 Subject: [Haiku-commits] r31053 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200906141951.n5EJpUNG026153@sheep.berlios.de> Author: oruizdorantes Date: 2009-06-14 21:51:29 +0200 (Sun, 14 Jun 2009) New Revision: 31053 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31053&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c Log: - Cancelling pending transfers at close hook while it is still plugged preventing any resubmittion, this is related ticket 2353 - Free device in correct hook This allows closing and reopening the bluetooth_server keeping bluetooth functionality Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2009-06-14 17:16:08 UTC (rev 31052) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2009-06-14 19:51:29 UTC (rev 31053) @@ -374,23 +374,21 @@ flowf("Cancelling queues...\n"); if (bdev->intr_in_ep != NULL) { usb->cancel_queued_transfers(bdev->intr_in_ep->handle); - flowf("Cancelling impossible EVENTS\n"); + flowf("Cancelling possible EVENTS\n"); } if (bdev->bulk_in_ep!=NULL) { usb->cancel_queued_transfers(bdev->bulk_in_ep->handle); - flowf("Cancelling impossible ACL in\n"); + flowf("Cancelling possible ACL in\n"); } if (bdev->bulk_out_ep!=NULL) { usb->cancel_queued_transfers(bdev->bulk_out_ep->handle); - flowf("Cancelling impossible ACL out\n"); + flowf("Cancelling possible ACL out\n"); } bdev->connected = false; - // TODO: place this in the appropiated hook - // kill_device(bdev); return B_OK; } @@ -533,6 +531,24 @@ // Clean queues + if (bdev->connected == true) { + flowf("Cancelling queues...\n"); + if (bdev->intr_in_ep != NULL) { + usb->cancel_queued_transfers(bdev->intr_in_ep->handle); + flowf("Cancelling possible EVENTS\n"); + } + + if (bdev->bulk_in_ep!=NULL) { + usb->cancel_queued_transfers(bdev->bulk_in_ep->handle); + flowf("Cancelling possible ACL in\n"); + } + + if (bdev->bulk_out_ep!=NULL) { + usb->cancel_queued_transfers(bdev->bulk_out_ep->handle); + flowf("Cancelling possible ACL out\n"); + } + } + // TX for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { if (i == BT_COMMAND) @@ -578,14 +594,9 @@ debugf("device_free() called on %s \n",BLUETOOTH_DEVICE_PATH); - - if (--bdev->open_count == 0) { - - /* GotoLowPower */ - // interesting ..... - } else { - /* The last client has closed, and the device is no longer - connected, so remove it from the list. */ + if (!bdev->connected) { + flowf("Device not present can be killed\n"); + kill_device(bdev); } return err; Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2009-06-14 17:16:08 UTC (rev 31052) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2009-06-14 19:51:29 UTC (rev 31053) @@ -164,12 +164,12 @@ //bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option status_t error; - debugf("cookie@%p status=%ld len=%ld\n", cookie, status, actual_len); + debugf("cookie@%p status=%s len=%ld\n", cookie, strerror(status), actual_len); if (bdev == NULL) return; - if (status == B_CANCELED) // or not running anymore... + if (status == B_CANCELED || status == B_DEV_CRC_ERROR) // or not running anymore... return; if (status != B_OK || actual_len == 0) @@ -210,7 +210,7 @@ if (bdev == NULL) return; - if (status == B_CANCELED) // or not running anymore... + if (status == B_CANCELED || status == B_DEV_CRC_ERROR) // or not running anymore... return; if (status != B_OK || actual_len == 0) @@ -312,7 +312,7 @@ snet_buffer* snbuf = (snet_buffer*)cookie; bt_usb_dev* bdev = snb_cookie(snbuf); - debugf("len = %ld @%p\n", actual_len, data); + debugf("status = %ld len = %ld @%p\n", status, actual_len, data); if (status == B_OK) { bdev->stat.successfulTX++; @@ -379,7 +379,7 @@ snb_set_cookie(snbuf, bdev); debugf("@%p\n", snb_get(snbuf)); - + error = usb->queue_request(bdev->dev, bRequestType, bRequest, value, wIndex, wLength, snb_get(snbuf), #ifndef HAIKU_TARGET_PLATFORM_HAIKU From axeld at pinc-software.de Sun Jun 14 23:02:20 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 14 Jun 2009 23:02:20 +0200 CEST Subject: [Haiku-commits] r31038 - haiku/trunk/src/preferences/media In-Reply-To: Message-ID: <7412854504-BeMail@zon> Rene Gollent wrote: > However, if I then resize the window wide enough such that said > scroll > bar is no longer necessary, I can then no longer size the window any > smaller than that (ergo small enough to make the scrollbar reappear). > I have yet to find where in any of the code this clamping effect > comes > from. Anyone who knows the layout kit and such better have any ideas? If you have the window manage the window limits automatically, this should be normal, as the window cannot get any smaller with having all items visible then. Bye, Axel. From zooey at mail.berlios.de Sun Jun 14 23:07:41 2009 From: zooey at mail.berlios.de (zooey at BerliOS) Date: Sun, 14 Jun 2009 23:07:41 +0200 Subject: [Haiku-commits] r31054 - buildtools/trunk/legacy/gcc/gcc Message-ID: <200906142107.n5EL7f2s009445@sheep.berlios.de> Author: zooey Date: 2009-06-14 23:07:41 +0200 (Sun, 14 Jun 2009) New Revision: 31054 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31054&view=rev Modified: buildtools/trunk/legacy/gcc/gcc/expr.c Log: * applied fix for optimization of wchar_t constants which is mentioned in the ICU configuration for BeOS, since otherwise we could not use optimization for ICU at all. [see http://gcc.gnu.org/ml/gcc-patches/2000-09/msg00454.html] Modified: buildtools/trunk/legacy/gcc/gcc/expr.c =================================================================== --- buildtools/trunk/legacy/gcc/gcc/expr.c 2009-06-14 19:51:29 UTC (rev 31053) +++ buildtools/trunk/legacy/gcc/gcc/expr.c 2009-06-14 21:07:41 UTC (rev 31054) @@ -6448,9 +6448,16 @@ && TREE_INT_CST_HIGH (index) == 0 && (TREE_INT_CST_LOW (index) < TREE_STRING_LENGTH (init))) - return (GEN_INT - (TREE_STRING_POINTER - (init)[TREE_INT_CST_LOW (index)])); + { + tree type = TREE_TYPE (TREE_TYPE (init)); + enum machine_mode mode = TYPE_MODE (type); + + if (GET_MODE_CLASS (mode) == MODE_INT + && GET_MODE_SIZE (mode) == 1) + return (GEN_INT + (TREE_STRING_POINTER + (init)[TREE_INT_CST_LOW (index)])); + } } } } From axeld at pinc-software.de Sun Jun 14 23:28:29 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 14 Jun 2009 23:28:29 +0200 CEST Subject: [Haiku-commits] r31010 - haiku/trunk/src/system/kernel/fs In-Reply-To: <20090612152406.375.1@knochen-vm.localdomain> Message-ID: <8981250928-BeMail@zon> Ingo Weinhold wrote: > > Well, we have the source, haven't we? But apart from that, we can > > keep > > it in as well, as most file systems cannot deliver the extra > > resolution, anyway. > Then they should set it to 0. No reason to do extra work for file > systems > that can (e.g. BFS). You would wish it could ;-) But seriously, I've already changed it to do so. It's just not that clean, as Be went with a very strange mechanism for this - they shift a time_t value 16 bits to the left, and than or a random 16 bit value in, to make duplicate values less probable. So we have only 16 bits resolution for the nanoseconds - I cut that down even more to 12 in order to avoid the duplicates. In any case, I'll finish that up tomorrow. Comments welcome. Bye, Axel. From anevilyak at mail.berlios.de Mon Jun 15 02:13:38 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Mon, 15 Jun 2009 02:13:38 +0200 Subject: [Haiku-commits] r31055 - haiku/trunk/build/jam Message-ID: <200906150013.n5F0Dcti001910@sheep.berlios.de> Author: anevilyak Date: 2009-06-15 02:13:37 +0200 (Mon, 15 Jun 2009) New Revision: 31055 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31055&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Applied patch by Ankur Sethi - add CLucene optional package to be used by indexing HCD project. Closes ticket #4027. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2009-06-14 21:07:41 UTC (rev 31054) +++ haiku/trunk/build/jam/OptionalPackages 2009-06-15 00:13:37 UTC (rev 31055) @@ -21,6 +21,7 @@ # BePDF # Bluetooth # CDRecord +# CLucene # CVS # Development - more complete dev environment (including autotools) # DevelopmentBase - basic development environment (gcc, headers, libs,...) @@ -201,6 +202,22 @@ } +# CLucene +if [ IsOptionalHaikuImagePackageAdded CLucene ] { + if $(TARGET_ARCH) != x86 { + Echo "No optional package CLucene available for $(TARGET_ARCH)" ; + } else if $(HAIKU_GCC_VERSION[1]) < 4 && $(isHybridBuild) = 0 { + Echo "No optional package CLucene available for GCC2" ; + } else { + local baseURL = http://haiku-files.org/files/optional-packages ; + InstallOptionalHaikuImagePackage clucene-0.9.21svn-x86-gcc4-haiku-2009-06-11 + : $(baseURL)/clucene-0.9.21svn-x86-gcc4-haiku-2009-06-11.zip + : + ; + } +} + + # CVS if [ IsOptionalHaikuImagePackageAdded CVS ] { if $(TARGET_ARCH) != x86 { From bonefish at mail.berlios.de Mon Jun 15 02:42:09 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 15 Jun 2009 02:42:09 +0200 Subject: [Haiku-commits] r31056 - haiku/trunk/src/apps/debugger Message-ID: <200906150042.n5F0g9Qe006216@sheep.berlios.de> Author: bonefish Date: 2009-06-15 02:42:03 +0200 (Mon, 15 Jun 2009) New Revision: 31056 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31056&view=rev Modified: haiku/trunk/src/apps/debugger/AttributeValue.h haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/DebugInfoEntries.h haiku/trunk/src/apps/debugger/DebugInfoEntry.cpp haiku/trunk/src/apps/debugger/DebugInfoEntry.h Log: * More work on the type debug info entry classes. * New base classes for other entries handling common attributes. * Annotated all classes with their missing attributes. Modified: haiku/trunk/src/apps/debugger/AttributeValue.h =================================================================== --- haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-15 00:13:37 UTC (rev 31055) +++ haiku/trunk/src/apps/debugger/AttributeValue.h 2009-06-15 00:42:03 UTC (rev 31056) @@ -73,6 +73,45 @@ }; +struct ConstantAttributeValue { + union { + uint64 constant; + const char* string; + struct { + const void* data; + dwarf_size_t length; + } block; + }; + uint8 attributeClass; + + ConstantAttributeValue() + : + attributeClass(ATTRIBUTE_CLASS_CONSTANT) + { + this->constant = 0; + } + + void SetTo(uint64 constant) + { + this->constant = constant; + attributeClass = ATTRIBUTE_CLASS_CONSTANT; + } + + void SetTo(const char* string) + { + this->string = string; + attributeClass = ATTRIBUTE_CLASS_STRING; + } + + void SetTo(const void* data, dwarf_size_t length) + { + block.data = data; + block.length = length; + attributeClass = ATTRIBUTE_CLASS_BLOCK; + } +}; + + struct DeclarationLocation { uint32 file; uint32 line; Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-15 00:13:37 UTC (rev 31055) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp 2009-06-15 00:42:03 UTC (rev 31056) @@ -241,7 +241,7 @@ const AttributeValue& value) { fType = dynamic_cast(value.reference); - return B_OK; + return fType != NULL ? B_OK : B_BAD_DATA; } @@ -270,6 +270,7 @@ DIEDeclaredType::DIEDeclaredType() : + fDescription(NULL), fAbstractOrigin(NULL), fAccessibility(0), fDeclaration(false) @@ -277,57 +278,53 @@ } -status_t -DIEDeclaredType::AddAttribute_decl_file(uint16 attributeName, - const AttributeValue& value) +const char* +DIEDeclaredType::Description() const { - fDeclarationLocation.SetFile(value.constant); - return B_OK; + return fDescription; } status_t -DIEDeclaredType::AddAttribute_decl_line(uint16 attributeName, +DIEDeclaredType::AddAttribute_accessibility(uint16 attributeName, const AttributeValue& value) { - fDeclarationLocation.SetLine(value.constant); + fAccessibility = value.constant; return B_OK; } status_t -DIEDeclaredType::AddAttribute_decl_column(uint16 attributeName, +DIEDeclaredType::AddAttribute_declaration(uint16 attributeName, const AttributeValue& value) { - fDeclarationLocation.SetColumn(value.constant); + fDeclaration = value.flag; return B_OK; } status_t -DIEDeclaredType::AddAttribute_accessibility(uint16 attributeName, +DIEDeclaredType::AddAttribute_description(uint16 attributeName, const AttributeValue& value) { - fAccessibility = value.constant; + fDescription = value.string; return B_OK; } status_t -DIEDeclaredType::AddAttribute_declaration(uint16 attributeName, +DIEDeclaredType::AddAttribute_abstract_origin(uint16 attributeName, const AttributeValue& value) { - fDeclaration = value.flag; + fAbstractOrigin = value.reference; return B_OK; } -status_t -DIEDeclaredType::AddAttribute_abstract_origin(uint16 attributeName, - const AttributeValue& value) +DeclarationLocation* +DIEDeclaredType::GetDeclarationLocation() { - fAbstractOrigin = value.reference; - return B_OK; + return &fDeclarationLocation; } @@ -346,7 +343,7 @@ const AttributeValue& value) { fType = dynamic_cast(value.reference); - return B_OK; + return fType != NULL ? B_OK : B_BAD_DATA; } @@ -356,11 +353,26 @@ DIECompoundType::DIECompoundType() + : + fSpecification(NULL) { } status_t +DIECompoundType::AddChild(DebugInfoEntry* child) +{ + if (child->Tag() == DW_TAG_member) { + // TODO: Not for interfaces! + fDataMembers.Add(child); + return B_OK; + } + + return DIEDeclaredType::AddChild(child); +} + + +status_t DIECompoundType::AddAttribute_byte_size(uint16 attributeName, const AttributeValue& value) { @@ -368,6 +380,15 @@ } +status_t +DIECompoundType::AddAttribute_specification(uint16 attributeName, + const AttributeValue& value) +{ + fSpecification = dynamic_cast(value.reference); + return fSpecification != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIEClassBaseType @@ -376,11 +397,158 @@ } +status_t +DIEClassBaseType::AddChild(DebugInfoEntry* child) +{ + switch (child->Tag()) { + case DW_TAG_inheritance: + fDataMembers.Add(child); + return B_OK; + case DW_TAG_friend: + fFriends.Add(child); + return B_OK; + case DW_TAG_access_declaration: + fAccessDeclarations.Add(child); + return B_OK; + case DW_TAG_subprogram: + fMemberFunctions.Add(child); + return B_OK; +// TODO: Templates! +// TODO: Variants! + default: + return DIECompoundType::AddChild(child); + } +} + + +// #pragma mark - DIENamedBase + + +DIENamedBase::DIENamedBase() + : + fName(NULL), + fDescription(NULL) +{ +} + + +const char* +DIENamedBase::Name() const +{ + return fName; +} + + +const char* +DIENamedBase::Description() const +{ + return fDescription; +} + + +status_t +DIENamedBase::AddAttribute_name(uint16 attributeName, + const AttributeValue& value) +{ + fName = value.string; + return B_OK; +} + + +status_t +DIENamedBase::AddAttribute_description(uint16 attributeName, + const AttributeValue& value) +{ + fDescription = value.string; + return B_OK; +} + + +// #pragma mark - DIEDeclaredBase + + +DIEDeclaredBase::DIEDeclaredBase() +{ +} + + +DeclarationLocation* +DIEDeclaredBase::GetDeclarationLocation() +{ + return &fDeclarationLocation; +} + + +// #pragma mark - DIEDeclaredNamedBase + + +DIEDeclaredNamedBase::DIEDeclaredNamedBase() + : + fName(NULL), + fDescription(NULL), + fAccessibility(0), + fVisibility(0), + fDeclaration(false) +{ +} + + +const char* +DIEDeclaredNamedBase::Name() const +{ + return fName; +} + + +const char* +DIEDeclaredNamedBase::Description() const +{ + return fDescription; +} + + +status_t +DIEDeclaredNamedBase::AddAttribute_name(uint16 attributeName, + const AttributeValue& value) +{ + fName = value.string; + return B_OK; +} + + +status_t +DIEDeclaredNamedBase::AddAttribute_description(uint16 attributeName, + const AttributeValue& value) +{ + fDescription = value.string; + return B_OK; +} + + +status_t +DIEDeclaredNamedBase::AddAttribute_accessibility(uint16 attributeName, + const AttributeValue& value) +{ + fAccessibility = value.constant; + return B_OK; +} + + +status_t +DIEDeclaredNamedBase::AddAttribute_declaration(uint16 attributeName, + const AttributeValue& value) +{ + fDeclaration = value.flag; + return B_OK; +} + + // #pragma mark - DIEArrayType DIEArrayType::DIEArrayType() : + fSpecification(NULL), fOrdering(DW_ORD_row_major) { } @@ -448,6 +616,15 @@ } +status_t +DIEArrayType::AddAttribute_specification(uint16 attributeName, + const AttributeValue& value) +{ + fSpecification = dynamic_cast(value.reference); + return fSpecification != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIEClassType @@ -482,6 +659,8 @@ DIEEnumerationType::DIEEnumerationType() + : + fSpecification(NULL) { } @@ -493,6 +672,51 @@ } +status_t +DIEEnumerationType::AddChild(DebugInfoEntry* child) +{ + if (child->Tag() == DW_TAG_enumerator) { + fEnumerators.Add(child); + return B_OK; + } + + return DIEDerivedType::AddChild(child); +} + + +status_t +DIEEnumerationType::AddAttribute_bit_stride(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fBitStride, value); +} + + +status_t +DIEEnumerationType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteSize, value); +} + + +status_t +DIEEnumerationType::AddAttribute_byte_stride(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteStride, value); +} + + +status_t +DIEEnumerationType::AddAttribute_specification(uint16 attributeName, + const AttributeValue& value) +{ + fSpecification = dynamic_cast(value.reference); + return fSpecification != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIEFormalParameter @@ -572,6 +796,8 @@ DIEPointerType::DIEPointerType() + : + fSpecification(NULL) { } @@ -583,6 +809,15 @@ } +status_t +DIEPointerType::AddAttribute_specification(uint16 attributeName, + const AttributeValue& value) +{ + fSpecification = dynamic_cast(value.reference); + return fSpecification != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIEReferenceType @@ -628,6 +863,14 @@ } +status_t +DIEStringType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteSize, value); +} + + // #pragma mark - DIEStructureType @@ -647,6 +890,10 @@ DIESubroutineType::DIESubroutineType() + : + fReturnType(NULL), + fAddressClass(0), + fPrototyped(false) { } @@ -658,6 +905,48 @@ } +status_t +DIESubroutineType::AddChild(DebugInfoEntry* child) +{ + switch (child->Tag()) { + case DW_TAG_formal_parameter: + case DW_TAG_unspecified_parameters: + fParameters.Add(child); + return B_OK; + default: + return DIEDeclaredType::AddChild(child); + } +} + + +status_t +DIESubroutineType::AddAttribute_address_class(uint16 attributeName, + const AttributeValue& value) +{ +// TODO: How is the address class handled? + fAddressClass = value.constant; + return B_OK; +} + + +status_t +DIESubroutineType::AddAttribute_prototyped(uint16 attributeName, + const AttributeValue& value) +{ + fPrototyped = value.flag; + return B_OK; +} + + +status_t +DIESubroutineType::AddAttribute_type(uint16 attributeName, + const AttributeValue& value) +{ + fReturnType = dynamic_cast(value.reference); + return fReturnType != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIETypedef @@ -797,6 +1086,9 @@ DIEPointerToMemberType::DIEPointerToMemberType() + : + fContainingType(NULL), + fAddressClass(0) { } @@ -808,6 +1100,25 @@ } +status_t +DIEPointerToMemberType::AddAttribute_address_class(uint16 attributeName, + const AttributeValue& value) +{ +// TODO: How is the address class handled? + fAddressClass = value.constant; + return B_OK; +} + + +status_t +DIEPointerToMemberType::AddAttribute_containing_type(uint16 attributeName, + const AttributeValue& value) +{ + fContainingType = dynamic_cast(value.reference); + return fContainingType != NULL ? B_OK : B_BAD_DATA; +} + + // #pragma mark - DIESetType @@ -823,10 +1134,20 @@ } +status_t +DIESetType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteSize, value); +} + + // #pragma mark - DIESubrangeType DIESubrangeType::DIESubrangeType() + : + fThreadsScaled(false) { } @@ -838,6 +1159,63 @@ } +status_t +DIESubrangeType::AddAttribute_bit_stride(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fBitStride, value); +} + + +status_t +DIESubrangeType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteSize, value); +} + + +status_t +DIESubrangeType::AddAttribute_byte_stride(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteStride, value); +} + + +status_t +DIESubrangeType::AddAttribute_count(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fCount, value); +} + + +status_t +DIESubrangeType::AddAttribute_lower_bound(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fLowerBound, value); +} + + +status_t +DIESubrangeType::AddAttribute_upper_bound(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fUpperBound, value); +} + + +status_t +DIESubrangeType::AddAttribute_threads_scaled(uint16 attributeName, + const AttributeValue& value) +{ + fThreadsScaled = value.flag; + return B_OK; +} + + // #pragma mark - DIEWithStatement @@ -988,6 +1366,14 @@ } +status_t +DIEEnumerator::AddAttribute_const_value(uint16 attributeName, + const AttributeValue& value) +{ + return SetConstantAttributeValue(fValue, value); +} + + // #pragma mark - DIEFileType @@ -1003,6 +1389,14 @@ } +status_t +DIEFileType::AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value) +{ + return SetDynamicAttributeValue(fByteSize, value); +} + + // #pragma mark - DIEFriend Modified: haiku/trunk/src/apps/debugger/DebugInfoEntries.h =================================================================== --- haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-15 00:13:37 UTC (rev 31055) +++ haiku/trunk/src/apps/debugger/DebugInfoEntries.h 2009-06-15 00:42:03 UTC (rev 31056) @@ -238,7 +238,7 @@ const AttributeValue& value); protected: - uint64 fAddressClass; + uint8 fAddressClass; }; @@ -246,28 +246,30 @@ public: DIEDeclaredType(); - virtual status_t AddAttribute_decl_file(uint16 attributeName, - const AttributeValue& value); - virtual status_t AddAttribute_decl_line(uint16 attributeName, - const AttributeValue& value); - virtual status_t AddAttribute_decl_column(uint16 attributeName, - const AttributeValue& value); + virtual const char* Description() const; + virtual status_t AddAttribute_accessibility(uint16 attributeName, const AttributeValue& value); // TODO: !file, !pointer to member virtual status_t AddAttribute_declaration(uint16 attributeName, const AttributeValue& value); // TODO: !file + virtual status_t AddAttribute_description(uint16 attributeName, + const AttributeValue& value); + // TODO: !interface virtual status_t AddAttribute_abstract_origin( uint16 attributeName, const AttributeValue& value); // TODO: !interface // TODO: -// DW_AT_description // !interface // DW_AT_visibility // !interface protected: + virtual DeclarationLocation* GetDeclarationLocation(); + +protected: + const char* fDescription; DeclarationLocation fDeclarationLocation; DebugInfoEntry* fAbstractOrigin; uint8 fAccessibility; @@ -291,15 +293,19 @@ public: DIECompoundType(); + virtual status_t AddChild(DebugInfoEntry* child); + virtual status_t AddAttribute_byte_size(uint16 attributeName, const AttributeValue& value); // TODO: !interface + virtual status_t AddAttribute_specification(uint16 attributeName, + const AttributeValue& value); + // TODO: !interface -// TODO: -// DW_AT_specification // !interface - protected: DynamicAttributeValue fByteSize; + DIECompoundType* fSpecification; + DebugInfoEntryList fDataMembers; }; @@ -307,11 +313,71 @@ public: DIEClassBaseType(); + virtual status_t AddChild(DebugInfoEntry* child); + protected: + DebugInfoEntryList fBaseTypes; + DebugInfoEntryList fFriends; + DebugInfoEntryList fAccessDeclarations; + DebugInfoEntryList fMemberFunctions; }; +class DIENamedBase : public DebugInfoEntry { +public: + DIENamedBase(); + virtual const char* Name() const; + virtual const char* Description() const; + + virtual status_t AddAttribute_name(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_description(uint16 attributeName, + const AttributeValue& value); + +protected: + const char* fName; + const char* fDescription; +}; + + +class DIEDeclaredBase : public DebugInfoEntry { +public: + DIEDeclaredBase(); + +protected: + virtual DeclarationLocation* GetDeclarationLocation(); + +protected: + DeclarationLocation fDeclarationLocation; +}; + + +class DIEDeclaredNamedBase : public DIEDeclaredBase { +public: + DIEDeclaredNamedBase(); + + virtual const char* Name() const; + virtual const char* Description() const; + + virtual status_t AddAttribute_name(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_description(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_accessibility(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_declaration(uint16 attributeName, + const AttributeValue& value); + +protected: + const char* fName; + const char* fDescription; + uint8 fAccessibility; + uint8 fVisibility; + bool fDeclaration; +}; + + // #pragma mark - @@ -334,14 +400,14 @@ const AttributeValue& value); virtual status_t AddAttribute_byte_size(uint16 attributeName, const AttributeValue& value); + virtual status_t AddAttribute_specification(uint16 attributeName, + const AttributeValue& value); -// TODO: -// DW_AT_specification - private: DynamicAttributeValue fBitStride; DynamicAttributeValue fByteSize; DebugInfoEntryList fDimensions; + DIEArrayType* fSpecification; uint8 fOrdering; }; @@ -359,6 +425,17 @@ DIEEntryPoint(); virtual uint16 Tag() const; + +// TODO: +// DW_AT_address_class +// DW_AT_description +// DW_AT_frame_base +// DW_AT_low_pc +// DW_AT_name +// DW_AT_return_addr +// DW_AT_segment +// DW_AT_static_link +// DW_AT_type }; @@ -368,51 +445,101 @@ virtual uint16 Tag() const; -// TODO: -// DW_AT_bit_stride -// DW_AT_byte_size -// DW_AT_byte_stride -// DW_AT_specification + virtual status_t AddChild(DebugInfoEntry* child); + + virtual status_t AddAttribute_bit_stride(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_byte_stride(uint16 attributeName, + const AttributeValue& value); + virtual status_t AddAttribute_specification(uint16 attributeName, + const AttributeValue& value); + +private: + DynamicAttributeValue fBitStride; + DynamicAttributeValue fByteSize; + DynamicAttributeValue fByteStride; + DIEEnumerationType* fSpecification; + DebugInfoEntryList fEnumerators; }; -class DIEFormalParameter : public DebugInfoEntry { +class DIEFormalParameter : public DIEDeclaredNamedBase { public: DIEFormalParameter(); virtual uint16 Tag() const; + +// TODO: +// DW_AT_abstract_origin +// DW_AT_artificial +// DW_AT_const_value +// DW_AT_default_value +// DW_AT_endianity +// DW_AT_is_optional +// DW_AT_location +// DW_AT_segment +// DW_AT_type +// DW_AT_variable_parameter }; -class DIEImportedDeclaration : public DebugInfoEntry { +class DIEImportedDeclaration : public DIEDeclaredNamedBase { public: DIEImportedDeclaration(); virtual uint16 Tag() const; + +// TODO: +// DW_AT_import +// DW_AT_start_scope }; -class DIELabel : public DebugInfoEntry { +class DIELabel : public DIEDeclaredNamedBase { public: DIELabel(); virtual uint16 Tag() const; + +// TODO: +// DW_AT_abstract_origin +// DW_AT_low_pc +// DW_AT_segment +// DW_AT_start_scope }; -class DIELexicalBlock : public DebugInfoEntry { +class DIELexicalBlock : public DIENamedBase { public: DIELexicalBlock(); virtual uint16 Tag() const; + +// TODO: +// DW_AT_abstract_origin +// DW_AT_high_pc +// DW_AT_low_pc +// DW_AT_ranges +// DW_AT_segment }; -class DIEMember : public DebugInfoEntry { +class DIEMember : public DIEDeclaredNamedBase { public: DIEMember(); virtual uint16 Tag() const; + +// TODO: +// DW_AT_bit_offset +// DW_AT_bit_size +// DW_AT_byte_size +// DW_AT_data_member_location +// DW_AT_mutable +// DW_AT_type + }; @@ -422,8 +549,11 @@ virtual uint16 Tag() const; -// TODO: -// DW_AT_specification + virtual status_t AddAttribute_specification(uint16 attributeName, + const AttributeValue& value); + +private: + DIEPointerType* fSpecification; }; @@ -449,8 +579,12 @@ virtual uint16 Tag() const; + virtual status_t AddAttribute_byte_size(uint16 attributeName, + const AttributeValue& value); + +private: [... truncated: 705 lines follow ...] From axeld at mail.berlios.de Mon Jun 15 11:49:14 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 15 Jun 2009 11:49:14 +0200 Subject: [Haiku-commits] r31057 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200906150949.n5F9nEdW007069@sheep.berlios.de> Author: axeld Date: 2009-06-15 11:49:12 +0200 (Mon, 15 Jun 2009) New Revision: 31057 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31057&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: * Cleanup of how the time is converted between bfs_inode and the outside world: there is now a couple of conversion functions, and I changed the type from bigtime_t to int64, as it's not what a bigtime_t would usually contain, but some shift magic in order to make duplicate index entries less likely. * We now correctly fill in the timespec in struct stat as good as possible; the 12 of the 16 possible bits are used for the nano second value. The lower 8 bits are used to avoid the duplicate index entries. Only if the nano second time is 0, the lower 12 bits are used to achieve that. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2009-06-15 09:49:12 UTC (rev 31057) @@ -117,12 +117,15 @@ kprintf(" gid = %u\n", (unsigned)inode->GroupID()); kprintf(" mode = %08x\n", (int)inode->Mode()); kprintf(" flags = %08x\n", (int)inode->Flags()); - kprintf(" create_time = %Ld (%Ld)\n", inode->CreateTime(), - inode->CreateTime() >> INODE_TIME_SHIFT); - kprintf(" last_modified_time = %Ld (%Ld)\n", inode->LastModifiedTime(), - inode->LastModifiedTime() >> INODE_TIME_SHIFT); - kprintf(" status_change_time = %Ld (%Ld)\n", inode->StatusChangeTime(), - inode->StatusChangeTime() >> INODE_TIME_SHIFT); + kprintf(" create_time = %llx (%ld.%u)\n", inode->CreateTime(), + bfs_inode::ToSecs(inode->CreateTime()), + (unsigned)bfs_inode::ToUsecs(inode->CreateTime())); + kprintf(" last_modified_time = %llx (%ld.%u)\n", inode->LastModifiedTime(), + bfs_inode::ToSecs(inode->LastModifiedTime()), + (unsigned)bfs_inode::ToUsecs(inode->LastModifiedTime())); + kprintf(" status_change_time = %llx (%ld.%u)\n", inode->StatusChangeTime(), + bfs_inode::ToSecs(inode->StatusChangeTime()), + (unsigned)bfs_inode::ToUsecs(inode->StatusChangeTime())); dump_block_run( " parent = ", inode->parent); dump_block_run( " attributes = ", inode->attributes); kprintf(" type = %u\n", (unsigned)inode->Type()); Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp 2009-06-15 09:49:12 UTC (rev 31057) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2001-2009, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -390,9 +390,7 @@ bigtime_t oldModified = inode->OldLastModified(); if (modified == -1) - modified = (bigtime_t)time(NULL) << INODE_TIME_SHIFT; - modified &= ~INODE_TIME_MASK; - modified |= fVolume->GetUniqueID() & INODE_TIME_MASK; + modified = bfs_inode::ToInode(real_time_clock_usecs()); status_t status = Update(transaction, "last_modified", B_INT64_TYPE, (uint8*)&oldModified, sizeof(int64), (uint8*)&modified, Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2009-06-15 09:49:12 UTC (rev 31057) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2001-2009, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -389,13 +389,8 @@ Node().mode = HOST_ENDIAN_TO_BFS_INT32(mode); Node().flags = HOST_ENDIAN_TO_BFS_INT32(INODE_IN_USE); - Node().create_time = HOST_ENDIAN_TO_BFS_INT64((bigtime_t)time(NULL) - << INODE_TIME_SHIFT); - Node().last_modified_time = HOST_ENDIAN_TO_BFS_INT64(Node().create_time - | (volume->GetUniqueID() & INODE_TIME_MASK)); - // we use Volume::GetUniqueID() to avoid having too many duplicates - // in the last_modified index - Node().status_change_time = HOST_ENDIAN_TO_BFS_INT64(Node().create_time); + Node().create_time = Node().last_modified_time = Node().status_change_time + = HOST_ENDIAN_TO_BFS_INT64(bfs_inode::ToInode(real_time_clock_usecs())); Node().inode_size = HOST_ENDIAN_TO_BFS_INT32(volume->InodeSize()); @@ -1468,8 +1463,8 @@ // update the last modification time in memory, it will be written // back to the inode, and the index when the file is closed // TODO: should update the internal last modified time only at this point! - Node().last_modified_time = HOST_ENDIAN_TO_BFS_INT64((bigtime_t)time(NULL) - << INODE_TIME_SHIFT); + Node().last_modified_time + = HOST_ENDIAN_TO_BFS_INT64(bfs_inode::ToInode(real_time_clock_usecs())); // TODO: support INODE_LOGGED! Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp 2009-06-15 09:49:12 UTC (rev 31057) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2001-2009, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -279,7 +279,6 @@ fRootNode(NULL), fIndicesNode(NULL), fDirtyCachedBlocks(0), - fUniqueID(0), fFlags(0), fCheckingThread(-1) { Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h 2009-06-15 09:49:12 UTC (rev 31057) @@ -126,8 +126,6 @@ void* BlockCache() { return fBlockCache; } - uint32 GetUniqueID(); - static status_t CheckSuperBlock(const uint8* data, uint32* _offset = NULL); static status_t Identify(int fd, disk_super_block* superBlock); @@ -155,7 +153,6 @@ mutex fQueryLock; SinglyLinkedList fQueries; - int32 fUniqueID; uint32 fFlags; void* fBlockCache; @@ -226,10 +223,4 @@ } -inline uint32 -Volume::GetUniqueID() -{ - return atomic_add(&fUniqueID, 1); -} - #endif // VOLUME_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2009-06-15 09:49:12 UTC (rev 31057) @@ -28,7 +28,8 @@ uint16 start; uint16 length; - int32 AllocationGroup() const { return BFS_ENDIAN_TO_HOST_INT32(allocation_group); } + int32 AllocationGroup() const + { return BFS_ENDIAN_TO_HOST_INT32(allocation_group); } uint16 Start() const { return BFS_ENDIAN_TO_HOST_INT16(start); } uint16 Length() const { return BFS_ENDIAN_TO_HOST_INT16(length); } @@ -87,9 +88,11 @@ off_t NumBlocks() const { return BFS_ENDIAN_TO_HOST_INT64(num_blocks); } off_t UsedBlocks() const { return BFS_ENDIAN_TO_HOST_INT64(used_blocks); } int32 InodeSize() const { return BFS_ENDIAN_TO_HOST_INT32(inode_size); } - int32 BlocksPerAllocationGroup() const { return BFS_ENDIAN_TO_HOST_INT32(blocks_per_ag); } + int32 BlocksPerAllocationGroup() const + { return BFS_ENDIAN_TO_HOST_INT32(blocks_per_ag); } int32 AllocationGroups() const { return BFS_ENDIAN_TO_HOST_INT32(num_ags); } - int32 AllocationGroupShift() const { return BFS_ENDIAN_TO_HOST_INT32(ag_shift); } + int32 AllocationGroupShift() const + { return BFS_ENDIAN_TO_HOST_INT32(ag_shift); } int32 Flags() const { return BFS_ENDIAN_TO_HOST_INT32(flags); } off_t LogStart() const { return BFS_ENDIAN_TO_HOST_INT64(log_start); } off_t LogEnd() const { return BFS_ENDIAN_TO_HOST_INT64(log_end); } @@ -121,10 +124,14 @@ off_t max_double_indirect_range; off_t size; - off_t MaxDirectRange() const { return BFS_ENDIAN_TO_HOST_INT64(max_direct_range); } - off_t MaxIndirectRange() const { return BFS_ENDIAN_TO_HOST_INT64(max_indirect_range); } - off_t MaxDoubleIndirectRange() const { return BFS_ENDIAN_TO_HOST_INT64(max_double_indirect_range); } - off_t Size() const { return BFS_ENDIAN_TO_HOST_INT64(size); } + off_t MaxDirectRange() const + { return BFS_ENDIAN_TO_HOST_INT64(max_direct_range); } + off_t MaxIndirectRange() const + { return BFS_ENDIAN_TO_HOST_INT64(max_indirect_range); } + off_t MaxDoubleIndirectRange() const + { return BFS_ENDIAN_TO_HOST_INT64(max_double_indirect_range); } + off_t Size() const + { return BFS_ENDIAN_TO_HOST_INT64(size); } } _PACKED; // This defines the size of the indirect and double indirect @@ -168,6 +175,13 @@ #define SHORT_SYMLINK_NAME_LENGTH 144 // length incl. terminating '\0' +#define INODE_MAGIC1 0x3bbe0ad9 +#define INODE_FILE_NAME_LENGTH 256 +#define INODE_TIME_SHIFT 16 +#define INODE_TIME_MASK 0xffff + +inline uint32 unique_from_nsec(uint32 time); + struct bfs_inode { int32 magic1; inode_addr inode_num; @@ -175,8 +189,8 @@ int32 gid; int32 mode; // see sys/stat.h int32 flags; - bigtime_t create_time; - bigtime_t last_modified_time; + int64 create_time; + int64 last_modified_time; inode_addr parent; inode_addr attributes; uint32 type; // attribute type @@ -201,23 +215,30 @@ int32 Flags() const { return BFS_ENDIAN_TO_HOST_INT32(flags); } int32 Type() const { return BFS_ENDIAN_TO_HOST_INT32(type); } int32 InodeSize() const { return BFS_ENDIAN_TO_HOST_INT32(inode_size); } - bigtime_t LastModifiedTime() const { - return BFS_ENDIAN_TO_HOST_INT64(last_modified_time); } - bigtime_t CreateTime() const { - return BFS_ENDIAN_TO_HOST_INT64(create_time); } - small_data *SmallDataStart() { return small_data_start; } - bigtime_t StatusChangeTime() const { - return BFS_ENDIAN_TO_HOST_INT64(status_change_time); } + int64 LastModifiedTime() const + { return BFS_ENDIAN_TO_HOST_INT64(last_modified_time); } + int64 CreateTime() const + { return BFS_ENDIAN_TO_HOST_INT64(create_time); } + int64 StatusChangeTime() const + { return BFS_ENDIAN_TO_HOST_INT64(status_change_time); } + small_data* SmallDataStart() { return small_data_start; } status_t InitCheck(Volume *volume); // defined in Inode.cpp + + static int64 ToInode(bigtime_t time) + { return ((time / 1000000) << INODE_TIME_SHIFT) + + unique_from_nsec((time % 1000000) * 1000); } + static int64 ToInode(const timespec& tv) + { return ((int64)tv.tv_sec << INODE_TIME_SHIFT) + + unique_from_nsec(tv.tv_nsec); } + + static time_t ToSecs(bigtime_t time) + { return time >> INODE_TIME_SHIFT; } + static uint32 ToUsecs(bigtime_t time) + { return (time & INODE_TIME_MASK) << 14; } } _PACKED; -#define INODE_MAGIC1 0x3bbe0ad9 -#define INODE_TIME_SHIFT 16 -#define INODE_TIME_MASK 0xffff -#define INODE_FILE_NAME_LENGTH 256 - enum inode_flags { INODE_IN_USE = 0x00000001, // always set INODE_ATTR_INODE = 0x00000004, @@ -235,6 +256,7 @@ INODE_DONT_FREE_SPACE = 0x00080000 }; + //************************************** struct file_cookie { @@ -252,6 +274,24 @@ //************************************** +/*! Converts the nano seconds given to the internal 16 bit resolution that + BFS uses. If \a time is zero, 12 bits will get a monotonically increasing + number. For all other values, only the lower 4 bits are changed this way. + + This is done to decrease the number of duplicate time values, which speeds + up the way BFS handles the time indices. +*/ +inline uint32 +unique_from_nsec(uint32 time) +{ + static vint32 number; + if (time != 0) + return ((time >> 14) & INODE_TIME_MASK) | (++number & 0xf); + + return ++number & 0xfff; +} + + inline int32 divide_roundup(int32 num,int32 divisor) { Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2009-06-15 00:42:03 UTC (rev 31056) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2009-06-15 09:49:12 UTC (rev 31057) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2001-2009, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -31,6 +31,34 @@ extern void fill_stat_buffer(Inode* inode, struct stat& stat); +static void +fill_stat_time(const bfs_inode& node, struct stat& stat) +{ + stat.st_atim.tv_sec = real_time_clock(); + stat.st_atim.tv_nsec = real_time_clock_usecs() % 1000000; + + stat.st_mtim.tv_sec = bfs_inode::ToSecs(node.LastModifiedTime()); + stat.st_mtim.tv_nsec = bfs_inode::ToUsecs(node.LastModifiedTime()); + stat.st_crtim.tv_sec = bfs_inode::ToSecs(node.CreateTime()); + stat.st_crtim.tv_nsec = bfs_inode::ToUsecs(node.CreateTime()); + + // if on-disk ctime is invalid (pointer value from previous [ab]use of + // the first 4 bytes) or 0, fall back to mtime: + // N.B.: This has the drawback that explicitly setting a ctime of 0 + // will not work, but I suppose no one will do that, since ctime + // is usually just set to the current time whenever something happens + // to the inode. + // TODO: find out if this sanity check should be dropped! + bigtime_t changeTime = node.StatusChangeTime(); + if (((uint64)changeTime & 0xFFFF00000000FFFFULL) != 0 || changeTime == 0) + stat.st_ctim = stat.st_mtim; + else { + stat.st_ctim.tv_sec = bfs_inode::ToSecs(changeTime); + stat.st_ctim.tv_nsec = bfs_inode::ToUsecs(changeTime); + } +} + + void fill_stat_buffer(Inode* inode, struct stat& stat) { @@ -46,23 +74,8 @@ stat.st_mode = node.Mode(); stat.st_type = node.Type(); - stat.st_atime = time(NULL); - stat.st_mtime = (time_t)(node.LastModifiedTime() >> INODE_TIME_SHIFT); - stat.st_crtime = (time_t)(node.CreateTime() >> INODE_TIME_SHIFT); + fill_stat_time(node, stat); - // if on-disk ctime is invalid (pointer value from previous [ab]use of - // the first 4 bytes) or 0, fall back to mtime: - // N.B.: This has the drawback that explicitly setting a ctime of 0 - // will not work, but I suppose no one will do that, since ctime - // is usually just set to the current time whenever something happens - // to the inode. - // TODO: find out if this sanity check should be dropped! - bigtime_t ctime = node.StatusChangeTime(); - if (((uint64)ctime & 0xFFFF00000000FFFFULL) != 0 || ctime == 0) - stat.st_ctime = stat.st_mtime; - else - stat.st_ctime = (time_t)(ctime >> INODE_TIME_SHIFT); - if (inode->IsSymLink() && (inode->Flags() & INODE_LONG_SYMLINK) == 0) { // symlinks report the size of the link here stat.st_size = strlen(node.short_symlink); @@ -786,7 +799,8 @@ } if ((mask & B_STAT_MODE) != 0) { - PRINT(("original mode = %ld, stat->st_mode = %d\n", node.Mode(), stat->st_mode)); + PRINT(("original mode = %ld, stat->st_mode = %d\n", node.Mode(), + stat->st_mode)); node.mode = HOST_ENDIAN_TO_BFS_INT32((node.Mode() & ~S_IUMSK) | (stat->st_mode & S_IUMSK)); updateTime = true; @@ -804,27 +818,27 @@ if ((mask & B_STAT_MODIFICATION_TIME) != 0) { if (!inode->InLastModifiedIndex()) { // directory modification times are not part of the index - node.last_modified_time = HOST_ENDIAN_TO_BFS_INT64( - (bigtime_t)stat->st_mtime << INODE_TIME_SHIFT); + node.last_modified_time + = HOST_ENDIAN_TO_BFS_INT64(bfs_inode::ToInode(stat->st_mtim)); } else if (!inode->IsDeleted()) { // Index::UpdateLastModified() will set the new time in the inode Index index(volume); index.UpdateLastModified(transaction, inode, - (bigtime_t)stat->st_mtime << INODE_TIME_SHIFT); + bfs_inode::ToInode(stat->st_mtim)); } } if ((mask & B_STAT_CREATION_TIME) != 0) { - node.create_time = HOST_ENDIAN_TO_BFS_INT64( - (bigtime_t)stat->st_crtime << INODE_TIME_SHIFT); + node.create_time + = HOST_ENDIAN_TO_BFS_INT64(bfs_inode::ToInode(stat->st_crtim)); } if ((mask & B_STAT_CHANGE_TIME) != 0 || updateTime) { bigtime_t newTime; if ((mask & B_STAT_CHANGE_TIME) == 0) - newTime = (bigtime_t)time(NULL); + newTime = bfs_inode::ToInode(real_time_clock_usecs()); else - newTime = (bigtime_t)stat->st_ctime; - node.status_change_time - = HOST_ENDIAN_TO_BFS_INT64(newTime << INODE_TIME_SHIFT); + newTime = bfs_inode::ToInode(stat->st_ctim); + + node.status_change_time = HOST_ENDIAN_TO_BFS_INT64(newTime); } status = inode->WriteBack(transaction); @@ -841,7 +855,8 @@ bfs_create(fs_volume* _volume, fs_vnode* _directory, const char* name, int openMode, int mode, void** _cookie, ino_t* _vnodeID) { - FUNCTION_START(("name = \"%s\", perms = %d, openMode = %d\n", name, mode, openMode)); + FUNCTION_START(("name = \"%s\", perms = %d, openMode = %d\n", name, mode, + openMode)); Volume* volume = (Volume*)_volume->private_volume; Inode* directory = (Inode*)_directory->private_node; @@ -2037,19 +2052,18 @@ bfs_inode& node = index.Node()->Node(); stat->st_type = index.Type(); - stat->st_size = node.data.Size(); stat->st_mode = node.Mode(); + stat->st_size = node.data.Size(); + stat->st_blocks = index.Node()->AllocatedSize() / 512; + stat->st_nlink = 1; stat->st_blksize = 65536; stat->st_uid = node.UserID(); stat->st_gid = node.GroupID(); - stat->st_atime = time(NULL); - stat->st_mtime = (time_t)(node.LastModifiedTime() >> INODE_TIME_SHIFT); - stat->st_ctime = (time_t)(node.StatusChangeTime() >> INODE_TIME_SHIFT); - stat->st_crtime = (time_t)(node.CreateTime() >> INODE_TIME_SHIFT); + fill_stat_time(node, *stat); return B_OK; } From axeld at mail.berlios.de Mon Jun 15 12:51:30 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 15 Jun 2009 12:51:30 +0200 Subject: [Haiku-commits] r31058 - haiku/trunk/src/preferences/cpufrequency Message-ID: <200906151051.n5FApUwU027271@sheep.berlios.de> Author: axeld Date: 2009-06-15 12:51:29 +0200 (Mon, 15 Jun 2009) New Revision: 31058 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31058&view=rev Modified: haiku/trunk/src/preferences/cpufrequency/StatusView.cpp Log: * Fixed typos, this also closes ticket #4026. * Fixed many coding style issues. Modified: haiku/trunk/src/preferences/cpufrequency/StatusView.cpp =================================================================== --- haiku/trunk/src/preferences/cpufrequency/StatusView.cpp 2009-06-15 09:49:12 UTC (rev 31057) +++ haiku/trunk/src/preferences/cpufrequency/StatusView.cpp 2009-06-15 10:51:29 UTC (rev 31058) @@ -7,8 +7,9 @@ */ #include "StatusView.h" -#include "CPUFrequencyView.h" +#include + #include #include #include @@ -19,14 +20,16 @@ #include #include -#include +#include "CPUFrequencyView.h" + extern "C" _EXPORT BView *instantiate_deskbar_item(void); + #define MAX_FREQ_STRING "9999MHz" // messages FrequencySwitcher -const uint32 kMsgDynamicPolicyPuls = '&dpp'; +const uint32 kMsgDynamicPolicyPulse = '&dpp'; // messages menu const uint32 kMsgPolicyDynamic = 'pody'; @@ -40,15 +43,14 @@ FrequencySwitcher::FrequencySwitcher(CPUFreqDriverInterface* interface, - BHandler* target) - : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE), - fDriverInterface(interface), - fTarget(target), - fMessageRunner(NULL), - fCurrentFrequency(NULL), - fDynamicPolicyStarted(false) + BHandler* target) + : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE), + fDriverInterface(interface), + fTarget(target), + fMessageRunner(NULL), + fCurrentFrequency(NULL), + fDynamicPolicyStarted(false) { - } @@ -60,10 +62,10 @@ filter_result -FrequencySwitcher::Filter(BMessage *message, BHandler **target) +FrequencySwitcher::Filter(BMessage* message, BHandler** target) { filter_result result = B_DISPATCH_MESSAGE; - if (message->what == kMsgDynamicPolicyPuls) { + if (message->what == kMsgDynamicPolicyPulse) { _CalculateDynamicState(); result = B_SKIP_MESSAGE; } @@ -79,32 +81,31 @@ freq_info* currentState = fDriverInterface->GetCurrentFrequencyState(); freq_info* state = NULL; bool isDynamic = false; - + switch (pref.mode) { case DYNAMIC: isDynamic = true; fSteppingThreshold = pref.stepping_threshold; - if (fMessageRunner && fIntegrationTime != pref.integration_time) - { + if (fMessageRunner && fIntegrationTime != pref.integration_time) { fIntegrationTime = pref.integration_time; fMessageRunner->SetInterval(fIntegrationTime); } if (!fDynamicPolicyStarted) _StartDynamicPolicy(true, pref); break; - + case PERFORMANCE: state = list->ItemAt(int32(0)); if (state != currentState) fDriverInterface->SetFrequencyState(state); break; - + case LOW_ENERGIE: state = list->ItemAt(stateCount - 1); if (state != currentState) fDriverInterface->SetFrequencyState(state); break; - + case CUSTOM: if (pref.custom_stepping < stateCount) { state = list->ItemAt(pref.custom_stepping); @@ -112,7 +113,7 @@ } break; } - + if (!isDynamic && fDynamicPolicyStarted) { fDynamicPolicyStarted = false; _StartDynamicPolicy(false, pref); @@ -127,26 +128,24 @@ get_system_info(&sysInfo); bigtime_t now = system_time(); bigtime_t activeTime = sysInfo.cpu_infos[0].active_time; - - // if the dynamic mode is not started firt init the prev values + + // if the dynamic mode is not started first init the prev values if (!fDynamicPolicyStarted) { fPrevActiveTime = activeTime; fPrevTime = now; fDynamicPolicyStarted = true; - } - else { + } else { float usage = (float)(activeTime - fPrevActiveTime ) / (now - fPrevTime); if (usage >= 1.0) usage = 0.9999999; - + int32 numberOfStates = fDriverInterface->GetNumberOfFrequencyStates(); for (int i = 0; i < numberOfStates; i++) { float usageOfStep = ColorStepView::UsageOfStep(i, numberOfStates, - fSteppingThreshold); + fSteppingThreshold); - if (usage < usageOfStep) - { + if (usage < usageOfStep) { StateList* list = fDriverInterface->GetCpuFrequencyStates(); freq_info* newState = list->ItemAt(numberOfStates - 1 - i); if (newState != fCurrentFrequency) { @@ -154,7 +153,7 @@ fDriverInterface->SetFrequencyState(newState); fCurrentFrequency = newState; } - break; + break; } } fPrevActiveTime = activeTime; @@ -164,48 +163,46 @@ void -FrequencySwitcher::_StartDynamicPolicy(bool start, - const freq_preferences& pref) +FrequencySwitcher::_StartDynamicPolicy(bool start, const freq_preferences& pref) { if (start) { if (!fMessageRunner) { fIntegrationTime = pref.integration_time; fMessageRunner = new BMessageRunner(fTarget, - new BMessage(kMsgDynamicPolicyPuls) - , pref.integration_time, -1); + new BMessage(kMsgDynamicPolicyPulse), pref.integration_time, -1); fCurrentFrequency = fDriverInterface->GetCurrentFrequencyState(); } + } else { + delete fMessageRunner; + fMessageRunner = NULL; } - else { - if (fMessageRunner) { - delete fMessageRunner; - fMessageRunner = NULL; - } - } } +// #pragma mark - + + FrequencyMenu::FrequencyMenu(BMenu* menu, BHandler* target, - PreferencesStorage * storage, - CPUFreqDriverInterface* interface) - : BMessageFilter(B_PROGRAMMED_DELIVERY, B_LOCAL_SOURCE), - fTarget(target), - fStorage(storage), - fInterface(interface) + PreferencesStorage* storage, + CPUFreqDriverInterface* interface) + : BMessageFilter(B_PROGRAMMED_DELIVERY, B_LOCAL_SOURCE), + fTarget(target), + fStorage(storage), + fInterface(interface) { fDynamicPerformance = new BMenuItem("Dynamic Performance", - new BMessage(kMsgPolicyDynamic)); + new BMessage(kMsgPolicyDynamic)); fHighPerformance = new BMenuItem("High Performance", - new BMessage(kMsgPolicyPerformance)); - fLowEnergie = new BMenuItem("Low Energie", - new BMessage(kMsgPolicyLowEnergy)); - + new BMessage(kMsgPolicyPerformance)); + fLowEnergie = new BMenuItem("Low Energy", + new BMessage(kMsgPolicyLowEnergy)); + menu->AddItem(fDynamicPerformance); menu->AddItem(fHighPerformance); menu->AddItem(fLowEnergie); - + fCustomStateMenu = new BMenu("Set State"); - + StateList* stateList = fInterface->GetCpuFrequencyStates(); for (int i = 0; i < stateList->CountItems(); i++) { freq_info* info = stateList->ItemAt(i); @@ -213,16 +210,16 @@ label << info->frequency; label += " MHz"; fCustomStateMenu->AddItem(new BMenuItem(label.String(), - new BMessage(kMsgPolicySetState))); + new BMessage(kMsgPolicySetState))); } - + menu->AddItem(fCustomStateMenu); - + // set the target of the items fDynamicPerformance->SetTarget(fTarget); fHighPerformance->SetTarget(fTarget); fLowEnergie->SetTarget(fTarget); - + fCustomStateMenu->SetTargetForItems(fTarget); } @@ -242,19 +239,18 @@ filter_result -FrequencyMenu::Filter(BMessage *msg, BHandler **target) +FrequencyMenu::Filter(BMessage* msg, BHandler** target) { filter_result result = B_DISPATCH_MESSAGE; - + BMenuItem* item, *superItem, *markedItem; msg->FindPointer("source", (void**)&item); - if (!item) { + if (!item) return result; - } - + bool safeChanges = false; freq_preferences* pref = fStorage->GetPreferences(); - + switch (msg->what) { case kMsgPolicyDynamic: pref->mode = DYNAMIC; @@ -262,25 +258,25 @@ safeChanges = true; msg->what = kUpdatedPreferences; break; - + case kMsgPolicyPerformance: pref->mode = PERFORMANCE; _SetL1MenuLabelFrom(item); safeChanges = true; msg->what = kUpdatedPreferences; break; - + case kMsgPolicyLowEnergy: pref->mode = LOW_ENERGIE; _SetL1MenuLabelFrom(item); safeChanges = true; msg->what = kUpdatedPreferences; break; - + case kMsgPolicySetState: pref->mode = CUSTOM; pref->custom_stepping = item->Menu()->IndexOf(item); - + superItem = item->Menu()->Supermenu()->Superitem(); if (superItem) superItem->SetLabel(item->Label()); @@ -291,15 +287,15 @@ if (markedItem) markedItem->SetMarked(false); item->SetMarked(true); - + safeChanges = true; msg->what = kUpdatedPreferences; break; } - + if (safeChanges) fStorage->SavePreferences(); - + return result; } @@ -307,39 +303,43 @@ void FrequencyMenu::UpdateMenu() { - BMenuItem* customItem, *markedItem, *superItem; - freq_preferences* pref = fStorage->GetPreferences(); switch (pref->mode) { case DYNAMIC: _SetL1MenuLabelFrom(fDynamicPerformance); break; - + case PERFORMANCE: _SetL1MenuLabelFrom(fHighPerformance); break; - + case LOW_ENERGIE: _SetL1MenuLabelFrom(fLowEnergie); break; - + case CUSTOM: - markedItem = fCustomStateMenu->FindMarked(); + { + BMenuItem* markedItem = fCustomStateMenu->FindMarked(); if (markedItem) markedItem->SetMarked(false); - customItem = fCustomStateMenu->ItemAt(pref->custom_stepping); + BMenuItem* customItem + = fCustomStateMenu->ItemAt(pref->custom_stepping); if (customItem) customItem->SetMarked(true); - superItem = fCustomStateMenu->Supermenu()->Superitem(); + BMenuItem* superItem = fCustomStateMenu->Supermenu()->Superitem(); if (superItem && customItem) - superItem->SetLabel(customItem->Label()); - break; + superItem->SetLabel(customItem->Label()); + break; + } } } +// #pragma mark - + + StatusView::StatusView(BRect frame, bool inDeskbar, - PreferencesStorage* storage) + PreferencesStorage* storage) : BView(frame, kDeskbarItemName, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS), fInDeskbar(inDeskbar), @@ -355,17 +355,16 @@ B_FOLLOW_NONE); AddChild(fDragger); } - + if (storage) { fOwningStorage = false; fStorage = storage; - } - else { + } else { fOwningStorage = true; fStorage = new PreferencesStorage("CPUFrequency", - kDefaultPreferences); + kDefaultPreferences); } - + _Init(); } @@ -383,7 +382,7 @@ fOwningStorage = true; fStorage = new PreferencesStorage(kPreferencesFileName, - kDefaultPreferences); + kDefaultPreferences); _Init(); } @@ -426,7 +425,7 @@ } -StatusView * +StatusView* StatusView::Instantiate(BMessage* archive) { if (!validate_instantiation(archive, "StatusView")) @@ -459,30 +458,29 @@ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); - + // watching if the driver change the frequency fDriverInterface.StartWatching(this); // monitor preferences file fPrefFileWatcher = new PrefFileWatcher(fStorage, this); AddFilter(fPrefFileWatcher); - + // FrequencySwitcher fFrequencySwitcher = new FrequencySwitcher(&fDriverInterface, this); fFrequencySwitcher->SetMode(*(fStorage->GetPreferences())); AddFilter(fFrequencySwitcher); - + // perferences menu fPreferencesMenu = new BPopUpMenu(B_EMPTY_STRING, false, false); - fPreferencesMenuFilter = new FrequencyMenu(fPreferencesMenu, this, - fStorage, - &fDriverInterface); - + fPreferencesMenuFilter = new FrequencyMenu(fPreferencesMenu, this, fStorage, + &fDriverInterface); + fPreferencesMenu->SetFont(be_plain_font); fPreferencesMenu->AddSeparatorItem(); fOpenPrefItem = new BMenuItem("Open Speedstep Preferences" B_UTF8_ELLIPSIS, - new BMessage(kMsgOpenSSPreferences)); + new BMessage(kMsgOpenSSPreferences)); fPreferencesMenu->AddItem(fOpenPrefItem); fOpenPrefItem->SetTarget(this); @@ -492,7 +490,7 @@ fQuitItem->SetTarget(this); } AddFilter(fPreferencesMenuFilter); - + fPreferencesMenuFilter->UpdateMenu(); } @@ -501,7 +499,7 @@ StatusView::DetachedFromWindow() { fDriverInterface.StopWatching(); - + if (RemoveFilter(fPrefFileWatcher)) delete fPrefFileWatcher; if (RemoveFilter(fFrequencySwitcher)) @@ -525,16 +523,16 @@ _SetupNewFreqString(); Invalidate(); break; - + case kUpdatedPreferences: fFrequencySwitcher->SetMode(*(fStorage->GetPreferences())); fPreferencesMenuFilter->UpdateMenu(); break; - + case B_ABOUT_REQUESTED: _AboutRequested(); break; - + case B_QUIT_REQUESTED: _Quit(); break; @@ -558,9 +556,9 @@ font_height fontHeight; GetFontHeight(&fontHeight); float height = fontHeight.ascent + fontHeight.descent; - + MovePenTo(0, height); - + DrawString(fFreqString.String()); } @@ -612,13 +610,13 @@ fFrequencySwitcher->SetMode(*(fStorage->GetPreferences())); } - + void StatusView::_Init() { fShowPopUpMenu = true; fCurrentFrequency = fDriverInterface.GetCurrentFrequencyState(); - + _SetupNewFreqString(); } @@ -626,10 +624,10 @@ void StatusView::_SetupNewFreqString() { - if (fCurrentFrequency) + if (fCurrentFrequency) { fFreqString = ColorStepView::CreateFrequencyString( fCurrentFrequency->frequency); - else + } else fFreqString = "? MHz"; ResizeToPreferred(); @@ -663,7 +661,10 @@ } -extern "C" _EXPORT BView * +// #pragma mark - + + +extern "C" _EXPORT BView* instantiate_deskbar_item(void) { return new StatusView(BRect(0, 0, 15, 15), true, NULL); From ingo_weinhold at gmx.de Mon Jun 15 14:16:35 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 15 Jun 2009 14:16:35 +0200 Subject: [Haiku-commits] r31047 - in haiku/trunk/src/apps: . debugger In-Reply-To: <2372987327-BeMail@laptop> References: <2372987327-BeMail@laptop> Message-ID: <20090615141635.592.3@knochen-vm.localdomain> On 2009-06-14 at 20:33:27 [+0200], Fran?ois Revol wrote: > > > Wouldn't a gdb based GUI be faster to write ? > > > IIRC there is a library that can be used. > > > It should be GPLed but that shouldn't matter much anyway... > > > > But Ingo is the one who ported our GDB. So he is probably aware of > > it. :-} > > Maybe he didn't look at the library API. Thanks for the hint! Indeed I missed the library -- libdwarf BTW -- when first looking for helpful code. It doesn't seem particulary popular (neither gcc/binutils nor gdb use it at least). It is LGPL though and still maintained. Will have a closer look at the API. > > enough technical reasons to do this, but even as a user, I could see > > where > > this is comming from, because both KDevelop and QtCreator are no fun > > to do > > debugging on in my experience. Even when GDB does run for a while > > without > > crashing. > > I just scratched the surface with gdb, it's quite powerful but I never > read the manual. Yep, it is powerful. It is also ancient and "grown" code, that isn't particular fun to hack. Worst of all, though, the current version (6.8) seems to be buggy enough (under Linux at least) that using it isn't particular fun either. Neither the old version 6.3 Haiku currently uses, nor the current 6.8 can even read Haiku's gcc 2 kernel when compiled with debug info (the latter just hangs). All not particularly motivating to use it as a base for a GUI debugger at least. CU, Ingo From axeld at mail.berlios.de Mon Jun 15 16:03:28 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 15 Jun 2009 16:03:28 +0200 Subject: [Haiku-commits] r31059 - in haiku/trunk/src/system/kernel: device_manager fs Message-ID: <200906151403.n5FE3SMe014562@sheep.berlios.de> Author: axeld Date: 2009-06-15 16:03:24 +0200 (Mon, 15 Jun 2009) New Revision: 31059 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31059&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp haiku/trunk/src/system/kernel/fs/fifo.cpp haiku/trunk/src/system/kernel/fs/rootfs.cpp haiku/trunk/src/system/kernel/fs/socket.cpp Log: * Made the internal file systems correctly handle the timespec struct stat times. Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2009-06-15 10:51:29 UTC (rev 31058) +++ haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2009-06-15 14:03:24 UTC (rev 31059) @@ -84,8 +84,8 @@ struct devfs_vnode* all_next; ino_t id; char* name; - time_t modification_time; - time_t creation_time; + timespec modification_time; + timespec creation_time; uid_t uid; gid_t gid; struct devfs_vnode* parent; @@ -151,6 +151,18 @@ // #pragma mark - devfs private +static timespec +current_timespec() +{ + bigtime_t time = real_time_clock_usecs(); + + timespec tv; + tv.tv_sec = time / 1000000; + tv.tv_nsec = (time % 1000000) * 1000; + return tv; +} + + static int32 scan_mode(void) { @@ -228,7 +240,7 @@ return NULL; } - vnode->creation_time = vnode->modification_time = time(NULL); + vnode->creation_time = vnode->modification_time = current_timespec(); vnode->uid = geteuid(); vnode->gid = parent ? parent->gid : getegid(); // inherit group from parent if possible @@ -333,7 +345,7 @@ } vnode->parent = dir; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_entry_created(sDeviceFileSystem->id, dir->id, vnode->name, vnode->id); @@ -360,7 +372,7 @@ else dir->stream.u.dir.dir_head = vnode->dir_next; vnode->dir_next = NULL; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_entry_removed(sDeviceFileSystem->id, dir->id, vnode->name, vnode->id); @@ -1796,11 +1808,11 @@ stat->st_uid = vnode->uid; stat->st_gid = vnode->gid; - stat->st_atime = time(NULL); - stat->st_mtime = stat->st_ctime = vnode->modification_time; - stat->st_crtime = vnode->creation_time; + stat->st_atim = current_timespec(); + stat->st_mtim = stat->st_ctim = vnode->modification_time; + stat->st_crtim = vnode->creation_time; - // ToDo: this only works for partitions right now - if we should decide + // TODO: this only works for partitions right now - if we should decide // to keep this feature, we should have a better solution if (S_ISCHR(vnode->stream.type)) { //device_geometry geometry; @@ -1854,9 +1866,9 @@ vnode->gid = stat->st_gid; if (statMask & B_STAT_MODIFICATION_TIME) - vnode->modification_time = stat->st_mtime; + vnode->modification_time = stat->st_mtim; if (statMask & B_STAT_CREATION_TIME) - vnode->creation_time = stat->st_crtime; + vnode->creation_time = stat->st_crtim; notify_stat_changed(fs->id, vnode->id, statMask); return B_OK; Modified: haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2009-06-15 10:51:29 UTC (rev 31058) +++ haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2009-06-15 14:03:24 UTC (rev 31059) @@ -89,7 +89,7 @@ const char* name; dev_t device; ino_t node; - time_t last_modified; + timespec last_modified; image_id image; uint32 devices_used; bool binary_updated; @@ -567,7 +567,7 @@ driver->device = stat.st_dev; driver->node = stat.st_ino; driver->image = image; - driver->last_modified = stat.st_mtime; + driver->last_modified = stat.st_mtim; driver->devices_used = 0; driver->binary_updated = false; driver->priority = priority; @@ -756,7 +756,8 @@ kprintf(" image: %ld\n", driver->image); kprintf(" device: %ld\n", driver->device); kprintf(" node: %Ld\n", driver->node); - kprintf(" last modified: %ld\n", driver->last_modified); + kprintf(" last modified: %ld.%lu\n", driver->last_modified.tv_sec, + driver->last_modified.tv_nsec); kprintf(" devs used: %ld\n", driver->devices_used); kprintf(" devs published: %ld\n", driver->devices.Count()); kprintf(" binary updated: %d\n", driver->binary_updated); Modified: haiku/trunk/src/system/kernel/fs/fifo.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fifo.cpp 2009-06-15 10:51:29 UTC (rev 31058) +++ haiku/trunk/src/system/kernel/fs/fifo.cpp 2009-06-15 14:03:24 UTC (rev 31059) @@ -1,6 +1,6 @@ /* * Copyright 2007-2008, Ingo Weinhold, ingo_weinhold at gmx.de. - * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2003-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -137,11 +137,11 @@ status_t InitCheck(); bool IsActive() const { return fActive; } - time_t CreationTime() const { return fCreationTime; } - void SetCreationTime(time_t creationTime) + timespec CreationTime() const { return fCreationTime; } + void SetCreationTime(timespec creationTime) { fCreationTime = creationTime; } - time_t ModificationTime() const { return fModificationTime; } - void SetModificationTime(time_t modificationTime) + timespec ModificationTime() const { return fModificationTime; } + void SetModificationTime(timespec modificationTime) { fModificationTime = modificationTime; } mutex *RequestLock() { return &fRequestLock; } @@ -171,8 +171,8 @@ status_t Deselect(uint8 event, selectsync *sync, int openMode); private: - time_t fCreationTime; - time_t fModificationTime; + timespec fCreationTime; + timespec fModificationTime; RingBuffer fBuffer; @@ -319,7 +319,10 @@ fWriteCondition.Publish(this, "pipe"); mutex_init(&fRequestLock, "pipe request"); - fCreationTime = fModificationTime = time(NULL); + bigtime_t time = real_time_clock(); + fModificationTime.tv_sec = time / 1000000; + fModificationTime.tv_nsec = (time % 1000000) * 1000; + fCreationTime = fModificationTime; } @@ -855,10 +858,10 @@ st->st_blksize = 4096; -// TODO: Just pass the changes to our modification time on to the super node. - st->st_atime = time(NULL); - st->st_mtime = st->st_ctime = fifo->ModificationTime(); -// st->st_crtime = inode->CreationTime(); + // TODO: Just pass the changes to our modification time on to the super node. + st->st_atim.tv_sec = time(NULL); + st->st_atim.tv_nsec = 0; + st->st_mtim = st->st_ctim = fifo->ModificationTime(); return B_OK; } Modified: haiku/trunk/src/system/kernel/fs/rootfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/rootfs.cpp 2009-06-15 10:51:29 UTC (rev 31058) +++ haiku/trunk/src/system/kernel/fs/rootfs.cpp 2009-06-15 14:03:24 UTC (rev 31059) @@ -60,8 +60,8 @@ struct rootfs_vnode* all_next; ino_t id; char* name; - time_t modification_time; - time_t creation_time; + timespec modification_time; + timespec creation_time; uid_t uid; gid_t gid; struct rootfs_vnode* parent; @@ -102,6 +102,18 @@ #define ROOTFS_HASH_SIZE 16 +static timespec +current_timespec() +{ + bigtime_t time = real_time_clock_usecs(); + + timespec tv; + tv.tv_sec = time / 1000000; + tv.tv_nsec = (time % 1000000) * 1000; + return tv; +} + + static uint32 rootfs_vnode_hash_func(void* _v, const void* _key, uint32 range) { @@ -150,7 +162,7 @@ vnode->id = fs->next_vnode_id++; vnode->stream.type = type; - vnode->creation_time = vnode->modification_time = time(NULL); + vnode->creation_time = vnode->modification_time = current_timespec(); vnode->uid = geteuid(); vnode->gid = parent ? parent->gid : getegid(); // inherit group from parent if possible @@ -235,7 +247,7 @@ } vnode->parent = dir; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_stat_changed(fs->id, dir->id, B_STAT_MODIFICATION_TIME); return B_OK; @@ -261,7 +273,7 @@ dir->stream.dir.dir_head = vnode->dir_next; vnode->dir_next = NULL; - dir->modification_time = time(NULL); + dir->modification_time = current_timespec(); notify_stat_changed(fs->id, dir->id, B_STAT_MODIFICATION_TIME); return B_OK; } @@ -1002,9 +1014,10 @@ stat->st_uid = vnode->uid; stat->st_gid = vnode->gid; - stat->st_atime = time(NULL); - stat->st_mtime = stat->st_ctime = vnode->modification_time; - stat->st_crtime = vnode->creation_time; + stat->st_atim.tv_sec = real_time_clock(); + stat->st_atim.tv_nsec = 0; + stat->st_mtim = stat->st_ctim = vnode->modification_time; + stat->st_crtim = vnode->creation_time; return B_OK; } @@ -1037,9 +1050,9 @@ vnode->gid = stat->st_gid; if ((statMask & B_STAT_MODIFICATION_TIME) != 0) - vnode->modification_time = stat->st_mtime; + vnode->modification_time = stat->st_mtim; if ((statMask & B_STAT_CREATION_TIME) != 0) - vnode->creation_time = stat->st_crtime; + vnode->creation_time = stat->st_crtim; mutex_unlock(&fs->lock); Modified: haiku/trunk/src/system/kernel/fs/socket.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/socket.cpp 2009-06-15 10:51:29 UTC (rev 31058) +++ haiku/trunk/src/system/kernel/fs/socket.cpp 2009-06-15 14:03:24 UTC (rev 31059) @@ -288,13 +288,17 @@ st->st_size = 0; st->st_rdev = 0; st->st_blksize = 1024; // use MTU for datagram sockets? - time_t now = time(NULL); - st->st_atime = now; - st->st_mtime = now; - st->st_ctime = now; - st->st_crtime = now; st->st_type = 0; + timespec now; + now.tv_sec = time(NULL); + now.tv_nsec = 0; + + st->st_atim = now; + st->st_mtim = now; + st->st_ctim = now; + st->st_crtim = now; + return B_OK; } From stippi at mail.berlios.de Mon Jun 15 17:15:34 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Mon, 15 Jun 2009 17:15:34 +0200 Subject: [Haiku-commits] r31060 - haiku/trunk/src/kits/game Message-ID: <200906151515.n5FFFYYW023064@sheep.berlios.de> Author: stippi Date: 2009-06-15 17:15:32 +0200 (Mon, 15 Jun 2009) New Revision: 31060 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31060&view=rev Modified: haiku/trunk/src/kits/game/FileGameSound.cpp haiku/trunk/src/kits/game/GameSound.cpp haiku/trunk/src/kits/game/GameSoundDevice.cpp Log: * Added a couple TODOs after reading a bit in the source. * Introduced a lock in GetDefaultDevice() and ReleaseDevice() as a quick solution to the race condition in those functions. It could also use proper atomic ref counting. Untested. * Automatic white space cleanup. Modified: haiku/trunk/src/kits/game/FileGameSound.cpp =================================================================== --- haiku/trunk/src/kits/game/FileGameSound.cpp 2009-06-15 14:03:24 UTC (rev 31059) +++ haiku/trunk/src/kits/game/FileGameSound.cpp 2009-06-15 15:15:32 UTC (rev 31060) @@ -151,8 +151,13 @@ BFileGameSound::~BFileGameSound() { - if (fReadThread >= 0) + if (fReadThread >= 0) { + // TODO: kill_thread() is very bad, since it will leak any resources + // that the thread had allocated. It will also keep locks locked that + // the thread holds! Set a flag to make the thread quit and use + // wait_for_thread() here! kill_thread(fReadThread); + } if (fAudioStream) { if (fAudioStream->stream) @@ -223,7 +228,7 @@ // fPlayPosition is where we got up to in the input buffer after last call size_t out_offset = 0; - + while (inByteCount > 0 && !fPaused) { if (!fPaused || fPausing) { printf("mixout %ld, inByteCount %ld, decin %ld, BufferSize %ld\n",out_offset, inByteCount, fPlayPosition, fBufferSize); @@ -233,14 +238,14 @@ if (fPausing) { Lock(); - + bool rampDone = false; size_t bytes = fBufferSize - fPlayPosition; - + if (bytes > inByteCount) { bytes = inByteCount; } - + // Fill the requested buffer, stopping if the paused flag is set char * buffer = (char*)inBuffer; @@ -248,24 +253,24 @@ case gs_audio_format::B_GS_U8: rampDone = ::FillBuffer(fPausing, (uint8*)&buffer[out_offset], (uint8*)&fBuffer[fPlayPosition], &bytes); break; - + case gs_audio_format::B_GS_S16: rampDone = ::FillBuffer(fPausing, (int16*)&buffer[out_offset], (int16*)&fBuffer[fPlayPosition], &bytes); break; - + case gs_audio_format::B_GS_S32: rampDone = ::FillBuffer(fPausing, (int32*)&buffer[out_offset], (int32*)&fBuffer[fPlayPosition], &bytes); break; - + case gs_audio_format::B_GS_F: rampDone = ::FillBuffer(fPausing, (float*)&buffer[out_offset], (float*)&fBuffer[fPlayPosition], &bytes); break; } - + inByteCount -= bytes; out_offset += bytes; fPlayPosition += bytes; - + // We finished ramping if (rampDone) { @@ -274,14 +279,14 @@ buffer[out_offset++] = fBuffer[fPlayPosition++]; inByteCount--; } - + delete fPausing; fPausing = NULL; } - + Unlock(); } else { - + char * buffer = (char*)inBuffer; // We need to be able to stop asap when the pause flag is flipped. @@ -410,7 +415,7 @@ fAudioStream->stream->ReadFrames(fBuffer, &frames); fBufferSize = frames * fFrameSize; fPlayPosition = 0; - + if (fBufferSize <= 0) { // EOF if (fLooping) { @@ -421,7 +426,7 @@ StopPlaying(); } } - + return true; } Modified: haiku/trunk/src/kits/game/GameSound.cpp =================================================================== --- haiku/trunk/src/kits/game/GameSound.cpp 2009-06-15 14:03:24 UTC (rev 31059) +++ haiku/trunk/src/kits/game/GameSound.cpp 2009-06-15 15:15:32 UTC (rev 31060) @@ -1,8 +1,8 @@ -/* +/* * Copyright 2001-2002, Haiku Inc. * Authors: * Christopher ML Zumwalt May (zummy at users.sf.net) - * + * * Distributed under the terms of the MIT License. */ @@ -23,6 +23,9 @@ BGameSound::BGameSound(BGameSoundDevice *device) : fSound(-1) { + // TODO: device is ignored! + // NOTE: BeBook documents that BGameSoundDevice must currently always + // be NULL... fDevice = GetDefaultDevice(); fInitError = fDevice->InitCheck(); } @@ -32,9 +35,10 @@ : fSound(-1) { memcpy(&fFormat, &other.fFormat, sizeof(gs_audio_format)); + // TODO: device from other is ignored! fDevice = GetDefaultDevice(); - - fInitError = fDevice->InitCheck(); + + fInitError = fDevice->InitCheck(); } @@ -42,7 +46,7 @@ { if (fSound >= 0) fDevice->ReleaseBuffer(fSound); - + ReleaseDevice(); } @@ -57,6 +61,7 @@ BGameSoundDevice * BGameSound::Device() const { + // TODO: Must return NULL if default device is being used! return fDevice; } @@ -64,6 +69,8 @@ gs_id BGameSound::ID() const { + // TODO: Should be 0 if no sound has been selected! But fSound + // is initialized with -1 in the constructors. return fSound; } @@ -103,13 +110,13 @@ bigtime_t duration) { gs_attribute attribute; - + attribute.attribute = B_GS_GAIN; attribute.value = gain; attribute.duration = duration; attribute.flags = 0; - - return fDevice->SetAttributes(fSound, &attribute, 1); + + return fDevice->SetAttributes(fSound, &attribute, 1); } @@ -118,12 +125,12 @@ bigtime_t duration) { gs_attribute attribute; - + attribute.attribute = B_GS_PAN; attribute.value = pan; attribute.duration = duration; attribute.flags = 0; - + return fDevice->SetAttributes(fSound, &attribute, 1); } @@ -132,13 +139,13 @@ BGameSound::Gain() { gs_attribute attribute; - + attribute.attribute = B_GS_GAIN; attribute.flags = 0; - + if (fDevice->GetAttributes(fSound, &attribute, 1) != B_OK) return 0.0; - + return attribute.value; } @@ -147,13 +154,13 @@ BGameSound::Pan() { gs_attribute attribute; - + attribute.attribute = B_GS_PAN; attribute.flags = 0; - + if (fDevice->GetAttributes(fSound, &attribute, 1) != B_OK) return 0.0; - + return attribute.value; } @@ -247,7 +254,7 @@ { if (fSound < 0) fSound = handle; - + return B_OK; } @@ -257,10 +264,12 @@ { if (fSound) fDevice->ReleaseBuffer(fSound); - + fSound = other.fSound; fInitError = other.fInitError; - + + // TODO: This would need to acquire the sound another time! + return this; } */ @@ -269,8 +278,8 @@ * * BGameSound::BGameSound() */ - + status_t BGameSound::_Reserved_BGameSound_0(int32 arg, ...) { Modified: haiku/trunk/src/kits/game/GameSoundDevice.cpp =================================================================== --- haiku/trunk/src/kits/game/GameSoundDevice.cpp 2009-06-15 14:03:24 UTC (rev 31059) +++ haiku/trunk/src/kits/game/GameSoundDevice.cpp 2009-06-15 15:15:32 UTC (rev 31060) @@ -22,7 +22,7 @@ // File Name: BGameSoundDevice.cpp // Author: Christopher ML Zumwalt May (zummy at users.sf.net) // Description: Manages the game producer. The class may change with out -// notice and was only inteneded for use by the GameKit at +// notice and was only inteneded for use by the GameKit at // this time. Use at your own risk. //------------------------------------------------------------------------------ @@ -30,7 +30,9 @@ #include #include +#include #include +#include #include #include #include @@ -47,14 +49,17 @@ static int32 sDeviceCount = 0; static BGameSoundDevice* sDevice = NULL; +static BLocker sDeviceRefCountLock = BLocker("GameSound device lock"); BGameSoundDevice * GetDefaultDevice() { + BAutolock _(sDeviceRefCountLock); + if (!sDevice) sDevice = new BGameSoundDevice(); - + sDeviceCount++; return sDevice; } @@ -63,8 +68,10 @@ void ReleaseDevice() { + BAutolock _(sDeviceRefCountLock); + sDeviceCount--; - + if (sDeviceCount <= 0) { delete sDevice; sDevice = NULL; @@ -79,12 +86,12 @@ { fConnection = new Connection; memset(&fFormat, 0, sizeof(gs_audio_format)); - + fInitError = Connect(); - + fSounds = new GameSoundBuffer*[kInitSoundCount]; for (int32 i = 0; i < kInitSoundCount; i++) - fSounds[i] = NULL; + fSounds[i] = NULL; } @@ -98,23 +105,23 @@ fSounds[i]->StopPlaying(); delete fSounds[i]; } - + if (fIsConnected) { // stop the nodes if they are running roster->StopNode(fConnection->producer, 0, true); // synchronous stop - + // Ordinarily we'd stop *all* of the nodes in the chain at this point. However, // one of the nodes is the System Mixer, and stopping the Mixer is a Bad Idea (tm). // So, we just disconnect from it, and release our references to the nodes that // we're using. We *are* supposed to do that even for global nodes like the Mixer. roster->Disconnect(fConnection->producer.node, fConnection->source, fConnection->consumer.node, fConnection->destination); - + roster->ReleaseNode(fConnection->producer); roster->ReleaseNode(fConnection->consumer); } - + delete[] fSounds; delete fConnection; } @@ -154,20 +161,20 @@ const void * data, int64 frames) { - if (frames <= 0 || !sound) + if (frames <= 0 || !sound) return B_BAD_VALUE; - - status_t err = B_MEDIA_TOO_MANY_BUFFERS; + + status_t err = B_MEDIA_TOO_MANY_BUFFERS; int32 position = AllocateSound(); - + if (position >= 0) { fSounds[position] = new SimpleSoundBuffer(format, data, frames); err = fSounds[position]->Connect(&fConnection->producer); - } + } - if (err == B_OK) + if (err == B_OK) *sound = gs_id(position + 1); - return err; + return err; } @@ -176,20 +183,20 @@ const void * object, const gs_audio_format * format) { - if (!object || !sound) + if (!object || !sound) return B_BAD_VALUE; - - status_t err = B_MEDIA_TOO_MANY_BUFFERS; + + status_t err = B_MEDIA_TOO_MANY_BUFFERS; int32 position = AllocateSound(); - + if (position >= 0) { fSounds[position] = new StreamingSoundBuffer(format, object); err = fSounds[position]->Connect(&fConnection->producer); - } + } - if (err == B_OK) + if (err == B_OK) *sound = gs_id(position+1); - return err; + return err; } @@ -203,13 +210,13 @@ // We must stop playback befor destroying the sound or else // we may recieve fatel errors. fSounds[sound - 1]->StopPlaying(); - + delete fSounds[sound - 1]; fSounds[sound - 1] = NULL; - } + } } - + status_t BGameSoundDevice::Buffer(gs_id sound, gs_audio_format* format, void *& data) { @@ -222,8 +229,8 @@ memcpy(data, fSounds[sound-1]->Data(), format->buffer_size); } else data = NULL; - - return B_OK; + + return B_OK; } @@ -232,12 +239,12 @@ { if (sound <= 0) return B_BAD_VALUE; - + if (!fSounds[sound - 1]->IsPlaying()) { // tell the producer to start playing the sound return fSounds[sound - 1]->StartPlaying(); } - + fSounds[sound - 1]->Reset(); return EALREADY; } @@ -248,13 +255,13 @@ { if (sound <= 0) return B_BAD_VALUE; - + if (fSounds[sound - 1]->IsPlaying()) { // Tell the producer to stop play this sound - fSounds[sound - 1]->Reset(); + fSounds[sound - 1]->Reset(); return fSounds[sound - 1]->StopPlaying(); } - + return EALREADY; } @@ -265,7 +272,7 @@ if (sound <= 0) return false; return fSounds[sound - 1]->IsPlaying(); -} +} status_t @@ -273,76 +280,76 @@ gs_attribute * attributes, size_t attributeCount) { - if (!fSounds[sound - 1]) + if (!fSounds[sound - 1]) return B_ERROR; - - return fSounds[sound - 1]->GetAttributes(attributes, attributeCount); + + return fSounds[sound - 1]->GetAttributes(attributes, attributeCount); } - + status_t BGameSoundDevice::SetAttributes(gs_id sound, gs_attribute * attributes, size_t attributeCount) { - if (!fSounds[sound - 1]) + if (!fSounds[sound - 1]) return B_ERROR; - + return fSounds[sound - 1]->SetAttributes(attributes, attributeCount); -} +} status_t BGameSoundDevice::Connect() { BMediaRoster* roster = BMediaRoster::Roster(); - + // create your own audio mixer // TODO: Don't do this!!! See bug #575 dormant_node_info mixer_dormant_info; int32 mixer_count = 1; // for now, we only care about the first we find. status_t err = roster->GetDormantNodes(&mixer_dormant_info, &mixer_count, 0, 0, 0, B_SYSTEM_MIXER, 0); - if (err != B_OK) + if (err != B_OK) return err; - + //fMixer = new media_node; err = roster->InstantiateDormantNode(mixer_dormant_info, &fConnection->producer); - if (err != B_OK) + if (err != B_OK) return err; - + // retieve the system's audio mixer err = roster->GetAudioMixer(&fConnection->consumer); - if (err != B_OK) + if (err != B_OK) return err; - + int32 count = 1; media_input mixerInput; err = roster->GetFreeInputsFor(fConnection->consumer, &mixerInput, 1, &count); - if (err != B_OK) + if (err != B_OK) return err; - + count = 1; media_output mixerOutput; err = roster->GetFreeOutputsFor(fConnection->producer, &mixerOutput, 1, &count); - if (err != B_OK) + if (err != B_OK) return err; - + media_format format(mixerOutput.format); err = roster->Connect(mixerOutput.source, mixerInput.destination, &format, &mixerOutput, &mixerInput); - if (err != B_OK) - return err; - + if (err != B_OK) + return err; + // set the producer's time source to be the "default" time source, which // the Mixer uses too. roster->GetTimeSource(&fConnection->timeSource); roster->SetTimeSourceFor(fConnection->producer.node, fConnection->timeSource.node); - - // Start our mixer's time source if need be. Chances are, it won't need to be, + + // Start our mixer's time source if need be. Chances are, it won't need to be, // but if we forget to do this, our mixer might not do anything at all. BTimeSource* mixerTimeSource = roster->MakeTimeSourceFor(fConnection->producer); - if (!mixerTimeSource) + if (!mixerTimeSource) return B_ERROR; if (!mixerTimeSource->IsRunning()) { @@ -357,9 +364,9 @@ bigtime_t tpNow = mixerTimeSource->Now(); err = roster->StartNode(fConnection->producer, tpNow + 10000); mixerTimeSource->Release(); - if (err != B_OK) + if (err != B_OK) return err; - + // the inputs and outputs might have been reassigned during the // nodes' negotiation of the Connect(). That's why we wait until // after Connect() finishes to save their contents. @@ -382,20 +389,20 @@ for (int32 i = 0; i < fSoundCount; i++) if (!fSounds[i]) return i; - + // we need to allocate new space for the sound GameSoundBuffer ** sounds = new GameSoundBuffer*[fSoundCount + kGrowth]; for (int32 i = 0; i < fSoundCount; i++) sounds[i] = fSounds[i]; - + for (int32 i = fSoundCount; i < fSoundCount + kGrowth; i++) sounds[i] = NULL; - - // replace the old list + + // replace the old list delete [] fSounds; fSounds = sounds; fSoundCount += kGrowth; - + return fSoundCount - kGrowth; } From rudolfc at mail.berlios.de Mon Jun 15 20:29:47 2009 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Mon, 15 Jun 2009 20:29:47 +0200 Subject: [Haiku-commits] r31061 - haiku/trunk/src/add-ons/accelerants/nvidia/engine Message-ID: <200906151829.n5FITlbG017888@sheep.berlios.de> Author: rudolfc Date: 2009-06-15 20:29:46 +0200 (Mon, 15 Jun 2009) New Revision: 31061 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31061&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac.c haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c Log: added pixelPLLs programming settings dump to driver logfile before overwriting it with new calculated settings. Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac.c 2009-06-15 15:15:32 UTC (rev 31060) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac.c 2009-06-15 18:29:46 UTC (rev 31061) @@ -1,12 +1,13 @@ /* program the DAC */ /* Author: - Rudolf Cornelissen 12/2003-10/2004 + Rudolf Cornelissen 12/2003-6/2009 */ #define MODULE_BIT 0x00010000 #include "nv_std.h" +static void nv_dac_dump_pix_pll(void); static status_t nv4_nv10_nv20_dac_pix_pll_find( display_mode target,float * calc_pclk,uint8 * m_result,uint8 * n_result,uint8 * p_result, uint8 test); @@ -148,7 +149,6 @@ status_t nv_dac_set_pix_pll(display_mode target) { uint8 m=0,n=0,p=0; -// uint time = 0; float pix_setting, req_pclk; status_t result; @@ -160,7 +160,11 @@ //fixme: when VESA DDC EDID stuff is implemented, this option can be deleted... if (si->ps.tmds1_active && !si->settings.pgm_panel) { - LOG(4,("DAC: Not programming DFP refresh (specified in nv.settings)\n")); + LOG(4,("DAC: Not programming DFP refresh (specified in nvidia.settings)\n")); + + /* dump current setup for learning purposes */ + nv_dac_dump_pix_pll(); + return B_OK; } @@ -185,9 +189,8 @@ return result; } - /*reprogram (disable,select,wait for stability,enable)*/ -// DXIW(PIXCLKCTRL,(DXIR(PIXCLKCTRL)&0x0F)|0x04); /*disable the PIXPLL*/ -// DXIW(PIXCLKCTRL,(DXIR(PIXCLKCTRL)&0x0C)|0x01); /*select the PIXPLL*/ + /* dump old setup for learning purposes */ + nv_dac_dump_pix_pll(); /* program new frequency */ DACW(PIXPLLC, ((p << 16) | (n << 8) | m)); @@ -195,29 +198,58 @@ /* program 2nd set N and M scalers if they exist (b31=1 enables them) */ if (si->ps.ext_pll) DACW(PIXPLLC2, 0x80000401); - /* Wait for the PIXPLL frequency to lock until timeout occurs */ -//fixme: do NV cards have a LOCK indication bit?? -/* while((!(DXIR(PIXPLLSTAT)&0x40)) & (time <= 2000)) - { - time++; - snooze(1); - } - - if (time > 2000) - LOG(2,("DAC: PIX PLL frequency not locked!\n")); - else - LOG(2,("DAC: PIX PLL frequency locked\n")); - DXIW(PIXCLKCTRL,DXIR(PIXCLKCTRL)&0x0B); //enable the PIXPLL -*/ - -//for now: - /* Give the PIXPLL frequency some time to lock... */ + /* Give the PIXPLL frequency some time to lock... (there's no indication bit available) */ snooze(1000); LOG(2,("DAC: PIX PLL frequency should be locked now...\n")); return B_OK; } +static void nv_dac_dump_pix_pll(void) +{ + uint32 dividers1, dividers2; + uint8 m1, n1, p1; + uint8 m2 = 1, n2 = 1; + float f_vco, f_phase, f_pixel; + + LOG(2,("DAC: dumping current pixelPLL settings:\n")); + + dividers1 = DACR(PIXPLLC); + m1 = (dividers1 & 0x000000ff); + n1 = (dividers1 & 0x0000ff00) >> 8; + p1 = 0x01 << ((dividers1 & 0x00070000) >> 16); + LOG(2,("DAC: divider1 settings ($%08x): M1=%d, N1=%d, P1=%d\n", dividers1, m1, n1, p1)); + + if (si->ps.ext_pll) { + dividers2 = DACR(PIXPLLC2); + if (dividers2 & 0x8000000) { + /* the extended PLL part is enabled */ + m2 = (dividers2 & 0x000000ff); + n2 = (dividers2 & 0x0000ff00) >> 8; + LOG(2,("DAC: divider2 is enabled, settings ($%08x): M2=%d, N2=%d\n", dividers2, m2, n2)); + } else { + LOG(2,("DAC: divider2 is disabled ($%08x)\n", dividers2)); + } + } + + /* log the frequencies found */ + f_phase = si->ps.f_ref / (m1 * m2); + f_vco = (f_phase * n1 * n2); + f_pixel = f_vco / p1; + + LOG(2,("DAC: phase discriminator frequency is %fMhz\n", f_phase)); + LOG(2,("DAC: VCO frequency is %fMhz\n", f_vco)); + LOG(2,("DAC: pixelclock is %fMhz\n", f_pixel)); + LOG(2,("DAC: end of dump.\n")); + + /* apparantly if a VESA modecall during boot fails we need to explicitly select the PLL's + * again (was already done during driver init) if we readout the current PLL setting.. */ + if (si->ps.secondary_head) + DACW(PLLSEL, 0x30000f00); + else + DACW(PLLSEL, 0x10000700); +} + /* find nearest valid pix pll */ status_t nv_dac_pix_pll_find (display_mode target,float * calc_pclk,uint8 * m_result,uint8 * n_result,uint8 * p_result, uint8 test) @@ -238,24 +270,6 @@ float f_vco, max_pclk; float req_pclk = target.timing.pixel_clock/1000.0; - /* determine the max. reference-frequency postscaler setting for the - * current card (see G100, G200 and G400 specs). */ -/* switch(si->ps.card_type) - { - case G100: - LOG(4,("DAC: G100 restrictions apply\n")); - m_max = 7; - break; - case G200: - LOG(4,("DAC: G200 restrictions apply\n")); - m_max = 7; - break; - default: - LOG(4,("DAC: G400/G400MAX restrictions apply\n")); - m_max = 32; - break; - } -*/ LOG(4,("DAC: NV4/NV10/NV20 restrictions apply\n")); /* determine the max. pixelclock for the current videomode */ Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c 2009-06-15 15:15:32 UTC (rev 31060) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c 2009-06-15 18:29:46 UTC (rev 31061) @@ -1,12 +1,13 @@ /* program the secondary DAC */ /* Author: - Rudolf Cornelissen 12/2003-9/2004 + Rudolf Cornelissen 12/2003-6/2009 */ #define MODULE_BIT 0x00001000 #include "nv_std.h" +static void nv_dac2_dump_pix_pll(void); static status_t nv10_nv20_dac2_pix_pll_find( display_mode target,float * calc_pclk,uint8 * m_result,uint8 * n_result,uint8 * p_result, uint8 test); @@ -145,7 +146,6 @@ status_t nv_dac2_set_pix_pll(display_mode target) { uint8 m=0,n=0,p=0; -// uint time = 0; float pix_setting, req_pclk; status_t result; @@ -157,7 +157,11 @@ //fixme: when VESA DDC EDID stuff is implemented, this option can be deleted... if (si->ps.tmds2_active && !si->settings.pgm_panel) { - LOG(4,("DAC2: Not programming DFP refresh (specified in nv.settings)\n")); + LOG(4,("DAC2: Not programming DFP refresh (specified in nvidia.settings)\n")); + + /* dump current setup for learning purposes */ + nv_dac2_dump_pix_pll(); + return B_OK; } @@ -182,9 +186,8 @@ return result; } - /*reprogram (disable,select,wait for stability,enable)*/ -// DXIW(PIXCLKCTRL,(DXIR(PIXCLKCTRL)&0x0F)|0x04); /*disable the PIXPLL*/ -// DXIW(PIXCLKCTRL,(DXIR(PIXCLKCTRL)&0x0C)|0x01); /*select the PIXPLL*/ + /* dump old setup for learning purposes */ + nv_dac2_dump_pix_pll(); /* program new frequency */ DAC2W(PIXPLLC, ((p << 16) | (n << 8) | m)); @@ -192,29 +195,58 @@ /* program 2nd set N and M scalers if they exist (b31=1 enables them) */ if (si->ps.ext_pll) DAC2W(PIXPLLC2, 0x80000401); - /* Wait for the PIXPLL frequency to lock until timeout occurs */ -//fixme: do NV cards have a LOCK indication bit?? -/* while((!(DXIR(PIXPLLSTAT)&0x40)) & (time <= 2000)) - { - time++; - snooze(1); - } - - if (time > 2000) - LOG(2,("DAC: PIX PLL frequency not locked!\n")); - else - LOG(2,("DAC: PIX PLL frequency locked\n")); - DXIW(PIXCLKCTRL,DXIR(PIXCLKCTRL)&0x0B); //enable the PIXPLL -*/ - -//for now: - /* Give the PIXPLL frequency some time to lock... */ + /* Give the PIXPLL frequency some time to lock... (there's no indication bit available) */ snooze(1000); LOG(2,("DAC2: PIX PLL frequency should be locked now...\n")); return B_OK; } +static void nv_dac2_dump_pix_pll(void) +{ + uint32 dividers1, dividers2; + uint8 m1, n1, p1; + uint8 m2 = 1, n2 = 1; + float f_vco, f_phase, f_pixel; + + LOG(2,("DAC2: dumping current pixelPLL settings:\n")); + + dividers1 = DAC2R(PIXPLLC); + m1 = (dividers1 & 0x000000ff); + n1 = (dividers1 & 0x0000ff00) >> 8; + p1 = 0x01 << ((dividers1 & 0x00070000) >> 16); + LOG(2,("DAC2: divider1 settings ($%08x): M1=%d, N1=%d, P1=%d\n", dividers1, m1, n1, p1)); + + if (si->ps.ext_pll) { + dividers2 = DAC2R(PIXPLLC2); + if (dividers2 & 0x8000000) { + /* the extended PLL part is enabled */ + m2 = (dividers2 & 0x000000ff); + n2 = (dividers2 & 0x0000ff00) >> 8; + LOG(2,("DAC2: divider2 is enabled, settings ($%08x): M2=%d, N2=%d\n", dividers2, m2, n2)); + } else { + LOG(2,("DAC2: divider2 is disabled ($%08x)\n", dividers2)); + } + } + + /* log the frequencies found */ + f_phase = si->ps.f_ref / (m1 * m2); + f_vco = (f_phase * n1 * n2); + f_pixel = f_vco / p1; + + LOG(2,("DAC2: phase discriminator frequency is %fMhz\n", f_phase)); + LOG(2,("DAC2: VCO frequency is %fMhz\n", f_vco)); + LOG(2,("DAC2: pixelclock is %fMhz\n", f_pixel)); + LOG(2,("DAC2: end of dump.\n")); + + /* apparantly if a VESA modecall during boot fails we need to explicitly select the PLL's + * again (was already done during driver init) if we readout the current PLL setting.. */ + if (si->ps.secondary_head) + DACW(PLLSEL, 0x30000f00); + else + DACW(PLLSEL, 0x10000700); +} + /* find nearest valid pix pll */ status_t nv_dac2_pix_pll_find (display_mode target,float * calc_pclk,uint8 * m_result,uint8 * n_result,uint8 * p_result, uint8 test) @@ -235,24 +267,6 @@ float f_vco, max_pclk; float req_pclk = target.timing.pixel_clock/1000.0; - /* determine the max. reference-frequency postscaler setting for the - * current card (see G100, G200 and G400 specs). */ -/* switch(si->ps.card_type) - { - case G100: - LOG(4,("DAC: G100 restrictions apply\n")); - m_max = 7; - break; - case G200: - LOG(4,("DAC: G200 restrictions apply\n")); - m_max = 7; - break; - default: - LOG(4,("DAC: G400/G400MAX restrictions apply\n")); - m_max = 32; - break; - } -*/ LOG(4,("DAC2: NV10/NV20 restrictions apply\n")); /* determine the max. pixelclock for the current videomode */ From rudolfc at mail.berlios.de Mon Jun 15 20:35:40 2009 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Mon, 15 Jun 2009 20:35:40 +0200 Subject: [Haiku-commits] r31062 - haiku/trunk/src/add-ons/accelerants/nvidia/engine Message-ID: <200906151835.n5FIZeug018899@sheep.berlios.de> Author: rudolfc Date: 2009-06-15 20:35:40 +0200 (Mon, 15 Jun 2009) New Revision: 31062 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31062&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c Log: obviously a card is always dualhead when it has two dacs. Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c 2009-06-15 18:29:46 UTC (rev 31061) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c 2009-06-15 18:35:40 UTC (rev 31062) @@ -241,10 +241,7 @@ /* apparantly if a VESA modecall during boot fails we need to explicitly select the PLL's * again (was already done during driver init) if we readout the current PLL setting.. */ - if (si->ps.secondary_head) - DACW(PLLSEL, 0x30000f00); - else - DACW(PLLSEL, 0x10000700); + DACW(PLLSEL, 0x30000f00); } /* find nearest valid pix pll */ From bonefish at mail.berlios.de Mon Jun 15 23:49:45 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 15 Jun 2009 23:49:45 +0200 Subject: [Haiku-commits] r31063 - haiku/trunk/src/apps/debugger Message-ID: <200906152149.n5FLnji5004395@sheep.berlios.de> Author: bonefish Date: 2009-06-15 23:49:42 +0200 (Mon, 15 Jun 2009) New Revision: 31063 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31063&view=rev Removed: haiku/trunk/src/apps/debugger/HaikuTypes.h Log: Obsolete file. Deleted: haiku/trunk/src/apps/debugger/HaikuTypes.h From bonefish at mail.berlios.de Mon Jun 15 23:50:16 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 15 Jun 2009 23:50:16 +0200 Subject: [Haiku-commits] r31064 - in haiku/trunk/src/apps/debugger: . dwarf Message-ID: <200906152150.n5FLoGtA004496@sheep.berlios.de> Author: bonefish Date: 2009-06-15 23:50:04 +0200 (Mon, 15 Jun 2009) New Revision: 31064 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31064&view=rev Added: haiku/trunk/src/apps/debugger/dwarf/ haiku/trunk/src/apps/debugger/dwarf/AttributeValue.cpp haiku/trunk/src/apps/debugger/dwarf/AttributeValue.h haiku/trunk/src/apps/debugger/dwarf/DataReader.h haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.h haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntry.cpp haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntry.h haiku/trunk/src/apps/debugger/dwarf/DwarfManager.cpp haiku/trunk/src/apps/debugger/dwarf/DwarfManager.h haiku/trunk/src/apps/debugger/dwarf/SourceLanguageInfo.cpp haiku/trunk/src/apps/debugger/dwarf/SourceLanguageInfo.h haiku/trunk/src/apps/debugger/dwarf/attribute_classes.cpp haiku/trunk/src/apps/debugger/dwarf/attribute_classes.h haiku/trunk/src/apps/debugger/dwarf/dwarf.h haiku/trunk/src/apps/debugger/dwarf/tag_names.cpp haiku/trunk/src/apps/debugger/dwarf/tag_names.h haiku/trunk/src/apps/debugger/dwarf/types.h Removed: haiku/trunk/src/apps/debugger/AttributeValue.cpp haiku/trunk/src/apps/debugger/AttributeValue.h haiku/trunk/src/apps/debugger/DataReader.h haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp haiku/trunk/src/apps/debugger/DebugInfoEntries.h haiku/trunk/src/apps/debugger/DebugInfoEntry.cpp haiku/trunk/src/apps/debugger/DebugInfoEntry.h haiku/trunk/src/apps/debugger/DwarfManager.cpp haiku/trunk/src/apps/debugger/DwarfManager.h haiku/trunk/src/apps/debugger/SourceLanguageInfo.cpp haiku/trunk/src/apps/debugger/SourceLanguageInfo.h haiku/trunk/src/apps/debugger/attribute_classes.cpp haiku/trunk/src/apps/debugger/attribute_classes.h haiku/trunk/src/apps/debugger/dwarf.h haiku/trunk/src/apps/debugger/tag_names.cpp haiku/trunk/src/apps/debugger/tag_names.h haiku/trunk/src/apps/debugger/types.h Modified: haiku/trunk/src/apps/debugger/Jamfile Log: Moved dwarf related code into dwarf/ subdirectory. Deleted: haiku/trunk/src/apps/debugger/AttributeValue.cpp Deleted: haiku/trunk/src/apps/debugger/AttributeValue.h Deleted: haiku/trunk/src/apps/debugger/DataReader.h Deleted: haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp Deleted: haiku/trunk/src/apps/debugger/DebugInfoEntries.h Deleted: haiku/trunk/src/apps/debugger/DebugInfoEntry.cpp Deleted: haiku/trunk/src/apps/debugger/DebugInfoEntry.h Deleted: haiku/trunk/src/apps/debugger/DwarfManager.cpp Deleted: haiku/trunk/src/apps/debugger/DwarfManager.h Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 21:49:42 UTC (rev 31063) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 21:50:04 UTC (rev 31064) @@ -7,15 +7,17 @@ UsePrivateSystemHeaders ; Application Debugger : - attribute_classes.cpp - AttributeValue.cpp debugger.cpp - DebugInfoEntries.cpp - DebugInfoEntry.cpp - DwarfManager.cpp ElfFile.cpp - SourceLanguageInfo.cpp - tag_names.cpp +# DWARF +# attribute_classes.cpp +# AttributeValue.cpp +# DebugInfoEntries.cpp +# DebugInfoEntry.cpp +# DwarfManager.cpp +# SourceLanguageInfo.cpp +3 tag_names.cpp + : $(TARGET_LIBSUPC++) ; Deleted: haiku/trunk/src/apps/debugger/SourceLanguageInfo.cpp Deleted: haiku/trunk/src/apps/debugger/SourceLanguageInfo.h Deleted: haiku/trunk/src/apps/debugger/attribute_classes.cpp Deleted: haiku/trunk/src/apps/debugger/attribute_classes.h Copied: haiku/trunk/src/apps/debugger/dwarf/AttributeValue.cpp (from rev 31047, haiku/trunk/src/apps/debugger/AttributeValue.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/AttributeValue.h (from rev 31056, haiku/trunk/src/apps/debugger/AttributeValue.h) Copied: haiku/trunk/src/apps/debugger/dwarf/DataReader.h (from rev 31047, haiku/trunk/src/apps/debugger/DataReader.h) Copied: haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.cpp (from rev 31056, haiku/trunk/src/apps/debugger/DebugInfoEntries.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.h (from rev 31056, haiku/trunk/src/apps/debugger/DebugInfoEntries.h) Copied: haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntry.cpp (from rev 31056, haiku/trunk/src/apps/debugger/DebugInfoEntry.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntry.h (from rev 31056, haiku/trunk/src/apps/debugger/DebugInfoEntry.h) Copied: haiku/trunk/src/apps/debugger/dwarf/DwarfManager.cpp (from rev 31047, haiku/trunk/src/apps/debugger/DwarfManager.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/DwarfManager.h (from rev 31047, haiku/trunk/src/apps/debugger/DwarfManager.h) Copied: haiku/trunk/src/apps/debugger/dwarf/SourceLanguageInfo.cpp (from rev 31047, haiku/trunk/src/apps/debugger/SourceLanguageInfo.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/SourceLanguageInfo.h (from rev 31047, haiku/trunk/src/apps/debugger/SourceLanguageInfo.h) Copied: haiku/trunk/src/apps/debugger/dwarf/attribute_classes.cpp (from rev 31047, haiku/trunk/src/apps/debugger/attribute_classes.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/attribute_classes.h (from rev 31047, haiku/trunk/src/apps/debugger/attribute_classes.h) Copied: haiku/trunk/src/apps/debugger/dwarf/dwarf.h (from rev 31047, haiku/trunk/src/apps/debugger/dwarf.h) Copied: haiku/trunk/src/apps/debugger/dwarf/tag_names.cpp (from rev 31047, haiku/trunk/src/apps/debugger/tag_names.cpp) Copied: haiku/trunk/src/apps/debugger/dwarf/tag_names.h (from rev 31047, haiku/trunk/src/apps/debugger/tag_names.h) Copied: haiku/trunk/src/apps/debugger/dwarf/types.h (from rev 31047, haiku/trunk/src/apps/debugger/types.h) Deleted: haiku/trunk/src/apps/debugger/dwarf.h Deleted: haiku/trunk/src/apps/debugger/tag_names.cpp Deleted: haiku/trunk/src/apps/debugger/tag_names.h Deleted: haiku/trunk/src/apps/debugger/types.h From bonefish at mail.berlios.de Mon Jun 15 23:50:55 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 15 Jun 2009 23:50:55 +0200 Subject: [Haiku-commits] r31065 - haiku/trunk/src/apps/debugger Message-ID: <200906152150.n5FLot6J004549@sheep.berlios.de> Author: bonefish Date: 2009-06-15 23:50:50 +0200 (Mon, 15 Jun 2009) New Revision: 31065 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31065&view=rev Modified: haiku/trunk/src/apps/debugger/Jamfile Log: Typo. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 21:50:04 UTC (rev 31064) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 21:50:50 UTC (rev 31065) @@ -17,7 +17,7 @@ # DebugInfoEntry.cpp # DwarfManager.cpp # SourceLanguageInfo.cpp -3 tag_names.cpp +# tag_names.cpp : $(TARGET_LIBSUPC++) ; From phoudoin at mail.berlios.de Tue Jun 16 01:11:24 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Tue, 16 Jun 2009 01:11:24 +0200 Subject: [Haiku-commits] r31066 - in haiku/trunk/src/apps/debugger: . gui gui/running_teams_window Message-ID: <200906152311.n5FNBOKA011629@sheep.berlios.de> Author: phoudoin Date: 2009-06-16 01:11:19 +0200 (Tue, 16 Jun 2009) New Revision: 31066 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31066&view=rev Added: haiku/trunk/src/apps/debugger/gui/ haiku/trunk/src/apps/debugger/gui/running_teams_window/ haiku/trunk/src/apps/debugger/gui/running_teams_window/Jamfile haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.cpp haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.h haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.h haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamsListView.cpp haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamsListView.h haiku/trunk/src/apps/debugger/gui/running_teams_window/hdb.cpp haiku/trunk/src/apps/debugger/gui/running_teams_window/hdb.h Modified: haiku/trunk/src/apps/debugger/Jamfile Log: A tiny contribution to an Haiku Debugger rebirth: a Running Teams window designed similar to old' bdb one. The skeleton 'hdb' application does nothing usefull beside, as I was trying to get fluent in team_debugger messages. That's pretty much all what I came with during a pathetic attempt to secure some free time to work on a (indeed) most wanted native graphical debugger for Haiku. Building libdwarf was pending when I've realized I wont have time ever. Ingo, I hope you don't mind. Fee free to do whatever you want with it, remove included. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 23:11:19 UTC (rev 31066) @@ -21,3 +21,5 @@ : $(TARGET_LIBSUPC++) ; + +HaikuSubInclude gui running_teams_window ; Added: haiku/trunk/src/apps/debugger/gui/running_teams_window/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/gui/running_teams_window/Jamfile 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/gui/running_teams_window/Jamfile 2009-06-15 23:11:19 UTC (rev 31066) @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src apps debugger gui running_teams_window ; + +CCFLAGS += -Werror ; +C++FLAGS += -Werror ; + +UsePrivateHeaders debug ; +UsePrivateSystemHeaders ; + +Application hdb : + hdb.cpp + RunningTeamsWindow.cpp + TeamsListView.cpp + TeamWindow.cpp + + : be tracker translation libdebug.so +; Added: haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.cpp 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.cpp 2009-06-15 23:11:19 UTC (rev 31066) @@ -0,0 +1,138 @@ +/* + * Copyright 2009, Philippe Houdoin, phoudoin at haiku-os.org. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "hdb.h" + +#include "RunningTeamsWindow.h" +#include "TeamsListView.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +RunningTeamsWindow::RunningTeamsWindow() + : BWindow(BRect(100, 100, 500, 250), "Running Teams", B_DOCUMENT_WINDOW, + B_ASYNCHRONOUS_CONTROLS) +{ + BMessage settings; + _LoadSettings(settings); + + BRect frame; + if (settings.FindRect("running teams window frame", &frame) == B_OK) { + MoveTo(frame.LeftTop()); + ResizeTo(frame.Width(), frame.Height()); + } + + // Add a teams list view + BRect rect = Bounds(); + rect.right -= B_V_SCROLL_BAR_WIDTH; + fTeamsListView = new TeamsListView(rect, "RunningTeamsList", B_FOLLOW_ALL); + + // Set the message sent on team list item invocation + fTeamsListView->SetInvocationMessage(new BMessage(kMsgDebugThisTeam)); + + BScrollView * scroller = new BScrollView("RunningTeamsListScroller", + fTeamsListView, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, + false, true); // Vertical scrollbar only + + AddChild(scroller); +} + + +RunningTeamsWindow::~RunningTeamsWindow() +{ +} + + +void +RunningTeamsWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kMsgDebugThisTeam: + { + TeamListItem* item = dynamic_cast(fTeamsListView->ItemAt( + fTeamsListView->CurrentSelection())); + + if (item != NULL) { + BMessage message(kMsgOpenTeamWindow); + message.AddInt32("team_id", item->TeamID()); + be_app_messenger.SendMessage(&message); + } + break; + } + + default: + BWindow::MessageReceived(message); + break; + } +} + + +bool +RunningTeamsWindow::QuitRequested() +{ + _SaveSettings(); + + be_app_messenger.SendMessage(kMsgRunningTeamsWindowClosed); + return true; +} + + +// #pragma mark -- + + +status_t +RunningTeamsWindow::_OpenSettings(BFile& file, uint32 mode) +{ + BPath path; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + return B_ERROR; + + path.Append("Debugger settings"); + + return file.SetTo(path.Path(), mode); +} + + +status_t +RunningTeamsWindow::_LoadSettings(BMessage& settings) +{ + BFile file; + status_t status = _OpenSettings(file, B_READ_ONLY); + if (status < B_OK) + return status; + + return settings.Unflatten(&file); +} + + +status_t +RunningTeamsWindow::_SaveSettings() +{ + BFile file; + status_t status = _OpenSettings(file, + B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); + + if (status < B_OK) + return status; + + BMessage settings('hdbg'); + status = settings.AddRect("running teams window frame", Frame()); + if (status != B_OK) + return status; + + if (status == B_OK) + status = settings.Flatten(&file); + + return status; +} Added: haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.h 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/gui/running_teams_window/RunningTeamsWindow.h 2009-06-15 23:11:19 UTC (rev 31066) @@ -0,0 +1,36 @@ +/* + * Copyright 2009, Philippe Houdoin, phoudoin at haiku-os.org. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef RUNNING_TEAMS_WINDOW_H +#define RUNNING_TEAMS_WINDOW_H + +#include + +class BListView; +class BFile; +class BMessage; + + +class RunningTeamsWindow : public BWindow { +public: + RunningTeamsWindow(); + virtual ~RunningTeamsWindow(); + + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); + +private: + + status_t _OpenSettings(BFile& file, uint32 mode); + status_t _LoadSettings(BMessage& settings); + status_t _SaveSettings(); + + BListView* fTeamsListView; + +}; + +static const uint32 kMsgDebugThisTeam = 'dbtm'; + +#endif // RUNNING_TEAMS_WINDOW_H Added: haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.cpp 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.cpp 2009-06-15 23:11:19 UTC (rev 31066) @@ -0,0 +1,373 @@ +/* + * Copyright 2008, Philippe Houdoin, phoudoin at haiku-os.org. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "hdb.h" +#include "TeamWindow.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +TeamWindow::TeamWindow(team_id team) + : BWindow(BRect(100, 100, 500, 250), "Running Teams", B_DOCUMENT_WINDOW, + B_ASYNCHRONOUS_CONTROLS), + fTeam(team), + fNubThread(-1), + fNubPort(-1), + fListenerThread(-1), + fListenerPort(-1) +{ + BMessage settings; + _LoadSettings(settings); + + BRect frame; + if (settings.FindRect("team window frame", &frame) == B_OK) { + MoveTo(frame.LeftTop()); + ResizeTo(frame.Width(), frame.Height()); + } + + team_info info; + get_team_info(team, &info); + + BString title; + title << "Team " << fTeam << ": " << info.args; + + SetTitle(title.String()); + + _InstallDebugger(); +} + + +TeamWindow::~TeamWindow() +{ + _RemoveDebugger(); +} + + +void +TeamWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + default: + BWindow::MessageReceived(message); + break; + } +} + + +bool +TeamWindow::QuitRequested() +{ +/* _SaveSettings(); + + BMessage update(kMsgSettingsChanged); + update.AddRect("window_frame", Frame()); + be_app_messenger.SendMessage(&update); +*/ + be_app_messenger.SendMessage(kMsgWindowClosed); + return true; +} + + +// #pragma mark -- + + +status_t +TeamWindow::_InstallDebugger() +{ + char name[32]; + status_t result; + + snprintf(name, sizeof(name), "team %ld nub listener", fTeam); + printf("Starting %s...\n", name); + + // create listener port + fListenerPort = create_port(10, name); + if (fListenerPort < 0) + return fListenerPort; + + // spawn the listener thread + fListenerThread = spawn_thread(_ListenerEntry, name, + B_NORMAL_PRIORITY, this); + if (fListenerThread < 0) + return fListenerThread; + + // register as this team debugger + printf("Installing team %ld debugger on port 0x%lx...\n", + fTeam, fListenerPort); + fNubPort = install_team_debugger(fTeam, fListenerPort); + if (fNubPort < 0) + return fNubPort; + + // init the debug context + result = init_debug_context(&fDebugContext, fTeam, fNubPort); + if (result != B_OK) { + fprintf(stderr, "Failed to init debug context for team %ld: %s\n", + fTeam, strerror(result)); + } + + // get team nub thread + team_info teamInfo; + result = get_team_info(fTeam, &teamInfo); + if (result != B_OK) { + fprintf(stderr, "Failed to get info for team %ld: %s\n", + fTeam, strerror(result)); + } + fNubThread = teamInfo.debugger_nub_thread; + + // set the team debug flags + debug_nub_set_team_flags message; + message.flags = + B_TEAM_DEBUG_SIGNALS | + // B_TEAM_DEBUG_PRE_SYSCALL | + // B_TEAM_DEBUG_POST_SYSCALL | + B_TEAM_DEBUG_TEAM_CREATION | + B_TEAM_DEBUG_THREADS | + B_TEAM_DEBUG_IMAGES | + // B_TEAM_DEBUG_STOP_NEW_THREADS | + 0; + + send_debug_message(&fDebugContext, + B_DEBUG_MESSAGE_SET_TEAM_FLAGS, &message, sizeof(message), NULL, 0); + + // resume the listener + resume_thread(fListenerThread); + + return B_OK; +} + + +status_t +TeamWindow::_RemoveDebugger() +{ + if (fListenerPort < 0) + // No debugger installed (yet?) + return B_OK; + + printf("Stopping team %ld nub listener...\n", fTeam); + + printf("Removing team %ld debugger installed on port 0x%lx...\n", + fTeam, fListenerPort); + status_t status = remove_team_debugger(fTeam); + + delete_port(fListenerPort); + if (fListenerThread >= 0 && find_thread(NULL) != fListenerThread) { + status_t result; + wait_for_thread(fListenerThread, &result); + fListenerThread = -1; + } + + destroy_debug_context(&fDebugContext); + fListenerPort = -1; + + return status; +} + + +status_t +TeamWindow::_ListenerEntry(void *data) +{ + return ((TeamWindow*) data)->_Listener(); +} + +// _Listener +status_t +TeamWindow::_Listener() +{ + printf("Team %ld nub listener on port 0x%lx started...\n", fTeam, fListenerPort); + + while (true) { + // receive the next debug message + debug_debugger_message code; + debug_debugger_message_data data; + ssize_t bytesRead; + + do { + bytesRead = read_port(fListenerPort, (int32 *) &code, &data, + sizeof(debug_debugger_message_data)); + } while (bytesRead == B_INTERRUPTED); + + if (bytesRead == B_BAD_PORT_ID) + break; + + if (bytesRead < 0) { + fprintf(stderr, "Team %ld nub listener: failed to read from " + "listener port: %s. Terminating!\n", + fTeam, strerror(bytesRead)); + break; + } + + _HandleDebugMessage(code, data); + } + + printf("Team %ld nub listener on port 0x%lx stopped.\n", fTeam, fListenerPort); + + return B_OK; +} + + +status_t +TeamWindow::_HandleDebugMessage(debug_debugger_message code, + debug_debugger_message_data & data) +{ + char dump[512]; + get_debug_message_string(code, dump, sizeof(dump)); + + printf("Team %ld nub listener: code %d from team %ld received: %s\n", + fTeam, code, data.origin.team, dump); + + switch (code) { + case B_DEBUGGER_MESSAGE_DEBUGGER_CALL: + { + // print the debugger message + char debuggerMessage[1024]; + ssize_t bytesRead = debug_read_string(&fDebugContext, + data.debugger_call.message, debuggerMessage, + sizeof(debuggerMessage)); + if (bytesRead > 0) { + printf(" Thread %ld called debugger(): %s\n", + data.origin.thread, debuggerMessage); + } else { + fprintf(stderr, " Thread %ld called debugger(), but failed" + "to get the debugger message.\n", + data.origin.thread); + } + // fall through... + } + case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: + case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: + case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: + case B_DEBUGGER_MESSAGE_SINGLE_STEP: { + // ATM, just continue + debug_nub_continue_thread message; + message.thread = data.origin.thread; + message.handle_event = B_THREAD_DEBUG_HANDLE_EVENT; + message.single_step = false; // run full speed + + status_t result= send_debug_message(&fDebugContext, + B_DEBUG_MESSAGE_CONTINUE_THREAD, &message, sizeof(message), + NULL, 0); + if (result != B_OK) { + fprintf(stderr, "Failed to resume thread %ld: %s\n", + message.thread, strerror(result)); + } + break; + } + case B_DEBUGGER_MESSAGE_PRE_SYSCALL: + printf(" pre_syscall.syscall = %ld\n", data.pre_syscall.syscall); + break; + + case B_DEBUGGER_MESSAGE_POST_SYSCALL: + printf(" post_syscall.syscall = %ld\n", data.post_syscall.syscall); + break; + + case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED: + printf(" signal_received.signal = %d\n", + data.signal_received.signal); + break; + + case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: + { + // print the exception message + char exception[1024]; + get_debug_exception_string(data.exception_occurred.exception, + exception, sizeof(exception)); + printf(" Thread %ld caused an exception: signal %d, %s\n", + data.origin.thread, data.exception_occurred.signal, exception); + break; + } + + case B_DEBUGGER_MESSAGE_TEAM_CREATED: + case B_DEBUGGER_MESSAGE_TEAM_DELETED: + break; + + case B_DEBUGGER_MESSAGE_THREAD_CREATED: + printf(" thread_created.new_thread = %ld\n", + data.thread_created.new_thread); + break; + case B_DEBUGGER_MESSAGE_THREAD_DELETED: + printf(" thread_deleted.origin.thread = %ld\n", + data.thread_deleted.origin.thread); + break; + + case B_DEBUGGER_MESSAGE_IMAGE_CREATED: + printf(" id = %ld, type = %d, name = %s\n", + data.image_created.info.id, + data.image_created.info.type, + data.image_created.info.name); + break; + + case B_DEBUGGER_MESSAGE_IMAGE_DELETED: + printf(" id = %ld, type = %d, name = %s\n", + data.image_deleted.info.id, + data.image_deleted.info.type, + data.image_deleted.info.name); + break; + + default: + // unknown message, ignore + break; + } + + return B_OK; + +} + +// ---- + +status_t +TeamWindow::_OpenSettings(BFile& file, uint32 mode) +{ + BPath path; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + return B_ERROR; + + path.Append("Debugger settings"); + + return file.SetTo(path.Path(), mode); +} + + +status_t +TeamWindow::_LoadSettings(BMessage& settings) +{ + BFile file; + status_t status = _OpenSettings(file, B_READ_ONLY); + if (status < B_OK) + return status; + + return settings.Unflatten(&file); +} + + +status_t +TeamWindow::_SaveSettings() +{ + BFile file; + status_t status = _OpenSettings(file, + B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); + + if (status < B_OK) + return status; + + BMessage settings('hdbg'); + status = settings.AddRect("team window frame", Frame()); + if (status != B_OK) + return status; + + if (status == B_OK) + status = settings.Flatten(&file); + + return status; +} Added: haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.h 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamWindow.h 2009-06-15 23:11:19 UTC (rev 31066) @@ -0,0 +1,51 @@ +/* + * Copyright 2008, Philippe Houdoin, phoudoin at haiku-os.org. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef TEAM_WINDOW_H +#define TEAM_WINDOW_H + +#include +#include + +class BFile; +class BMessage; + + +class TeamWindow : public BWindow { +public: + TeamWindow(team_id team); + virtual ~TeamWindow(); + + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); + + team_id Team() { return fTeam; }; + +private: + + status_t _InstallDebugger(); + status_t _RemoveDebugger(); + + static status_t _ListenerEntry(void *data); + status_t _Listener(); + status_t _HandleDebugMessage(debug_debugger_message message, + debug_debugger_message_data & data); + + status_t _OpenSettings(BFile& file, uint32 mode); + status_t _LoadSettings(BMessage& settings); + status_t _SaveSettings(); + + // ---- + + team_id fTeam; + thread_id fNubThread; + port_id fNubPort; + debug_context fDebugContext; + + thread_id fListenerThread; + port_id fListenerPort; +}; + +#endif // TEAM_WINDOW_H Added: haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamsListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamsListView.cpp 2009-06-15 21:50:50 UTC (rev 31065) +++ haiku/trunk/src/apps/debugger/gui/running_teams_window/TeamsListView.cpp 2009-06-15 23:11:19 UTC (rev 31066) @@ -0,0 +1,339 @@ +/* + * Copyright 2009, Philippe Houdoin, phoudoin at haiku-os.org. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "TeamsListView.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +TeamListItem::TeamListItem(team_info & info) + : BStringItem("", false), + fIcon(NULL) +{ + _SetTo(info); +} + + +TeamListItem::TeamListItem(team_id team) + : BStringItem("", false), + fIcon(NULL) +{ + team_info info; + get_team_info(team, &info); + _SetTo(info); +} + + +TeamListItem::~TeamListItem() +{ + delete fIcon; +} + +void +TeamListItem::DrawItem(BView *owner, BRect frame, bool complete) +{ + BRect rect = frame; + + if (fIcon) { + rgb_color highColor = owner->HighColor(); + rgb_color lowColor = owner->LowColor(); + + if (IsSelected() || complete) { + // Draw the background... + if (IsSelected()) + owner->SetLowColor(tint_color(lowColor, B_DARKEN_2_TINT)); + + owner->FillRect(rect, B_SOLID_LOW); + } + + BPoint point(rect.left + 2.0f, + rect.top + (rect.Height() - B_MINI_ICON) / 2.0f); + + // Draw icon + owner->SetDrawingMode(B_OP_ALPHA); + owner->DrawBitmap(fIcon, point); + owner->SetDrawingMode(B_OP_COPY); + + owner->MovePenTo(rect.left + B_MINI_ICON + 8.0f, frame.top + fBaselineOffset); + + if (!IsEnabled()) + owner->SetHighColor(tint_color(owner->HighColor(), B_LIGHTEN_2_TINT)); + else + owner->SetHighColor(0, 0, 0); + + owner->DrawString(Text()); + + owner->SetHighColor(highColor); + owner->SetLowColor(lowColor); + } else + // No icon, fallback on plain StringItem... + BStringItem::DrawItem(owner, rect, complete); +} + +void +TeamListItem::Update(BView *owner, const BFont *font) +{ + BStringItem::Update(owner, font); + + if (Height() < B_MINI_ICON + 4.0f) + SetHeight(B_MINI_ICON + 4.0f); + + font_height fontHeight; + font->GetHeight(&fontHeight); + + fBaselineOffset = fontHeight.ascent + + + (Height() - ceilf(fontHeight.ascent + fontHeight.descent)) / 2.0f; +} + + +/* static */ +int +TeamListItem::Compare(const void* a, const void* b) +{ + const BListItem *itemA = *static_cast(a); + const BListItem *itemB = *static_cast(b); + const TeamListItem *teamItemA = dynamic_cast(itemA); + const TeamListItem *teamItemB = dynamic_cast(itemB); + + if (teamItemA != NULL && teamItemB != NULL) { + return teamItemA->fTeamInfo.team - teamItemB->fTeamInfo.team; + } + + return 0; +} + + +status_t +TeamListItem::_SetTo(team_info & info) +{ + BPath systemPath; + team_info teamInfo = fTeamInfo = info; + + find_directory(B_BEOS_SYSTEM_DIRECTORY, &systemPath); + + // strip any trailing space(s)... + for (int len = strlen(teamInfo.args) - 1; + len >= 0 && teamInfo.args[len] == ' '; len--) { + teamInfo.args[len] = 0; + } + + app_info appInfo; + status_t status = be_roster->GetRunningAppInfo(teamInfo.team, &appInfo); + + if (status == B_OK || teamInfo.team == B_SYSTEM_TEAM) { + if (teamInfo.team == B_SYSTEM_TEAM) { + // Get icon and name from kernel + system_info systemInfo; + get_system_info(&systemInfo); + + BPath kernelPath(systemPath); + kernelPath.Append(systemInfo.kernel_name); + + get_ref_for_path(kernelPath.Path(), &appInfo.ref); + } + } else { + BEntry entry(teamInfo.args, true); + entry.GetRef(&appInfo.ref); + } + + SetText(teamInfo.args); + + fIcon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32); + + status = BNodeInfo::GetTrackerIcon(&appInfo.ref, fIcon, B_MINI_ICON); + if (status != B_OK) { + BMimeType genericAppType(B_APP_MIME_TYPE); + status = genericAppType.GetIcon(fIcon, B_MINI_ICON); + } + + if (status != B_OK) { + delete fIcon; + fIcon = NULL; + } + + return status; +} + +// #pragma mark - + + +TeamsListView::TeamsListView(BRect rect, const char* name, uint32 resizingMode) + : BListView(rect, name, B_SINGLE_SELECTION_LIST, resizingMode), + fUpdateRunner(NULL) +{ + team_info tmi; + get_team_info(B_CURRENT_TEAM, &tmi); + fThisTeam = tmi.team; +} + + +TeamsListView::~TeamsListView() +{ + delete fUpdateRunner; +} + + +void +TeamsListView::AttachedToWindow() +{ + BListView::AttachedToWindow(); + + _InitList(); + + be_roster->StartWatching(this, B_REQUEST_LAUNCHED | B_REQUEST_QUIT); + + BMessage msg(kMsgUpdateTeamsList); + fUpdateRunner = new BMessageRunner(this, &msg, 100000L); // 10Hz +} + + +void +TeamsListView::DetachedFromWindow() +{ + BListView::DetachedFromWindow(); + + be_roster->StopWatching(this); + + delete fUpdateRunner; + fUpdateRunner = NULL; + + // free all items, they will be retrieved again in AttachedToWindow() + for (int32 i = CountItems(); i-- > 0;) { + delete ItemAt(i); + } + MakeEmpty(); +} + + +void +TeamsListView::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kMsgUpdateTeamsList: + _UpdateList(); + break; + + case B_SOME_APP_LAUNCHED: + { + team_id team; + if (message->FindInt32("be:team", &team) != B_OK) + break; + + AddItem(new TeamListItem(team)); + SortItems(&TeamListItem::Compare); + break; + } + + case B_SOME_APP_QUIT: + { + team_id team; + if (message->FindInt32("be:team", &team) != B_OK) + break; + + TeamListItem *item = FindItem(team); + if (item != NULL) { + RemoveItem(item); + delete item; + } + break; + } + + default: + BListView::MessageReceived(message); + } +} + + +TeamListItem * +TeamsListView::FindItem(team_id teamId) +{ + for (int32 i = CountItems(); i-- > 0;) { + TeamListItem* item = dynamic_cast(ItemAt(i)); + if (item == NULL) + continue; + + if (item->TeamID() == teamId) + return item; + } + + return NULL; +} + + +void +TeamsListView::_InitList() +{ + int32 tmi_cookie = 0; + team_info tmi; + + while (get_next_team_info(&tmi_cookie, &tmi) == B_OK) { + TeamListItem * item = new TeamListItem(tmi); + + if (tmi.team == B_SYSTEM_TEAM || + tmi.team == fThisTeam) + // We don't support debugging kernel and... ourself! + // Don't show these two teams + continue; + + AddItem(item); + } + + // SortItems(&TeamListItem::Compare); +} + + +void +TeamsListView::_UpdateList() +{ + int32 tmi_cookie = 0; + team_info tmi; + TeamListItem *item; + int32 index = 0; + + // NOTA: assuming get_next_team_info() returns team ordered by team ID... + while (get_next_team_info(&tmi_cookie, &tmi) == B_OK) { + + if (tmi.team == B_SYSTEM_TEAM || + tmi.team == fThisTeam) + continue; // Ignore kernel and ourself teams + + item = (TeamListItem *) ItemAt(index); + + while (item && tmi.team > item->TeamID()) { + RemoveItem(item); + delete item; + item = (TeamListItem *) ItemAt(index); + } + + if (!item || tmi.team != item->TeamID()) { + // Team not found in known teams list: insert an new item + TeamListItem * item = new TeamListItem(tmi); + if (!item) + index++; // No item with team id bigger found: insert at list end + + AddItem(item, index); + } + index++; // Move list sync head. + } + + // Remove tail list items, if we don't walk list thru the end + while ((item = (TeamListItem *) ItemAt(index)) != NULL) { + RemoveItem(item); + delete item; + item = (TeamListItem *) ItemAt(++index); + } +} [... truncated: 348 lines follow ...] From phoudoin at mail.berlios.de Tue Jun 16 01:12:18 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Tue, 16 Jun 2009 01:12:18 +0200 Subject: [Haiku-commits] r31067 - haiku/trunk/src/apps/debugger Message-ID: <200906152312.n5FNCIBQ013084@sheep.berlios.de> Author: phoudoin Date: 2009-06-16 01:12:16 +0200 (Tue, 16 Jun 2009) New Revision: 31067 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31067&view=rev Modified: haiku/trunk/src/apps/debugger/Jamfile Log: Ooops, sorry. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 23:11:19 UTC (rev 31066) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 23:12:16 UTC (rev 31067) @@ -22,4 +22,3 @@ : $(TARGET_LIBSUPC++) ; -HaikuSubInclude gui running_teams_window ; From ingo_weinhold at gmx.de Tue Jun 16 02:16:33 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 16 Jun 2009 02:16:33 +0200 Subject: [Haiku-commits] r31066 - in haiku/trunk/src/apps/debugger: . gui gui/running_teams_window In-Reply-To: <200906152311.n5FNBOKA011629@sheep.berlios.de> References: <200906152311.n5FNBOKA011629@sheep.berlios.de> Message-ID: <20090616001633.315250@gmx.net> -------- Original-Nachricht -------- > Datum: Tue, 16 Jun 2009 01:11:24 +0200 > Von: phoudoin at mail.berlios.de > > Ingo, I hope you don't mind. Fee free to do whatever you want with it, > remove included. Thanks! Certainly doesn't harm to have it in the repository. I was considering not to have a team list window at all, though, but instead add a "Debug" button to the alert ProcessController shows when selecting a team. Seems the natural place to me. The only downside is, that then there's nothing really obvious to show when the debugger is invoked without arguments. So maybe in that case an initial dialog asking to select a running program or to start a new one could be shown. Opinions welcome... CU, Ingo From bonefish at mail.berlios.de Tue Jun 16 02:25:45 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 16 Jun 2009 02:25:45 +0200 Subject: [Haiku-commits] r31068 - haiku/trunk/src/apps/debugger Message-ID: <200906160025.n5G0PjZ3028454@sheep.berlios.de> Author: bonefish Date: 2009-06-16 02:25:36 +0200 (Tue, 16 Jun 2009) New Revision: 31068 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31068&view=rev Added: haiku/trunk/src/apps/debugger/Image.cpp haiku/trunk/src/apps/debugger/Image.h haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h haiku/trunk/src/apps/debugger/Thread.cpp haiku/trunk/src/apps/debugger/Thread.h Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/debugger.cpp Log: Initial skeletons of the model (Team, Thread, Image) and the controller (TeamDebugger) for debugging a team. Added: haiku/trunk/src/apps/debugger/Image.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Image.cpp 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Image.cpp 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,25 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Image.h" + + +Image::Image(const image_info& imageInfo) + : + fInfo(imageInfo) +{ +} + + +Image::~Image() +{ +} + + +status_t +Image::Init() +{ + return B_OK; +} Added: haiku/trunk/src/apps/debugger/Image.h =================================================================== --- haiku/trunk/src/apps/debugger/Image.h 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Image.h 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,32 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef IMAGE_H +#define IMAGE_H + +#include + +#include + + +class Image : public DoublyLinkedListLinkImpl { +public: + Image(const image_info& imageInfo); + ~Image(); + + status_t Init(); + + image_id ID() const { return fInfo.id; } + const char* Name() const { return fInfo.name; } + const image_info& Info() const { return fInfo; } + +private: + image_info fInfo; +}; + + +typedef DoublyLinkedList ImageList; + + +#endif // IMAGE_H Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-16 00:25:36 UTC (rev 31068) @@ -10,6 +10,11 @@ debugger.cpp ElfFile.cpp + Image.cpp + TeamDebugger.cpp + Team.cpp + Thread.cpp + # DWARF # attribute_classes.cpp # AttributeValue.cpp @@ -19,6 +24,7 @@ # SourceLanguageInfo.cpp # tag_names.cpp - : $(TARGET_LIBSUPC++) + : $(TARGET_LIBSUPC++) be ; +HaikuSubInclude gui running_teams_window ; Added: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,164 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Team.h" + +#include + + +Team::Team(team_id teamID) + : + fID(teamID) +{ +} + + +Team::~Team() +{ + while (Image* image = fImages.RemoveHead()) + delete image; + + while (Thread* thread = fThreads.RemoveHead()) + delete thread; +} + + +status_t +Team::Init() +{ + return BLocker::InitCheck(); +} + + +void +Team::SetName(const BString& name) +{ + fName = name; +} + + +void +Team::AddThread(Thread* thread) +{ + fThreads.Add(thread); +} + + +status_t +Team::AddThread(const thread_info& threadInfo, Thread** _thread) +{ + Thread* thread = new(std::nothrow) Thread(threadInfo.thread); + if (thread == NULL) + return B_NO_MEMORY; + + status_t error = thread->Init(); + if (error != B_OK) { + delete thread; + return error; + } + + thread->SetName(threadInfo.name); + AddThread(thread); + + if (_thread != NULL) + *_thread = thread; + + return B_OK; +} + + +void +Team::RemoveThread(Thread* thread) +{ + fThreads.Remove(thread); +} + + +bool +Team::RemoveThread(thread_id threadID) +{ + Thread* thread = ThreadByID(threadID); + if (thread == NULL) + return false; + + RemoveThread(thread); + delete thread; + return true; +} + + +Thread* +Team::ThreadByID(thread_id threadID) const +{ + for (ThreadList::ConstIterator it = fThreads.GetIterator(); + Thread* thread = it.Next();) { + if (thread->ID() == threadID) + return thread; + } + + return NULL; +} + + +void +Team::AddImage(Image* image) +{ + fImages.Add(image); +} + + +status_t +Team::AddImage(const image_info& imageInfo, Image** _image) +{ + Image* image = new(std::nothrow) Image(imageInfo); + if (image == NULL) + return B_NO_MEMORY; + + status_t error = image->Init(); + if (error != B_OK) { + delete image; + return error; + } + + AddImage(image); + + if (_image != NULL) + *_image = image; + + return B_OK; +} + + +void +Team::RemoveImage(Image* image) +{ + fImages.Remove(image); +} + + +bool +Team::RemoveImage(image_id imageID) +{ + Image* image = ImageByID(imageID); + if (image == NULL) + return false; + + RemoveImage(image); + delete image; + return true; +} + + +Image* +Team::ImageByID(image_id imageID) const +{ + for (ImageList::ConstIterator it = fImages.GetIterator(); + Image* image = it.Next();) { + if (image->ID() == imageID) + return image; + } + + return NULL; +} Added: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,47 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef TEAM_H +#define TEAM_H + +#include + +#include "Image.h" +#include "Thread.h" + + +class Team : public BLocker { +public: + Team(team_id teamID); + ~Team(); + + status_t Init(); + + team_id ID() const { return fID; } + + const char* Name() const { return fName.String(); } + void SetName(const BString& name); + + void AddThread(Thread* thread); + status_t AddThread(const thread_info& threadInfo, + Thread** _thread = NULL); + void RemoveThread(Thread* thread); + bool RemoveThread(thread_id threadID); + Thread* ThreadByID(thread_id threadID) const; + + void AddImage(Image* image); + status_t AddImage(const image_info& imageInfo, + Image** _image = NULL); + void RemoveImage(Image* image); + bool RemoveImage(image_id imageID); + Image* ImageByID(image_id imageID) const; + +private: + team_id fID; + BString fName; + ThreadList fThreads; + ImageList fImages; +}; + +#endif // TEAM_H Added: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,205 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "TeamDebugger.h" + +#include + +#include + +#include + +#include "Team.h" + + +TeamDebugger::TeamDebugger() + : + fLock("team debugger"), + fTeam(NULL), + fTeamID(-1), + fDebuggerPort(-1), + fNubPort(-1), + fDebugEventListener(-1), + fTerminating(false) +{ +} + + +TeamDebugger::~TeamDebugger() +{ + AutoLocker locker(fLock); + + fTerminating = true; + + if (fDebuggerPort >= 0) + delete_port(fDebuggerPort); + + locker.Unlock(); + + if (fDebugEventListener >= 0) + wait_for_thread(fDebugEventListener, NULL); + + delete fTeam; +} + + +status_t +TeamDebugger::Init(team_id teamID) +{ + fTeamID = teamID; + + status_t error = fLock.InitCheck(); + if (error != B_OK) + return error; + + // check whether the team exists at all + team_info teamInfo; + error = get_team_info(fTeamID, &teamInfo); + if (error != B_OK) + return error; + + // create a team object + fTeam = new(std::nothrow) Team(fTeamID); + if (fTeam == NULL) + return B_NO_MEMORY; + + error = fTeam->Init(); + if (error != B_OK) + return error; + fTeam->SetName(teamInfo.args); + // TODO: Set a better name! + + // create debugger port + char buffer[128]; + snprintf(buffer, sizeof(buffer), "team %ld debugger", fTeamID); + fDebuggerPort = create_port(100, buffer); + if (fDebuggerPort < 0) + return fDebuggerPort; + + // install as team debugger + fNubPort = install_team_debugger(fTeamID, fDebuggerPort); + if (fNubPort < 0) + return fNubPort; + +// TODO: Set the debug event flags! + + // get the initial state of the team + AutoLocker teamLocker(fTeam); + + thread_info threadInfo; + int32 cookie = 0; + while (get_next_thread_info(fTeamID, &cookie, &threadInfo) == B_OK) { + error = fTeam->AddThread(threadInfo); + if (error != B_OK) + return error; + } + + image_info imageInfo; + cookie = 0; + while (get_next_image_info(fTeamID, &cookie, &imageInfo) == B_OK) { + error = fTeam->AddImage(imageInfo); + if (error != B_OK) + return error; + } + + // create the debug event listener + snprintf(buffer, sizeof(buffer), "team %ld debug listener", fTeamID); + fDebugEventListener = spawn_thread(_DebugEventListenerEntry, buffer, + B_NORMAL_PRIORITY, this); + if (fDebugEventListener < 0) + return fDebugEventListener; + + resume_thread(fDebugEventListener); + + return B_OK; +} + + +/*static*/ status_t +TeamDebugger::_DebugEventListenerEntry(void* data) +{ + return ((TeamDebugger*)data)->_DebugEventListener(); +} + + +status_t +TeamDebugger::_DebugEventListener() +{ + while (!fTerminating) { + // read the next message + debug_debugger_message_data message; + int32 messageCode; + ssize_t size = read_port(fDebuggerPort, &messageCode, &message, + sizeof(message)); + if (size < 0) { + if (size == B_INTERRUPTED) + continue; +// TODO: Error handling! + break; + } + + if (message.origin.team != fTeamID) { +printf("TeamDebugger for team %ld: received message from team %ld!\n", fTeamID, +message.origin.team); + continue; + } + + _HandleDebuggerMessage(messageCode, message); + + if (messageCode == B_DEBUGGER_MESSAGE_TEAM_DELETED + || messageCode == B_DEBUGGER_MESSAGE_TEAM_EXEC) { + // TODO:... + break; + } + } + + return B_OK; +} + + +void +TeamDebugger::_HandleDebuggerMessage(int32 messageCode, + const debug_debugger_message_data& message) +{ + switch (messageCode) { + case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: + break; + case B_DEBUGGER_MESSAGE_DEBUGGER_CALL: + break; + case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: + break; + case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: + break; + case B_DEBUGGER_MESSAGE_SINGLE_STEP: + break; + case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: + break; + case B_DEBUGGER_MESSAGE_TEAM_CREATED: + break; + case B_DEBUGGER_MESSAGE_TEAM_DELETED: + break; + case B_DEBUGGER_MESSAGE_TEAM_EXEC: + break; + case B_DEBUGGER_MESSAGE_THREAD_CREATED: + break; + case B_DEBUGGER_MESSAGE_THREAD_DELETED: + break; + case B_DEBUGGER_MESSAGE_IMAGE_CREATED: + break; + case B_DEBUGGER_MESSAGE_IMAGE_DELETED: + break; + case B_DEBUGGER_MESSAGE_PRE_SYSCALL: + case B_DEBUGGER_MESSAGE_POST_SYSCALL: + case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED: + case B_DEBUGGER_MESSAGE_PROFILER_UPDATE: + case B_DEBUGGER_MESSAGE_HANDED_OVER: + // not interested + break; + default: + printf("TeamDebugger for team %ld: unknown message from kernel: " + "%ld\n", fTeamID, messageCode); + break; + } +} Added: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,40 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef TEAM_DEBUGGER_H +#define TEAM_DEBUGGER_H + +#include +#include + + +class Team; + + +class TeamDebugger { +public: + TeamDebugger(); + ~TeamDebugger(); + + status_t Init(team_id teamID); + + +private: + static status_t _DebugEventListenerEntry(void* data); + status_t _DebugEventListener(); + + void _HandleDebuggerMessage(int32 messageCode, + const debug_debugger_message_data& message); + +private: + BLocker fLock; + Team* fTeam; + team_id fTeamID; + port_id fDebuggerPort; + port_id fNubPort; + thread_id fDebugEventListener; + volatile bool fTerminating; +}; + +#endif // TEAM_DEBUGGER_H Added: haiku/trunk/src/apps/debugger/Thread.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,32 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Thread.h" + + +Thread::Thread(thread_id threadID) + : + fID(threadID) +{ +} + + +Thread::~Thread() +{ +} + + +status_t +Thread::Init() +{ + return B_OK; +} + + +void +Thread::SetName(const BString& name) +{ + fName = name; +} Added: haiku/trunk/src/apps/debugger/Thread.h =================================================================== --- haiku/trunk/src/apps/debugger/Thread.h 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/Thread.h 2009-06-16 00:25:36 UTC (rev 31068) @@ -0,0 +1,36 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef THREAD_H +#define THREAD_H + +#include +#include + +#include + + +class Thread : public DoublyLinkedListLinkImpl { +public: + Thread(thread_id threadID); + ~Thread(); + + status_t Init(); + + thread_id ID() const { return fID; } + + const char* Name() const { return fName.String(); } + void SetName(const BString& name); + + +private: + thread_id fID; + BString fName; +}; + + +typedef DoublyLinkedList ThreadList; + + +#endif // THREAD_H Modified: haiku/trunk/src/apps/debugger/debugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger.cpp 2009-06-15 23:12:16 UTC (rev 31067) +++ haiku/trunk/src/apps/debugger/debugger.cpp 2009-06-16 00:25:36 UTC (rev 31068) @@ -5,7 +5,7 @@ #include -#include "DwarfManager.h" +//#include "DwarfManager.h" int @@ -18,9 +18,10 @@ const char* fileName = argv[1]; - DwarfManager manager; - manager.LoadFile(fileName); - manager.FinishLoading(); +// DwarfManager manager; +// manager.LoadFile(fileName); +// manager.FinishLoading(); +(void)fileName; return 0; } From philippe.houdoin at gmail.com Tue Jun 16 11:03:56 2009 From: philippe.houdoin at gmail.com (Philippe Houdoin) Date: Tue, 16 Jun 2009 11:03:56 +0200 Subject: [Haiku-commits] r31066 - in haiku/trunk/src/apps/debugger: . gui gui/running_teams_window Message-ID: Hi, > I was considering not to have a team list window at all, though, > but instead add a "Debug" button to the alert ProcessController > shows when selecting a team. Seems the natural place to me. Being able to launch either gdb or a graphical debugger from ProcessController and debug_server make both sense indeed. But a graphical debugger is also targetting beginner developers, who be disappointed that double-clicking on this pretty ladybug icon (hint, icons artists!) does nothing. > The only downside is, that then there's nothing really obvious to show when the debugger > is invoked without arguments. So maybe in that case an initial dialog asking to select a running program > or to start a new one could be shown. Opinions welcome... I did planned initially to change this Running Teams window into a "Select Team" window : - by selecting one in the live-updated running teams list, as today (and as in bdb) - by entering/browsing an executable path and, optionally, edit its program arguments and environment variables set Maybe, I could find some spare the time to work on that, if you don't mind. In theory, having a valid team id to hand a debugger controller is all you need from such GUI component, right? Even if I've read a bit about Dwarf, libdwarf and Haiku debugger "kit", the *meat* is definitively out of my scope, both skills and time one. Bye, Philippe. From axeld at pinc-software.de Tue Jun 16 11:46:43 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 16 Jun 2009 11:46:43 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r31066_-_in_haiku/trunk/src/apps/debugg?= =?utf-8?q?er=3A_=2E_gui_gui/running=5Fteams=5Fwindow?= In-Reply-To: <20090616001633.315250@gmx.net> Message-ID: <6003518376-BeMail@zon> "Ingo Weinhold" wrote: > The only downside is, that then there's nothing really obvious to > show when > the debugger is invoked without arguments. So maybe in that case an > initial > dialog asking to select a running program or to start a new one could > be shown. > Opinions welcome... While I never liked the looks of that window, that possibility would be definitely welcome. Bye, Axel. From stippi at mail.berlios.de Tue Jun 16 12:38:29 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Tue, 16 Jun 2009 12:38:29 +0200 Subject: [Haiku-commits] r31069 - haiku/trunk/src/add-ons/kernel/partitioning_systems/efi Message-ID: <200906161038.n5GAcT3e005841@sheep.berlios.de> Author: stippi Date: 2009-06-16 12:38:25 +0200 (Tue, 16 Jun 2009) New Revision: 31069 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31069&view=rev Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h Log: * Apparently the "free_identify_partition_cookie()" function pointer should not be NULL. If the intention is to allow this, then there is a bug somewhere else. Fixes booting on Macs, thanks to Zenja for testing this! * Fixed what I believe to be an off-by-one error in BlockCount(). This also makes it symetrical with SetBlockCount(). Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2009-06-16 00:25:36 UTC (rev 31068) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp 2009-06-16 10:38:25 UTC (rev 31069) @@ -506,6 +506,13 @@ static void +efi_gpt_free_identify_partition_cookie(partition_data *partition, void *_cookie) +{ + // Cookie is freed in efi_gpt_free_partition_content_cookie(). +} + + +static void efi_gpt_free_partition_content_cookie(partition_data *partition) { delete (EFI::Header *)partition->content_cookie; @@ -1222,7 +1229,7 @@ // scanning efi_gpt_identify_partition, efi_gpt_scan_partition, - NULL, // free_identify_partition_cookie + efi_gpt_free_identify_partition_cookie, NULL, // free_partition_cookie efi_gpt_free_partition_content_cookie, Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h =================================================================== --- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h 2009-06-16 00:25:36 UTC (rev 31068) +++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.h 2009-06-16 10:38:25 UTC (rev 31069) @@ -113,7 +113,7 @@ void SetBlockCount(uint64 blockCount) { SetEndBlock(StartBlock() + blockCount - 1); } uint64 BlockCount() const - { return EndBlock() - StartBlock(); } + { return EndBlock() - StartBlock() + 1; } } _PACKED; #endif /* EFI_GPT_H */ From ingo_weinhold at gmx.de Tue Jun 16 13:40:22 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 16 Jun 2009 13:40:22 +0200 Subject: [Haiku-commits] r31066 - in haiku/trunk/src/apps/debugger: . gui gui/running_teams_window In-Reply-To: References: Message-ID: <20090616134022.499.2@knochen-vm.localdomain> On 2009-06-16 at 11:03:56 [+0200], Philippe Houdoin wrote: > > > I was considering not to have a team list window at all, though, > > but instead add a "Debug" button to the alert ProcessController > > shows when selecting a team. Seems the natural place to me. > > Being able to launch either gdb or a graphical debugger from > ProcessController and debug_server make both sense indeed. I would actually only start the graphical debugger from ProcessController and support handing over to gdb via menu item. > But a graphical debugger is also targetting beginner developers, who > be disappointed that double-clicking on > this pretty ladybug icon (hint, icons artists!) does nothing. > > > The only downside is, that then there's nothing really obvious to show > > when the debugger > > is invoked without arguments. So maybe in that case an initial dialog > > asking to select a running program > > or to start a new one could be shown. Opinions welcome... > > I did planned initially to change this Running Teams window into a > "Select Team" window : > - by selecting one in the live-updated running teams list, as today > (and as in bdb) > - by entering/browsing an executable path and, optionally, edit its > program arguments and environment variables set > Maybe, I could find some spare the time to work on that, if you don't > mind. Sounds good. I won't work on this until everything else is working, so feel free... > In theory, having a valid team id to hand a debugger controller > is all you need from such GUI component, right? Yep. CU, Ingo From stippi at mail.berlios.de Tue Jun 16 16:02:20 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Tue, 16 Jun 2009 16:02:20 +0200 Subject: [Haiku-commits] r31070 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906161402.n5GE2KfJ002804@sheep.berlios.de> Author: stippi Date: 2009-06-16 16:02:18 +0200 (Tue, 16 Jun 2009) New Revision: 31070 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31070&view=rev Modified: haiku/trunk/headers/os/interface/Control.h haiku/trunk/src/kits/interface/Control.cpp Log: * Updated header indentation style and small cleanups. Modified: haiku/trunk/headers/os/interface/Control.h =================================================================== --- haiku/trunk/headers/os/interface/Control.h 2009-06-16 10:38:25 UTC (rev 31069) +++ haiku/trunk/headers/os/interface/Control.h 2009-06-16 14:02:18 UTC (rev 31070) @@ -1,137 +1,99 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: Control.h -// Author: Marc Flerackers (mflerackers at androme.be) -// Description: BControl is the base class for user-event handling objects. -//------------------------------------------------------------------------------ - -#ifndef _CONTROL_H +/* + * Copyright (c) 2001-2009, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ + #ifndef _CONTROL_H #define _CONTROL_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- -#include #include -#include /* For convenience */ +#include // For convenience #include -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- enum { B_CONTROL_OFF = 0, B_CONTROL_ON = 1 }; -// Globals --------------------------------------------------------------------- - - class BWindow; -// BControl class -------------------------------------------------------------- -class BControl : public BView, public BInvoker { +class BControl : public BView, public BInvoker { public: - BControl(BRect frame, - const char *name, - const char *label, - BMessage *message, - uint32 resizingMode, - uint32 flags); - BControl(const char *name, - const char *label, - BMessage *message, - uint32 flags); -virtual ~BControl(); + BControl(BRect frame, const char* name, + const char* label, BMessage* message, + uint32 resizingMode, uint32 flags); + BControl(const char* name, const char* label, + BMessage* message, uint32 flags); + virtual ~BControl(); - BControl(BMessage *archive); -static BArchivable *Instantiate(BMessage *archive); -virtual status_t Archive(BMessage *archive, bool deep = true) const; + BControl(BMessage* archive); + static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* archive, + bool deep = true) const; -virtual void WindowActivated(bool active); -virtual void AttachedToWindow(); -virtual void MessageReceived(BMessage *message); -virtual void MakeFocus(bool focused = true); -virtual void KeyDown(const char *bytes, int32 numBytes); -virtual void MouseDown(BPoint point); -virtual void MouseUp(BPoint point); -virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); -virtual void DetachedFromWindow(); + virtual void WindowActivated(bool active); -virtual void SetLabel(const char *string); - const char *Label() const; + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + virtual void AllAttached(); + virtual void AllDetached(); -virtual void SetValue(int32 value); - int32 Value() const; + virtual void MessageReceived(BMessage* message); + virtual void MakeFocus(bool focused = true); -virtual void SetEnabled(bool enabled); - bool IsEnabled() const; + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MouseDown(BPoint point); + virtual void MouseUp(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, + const BMessage *message); -virtual void GetPreferredSize(float *width, float *height); -virtual void ResizeToPreferred(); + virtual void SetLabel(const char* string); + const char* Label() const; -virtual status_t Invoke(BMessage *message = NULL); -virtual BHandler *ResolveSpecifier(BMessage *message, - int32 index, - BMessage *specifier, - int32 what, - const char *property); -virtual status_t GetSupportedSuites(BMessage *message); + virtual void SetValue(int32 value); + int32 Value() const; -virtual void AllAttached(); -virtual void AllDetached(); + virtual void SetEnabled(bool enabled); + bool IsEnabled() const; -virtual status_t Perform(perform_code d, void *arg); + virtual void GetPreferredSize(float* _width, + float* _height); + virtual void ResizeToPreferred(); -protected: + virtual status_t Invoke(BMessage* message = NULL); + virtual BHandler* ResolveSpecifier(BMessage* message, + int32 index, BMessage* specifier, + int32 what, const char* property); + virtual status_t GetSupportedSuites(BMessage* message); - bool IsFocusChanging() const; - bool IsTracking() const; - void SetTracking(bool state); + virtual status_t Perform(perform_code d, void* arg); - void SetValueNoUpdate(int32 value); +protected: + bool IsFocusChanging() const; + bool IsTracking() const; + void SetTracking(bool state); + void SetValueNoUpdate(int32 value); + private: + virtual void _ReservedControl1(); + virtual void _ReservedControl2(); + virtual void _ReservedControl3(); + virtual void _ReservedControl4(); -virtual void _ReservedControl1(); -virtual void _ReservedControl2(); -virtual void _ReservedControl3(); -virtual void _ReservedControl4(); + BControl& operator=(const BControl&); - BControl &operator=(const BControl &); + void InitData(BMessage* data = NULL); - void InitData(BMessage *data = NULL); + char* fLabel; + int32 fValue; + bool fEnabled; + bool fFocusChanging; + bool fTracking; + bool fWantsNav; - char *fLabel; - int32 fValue; - bool fEnabled; - bool fFocusChanging; - bool fTracking; - bool fWantsNav; - uint32 _reserved[4]; + uint32 _reserved[4]; }; -//------------------------------------------------------------------------------ #endif // _CONTROL_H Modified: haiku/trunk/src/kits/interface/Control.cpp =================================================================== --- haiku/trunk/src/kits/interface/Control.cpp 2009-06-16 10:38:25 UTC (rev 31069) +++ haiku/trunk/src/kits/interface/Control.cpp 2009-06-16 14:02:18 UTC (rev 31070) @@ -163,6 +163,27 @@ void +BControl::DetachedFromWindow() +{ + BView::DetachedFromWindow(); +} + + +void +BControl::AllAttached() +{ + BView::AllAttached(); +} + + +void +BControl::AllDetached() +{ + BView::AllDetached(); +} + + +void BControl::MessageReceived(BMessage *message) { if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) { @@ -215,7 +236,7 @@ } } } - + if (handled) { message->SendReply(&reply); return; @@ -279,13 +300,6 @@ void -BControl::DetachedFromWindow() -{ - BView::DetachedFromWindow(); -} - - -void BControl::SetLabel(const char *label) { if (label != NULL && !label[0]) @@ -442,20 +456,6 @@ } -void -BControl::AllAttached() -{ - BView::AllAttached(); -} - - -void -BControl::AllDetached() -{ - BView::AllDetached(); -} - - status_t BControl::Perform(perform_code code, void* _data) { From axeld at mail.berlios.de Tue Jun 16 23:22:10 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 16 Jun 2009 23:22:10 +0200 Subject: [Haiku-commits] r31071 - haiku/trunk/src/servers/app Message-ID: <200906162122.n5GLMAnT020979@sheep.berlios.de> Author: axeld Date: 2009-06-16 23:22:10 +0200 (Tue, 16 Jun 2009) New Revision: 31071 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31071&view=rev Modified: haiku/trunk/src/servers/app/Desktop.cpp Log: * Implemented switching to the fallback video mode when pressing Command+Control+Escape. Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2009-06-16 14:02:18 UTC (rev 31070) +++ haiku/trunk/src/servers/app/Desktop.cpp 2009-06-16 21:22:10 UTC (rev 31071) @@ -146,12 +146,9 @@ if (message->what == B_KEY_DOWN && message->FindInt32("key", &key) == B_OK && message->FindInt32("modifiers", &modifiers) == B_OK) { - // Check for safe video mode (F12 + l-cmd + l-ctrl + l-shift) - if (key == B_F12_KEY - && (modifiers & (B_LEFT_COMMAND_KEY - | B_LEFT_CONTROL_KEY | B_LEFT_SHIFT_KEY)) != 0) { - // TODO: Set to Safe Mode in KeyboardEventHandler:B_KEY_DOWN. - STRACE(("Safe Video Mode invoked - code unimplemented\n")); + // Check for safe video mode (cmd + ctrl + escape) + if (key == 0x01 && (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY)) != 0) { + system("screenmode --fall-back &"); return B_SKIP_MESSAGE; } From bonefish at mail.berlios.de Tue Jun 16 23:42:03 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 16 Jun 2009 23:42:03 +0200 Subject: [Haiku-commits] r31072 - haiku/trunk/src/apps/debugger Message-ID: <200906162142.n5GLg36h023774@sheep.berlios.de> Author: bonefish Date: 2009-06-16 23:41:59 +0200 (Tue, 16 Jun 2009) New Revision: 31072 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31072&view=rev Modified: haiku/trunk/src/apps/debugger/Array.h Log: Added Clear()/MakeEmpty() methods. Modified: haiku/trunk/src/apps/debugger/Array.h =================================================================== --- haiku/trunk/src/apps/debugger/Array.h 2009-06-16 21:22:10 UTC (rev 31071) +++ haiku/trunk/src/apps/debugger/Array.h 2009-06-16 21:41:59 UTC (rev 31072) @@ -25,6 +25,9 @@ inline bool Insert(const Element& element, int index); inline bool Remove(int index); + void Clear(); + inline void MakeEmpty(); + inline Element& ElementAt(int index); inline const Element& ElementAt(int index) const; @@ -120,6 +123,29 @@ template +void +Array::Clear() +{ + if (fSize == 0) + return; + + free(fElements); + + fElements = NULL; + fSize = 0; + fCapacity = 0; +} + + +template +void +Array::MakeEmpty() +{ + Clear(); +} + + +template Element& Array::ElementAt(int index) { From bonefish at mail.berlios.de Tue Jun 16 23:47:57 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 16 Jun 2009 23:47:57 +0200 Subject: [Haiku-commits] r31073 - in haiku/trunk/src/apps/debugger: . gui gui/team_window Message-ID: <200906162147.n5GLlvrb025159@sheep.berlios.de> Author: bonefish Date: 2009-06-16 23:47:49 +0200 (Tue, 16 Jun 2009) New Revision: 31073 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31073&view=rev Added: haiku/trunk/src/apps/debugger/Debugger.cpp haiku/trunk/src/apps/debugger/Debugger.rdef haiku/trunk/src/apps/debugger/gui/team_window/ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.h Removed: haiku/trunk/src/apps/debugger/debugger.cpp Modified: haiku/trunk/src/apps/debugger/Image.h haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h haiku/trunk/src/apps/debugger/Thread.h Log: * Added bits and pieces to the model classes (Team, Thread, Image). * Added beginnings of the team window. Currently only showing the thread list (not updated yet). * Added application startup code and argument parsing. Copied: haiku/trunk/src/apps/debugger/Debugger.cpp (from rev 31068, haiku/trunk/src/apps/debugger/debugger.cpp) =================================================================== --- haiku/trunk/src/apps/debugger/debugger.cpp 2009-06-16 00:25:36 UTC (rev 31068) +++ haiku/trunk/src/apps/debugger/Debugger.cpp 2009-06-16 21:47:49 UTC (rev 31073) @@ -0,0 +1,300 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include + +#include + +#include +#include + +#include "debug_utils.h" + +#include "TeamDebugger.h" + + +extern const char* __progname; +const char* kProgramName = __progname; + +static const char* const kDebuggerSignature + = "application/x-vnd.Haiku-Debugger"; + + +static const char* kUsage = + "Usage: %s [ ]\n" + " %s [ ] \n" + " %s [ ] --team \n" + " %s [ ] --thread \n" + "\n" + "The first form starts the debugger displaying a requester to choose a\n" + "running team to debug respectively to specify the program to run and\n" + "debug.\n" + "\n" + "The second form runs the given command line and attaches the debugger to\n" + "the new team. Unless specified otherwise the program will be stopped at\n" + "the beginning of its main() function.\n" + "\n" + "The third and fourth forms attach the debugger to a running team. The\n" + "fourth form additionally stops the specified thread.\n" + "\n" + "Options:\n" + " -h, --help - Print this usage info and exit.\n" +; + + +static void +print_usage_and_exit(bool error) +{ + fprintf(error ? stderr : stdout, kUsage, kProgramName, kProgramName, + kProgramName, kProgramName); + exit(error ? 1 : 0); +} + + +struct Options { + int commandLineArgc; + const char* const* commandLineArgv; + team_id team; + thread_id thread; + + Options() + : + commandLineArgc(0), + commandLineArgv(NULL), + team(-1), + thread(-1) + { + } +}; + + +static bool +parse_arguments(int argc, const char* const* argv, bool noOutput, + Options& options) +{ +printf("parse_arguments(): argc: %d\n", argc); + + optind = 1; + + while (true) { + static struct option sLongOptions[] = { + { "help", no_argument, 0, 'h' }, + { "team", required_argument, 0, 't' }, + { "thread", required_argument, 0, 'T' }, + { 0, 0, 0, 0 } + }; + + opterr = 0; // don't print errors + + int c = getopt_long(argc, (char**)argv, "+h", sLongOptions, NULL); + if (c == -1) + break; + + switch (c) { + case 'h': + if (noOutput) + return false; + print_usage_and_exit(false); + break; + + case 't': + { + options.team = strtol(optarg, NULL, 0); + if (options.team <= 0) { + if (noOutput) + return false; + print_usage_and_exit(true); + } + break; + } + + case 'T': + { + options.thread = strtol(optarg, NULL, 0); + if (options.thread <= 0) { + if (noOutput) + return false; + print_usage_and_exit(true); + } + break; + } + + default: + if (noOutput) + return false; + print_usage_and_exit(true); + break; + } + } + + if (optind < argc) { + options.commandLineArgc = argc - optind; + options.commandLineArgv = argv + optind; + } + + int exclusiveParams = 0; + if (options.team > 0) + exclusiveParams++; + if (options.thread > 0) + exclusiveParams++; + if (options.commandLineArgc > 0) + exclusiveParams++; + +printf("exclusiveParams: %d\n", exclusiveParams); + if (exclusiveParams == 0) { + // TODO: Support! + if (noOutput) + return false; + fprintf(stderr, "Sorry, running without team/thread to debug not " + "supported yet.\n"); + exit(1); + } else if (exclusiveParams != 1) { + if (noOutput) + return false; + print_usage_and_exit(true); + } + + return true; +} + + +class Debugger : public BApplication { +public: + Debugger() + : + BApplication(kDebuggerSignature) + { + } + + ~Debugger() + { + } + + virtual void MessageReceived(BMessage* message) + { + switch (message->what) { + default: + BApplication::MessageReceived(message); + break; + } + } + + virtual void ReadyToRun() + { + } + + virtual void ArgvReceived(int32 argc, char** argv) + { + Options options; + if (!parse_arguments(argc, argv, true, options)) +{ +printf("Debugger::ArgvReceived(): parsing args failed!\n"); + return; +} + + team_id team = options.team; + thread_id thread = options.thread; + bool stopInMain = false; + + // If command line arguments were given, start the program. + if (options.commandLineArgc > 0) { +printf("loading program: \"%s\" ...\n", options.commandLineArgv[0]); + // TODO: What about the CWD? + thread = load_program(options.commandLineArgv, + options.commandLineArgc, false); + if (thread < 0) { + // TODO: Notify the user! + fprintf(stderr, "Error: Failed to load program \"%s\": %s\n", + options.commandLineArgv[0], strerror(thread)); + return; + } + + team = thread; + // main thread ID == team ID + stopInMain = true; + } + + // If we've got + if (team < 0) { +printf("no team yet, getting thread info...\n"); + thread_info threadInfo; + status_t error = get_thread_info(thread, &threadInfo); + if (error != B_OK) { + // TODO: Notify the user! + fprintf(stderr, "Error: Failed to get info for thread \"%ld\": " + "%s\n", thread, strerror(error)); + return; + } + + team = threadInfo.team; + } +printf("team: %ld, thread: %ld\n", team, thread); + + TeamDebugger* debugger = _TeamDebuggerForTeam(team); + if (debugger != NULL) { + // TODO: Activate the respective window! +printf("There's already a debugger for team: %ld\n", team); + return; + } + + debugger = new(std::nothrow) TeamDebugger; + if (debugger == NULL) { + // TODO: Notify the user! + fprintf(stderr, "Error: Out of memory!\n"); + } + + if (debugger->Init(team, thread, stopInMain) == B_OK) +{ +printf("debugger for team %ld created and initialized successfully!\n", team); + fTeamDebuggers.Add(debugger); +} + else + delete debugger; + } + + virtual bool QuitRequested() + { + // TODO:... + return true; + } + +private: + typedef DoublyLinkedList TeamDebuggerList; + +private: + TeamDebugger* _TeamDebuggerForTeam(team_id teamID) const + { + for (TeamDebuggerList::ConstIterator it = fTeamDebuggers.GetIterator(); + TeamDebugger* debugger = it.Next();) { + if (debugger->TeamID() == teamID) + return debugger; + } + + return NULL; + } + +private: + TeamDebuggerList fTeamDebuggers; +}; + + +int +main(int argc, const char* const* argv) +{ + // We test-parse the arguments here, so, when we're started from the + // terminal and there's an instance already running, we can print an error + // message to the terminal, if something's wrong with the arguments. + { + Options options; + parse_arguments(argc, argv, false, options); + } + + Debugger app; + app.Run(); + return 0; +} Added: haiku/trunk/src/apps/debugger/Debugger.rdef =================================================================== --- haiku/trunk/src/apps/debugger/Debugger.rdef 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/Debugger.rdef 2009-06-16 21:47:49 UTC (rev 31073) @@ -0,0 +1,18 @@ + +resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.Haiku-Debugger"; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + + variety = B_APPV_BETA, + internal = 0, + + short_info = "Debugger", + long_info = "Debugger ?2009 Haiku, Inc." +}; + +resource app_flags B_SINGLE_LAUNCH; + +// TODO: Please give me a nice icon! Modified: haiku/trunk/src/apps/debugger/Image.h =================================================================== --- haiku/trunk/src/apps/debugger/Image.h 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/Image.h 2009-06-16 21:47:49 UTC (rev 31073) @@ -7,10 +7,11 @@ #include +#include #include -class Image : public DoublyLinkedListLinkImpl { +class Image : public Referenceable, public DoublyLinkedListLinkImpl { public: Image(const image_info& imageInfo); ~Image(); Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-16 21:47:49 UTC (rev 31073) @@ -3,11 +3,20 @@ CCFLAGS += -Werror ; C++FLAGS += -Werror ; -UsePrivateHeaders kernel shared ; +UsePrivateHeaders interface kernel shared ; UsePrivateSystemHeaders ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ; + +local debugAnalyzerSources + = [ FDirName $(HAIKU_TOP) src apps debuganalyzer ] ; + +SubDirHdrs [ FDirName $(HAIKU_TOP) src bin debug ] ; +SubDirHdrs [ FDirName $(debugAnalyzerSources) gui ] ; +SubDirHdrs [ FDirName $(debugAnalyzerSources) util ] ; + Application Debugger : - debugger.cpp + Debugger.cpp ElfFile.cpp Image.cpp @@ -15,6 +24,13 @@ Team.cpp Thread.cpp + # DebugAnalyzer:util + Variant.cpp + + # gui/team_window + TeamWindow.cpp + ThreadListView.cpp + # DWARF # attribute_classes.cpp # AttributeValue.cpp @@ -24,7 +40,19 @@ # SourceLanguageInfo.cpp # tag_names.cpp - : $(TARGET_LIBSUPC++) be + : + DebugAnalyzer_gui_table.o + + debug_utils.a + libcolumnlistview.a + + $(TARGET_LIBSTDC++) + be + + : Debugger.rdef ; +SEARCH on [ FGristFiles Variant.cpp ] + = [ FDirName $(debugAnalyzerSources) util ] ; + HaikuSubInclude gui running_teams_window ; Modified: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-16 21:47:49 UTC (rev 31073) @@ -8,6 +8,9 @@ #include +// #pragma mark - Team + + Team::Team(team_id teamID) : fID(teamID) @@ -18,10 +21,10 @@ Team::~Team() { while (Image* image = fImages.RemoveHead()) - delete image; + image->RemoveReference(); while (Thread* thread = fThreads.RemoveHead()) - delete thread; + thread->RemoveReference(); } @@ -43,6 +46,7 @@ Team::AddThread(Thread* thread) { fThreads.Add(thread); + _NotifyThreadAdded(thread); } @@ -73,6 +77,7 @@ Team::RemoveThread(Thread* thread) { fThreads.Remove(thread); + _NotifyThreadRemoved(thread); } @@ -84,7 +89,7 @@ return false; RemoveThread(thread); - delete thread; + thread->RemoveReference(); return true; } @@ -102,10 +107,18 @@ } +const ThreadList& +Team::Threads() const +{ + return fThreads; +} + + void Team::AddImage(Image* image) { fImages.Add(image); + _NotifyImageAdded(image); } @@ -135,6 +148,7 @@ Team::RemoveImage(Image* image) { fImages.Remove(image); + _NotifyImageRemoved(image); } @@ -146,7 +160,7 @@ return false; RemoveImage(image); - delete image; + image->RemoveReference(); return true; } @@ -162,3 +176,95 @@ return NULL; } + + +const ImageList& +Team::Images() const +{ + return fImages; +} + + +void +Team::AddListener(Listener* listener) +{ + fListeners.Add(listener); +} + + +void +Team::RemoveListener(Listener* listener) +{ + fListeners.Remove(listener); +} + + +void +Team::_NotifyThreadAdded(Thread* thread) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ThreadAdded(this, thread); + } +} + + +void +Team::_NotifyThreadRemoved(Thread* thread) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ThreadRemoved(this, thread); + } +} + + +void +Team::_NotifyImageAdded(Image* image) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ImageAdded(this, image); + } +} + + +void +Team::_NotifyImageRemoved(Image* image) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ImageRemoved(this, image); + } +} + + +// #pragma mark - Listener + +Team::Listener::~Listener() +{ +} + + +void +Team::Listener::ThreadAdded(Team* team, Thread* thread) +{ +} + + +void +Team::Listener::ThreadRemoved(Team* team, Thread* thread) +{ +} + + +void +Team::Listener::ImageAdded(Team* team, Image* image) +{ +} + + +void +Team::Listener::ImageRemoved(Team* team, Image* image) +{ +} Modified: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-16 21:47:49 UTC (rev 31073) @@ -13,6 +13,9 @@ class Team : public BLocker { public: + class Listener; + +public: Team(team_id teamID); ~Team(); @@ -29,6 +32,7 @@ void RemoveThread(Thread* thread); bool RemoveThread(thread_id threadID); Thread* ThreadByID(thread_id threadID) const; + const ThreadList& Threads() const; void AddImage(Image* image); status_t AddImage(const image_info& imageInfo, @@ -36,12 +40,39 @@ void RemoveImage(Image* image); bool RemoveImage(image_id imageID); Image* ImageByID(image_id imageID) const; + const ImageList& Images() const; + void AddListener(Listener* listener); + void RemoveListener(Listener* listener); + private: + typedef DoublyLinkedList ListenerList; + +private: + void _NotifyThreadAdded(Thread* thread); + void _NotifyThreadRemoved(Thread* thread); + void _NotifyImageAdded(Image* image); + void _NotifyImageRemoved(Image* image); + +private: team_id fID; BString fName; ThreadList fThreads; ImageList fImages; + ListenerList fListeners; }; + +class Team::Listener : public DoublyLinkedListLinkImpl { +public: + virtual ~Listener(); + + virtual void ThreadAdded(Team* team, Thread* thread); + virtual void ThreadRemoved(Team* team, Thread* thread); + + virtual void ImageAdded(Team* team, Image* image); + virtual void ImageRemoved(Team* team, Image* image); +}; + + #endif // TEAM_H Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-16 21:47:49 UTC (rev 31073) @@ -9,6 +9,8 @@ #include +#include + #include #include "Team.h" @@ -16,12 +18,13 @@ TeamDebugger::TeamDebugger() : - fLock("team debugger"), + BLooper("team debugger"), fTeam(NULL), fTeamID(-1), fDebuggerPort(-1), fNubPort(-1), fDebugEventListener(-1), + fTeamWindow(NULL), fTerminating(false) { } @@ -29,7 +32,7 @@ TeamDebugger::~TeamDebugger() { - AutoLocker locker(fLock); + AutoLocker locker(this); fTerminating = true; @@ -46,22 +49,18 @@ status_t -TeamDebugger::Init(team_id teamID) +TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain) { fTeamID = teamID; - status_t error = fLock.InitCheck(); - if (error != B_OK) - return error; - // check whether the team exists at all team_info teamInfo; - error = get_team_info(fTeamID, &teamInfo); + status_t error = get_team_info(fTeamID, &teamInfo); if (error != B_OK) return error; // create a team object - fTeam = new(std::nothrow) Team(fTeamID); + fTeam = new(std::nothrow) ::Team(fTeamID); if (fTeam == NULL) return B_NO_MEMORY; @@ -86,7 +85,7 @@ // TODO: Set the debug event flags! // get the initial state of the team - AutoLocker teamLocker(fTeam); + AutoLocker< ::Team> teamLocker(fTeam); thread_info threadInfo; int32 cookie = 0; @@ -113,10 +112,47 @@ resume_thread(fDebugEventListener); + // run looper + thread_id looperThread = Run(); + if (looperThread < 0) + return looperThread; + + // create the team window + try { + fTeamWindow = TeamWindow::Create(fTeam, this); + } catch (...) { + // TODO: Notify the user! + fprintf(stderr, "Error: Failed to create team window!\n"); + return B_NO_MEMORY; + } + + fTeamWindow->Show(); + + // if requested, stop the given thread + if (threadID >= 0) { + if (stopInMain) { + // TODO: Set a temporary breakpoint in main and run the thread. + } else { + debug_thread(threadID); + // TODO: Superfluous, if the thread is already stopped. + } + } + return B_OK; } +void +TeamDebugger::MessageReceived(BMessage* message) +{ + switch (message->what) { + default: + BLooper::MessageReceived(message); + break; + } +} + + /*static*/ status_t TeamDebugger::_DebugEventListenerEntry(void* data) { Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-16 21:47:49 UTC (rev 31073) @@ -6,21 +6,31 @@ #define TEAM_DEBUGGER_H #include -#include +#include +#include +#include "TeamWindow.h" + + class Team; -class TeamDebugger { +class TeamDebugger : public DoublyLinkedListLinkImpl, + private BLooper, private TeamWindow::Listener { public: TeamDebugger(); ~TeamDebugger(); - status_t Init(team_id teamID); + status_t Init(team_id teamID, thread_id threadID, + bool stopInMain); + team_id TeamID() const { return fTeamID; } private: + virtual void MessageReceived(BMessage* message); + +private: static status_t _DebugEventListenerEntry(void* data); status_t _DebugEventListener(); @@ -28,12 +38,12 @@ const debug_debugger_message_data& message); private: - BLocker fLock; - Team* fTeam; + ::Team* fTeam; team_id fTeamID; port_id fDebuggerPort; port_id fNubPort; thread_id fDebugEventListener; + TeamWindow* fTeamWindow; volatile bool fTerminating; }; Modified: haiku/trunk/src/apps/debugger/Thread.h =================================================================== --- haiku/trunk/src/apps/debugger/Thread.h 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/Thread.h 2009-06-16 21:47:49 UTC (rev 31073) @@ -8,10 +8,11 @@ #include #include +#include #include -class Thread : public DoublyLinkedListLinkImpl { +class Thread : public Referenceable, public DoublyLinkedListLinkImpl { public: Thread(thread_id threadID); ~Thread(); Deleted: haiku/trunk/src/apps/debugger/debugger.cpp Added: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-16 21:47:49 UTC (rev 31073) @@ -0,0 +1,111 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "TeamWindow.h" + +#include +#include +#include + +#include "Team.h" +#include "ThreadListView.h" + + +// #pragma mark - TeamWindow + + +TeamWindow::TeamWindow(::Team* team, Listener* listener) + : + BWindow(BRect(100, 100, 399, 299), _GetWindowTitle(team).String(), + B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), + fTeam(team), + fListener(listener), + fTabView(NULL), + fThreadListView(NULL) +{ +} + + +TeamWindow::~TeamWindow() +{ +} + + +/*static*/ TeamWindow* +TeamWindow::Create(::Team* team, Listener* listener) +{ + TeamWindow* self = new TeamWindow(team, listener); + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; +} + + +void +TeamWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + default: + BWindow::MessageReceived(message); + break; + } +} + + +bool +TeamWindow::QuitRequested() +{ + return fListener->TeamWindowQuitRequested(this); +} + + +/*static*/ BString +TeamWindow::_GetWindowTitle(::Team* team) +{ + BString name = team->Name(); + if (team->ID() >= 0) + name << " (" << team->ID() << ")"; + return name; +} + + +void +TeamWindow::_Init() +{ + BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); + SetLayout(rootLayout); + + fTabView = new BTabView("tab view"); + + BGroupLayoutBuilder(rootLayout) + .Add(fTabView); + + fTabView->AddTab(fThreadListView = ThreadListView::Create()); +// fTabView->AddTab(fTeamsPage = new TeamsPage(this)); +// fTabView->AddTab(fThreadsPage = new ThreadsPage(this)); + + fThreadListView->SetTeam(fTeam); +} + + +// #pragma mark - Listener + + +TeamWindow::Listener::~Listener() +{ +} + + +bool +TeamWindow::Listener::TeamWindowQuitRequested(TeamWindow* window) +{ + return true; +} Added: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-16 21:41:59 UTC (rev 31072) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-16 21:47:49 UTC (rev 31073) @@ -0,0 +1,51 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef TEAM_WINDOW_H +#define TEAM_WINDOW_H + +#include +#include + + +class BTabView; +class Team; +class ThreadListView; + + +class TeamWindow : public BWindow { +public: + class Listener; + +public: + TeamWindow(::Team* team, Listener* listener); + ~TeamWindow(); [... truncated: 311 lines follow ...] From bonefish at mail.berlios.de Wed Jun 17 02:17:40 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 02:17:40 +0200 Subject: [Haiku-commits] r31074 - haiku/trunk/src/system/kernel/debug Message-ID: <200906170017.n5H0HeXX013354@sheep.berlios.de> Author: bonefish Date: 2009-06-17 02:17:37 +0200 (Wed, 17 Jun 2009) New Revision: 31074 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31074&view=rev Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp Log: Fixed comments and removed superfluous code. Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-16 21:47:49 UTC (rev 31073) +++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-17 00:17:37 UTC (rev 31074) @@ -355,7 +355,7 @@ struct team *team = thread->team; // If a debugger is installed for the team and the thread debug stuff - // initialized, changed the ownership of the debug port for the thread + // initialized, change the ownership of the debug port for the thread // to the kernel team, since exec_team() deletes all ports owned by this // team. We change the ownership back later. if (atomic_get(&team->debug_info.flags) & B_TEAM_DEBUG_DEBUGGER_INSTALLED) { @@ -458,8 +458,6 @@ "%s\n", strerror(port)); return port; } - - setPort = true; } // check the debug info structures once more: get the debugger port, set @@ -1334,9 +1332,10 @@ } -/** \brief Called by the debug nub thread of a team to broadcast a message - * that are initialized for debugging (and thus have a debug port). - */ +/*! \brief Called by the debug nub thread of a team to broadcast a message to + all threads of the team that are initialized for debugging (and + thus have a debug port). +*/ static void broadcast_debugged_thread_message(struct thread *nubThread, int32 code, const void *message, int32 size) From bonefish at mail.berlios.de Wed Jun 17 02:28:40 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 02:28:40 +0200 Subject: [Haiku-commits] r31075 - haiku/trunk/src/system/kernel/debug Message-ID: <200906170028.n5H0Seqa015167@sheep.berlios.de> Author: bonefish Date: 2009-06-17 02:28:36 +0200 (Wed, 17 Jun 2009) New Revision: 31075 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31075&view=rev Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp Log: broadcast_debugged_thread_message(): Only send the message to threads that are stopped. Besides that the message won't be interesting to the other threads anyway, we also risk filling the port and blocking the nub thread. Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-17 00:17:37 UTC (rev 31074) +++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-17 00:28:36 UTC (rev 31075) @@ -1354,7 +1354,8 @@ struct thread *thread = thread_get_thread_struct_locked(threadInfo.thread); if (thread && thread != nubThread && thread->team == nubThread->team - && thread->debug_info.flags & B_THREAD_DEBUG_INITIALIZED) { + && (thread->debug_info.flags & B_THREAD_DEBUG_INITIALIZED) != 0 + && (thread->debug_info.flags & B_THREAD_DEBUG_STOPPED) != 0) { threadDebugPort = thread->debug_info.debug_port; threadID = thread->id; } From bonefish at mail.berlios.de Wed Jun 17 03:02:34 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 03:02:34 +0200 Subject: [Haiku-commits] r31076 - haiku/trunk/src/system/kernel/debug Message-ID: <200906170102.n5H12YFL020114@sheep.berlios.de> Author: bonefish Date: 2009-06-17 03:02:33 +0200 (Wed, 17 Jun 2009) New Revision: 31076 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31076&view=rev Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp Log: Rewrote user_debug_thread_deleted(): * It was broken since the support for debugger handovers. Using debugger_write() couldn't work, since the thread didn't belong to the debugged team anymore (but to the kernel) and thus getting the debug info for team would always fail. This makes B_DEBUGGER_MESSAGE_THREAD_DELETED notifications work again. * Allow the thread to block. Locking/writing to the port was non-blocking before, but there shouldn't be a problem, if the thread has to wait. Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-17 00:28:36 UTC (rev 31075) +++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2009-06-17 01:02:33 UTC (rev 31076) @@ -950,42 +950,66 @@ void user_debug_thread_deleted(team_id teamID, thread_id threadID) { + // Things are a bit complicated here, since this thread no longer belongs to + // the debugged team (but to the kernel). So we can't use debugger_write(). + // get the team debug flags and debugger port - cpu_status state = disable_interrupts(); - GRAB_TEAM_LOCK(); + InterruptsSpinLocker teamLocker(gTeamSpinlock); struct team *team = team_get_team_struct_locked(teamID); + if (team == NULL) + return; - int32 teamDebugFlags = 0; - port_id debuggerPort = -1; - if (team) { - GRAB_TEAM_DEBUG_INFO_LOCK(team->debug_info); + SpinLocker debugInfoLocker(team->debug_info.lock); - teamDebugFlags = atomic_get(&team->debug_info.flags); - debuggerPort = team->debug_info.debugger_port; + int32 teamDebugFlags = atomic_get(&team->debug_info.flags); + port_id debuggerPort = team->debug_info.debugger_port; + sem_id writeLock = team->debug_info.debugger_write_lock; - RELEASE_TEAM_DEBUG_INFO_LOCK(team->debug_info); - } + debugInfoLocker.Unlock(); + teamLocker.Unlock(); - RELEASE_TEAM_LOCK(); - restore_interrupts(state); - // check, if a debugger is installed and is interested in thread events if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_THREADS)) { return; } - // notify the debugger - if (debuggerPort >= 0) { + // acquire the debugger write lock + status_t error = acquire_sem_etc(writeLock, 1, B_KILL_CAN_INTERRUPT, 0); + if (error != B_OK) + return; + + // re-get the team debug info -- we need to check whether anything changed + teamLocker.Lock(); + + team = team_get_team_struct_locked(teamID); + if (team == NULL) + return; + + debugInfoLocker.Lock(); + + teamDebugFlags = atomic_get(&team->debug_info.flags); + port_id newDebuggerPort = team->debug_info.debugger_port; + + debugInfoLocker.Unlock(); + teamLocker.Unlock(); + + // Send the message only if the debugger hasn't changed in the meantime or + // the team is about to be handed over. + if (newDebuggerPort == debuggerPort + || (teamDebugFlags & B_TEAM_DEBUG_DEBUGGER_HANDOVER) == 0) { debug_thread_deleted message; message.origin.thread = threadID; message.origin.team = teamID; message.origin.nub_port = -1; - debugger_write(debuggerPort, B_DEBUGGER_MESSAGE_THREAD_DELETED, - &message, sizeof(message), true); - // TODO: Would it be OK to wait here? + + write_port_etc(debuggerPort, B_DEBUGGER_MESSAGE_THREAD_DELETED, + &message, sizeof(message), B_KILL_CAN_INTERRUPT, 0); } + + // release the debugger write lock + release_sem(writeLock); } From axeld at mail.berlios.de Wed Jun 17 11:32:31 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 17 Jun 2009 11:32:31 +0200 Subject: [Haiku-commits] r31077 - in haiku/trunk/src/add-ons/kernel/network/protocols: icmp ipv4 l2cap tcp udp Message-ID: <200906170932.n5H9WVhH016089@sheep.berlios.de> Author: axeld Date: 2009-06-17 11:32:30 +0200 (Wed, 17 Jun 2009) New Revision: 31077 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31077&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp Log: * Added missing hooks with a description of what's missing for clarity. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp 2009-06-17 01:02:33 UTC (rev 31076) +++ haiku/trunk/src/add-ons/kernel/network/protocols/icmp/icmp.cpp 2009-06-17 09:32:30 UTC (rev 31077) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -369,9 +369,13 @@ icmp_get_domain, icmp_get_mtu, icmp_receive_data, - NULL, + NULL, // deliver_data() icmp_error, icmp_error_reply, + NULL, // add_ancillary_data() + NULL, // process_ancillary_data() + NULL, // send_data_no_buffer() + NULL // read_data_no_buffer() }; module_dependency module_dependencies[] = { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2009-06-17 01:02:33 UTC (rev 31076) +++ haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2009-06-17 09:32:30 UTC (rev 31077) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -1718,6 +1718,10 @@ ipv4_deliver_data, ipv4_error, ipv4_error_reply, + NULL, // add_ancillary_data() + NULL, // process_ancillary_data() + NULL, // send_data_no_buffer() + NULL // read_data_no_buffer() }; module_dependency module_dependencies[] = { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp 2009-06-17 01:02:33 UTC (rev 31076) +++ haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap.cpp 2009-06-17 09:32:30 UTC (rev 31077) @@ -378,9 +378,13 @@ l2cap_get_domain, l2cap_get_mtu, l2cap_receive_data, - NULL, + NULL, // deliver_data() l2cap_error, l2cap_error_reply, + NULL, // add_ancillary_data() + NULL, // process_ancillary_data() + NULL, // send_data_no_buffer() + NULL // read_data_no_buffer() }; module_dependency module_dependencies[] = { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp 2009-06-17 01:02:33 UTC (rev 31076) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp 2009-06-17 09:32:30 UTC (rev 31077) @@ -841,9 +841,13 @@ tcp_get_domain, tcp_get_mtu, tcp_receive_data, - NULL, + NULL, // deliver_data() tcp_error, tcp_error_reply, + NULL, // add_ancillary_data() + NULL, // process_ancillary_data() + NULL, // send_data_no_buffer() + NULL // read_data_no_buffer() }; module_dependency module_dependencies[] = { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2009-06-17 01:02:33 UTC (rev 31076) +++ haiku/trunk/src/add-ons/kernel/network/protocols/udp/udp.cpp 2009-06-17 09:32:30 UTC (rev 31077) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -1254,6 +1254,10 @@ udp_deliver_data, udp_error, udp_error_reply, + NULL, // add_ancillary_data() + NULL, // process_ancillary_data() + NULL, // send_data_no_buffer() + NULL // read_data_no_buffer() }; module_dependency module_dependencies[] = { From axeld at mail.berlios.de Wed Jun 17 11:55:08 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 17 Jun 2009 11:55:08 +0200 Subject: [Haiku-commits] r31078 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200906170955.n5H9t8iw019662@sheep.berlios.de> Author: axeld Date: 2009-06-17 11:55:07 +0200 (Wed, 17 Jun 2009) New Revision: 31078 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31078&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.cpp Log: * Minor cleanup. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.cpp 2009-06-17 09:32:30 UTC (rev 31077) +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.cpp 2009-06-17 09:55:07 UTC (rev 31078) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -128,7 +128,8 @@ static void disable_caches() { - x86_write_cr0((x86_read_cr0() | CR0_CACHE_DISABLE) & ~CR0_NOT_WRITE_THROUGH); + x86_write_cr0((x86_read_cr0() | CR0_CACHE_DISABLE) + & ~CR0_NOT_WRITE_THROUGH); wbinvd(); arch_cpu_global_TLB_invalidate(); } @@ -140,14 +141,16 @@ { wbinvd(); arch_cpu_global_TLB_invalidate(); - x86_write_cr0(x86_read_cr0() & ~(CR0_CACHE_DISABLE | CR0_NOT_WRITE_THROUGH)); + x86_write_cr0(x86_read_cr0() + & ~(CR0_CACHE_DISABLE | CR0_NOT_WRITE_THROUGH)); } static void set_mtrr(void *_parameter, int cpu) { - struct set_mtrr_parameter *parameter = (struct set_mtrr_parameter *)_parameter; + struct set_mtrr_parameter *parameter + = (struct set_mtrr_parameter *)_parameter; // wait until all CPUs have arrived here smp_cpu_rendezvous(&sCpuRendezvous, cpu); @@ -244,8 +247,7 @@ static void init_double_fault(int cpuNum) { - /* set up the double fault tss */ - /* TODO: Axel - fix SMP support */ + // set up the double fault TSS struct tss *tss = &gCPU[cpuNum].arch.double_fault_tss; memset(tss, 0, sizeof(struct tss)); @@ -426,15 +428,26 @@ // build the model string (need to swap ecx/edx data before copying) unsigned int temp; memset(cpu->arch.model_name, 0, sizeof(cpu->arch.model_name)); + get_current_cpuid(&cpuid, 0x80000002); - temp = cpuid.regs.edx; cpuid.regs.edx = cpuid.regs.ecx; cpuid.regs.ecx = temp; + temp = cpuid.regs.edx; + cpuid.regs.edx = cpuid.regs.ecx; + cpuid.regs.ecx = temp; memcpy(cpu->arch.model_name, cpuid.as_chars, sizeof(cpuid.as_chars)); + get_current_cpuid(&cpuid, 0x80000003); - temp = cpuid.regs.edx; cpuid.regs.edx = cpuid.regs.ecx; cpuid.regs.ecx = temp; - memcpy(cpu->arch.model_name + 16, cpuid.as_chars, sizeof(cpuid.as_chars)); + temp = cpuid.regs.edx; + cpuid.regs.edx = cpuid.regs.ecx; + cpuid.regs.ecx = temp; + memcpy(cpu->arch.model_name + 16, cpuid.as_chars, + sizeof(cpuid.as_chars)); + get_current_cpuid(&cpuid, 0x80000004); - temp = cpuid.regs.edx; cpuid.regs.edx = cpuid.regs.ecx; cpuid.regs.ecx = temp; - memcpy(cpu->arch.model_name + 32, cpuid.as_chars, sizeof(cpuid.as_chars)); + temp = cpuid.regs.edx; + cpuid.regs.edx = cpuid.regs.ecx; + cpuid.regs.ecx = temp; + memcpy(cpu->arch.model_name + 32, cpuid.as_chars, + sizeof(cpuid.as_chars)); // some cpus return a right-justified string int32 i = 0; @@ -714,8 +727,10 @@ } } + ssize_t -arch_cpu_user_strlcpy(char *to, const char *from, size_t size, addr_t *faultHandler) +arch_cpu_user_strlcpy(char *to, const char *from, size_t size, + addr_t *faultHandler) { int fromLength = 0; addr_t oldFaultHandler = *faultHandler; @@ -817,7 +832,7 @@ arch_cpu_memory_read_barrier(void) { asm volatile ("lock;" : : : "memory"); - asm volatile ("addl $0,0(%%esp);" : : : "memory"); + asm volatile ("addl $0, 0(%%esp);" : : : "memory"); } @@ -825,6 +840,6 @@ arch_cpu_memory_write_barrier(void) { asm volatile ("lock;" : : : "memory"); - asm volatile ("addl $0,0(%%esp);" : : : "memory"); + asm volatile ("addl $0, 0(%%esp);" : : : "memory"); } From axeld at mail.berlios.de Wed Jun 17 12:00:27 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 17 Jun 2009 12:00:27 +0200 Subject: [Haiku-commits] r31079 - haiku/trunk/src/add-ons/kernel/network/protocols/ipv4 Message-ID: <200906171000.n5HA0Rok021230@sheep.berlios.de> Author: axeld Date: 2009-06-17 12:00:26 +0200 (Wed, 17 Jun 2009) New Revision: 31079 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31079&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp Log: * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2009-06-17 09:55:07 UTC (rev 31078) +++ haiku/trunk/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp 2009-06-17 10:00:26 UTC (rev 31079) @@ -96,34 +96,38 @@ }; class FragmentPacket { - public: - FragmentPacket(const ipv4_packet_key &key); - ~FragmentPacket(); +public: + FragmentPacket(const ipv4_packet_key &key); + ~FragmentPacket(); - status_t AddFragment(uint16 start, uint16 end, net_buffer *buffer, - bool lastFragment); - status_t Reassemble(net_buffer *to); + status_t AddFragment(uint16 start, uint16 end, + net_buffer *buffer, bool lastFragment); + status_t Reassemble(net_buffer *to); - bool IsComplete() const { return fReceivedLastFragment && fBytesLeft == 0; } + bool IsComplete() const + { return fReceivedLastFragment + && fBytesLeft == 0; } - static uint32 Hash(void *_packet, const void *_key, uint32 range); - static int Compare(void *_packet, const void *_key); - static int32 NextOffset() { return offsetof(FragmentPacket, fNext); } - static void StaleTimer(struct net_timer *timer, void *data); + static uint32 Hash(void *_packet, const void *_key, uint32 range); + static int Compare(void *_packet, const void *_key); + static int32 NextOffset() + { return offsetof(FragmentPacket, fNext); } + static void StaleTimer(struct net_timer *timer, void *data); - private: - FragmentPacket *fNext; - struct ipv4_packet_key fKey; - bool fReceivedLastFragment; - int32 fBytesLeft; - FragmentList fFragments; - net_timer fTimer; +private: + FragmentPacket *fNext; + struct ipv4_packet_key fKey; + bool fReceivedLastFragment; + int32 fBytesLeft; + FragmentList fFragments; + net_timer fTimer; }; -class RawSocket : public DoublyLinkedListLinkImpl, public DatagramSocket<> { - public: - RawSocket(net_socket *socket); +class RawSocket + : public DoublyLinkedListLinkImpl, public DatagramSocket<> { +public: + RawSocket(net_socket *socket); }; typedef DoublyLinkedList RawSocketList; @@ -152,7 +156,10 @@ struct ipv4_protocol : net_protocol { ipv4_protocol() - : multicast_filter(this) {} + : + multicast_filter(this) + { + } RawSocket *raw; uint8 service_type; @@ -301,7 +308,7 @@ status_t status = gBufferModule->merge(buffer, previous, false); TRACE(" merge previous: %s", strerror(status)); - if (status < B_OK) { + if (status != B_OK) { fFragments.Insert(next, previous); return status; } @@ -327,7 +334,7 @@ status_t status = gBufferModule->merge(buffer, next, true); TRACE(" merge next: %s", strerror(status)); - if (status < B_OK) { + if (status != B_OK) { fFragments.Insert((net_buffer *)previous->link.next, next); return status; } @@ -389,7 +396,7 @@ buffer = fragment; } else status = gBufferModule->merge(buffer, fragment, true); - if (status < B_OK) + if (status != B_OK) return status; } else buffer = fragment; @@ -484,8 +491,39 @@ #endif -/*! - Attempts to re-assemble fragmented packets. +static int +dump_ipv4_multicast(int argc, char *argv[]) +{ + MulticastState::Iterator it = sMulticastState->GetIterator(); + + while (it.HasNext()) { + IPv4GroupInterface *state = it.Next(); + + char addressBuffer[64]; + + kprintf("%p: group <%s, %s, %s {", state, state->Interface()->name, + print_address(&state->Address(), addressBuffer, + sizeof(addressBuffer)), + state->Mode() == IPv4GroupInterface::kExclude + ? "Exclude" : "Include"); + + int count = 0; + IPv4GroupInterface::AddressSet::Iterator it + = state->Sources().GetIterator(); + while (it.HasNext()) { + kprintf("%s%s", count > 0 ? ", " : "", print_address(&it.Next(), + addressBuffer, sizeof(addressBuffer))); + count++; + } + + kprintf("}> sock %p\n", state->Parent()->Socket()); + } + + return 0; +} + + +/*! Attempts to re-assemble fragmented packets. \return B_OK if everything went well; if it could reassemble the packet, \a _buffer will point to its buffer, otherwise, it will be \c NULL. \return various error codes if something went wrong (mostly B_NO_MEMORY) @@ -538,7 +576,8 @@ if (packet->IsComplete()) { hash_remove(sFragmentHash, packet); - // no matter if reassembling succeeds, we won't need this packet anymore + // no matter if reassembling succeeds, we won't need this packet + // anymore status = packet->Reassemble(buffer); delete packet; @@ -553,8 +592,7 @@ } -/*! - Fragments the incoming buffer and send all fragments via the specified +/*! Fragments the incoming buffer and send all fragments via the specified \a route. */ static status_t @@ -564,7 +602,7 @@ TRACE_SK(protocol, "SendFragments(%lu bytes, mtu %lu)", buffer->size, mtu); NetBufferHeaderReader originalHeader(buffer); - if (originalHeader.Status() < B_OK) + if (originalHeader.Status() != B_OK) return originalHeader.Status(); uint16 headerLength = originalHeader->HeaderLength(); @@ -576,12 +614,13 @@ if (headerBuffer == NULL) return B_NO_MEMORY; - // TODO we need to make sure ipv4_header is contiguous or - // use another construct. + // TODO: we need to make sure ipv4_header is contiguous or + // use another construct. NetBufferHeaderReader bufferHeader(headerBuffer); ipv4_header *header = &bufferHeader.Data(); - // adapt MTU to be a multiple of 8 (fragment offsets can only be specified this way) + // Adapt MTU to be a multiple of 8 (fragment offsets can only be specified + // this way) mtu -= headerLength; mtu &= ~7; TRACE(" adjusted MTU to %ld\n", mtu); @@ -596,7 +635,8 @@ header->fragment_offset = htons((lastFragment ? 0 : IP_MORE_FRAGMENTS) | (fragmentOffset >> 3)); header->checksum = 0; - header->checksum = gStackModule->checksum((uint8 *)header, headerLength); + header->checksum = gStackModule->checksum((uint8 *)header, + headerLength); // TODO: compute the checksum only for those parts that changed? TRACE(" send fragment of %ld bytes (%ld bytes left)\n", fragmentLength, bytesLeft); @@ -625,7 +665,7 @@ break; } - if (status < B_OK) { + if (status != B_OK) { gBufferModule->free(fragmentBuffer); break; } @@ -660,8 +700,8 @@ // as Multicast filters are installed with an IPv4 protocol // reference, we need to go and find the appropriate instance // related to the 'receiving protocol' with module 'module'. - net_protocol *proto = - state->Parent()->Socket()->socket->first_protocol; + net_protocol *proto + = state->Parent()->Socket()->socket->first_protocol; while (proto && proto->module != module) proto = proto->next; @@ -725,7 +765,7 @@ status_t status = intf->first_info->join_multicast(intf->first_protocol, fill_sockaddr_in(&groupAddr, state->Address())); - if (status < B_OK) + if (status != B_OK) return status; sMulticastState->Insert(state); @@ -761,7 +801,8 @@ if (module != NULL) return module; - if (gStackModule->get_domain_receiving_protocol(sDomain, protocol, &module) == B_OK) + if (gStackModule->get_domain_receiving_protocol(sDomain, protocol, + &module) == B_OK) sReceivingProtocol[protocol] = module; return module; @@ -826,13 +867,13 @@ if (option == IP_DROP_MEMBERSHIP || option == IP_DROP_SOURCE_MEMBERSHIP) return EADDRNOTAVAIL; - else - return EINVAL; + + return B_BAD_VALUE; } break; } - if (status < B_OK) + if (status != B_OK) return status; status = ipv4_delta_group(state, option, interface, sourceAddr); @@ -930,6 +971,32 @@ } +static status_t +get_int_option(void *target, size_t length, int value) +{ + if (length != sizeof(int)) + return B_BAD_VALUE; + + return user_memcpy(target, &value, sizeof(int)); +} + + +template static status_t +set_int_option(Type &target, const void *_value, size_t length) +{ + int value; + + if (length != sizeof(int)) + return B_BAD_VALUE; + + if (user_memcpy(&value, _value, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + target = value; + return B_OK; +} + + // #pragma mark - @@ -960,8 +1027,7 @@ } -/*! - Since open() is only called on the top level protocol, when we get here +/*! Since open() is only called on the top level protocol, when we get here it means we are on a SOCK_RAW socket. */ status_t @@ -974,7 +1040,7 @@ return B_NO_MEMORY; status_t status = raw->InitCheck(); - if (status < B_OK) { + if (status != B_OK) { delete raw; return status; } @@ -1029,32 +1095,6 @@ } -static status_t -get_int_option(void *target, size_t length, int value) -{ - if (length != sizeof(int)) - return B_BAD_VALUE; - - return user_memcpy(target, &value, sizeof(int)); -} - - -template static status_t -set_int_option(Type &target, const void *_value, size_t length) -{ - int value; - - if (length != sizeof(int)) - return B_BAD_VALUE; - - if (user_memcpy(&value, _value, sizeof(int)) < B_OK) - return B_BAD_ADDRESS; - - target = value; - return B_OK; -} - - status_t ipv4_control(net_protocol *_protocol, int level, int option, void *value, size_t *_length) @@ -1073,17 +1113,19 @@ ipv4_protocol *protocol = (ipv4_protocol *)_protocol; if (level == IPPROTO_IP) { - if (option == IP_HDRINCL) + if (option == IP_HDRINCL) { return get_int_option(value, *_length, (protocol->flags & IP_FLAG_HEADER_INCLUDED) != 0); - else if (option == IP_TTL) + } + if (option == IP_TTL) return get_int_option(value, *_length, protocol->time_to_live); - else if (option == IP_TOS) + if (option == IP_TOS) return get_int_option(value, *_length, protocol->service_type); - else if (IP_MULTICAST_TTL) + if (IP_MULTICAST_TTL) { return get_int_option(value, *_length, protocol->multicast_time_to_live); - else if (option == IP_ADD_MEMBERSHIP + } + if (option == IP_ADD_MEMBERSHIP || option == IP_DROP_MEMBERSHIP || option == IP_BLOCK_SOURCE || option == IP_UNBLOCK_SOURCE @@ -1095,14 +1137,14 @@ || option == MCAST_UNBLOCK_SOURCE || option == MCAST_JOIN_SOURCE_GROUP || option == MCAST_LEAVE_SOURCE_GROUP) { - // RFC 3678, Section 4.1: - // ``An error of EOPNOTSUPP is returned if these options are - // used with getsockopt().'' - return EOPNOTSUPP; - } else { - dprintf("IPv4::getsockopt(): get unknown option: %d\n", option); - return ENOPROTOOPT; + // RFC 3678, Section 4.1: + // ``An error of EOPNOTSUPP is returned if these options are + // used with getsockopt().'' + return EOPNOTSUPP; } + + dprintf("IPv4::getsockopt(): get unknown option: %d\n", option); + return ENOPROTOOPT; } return sSocketModule->get_option(protocol->socket, level, option, value, @@ -1121,69 +1163,74 @@ int headerIncluded; if (length != sizeof(int)) return B_BAD_VALUE; - if (user_memcpy(&headerIncluded, value, sizeof(headerIncluded)) < B_OK) + if (user_memcpy(&headerIncluded, value, sizeof(headerIncluded)) + != B_OK) return B_BAD_ADDRESS; if (headerIncluded) protocol->flags |= IP_FLAG_HEADER_INCLUDED; else protocol->flags &= ~IP_FLAG_HEADER_INCLUDED; + return B_OK; - } else if (option == IP_TTL) { + } + if (option == IP_TTL) return set_int_option(protocol->time_to_live, value, length); - } else if (option == IP_TOS) { + if (option == IP_TOS) return set_int_option(protocol->service_type, value, length); - } else if (option == IP_MULTICAST_TTL) { + if (option == IP_MULTICAST_TTL) { return set_int_option(protocol->multicast_time_to_live, value, length); - } else if (option == IP_ADD_MEMBERSHIP - || option == IP_DROP_MEMBERSHIP) { + } + if (option == IP_ADD_MEMBERSHIP || option == IP_DROP_MEMBERSHIP) { ip_mreq mreq; if (length != sizeof(ip_mreq)) return B_BAD_VALUE; - if (user_memcpy(&mreq, value, sizeof(ip_mreq)) < B_OK) + if (user_memcpy(&mreq, value, sizeof(ip_mreq)) != B_OK) return B_BAD_ADDRESS; return ipv4_delta_membership(protocol, option, &mreq.imr_interface, &mreq.imr_multiaddr, NULL); - } else if (option == IP_BLOCK_SOURCE + } + if (option == IP_BLOCK_SOURCE || option == IP_UNBLOCK_SOURCE || option == IP_ADD_SOURCE_MEMBERSHIP || option == IP_DROP_SOURCE_MEMBERSHIP) { ip_mreq_source mreq; if (length != sizeof(ip_mreq_source)) return B_BAD_VALUE; - if (user_memcpy(&mreq, value, sizeof(ip_mreq_source)) < B_OK) + if (user_memcpy(&mreq, value, sizeof(ip_mreq_source)) != B_OK) return B_BAD_ADDRESS; return ipv4_delta_membership(protocol, option, &mreq.imr_interface, &mreq.imr_multiaddr, &mreq.imr_sourceaddr); - } else if (option == MCAST_LEAVE_GROUP - || option == MCAST_JOIN_GROUP) { + } + if (option == MCAST_LEAVE_GROUP || option == MCAST_JOIN_GROUP) { group_req greq; if (length != sizeof(group_req)) return B_BAD_VALUE; - if (user_memcpy(&greq, value, sizeof(group_req)) < B_OK) + if (user_memcpy(&greq, value, sizeof(group_req)) != B_OK) return B_BAD_ADDRESS; return ipv4_generic_delta_membership(protocol, option, greq.gr_interface, &greq.gr_group, NULL); - } else if (option == MCAST_BLOCK_SOURCE + } + if (option == MCAST_BLOCK_SOURCE || option == MCAST_UNBLOCK_SOURCE || option == MCAST_JOIN_SOURCE_GROUP || option == MCAST_LEAVE_SOURCE_GROUP) { group_source_req greq; if (length != sizeof(group_source_req)) return B_BAD_VALUE; - if (user_memcpy(&greq, value, sizeof(group_source_req)) < B_OK) + if (user_memcpy(&greq, value, sizeof(group_source_req)) != B_OK) return B_BAD_ADDRESS; return ipv4_generic_delta_membership(protocol, option, greq.gsr_interface, &greq.gsr_group, &greq.gsr_source); - } else { - dprintf("IPv4::setsockopt(): set unknown option: %d\n", option); - return ENOPROTOOPT; } + + dprintf("IPv4::setsockopt(): set unknown option: %d\n", option); + return ENOPROTOOPT; } return sSocketModule->set_option(protocol->socket, level, option, @@ -1260,22 +1307,22 @@ if (destination.sin_addr.s_addr == INADDR_ANY) return EDESTADDRREQ; - else if ((interface->device->flags & IFF_BROADCAST) != 0 + + if ((interface->device->flags & IFF_BROADCAST) != 0 && (destination.sin_addr.s_addr == INADDR_BROADCAST || destination.sin_addr.s_addr == broadcastAddress.sin_addr.s_addr)) { if (protocol && !(protocol->socket->options & SO_BROADCAST)) return B_BAD_VALUE; buffer->flags |= MSG_BCAST; - } else if (IN_MULTICAST(ntohl(destination.sin_addr.s_addr))) { + } else if (IN_MULTICAST(ntohl(destination.sin_addr.s_addr))) buffer->flags |= MSG_MCAST; - } // Add IP header (if needed) if (!headerIncluded) { NetBufferPrepend header(buffer); - if (header.Status() < B_OK) + if (header.Status() != B_OK) return header.Status(); header->version = IP_VERSION; @@ -1284,13 +1331,15 @@ header->total_length = htons(buffer->size); header->id = htons(atomic_add(&sPacketID, 1)); header->fragment_offset = 0; - if (protocol) - header->time_to_live = (buffer->flags & MSG_MCAST) ? - protocol->multicast_time_to_live : protocol->time_to_live; - else - header->time_to_live = (buffer->flags & MSG_MCAST) ? - kDefaultMulticastTTL : kDefaultTTL; - header->protocol = protocol ? protocol->socket->protocol : buffer->protocol; + if (protocol) { + header->time_to_live = (buffer->flags & MSG_MCAST) + ? protocol->multicast_time_to_live : protocol->time_to_live; + } else { + header->time_to_live = (buffer->flags & MSG_MCAST) + ? kDefaultMulticastTTL : kDefaultTTL; + } + header->protocol = protocol + ? protocol->socket->protocol : buffer->protocol; header->checksum = 0; header->source = source.sin_addr.s_addr; @@ -1298,7 +1347,7 @@ } else { // if IP_HDRINCL, check if the source address is set NetBufferHeaderReader header(buffer); - if (header.Status() < B_OK) + if (header.Status() != B_OK) return header.Status(); if (header->source == 0) { @@ -1312,11 +1361,13 @@ if (buffer->size > 0xffff) return EMSGSIZE; - if (checksumNeeded) + if (checksumNeeded) { *IPChecksumField(buffer) = gBufferModule->checksum(buffer, 0, sizeof(ipv4_header), true); + } - TRACE_SK(protocol, " SendRoutedData(): header chksum: %ld, buffer checksum: %ld", + TRACE_SK(protocol, " SendRoutedData(): header chksum: %ld, buffer " + "checksum: %ld", gBufferModule->checksum(buffer, 0, sizeof(ipv4_header), true), gBufferModule->checksum(buffer, 0, buffer->size, true)); @@ -1342,7 +1393,7 @@ if (protocol && (protocol->flags & IP_FLAG_HEADER_INCLUDED)) { if (buffer->size < sizeof(ipv4_header)) - return EINVAL; + return B_BAD_VALUE; sockaddr_in *source = (sockaddr_in *)buffer->source; sockaddr_in *destination = (sockaddr_in *)buffer->destination; @@ -1422,7 +1473,7 @@ TRACE("ReceiveData(%p [%ld bytes])", buffer, buffer->size); NetBufferHeaderReader bufferHeader(buffer); - if (bufferHeader.Status() < B_OK) + if (bufferHeader.Status() != B_OK) return bufferHeader.Status(); ipv4_header &header = bufferHeader.Data(); @@ -1442,7 +1493,8 @@ return B_BAD_DATA; struct sockaddr_in &source = *(struct sockaddr_in *)buffer->source; - struct sockaddr_in &destination = *(struct sockaddr_in *)buffer->destination; + struct sockaddr_in &destination + = *(struct sockaddr_in *)buffer->destination; fill_sockaddr_in(&source, header.source); fill_sockaddr_in(&destination, header.destination); @@ -1472,7 +1524,7 @@ // remove any trailing/padding data status_t status = gBufferModule->trim(buffer, packetLength); - if (status < B_OK) + if (status != B_OK) return status; // check for fragmentation @@ -1509,7 +1561,7 @@ return EAFNOSUPPORT; } - if (buffer->flags & MSG_MCAST) { + if ((buffer->flags & MSG_MCAST) != 0) { // Unfortunely historical reasons dictate that the IP multicast // model be a little different from the unicast one. We deliver // this frame directly to all sockets registered with interest @@ -1548,37 +1600,6 @@ } -static int -dump_ipv4_multicast(int argc, char *argv[]) -{ - MulticastState::Iterator it = sMulticastState->GetIterator(); - - while (it.HasNext()) { - IPv4GroupInterface *state = it.Next(); - - char addrBuf[64]; - - kprintf("%p: group <%s, %s, %s {", state, state->Interface()->name, - print_address(&state->Address(), addrBuf, sizeof(addrBuf)), - state->Mode() == IPv4GroupInterface::kExclude ? "Exclude" : - "Include"); - - int count = 0; - IPv4GroupInterface::AddressSet::Iterator it = - state->Sources().GetIterator(); - while (it.HasNext()) { - kprintf("%s%s", count > 0 ? ", " : "", print_address(&it.Next(), - addrBuf, sizeof(addrBuf))); - count++; - } - - kprintf("}> sock %p\n", state->Parent()->Socket()); - } - - return 0; -} - - // #pragma mark - @@ -1601,7 +1622,7 @@ } status = sMulticastState->Init(); - if (status < B_OK) + if (status != B_OK) goto err5; sFragmentHash = hash_init(MAX_HASH_FRAGMENTS, FragmentPacket::NextOffset(), @@ -1616,12 +1637,12 @@ status = gStackModule->register_domain_protocols(AF_INET, SOCK_RAW, 0, "network/protocols/ipv4/v1", NULL); - if (status < B_OK) + if (status != B_OK) goto err6; status = gStackModule->register_domain(AF_INET, "internet", &gIPv4Module, &gIPv4AddressModule, &sDomain); - if (status < B_OK) + if (status != B_OK) goto err6; add_debugger_command("ipv4_multicast", dump_ipv4_multicast, From bonefish at mail.berlios.de Wed Jun 17 15:31:39 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 15:31:39 +0200 Subject: [Haiku-commits] r31080 - haiku/trunk/src/apps/debuganalyzer/gui/table Message-ID: <200906171331.n5HDVdHB016904@sheep.berlios.de> Author: bonefish Date: 2009-06-17 15:31:33 +0200 (Wed, 17 Jun 2009) New Revision: 31080 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31080&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h Log: * Renamed AbstractTableModel to AbstractTableModelBase. * Added listener support to TableModel. * Table does now listen to the model and adds/removes rows accordingly. Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp 2009-06-17 10:00:26 UTC (rev 31079) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp 2009-06-17 13:31:33 UTC (rev 31080) @@ -10,10 +10,10 @@ #include "table/TableColumn.h" -// #pragma mark - AbstractTableModel +// #pragma mark - AbstractTableModelBase -AbstractTableModel::~AbstractTableModel() +AbstractTableModelBase::~AbstractTableModelBase() { } Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-17 10:00:26 UTC (rev 31079) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-17 13:31:33 UTC (rev 31080) @@ -12,9 +12,9 @@ class TableColumn; -class AbstractTableModel { +class AbstractTableModelBase { public: - virtual ~AbstractTableModel(); + virtual ~AbstractTableModelBase(); virtual int32 CountColumns() const = 0; }; @@ -53,7 +53,7 @@ AbstractColumn(TableColumn* tableColumn); virtual ~AbstractColumn(); - virtual void SetModel(AbstractTableModel* model) = 0; + virtual void SetModel(AbstractTableModelBase* model) = 0; TableColumn* GetTableColumn() const { return fTableColumn; } Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-17 10:00:26 UTC (rev 31079) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-17 13:31:33 UTC (rev 31080) @@ -29,6 +29,28 @@ }; +// #pragma mark - TableModelListener + + +TableModelListener::~TableModelListener() +{ +} + + +void +TableModelListener::TableRowsAdded(TableModel* model, int32 rowIndex, + int32 count) +{ +} + + +void +TableModelListener::TableRowsRemoved(TableModel* model, int32 rowIndex, + int32 count) +{ +} + + // #pragma mark - TableModel @@ -37,6 +59,40 @@ } +void +TableModel::AddListener(TableModelListener* listener) +{ + fListeners.Add(listener); +} + + +void +TableModel::RemoveListener(TableModelListener* listener) +{ + fListeners.Remove(listener); +} + + +void +TableModel::NotifyRowsAdded(int32 rowIndex, int32 count) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + TableModelListener* listener = it.Next();) { + listener->TableRowsAdded(this, rowIndex, count); + } +} + + +void +TableModel::NotifyRowsRemoved(int32 rowIndex, int32 count) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + TableModelListener* listener = it.Next();) { + listener->TableRowsRemoved(this, rowIndex, count); + } +} + + // #pragma mark - TableListener @@ -60,7 +116,7 @@ TableColumn* tableColumn); virtual ~Column(); - virtual void SetModel(AbstractTableModel* model); + virtual void SetModel(AbstractTableModelBase* model); protected: virtual void DrawTitle(BRect rect, BView* targetView); @@ -91,7 +147,7 @@ void -Table::Column::SetModel(AbstractTableModel* model) +Table::Column::SetModel(AbstractTableModelBase* model) { fModel = dynamic_cast(model); } @@ -196,6 +252,8 @@ { for (int32 i = CountColumns() - 1; i >= 0; i--) RemoveColumn(ColumnAt(i)); + + // rows are deleted by the BColumnListView destructor automatically } @@ -206,6 +264,9 @@ return; if (fModel != NULL) { + fModel->RemoveListener(this); + + fRows.MakeEmpty(); Clear(); for (int32 i = 0; AbstractColumn* column = fColumns.ItemAt(i); i++) @@ -217,14 +278,44 @@ if (fModel == NULL) return; + fModel->AddListener(this); + for (int32 i = 0; AbstractColumn* column = fColumns.ItemAt(i); i++) column->SetModel(fModel); + TableRowsAdded(fModel, 0, fModel->CountRows()); +} + + +bool +Table::AddTableListener(TableListener* listener) +{ + return fListeners.AddItem(listener); +} + + +void +Table::RemoveTableListener(TableListener* listener) +{ + fListeners.RemoveItem(listener); +} + + +AbstractTable::AbstractColumn* +Table::CreateColumn(TableColumn* column) +{ + return new Column(fModel, column); +} + + +void +Table::TableRowsAdded(TableModel* model, int32 rowIndex, int32 count) +{ // create the rows - int32 rowCount = fModel->CountRows(); + int32 endRow = rowIndex + count; int32 columnCount = fModel->CountColumns(); - for (int32 i = 0; i < rowCount; i++) { + for (int32 i = rowIndex; i < endRow; i++) { // create row BRow* row = new(std::nothrow) BRow(); if (row == NULL) { @@ -247,32 +338,29 @@ } // add row - AddRow(row); + if (!fRows.AddItem(row, i)) { + // TODO: Report error! + delete row; + return; + } + + AddRow(row, i); } } -bool -Table::AddTableListener(TableListener* listener) -{ - return fListeners.AddItem(listener); -} - - void -Table::RemoveTableListener(TableListener* listener) +Table::TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count) { - fListeners.RemoveItem(listener); + for (int32 i = rowIndex + count - 1; i >= rowIndex; i--) { + if (BRow* row = fRows.RemoveItemAt(i)) { + RemoveRow(row); + delete row; + } + } } -AbstractTable::AbstractColumn* -Table::CreateColumn(TableColumn* column) -{ - return new Column(fModel, column); -} - - void Table::ItemInvoked() { Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-17 10:00:26 UTC (rev 31079) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-17 13:31:33 UTC (rev 31080) @@ -7,6 +7,9 @@ #include +#include +#include + #include "table/AbstractTable.h" #include "table/TableColumn.h" @@ -14,16 +17,41 @@ class Table; +class TableModel; -class TableModel : public AbstractTableModel { +class TableModelListener : public DoublyLinkedListLinkImpl { public: + virtual ~TableModelListener(); + + virtual void TableRowsAdded(TableModel* model, + int32 rowIndex, int32 count); + virtual void TableRowsRemoved(TableModel* model, + int32 rowIndex, int32 count); +}; + + +class TableModel : public AbstractTableModelBase { +public: virtual ~TableModel(); virtual int32 CountRows() const = 0; virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) = 0; + + virtual void AddListener(TableModelListener* listener); + virtual void RemoveListener(TableModelListener* listener); + +protected: + typedef DoublyLinkedList ListenerList; + +protected: + void NotifyRowsAdded(int32 rowIndex, int32 count); + void NotifyRowsRemoved(int32 rowIndex, int32 count); + +protected: + ListenerList fListeners; }; @@ -35,7 +63,7 @@ }; -class Table : public AbstractTable { +class Table : public AbstractTable, private TableModelListener { public: Table(const char* name, uint32 flags, border_style borderStyle = B_NO_BORDER, @@ -56,15 +84,23 @@ virtual AbstractColumn* CreateColumn(TableColumn* column); private: + virtual void TableRowsAdded(TableModel* model, + int32 rowIndex, int32 count); + virtual void TableRowsRemoved(TableModel* model, + int32 rowIndex, int32 count); + +private: class Column; typedef BObjectList ListenerList; + typedef BObjectList RowList; private: virtual void ItemInvoked(); private: TableModel* fModel; + RowList fRows; ListenerList fListeners; }; Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp 2009-06-17 10:00:26 UTC (rev 31079) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp 2009-06-17 13:31:33 UTC (rev 31080) @@ -60,7 +60,7 @@ TableColumn* tableColumn); virtual ~Column(); - virtual void SetModel(AbstractTableModel* model); + virtual void SetModel(AbstractTableModelBase* model); protected: virtual void DrawTitle(BRect rect, BView* targetView); @@ -91,7 +91,7 @@ void -TreeTable::Column::SetModel(AbstractTableModel* model) +TreeTable::Column::SetModel(AbstractTableModelBase* model) { fModel = dynamic_cast(model); } Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h 2009-06-17 10:00:26 UTC (rev 31079) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h 2009-06-17 13:31:33 UTC (rev 31080) @@ -16,7 +16,7 @@ class TreeTable; -class TreeTableModel : public AbstractTableModel { +class TreeTableModel : public AbstractTableModelBase { public: virtual ~TreeTableModel(); From bonefish at mail.berlios.de Wed Jun 17 15:34:35 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 15:34:35 +0200 Subject: [Haiku-commits] r31081 - haiku/trunk/src/apps/debugger Message-ID: <200906171334.n5HDYZOL017048@sheep.berlios.de> Author: bonefish Date: 2009-06-17 15:34:31 +0200 (Wed, 17 Jun 2009) New Revision: 31081 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31081&view=rev Modified: haiku/trunk/src/apps/debugger/Debugger.cpp Log: Removed some debug output. Modified: haiku/trunk/src/apps/debugger/Debugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Debugger.cpp 2009-06-17 13:31:33 UTC (rev 31080) +++ haiku/trunk/src/apps/debugger/Debugger.cpp 2009-06-17 13:34:31 UTC (rev 31081) @@ -77,8 +77,6 @@ parse_arguments(int argc, const char* const* argv, bool noOutput, Options& options) { -printf("parse_arguments(): argc: %d\n", argc); - optind = 1; while (true) { @@ -145,7 +143,6 @@ if (options.commandLineArgc > 0) exclusiveParams++; -printf("exclusiveParams: %d\n", exclusiveParams); if (exclusiveParams == 0) { // TODO: Support! if (noOutput) From bonefish at mail.berlios.de Wed Jun 17 15:35:30 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 15:35:30 +0200 Subject: [Haiku-commits] r31082 - haiku/trunk/src/apps/debugger Message-ID: <200906171335.n5HDZUDQ017231@sheep.berlios.de> Author: bonefish Date: 2009-06-17 15:35:27 +0200 (Wed, 17 Jun 2009) New Revision: 31082 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31082&view=rev Modified: haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h Log: New AddThread() method. Modified: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-17 13:34:31 UTC (rev 31081) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-17 13:35:27 UTC (rev 31082) @@ -73,6 +73,15 @@ } +status_t +Team::AddThread(thread_id threadID, Thread** _thread) +{ + thread_info threadInfo; + status_t error = get_thread_info(threadID, &threadInfo); + return error == B_OK ? AddThread(threadInfo, _thread) : error; +} + + void Team::RemoveThread(Thread* thread) { Modified: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-17 13:34:31 UTC (rev 31081) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-17 13:35:27 UTC (rev 31082) @@ -29,6 +29,8 @@ void AddThread(Thread* thread); status_t AddThread(const thread_info& threadInfo, Thread** _thread = NULL); + status_t AddThread(thread_id threadID, + Thread** _thread = NULL); void RemoveThread(Thread* thread); bool RemoveThread(thread_id threadID); Thread* ThreadByID(thread_id threadID) const; From bonefish at mail.berlios.de Wed Jun 17 15:40:15 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 15:40:15 +0200 Subject: [Haiku-commits] r31083 - haiku/trunk/src/apps/debugger Message-ID: <200906171340.n5HDeFer017624@sheep.berlios.de> Author: bonefish Date: 2009-06-17 15:40:10 +0200 (Wed, 17 Jun 2009) New Revision: 31083 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31083&view=rev Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h Log: * Init a debug context and set the team debug event flags. * Handle the "thread/image created/deleted" events, maintaining the Team's lists. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-17 13:35:27 UTC (rev 31082) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-17 13:40:10 UTC (rev 31083) @@ -3,7 +3,7 @@ CCFLAGS += -Werror ; C++FLAGS += -Werror ; -UsePrivateHeaders interface kernel shared ; +UsePrivateHeaders debug interface kernel shared ; UsePrivateSystemHeaders ; SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ; @@ -47,7 +47,7 @@ libcolumnlistview.a $(TARGET_LIBSTDC++) - be + be debug : Debugger.rdef ; Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-17 13:35:27 UTC (rev 31082) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-17 13:40:10 UTC (rev 31083) @@ -13,6 +13,8 @@ #include +#include "debug_utils.h" + #include "Team.h" @@ -82,8 +84,15 @@ if (fNubPort < 0) return fNubPort; -// TODO: Set the debug event flags! + // init debug context + error = init_debug_context(&fDebugContext, fTeamID, fNubPort); + if (error != B_OK) + return error; + // set team debugging flags + set_team_debugging_flags(fNubPort, + B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_IMAGES); + // get the initial state of the team AutoLocker< ::Team> teamLocker(fTeam); @@ -199,32 +208,48 @@ TeamDebugger::_HandleDebuggerMessage(int32 messageCode, const debug_debugger_message_data& message) { +printf("TeamDebugger::_HandleDebuggerMessage(): %ld\n", messageCode); + bool handled = false; + switch (messageCode) { case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: +printf("B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: thread: %ld\n", message.origin.thread); break; case B_DEBUGGER_MESSAGE_DEBUGGER_CALL: +printf("B_DEBUGGER_MESSAGE_DEBUGGER_CALL: thread: %ld\n", message.origin.thread); break; case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: +printf("B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: thread: %ld\n", message.origin.thread); break; case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: +printf("B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: thread: %ld\n", message.origin.thread); break; case B_DEBUGGER_MESSAGE_SINGLE_STEP: +printf("B_DEBUGGER_MESSAGE_SINGLE_STEP: thread: %ld\n", message.origin.thread); break; case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: +printf("B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: thread: %ld\n", message.origin.thread); break; case B_DEBUGGER_MESSAGE_TEAM_CREATED: +printf("B_DEBUGGER_MESSAGE_TEAM_CREATED: team: %ld\n", message.team_created.new_team); break; case B_DEBUGGER_MESSAGE_TEAM_DELETED: +printf("B_DEBUGGER_MESSAGE_TEAM_DELETED: team: %ld\n", message.origin.team); break; case B_DEBUGGER_MESSAGE_TEAM_EXEC: +printf("B_DEBUGGER_MESSAGE_TEAM_EXEC: team: %ld\n", message.origin.team); break; case B_DEBUGGER_MESSAGE_THREAD_CREATED: + handled = _HandleThreadCreated(message.thread_created); break; case B_DEBUGGER_MESSAGE_THREAD_DELETED: + handled = _HandleThreadDeleted(message.thread_deleted); break; case B_DEBUGGER_MESSAGE_IMAGE_CREATED: + handled = _HandleImageCreated(message.image_created); break; case B_DEBUGGER_MESSAGE_IMAGE_DELETED: + handled = _HandleImageDeleted(message.image_deleted); break; case B_DEBUGGER_MESSAGE_PRE_SYSCALL: case B_DEBUGGER_MESSAGE_POST_SYSCALL: @@ -238,4 +263,43 @@ "%ld\n", fTeamID, messageCode); break; } + + if (!handled && message.origin.thread >= 0 && message.origin.nub_port >= 0) + continue_thread(message.origin.nub_port, message.origin.thread); } + + +bool +TeamDebugger::_HandleThreadCreated(const debug_thread_created& message) +{ + AutoLocker< ::Team> locker(fTeam); + fTeam->AddThread(message.new_thread); + return false; +} + + +bool +TeamDebugger::_HandleThreadDeleted(const debug_thread_deleted& message) +{ + AutoLocker< ::Team> locker(fTeam); + fTeam->RemoveThread(message.origin.thread); + return false; +} + + +bool +TeamDebugger::_HandleImageCreated(const debug_image_created& message) +{ + AutoLocker< ::Team> locker(fTeam); + fTeam->AddImage(message.info); + return false; +} + + +bool +TeamDebugger::_HandleImageDeleted(const debug_image_deleted& message) +{ + AutoLocker< ::Team> locker(fTeam); + fTeam->RemoveImage(message.info.id); + return false; +} Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-17 13:35:27 UTC (rev 31082) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-17 13:40:10 UTC (rev 31083) @@ -8,6 +8,7 @@ #include #include +#include #include #include "TeamWindow.h" @@ -37,11 +38,21 @@ void _HandleDebuggerMessage(int32 messageCode, const debug_debugger_message_data& message); + bool _HandleThreadCreated( + const debug_thread_created& message); + bool _HandleThreadDeleted( + const debug_thread_deleted& message); + bool _HandleImageCreated( + const debug_image_created& message); + bool _HandleImageDeleted( + const debug_image_deleted& message); + private: ::Team* fTeam; team_id fTeamID; port_id fDebuggerPort; port_id fNubPort; + debug_context fDebugContext; thread_id fDebugEventListener; TeamWindow* fTeamWindow; volatile bool fTerminating; From bonefish at mail.berlios.de Wed Jun 17 15:46:13 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 17 Jun 2009 15:46:13 +0200 Subject: [Haiku-commits] r31084 - haiku/trunk/src/apps/debugger/gui/team_window Message-ID: <200906171346.n5HDkDHq018141@sheep.berlios.de> Author: bonefish Date: 2009-06-17 15:45:07 +0200 (Wed, 17 Jun 2009) New Revision: 31084 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31084&view=rev Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp Log: Use a less lazy method to update the threads list view (use the table model listener mechanism to inform about the exact changes instead of rebuilding the complete list). Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-17 13:40:10 UTC (rev 31083) +++ haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-17 13:45:07 UTC (rev 31084) @@ -43,23 +43,47 @@ bool Update() { - for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++) - thread->RemoveReference(); - fThreads.MakeEmpty(); + if (fTeam == NULL) { + for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++) + thread->RemoveReference(); + fThreads.MakeEmpty(); - if (fTeam == NULL) return true; + } AutoLocker locker(fTeam); - for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator(); - Thread* thread = it.Next();) { - if (!fThreads.AddItem(thread)) + ThreadList::ConstIterator it = fTeam->Threads().GetIterator(); + Thread* newThread = it.Next(); + int32 index = 0; + + // remove no longer existing threads + while (Thread* oldThread = fThreads.ItemAt(index)) { + if (oldThread == newThread) { + index++; + newThread = it.Next(); + } else { + // TODO: Not particularly efficient! + fThreads.RemoveItemAt(index); + oldThread->RemoveReference(); + NotifyRowsRemoved(index, 1); + } + } + + // add new threads + int32 countBefore = fThreads.CountItems(); + while (newThread != NULL) { + if (!fThreads.AddItem(newThread)) return false; - thread->AddReference(); + newThread->AddReference(); + newThread = it.Next(); } + int32 count = fThreads.CountItems(); + if (count > countBefore) + NotifyRowsAdded(countBefore, count - countBefore); + return true; } @@ -169,11 +193,8 @@ { switch (message->what) { case MSG_SYNC_THREAD_LIST: - if (fThreadsTableModel != NULL) { - fThreadsTable->SetTableModel(NULL); + if (fThreadsTableModel != NULL) fThreadsTableModel->Update(); - fThreadsTable->SetTableModel(fThreadsTableModel); - } break; default: BGroupView::MessageReceived(message); From axeld at mail.berlios.de Wed Jun 17 16:07:25 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 17 Jun 2009 16:07:25 +0200 Subject: [Haiku-commits] r31085 - haiku/trunk/src/kits/storage Message-ID: <200906171407.n5HE7Phh021303@sheep.berlios.de> Author: axeld Date: 2009-06-17 16:07:24 +0200 (Wed, 17 Jun 2009) New Revision: 31085 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31085&view=rev Modified: haiku/trunk/src/kits/storage/Directory.cpp Log: * create_directory() did not take the umask into account. Modified: haiku/trunk/src/kits/storage/Directory.cpp =================================================================== --- haiku/trunk/src/kits/storage/Directory.cpp 2009-06-17 13:45:07 UTC (rev 31084) +++ haiku/trunk/src/kits/storage/Directory.cpp 2009-06-17 14:07:24 UTC (rev 31085) @@ -980,7 +980,7 @@ return B_NOT_A_DIRECTORY; } else { // it doesn't exist -- create it - error = _kern_create_dir(-1, dirPath.Path(), mode); + error = _kern_create_dir(-1, dirPath.Path(), mode & ~__gUmask); if (error != B_OK) return error; } From axeld at mail.berlios.de Wed Jun 17 16:09:44 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Wed, 17 Jun 2009 16:09:44 +0200 Subject: [Haiku-commits] r31086 - in haiku/trunk: headers/private/libroot src/kits/storage src/system/libroot/posix/sys src/system/libroot/posix/unistd Message-ID: <200906171409.n5HE9iBU021485@sheep.berlios.de> Author: axeld Date: 2009-06-17 16:09:40 +0200 (Wed, 17 Jun 2009) New Revision: 31086 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31086&view=rev Added: haiku/trunk/headers/private/libroot/umask.h Modified: haiku/trunk/src/kits/storage/Directory.cpp haiku/trunk/src/kits/storage/File.cpp haiku/trunk/src/kits/storage/Jamfile haiku/trunk/src/system/libroot/posix/sys/Jamfile haiku/trunk/src/system/libroot/posix/sys/mkdir.c haiku/trunk/src/system/libroot/posix/sys/umask.c haiku/trunk/src/system/libroot/posix/unistd/open.c Log: * Added private header defining __gUmask which is now used everywhere where needed. * Some cleanup in Directory.cpp, and File.cpp. Added: haiku/trunk/headers/private/libroot/umask.h =================================================================== --- haiku/trunk/headers/private/libroot/umask.h 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/headers/private/libroot/umask.h 2009-06-17 14:09:40 UTC (rev 31086) @@ -0,0 +1,14 @@ +/* + * Copyright 2009, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ +#ifndef UMASK_H +#define UMASK_H + + +#include + + +extern mode_t __gUmask; + +#endif /* UMASK_H */ Modified: haiku/trunk/src/kits/storage/Directory.cpp =================================================================== --- haiku/trunk/src/kits/storage/Directory.cpp 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/kits/storage/Directory.cpp 2009-06-17 14:09:40 UTC (rev 31086) @@ -24,12 +24,9 @@ #include #include +#include -extern mode_t __gUmask; - // declared in sys/umask.c - - //! Creates an uninitialized BDirectory object. BDirectory::BDirectory() : @@ -41,7 +38,7 @@ /*! \brief Creates a copy of the supplied BDirectory. \param dir the BDirectory object to be copied */ -BDirectory::BDirectory(const BDirectory &dir) +BDirectory::BDirectory(const BDirectory& dir) : fDirFd(-1) { @@ -53,7 +50,7 @@ to by the supplied entry_ref. \param ref the entry_ref referring to the directory */ -BDirectory::BDirectory(const entry_ref *ref) +BDirectory::BDirectory(const entry_ref* ref) : fDirFd(-1) { @@ -65,7 +62,7 @@ to by the supplied node_ref. \param nref the node_ref referring to the directory */ -BDirectory::BDirectory(const node_ref *nref) +BDirectory::BDirectory(const node_ref* nref) : fDirFd(-1) { @@ -77,7 +74,7 @@ to by the supplied BEntry. \param entry the BEntry referring to the directory */ -BDirectory::BDirectory(const BEntry *entry) +BDirectory::BDirectory(const BEntry* entry) : fDirFd(-1) { @@ -89,7 +86,7 @@ to by the supplied path name. \param path the directory's path name */ -BDirectory::BDirectory(const char *path) +BDirectory::BDirectory(const char* path) : fDirFd(-1) { @@ -103,7 +100,7 @@ given \param path the directory's path name relative to \a dir */ -BDirectory::BDirectory(const BDirectory *dir, const char *path) +BDirectory::BDirectory(const BDirectory* dir, const char* path) : fDirFd(-1) { @@ -140,7 +137,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::SetTo(const entry_ref *ref) +BDirectory::SetTo(const entry_ref* ref) { // open node status_t error = _SetTo(ref, true); @@ -177,7 +174,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::SetTo(const node_ref *nref) +BDirectory::SetTo(const node_ref* nref) { Unset(); status_t error = (nref ? B_OK : B_BAD_VALUE); @@ -205,7 +202,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::SetTo(const BEntry *entry) +BDirectory::SetTo(const BEntry* entry) { if (!entry) { Unset(); @@ -249,7 +246,7 @@ - \c B_NOT_A_DIRECTORY: \a path includes a non-directory. */ status_t -BDirectory::SetTo(const char *path) +BDirectory::SetTo(const char* path) { // open node status_t error = _SetTo(-1, path, true); @@ -290,7 +287,7 @@ - \c B_NOT_A_DIRECTORY: \a path includes a non-directory. */ status_t -BDirectory::SetTo(const BDirectory *dir, const char *path) +BDirectory::SetTo(const BDirectory* dir, const char* path) { if (!dir || !path || BPrivate::Storage::is_absolute_path(path)) { Unset(); @@ -344,7 +341,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::GetEntry(BEntry *entry) const +BDirectory::GetEntry(BEntry* entry) const { if (!entry) return B_BAD_VALUE; @@ -402,24 +399,27 @@ function does. */ status_t -BDirectory::FindEntry(const char *path, BEntry *entry, bool traverse) const +BDirectory::FindEntry(const char* path, BEntry* entry, bool traverse) const { - status_t error = (path && entry ? B_OK : B_BAD_VALUE); - if (entry) + if (path == NULL || entry == NULL) + return B_BAD_VALUE; + + entry->Unset(); + + // init a potentially abstract entry + status_t status; + if (InitCheck() == B_OK) + status = entry->SetTo(this, path, traverse); + else + status = entry->SetTo(path, traverse); + + // fail, if entry is abstract + if (status == B_OK && !entry->Exists()) { + status = B_ENTRY_NOT_FOUND; entry->Unset(); - if (error == B_OK) { - // init a potentially abstract entry - if (InitCheck() == B_OK) - error = entry->SetTo(this, path, traverse); - else - error = entry->SetTo(path, traverse); - // fail, if entry is abstract - if (error == B_OK && !entry->Exists()) { - error = B_ENTRY_NOT_FOUND; - entry->Unset(); - } } - return error; + + return status; } @@ -449,7 +449,7 @@ - \c false, otherwise */ bool -BDirectory::Contains(const char *path, int32 nodeFlags) const +BDirectory::Contains(const char* path, int32 nodeFlags) const { // check initialization and parameters if (InitCheck() != B_OK) @@ -484,7 +484,7 @@ - \c false, otherwise */ bool -BDirectory::Contains(const BEntry *entry, int32 nodeFlags) const +BDirectory::Contains(const BEntry* entry, int32 nodeFlags) const { // check, if the entry exists at all if (entry == NULL || !entry->Exists() || InitCheck() != B_OK) @@ -522,7 +522,7 @@ } -/*! \fn status_t BDirectory::GetStatFor(const char *path, struct stat *st) const +/*! \fn status_t BDirectory::GetStatFor(const char* path, struct stat* st) const \brief Returns the stat structure of the entry referred to by the supplied path name. \param path the entry's path name. May be relative to this directory or @@ -563,7 +563,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::GetNextEntry(BEntry *entry, bool traverse) +BDirectory::GetNextEntry(BEntry* entry, bool traverse) { status_t error = (entry ? B_OK : B_BAD_VALUE); if (error == B_OK) { @@ -596,7 +596,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::GetNextRef(entry_ref *ref) +BDirectory::GetNextRef(entry_ref* ref) { status_t error = (ref ? B_OK : B_BAD_VALUE); if (error == B_OK && InitCheck() != B_OK) @@ -643,7 +643,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ int32 -BDirectory::GetNextDirents(dirent *buf, size_t bufSize, int32 count) +BDirectory::GetNextDirents(dirent* buf, size_t bufSize, int32 count) { if (!buf) return B_BAD_VALUE; @@ -725,7 +725,7 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::CreateDirectory(const char *path, BDirectory *dir) +BDirectory::CreateDirectory(const char* path, BDirectory* dir) { if (!path) return B_BAD_VALUE; @@ -774,15 +774,16 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::CreateFile(const char *path, BFile *file, bool failIfExists) +BDirectory::CreateFile(const char* path, BFile* file, bool failIfExists) { if (!path) return B_BAD_VALUE; + // Let BFile do the dirty job. uint32 openMode = B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE | (failIfExists ? B_FAIL_IF_EXISTS : 0); BFile tmpFile; - BFile *realFile = file ? file : &tmpFile; + BFile* realFile = file ? file : &tmpFile; status_t error = B_OK; if (InitCheck() == B_OK && !BPrivate::Storage::is_absolute_path(path)) error = realFile->SetTo(this, path, openMode); @@ -814,8 +815,8 @@ - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t -BDirectory::CreateSymLink(const char *path, const char *linkToPath, - BSymLink *link) +BDirectory::CreateSymLink(const char* path, const char* linkToPath, + BSymLink* link) { if (!path || !linkToPath) return B_BAD_VALUE; @@ -843,8 +844,8 @@ \param dir the original BDirectory \return a reference to this BDirectory */ -BDirectory & -BDirectory::operator=(const BDirectory &dir) +BDirectory& +BDirectory::operator=(const BDirectory& dir) { if (&dir != this) { // no need to assign us to ourselves Unset(); @@ -856,7 +857,7 @@ status_t -BDirectory::_GetStatFor(const char *path, struct stat *st) const +BDirectory::_GetStatFor(const char* path, struct stat* st) const { if (!st) return B_BAD_VALUE; @@ -873,7 +874,7 @@ status_t -BDirectory::_GetStatFor(const char *path, struct stat_beos *st) const +BDirectory::_GetStatFor(const char* path, struct stat_beos* st) const { struct stat newStat; status_t error = _GetStatFor(path, &newStat); @@ -940,10 +941,11 @@ \todo Check for efficency. */ status_t -create_directory(const char *path, mode_t mode) +create_directory(const char* path, mode_t mode) { if (!path) return B_BAD_VALUE; + // That's the strategy: We start with the first component of the supplied // path, create a BPath object from it and successively add the following // components. Each time we get a new path, we check, if the entry it @@ -951,7 +953,7 @@ // to create it. This goes on, until we're done with the input path or // an error occurs. BPath dirPath; - char *component; + char* component; int32 nextComponent; do { // get the next path component @@ -959,6 +961,7 @@ component, nextComponent); if (error != B_OK) return error; + // append it to the BPath if (dirPath.InitCheck() == B_NO_INIT) // first component error = dirPath.SetTo(component); @@ -968,11 +971,13 @@ if (error != B_OK) return error; path += nextComponent; + // create a BEntry from the BPath BEntry entry; error = entry.SetTo(dirPath.Path(), true); if (error != B_OK) return error; + // check, if it exists if (entry.Exists()) { // yep, it exists Modified: haiku/trunk/src/kits/storage/File.cpp =================================================================== --- haiku/trunk/src/kits/storage/File.cpp 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/kits/storage/File.cpp 2009-06-17 14:09:40 UTC (rev 31086) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Haiku Inc. + * Copyright 2002-2009, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -19,17 +19,13 @@ #include "storage_support.h" #include +#include -extern mode_t __gUmask; - // declared in sys/umask.c - - //! Creates an uninitialized BFile. BFile::BFile() - : BNode(), - BPositionIO(), - fMode(0) + : + fMode(0) { } @@ -39,9 +35,8 @@ \param file the BFile object to be copied */ BFile::BFile(const BFile &file) - : BNode(), - BPositionIO(), - fMode(0) + : + fMode(0) { *this = file; } @@ -54,9 +49,8 @@ \see SetTo() for values for \a openMode */ BFile::BFile(const entry_ref *ref, uint32 openMode) - : BNode(), - BPositionIO(), - fMode(0) + : + fMode(0) { SetTo(ref, openMode); } @@ -69,9 +63,8 @@ \see SetTo() for values for \a openMode */ BFile::BFile(const BEntry *entry, uint32 openMode) - : BNode(), - BPositionIO(), - fMode(0) + : + fMode(0) { SetTo(entry, openMode); } @@ -84,9 +77,8 @@ \see SetTo() for values for \a openMode */ BFile::BFile(const char *path, uint32 openMode) - : BNode(), - BPositionIO(), - fMode(0) + : + fMode(0) { SetTo(path, openMode); } @@ -102,9 +94,8 @@ \see SetTo() for values for \a openMode */ BFile::BFile(const BDirectory *dir, const char *path, uint32 openMode) - : BNode(), - BPositionIO(), - fMode(0) + : + fMode(0) { SetTo(dir, path, openMode); } Modified: haiku/trunk/src/kits/storage/Jamfile =================================================================== --- haiku/trunk/src/kits/storage/Jamfile 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/kits/storage/Jamfile 2009-06-17 14:09:40 UTC (rev 31086) @@ -4,7 +4,7 @@ UseLibraryHeaders icon ; -UsePrivateHeaders shared app storage ; +UsePrivateHeaders app libroot shared storage ; UsePrivateSystemHeaders ; # for libbe_test Modified: haiku/trunk/src/system/libroot/posix/sys/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/Jamfile 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/system/libroot/posix/sys/Jamfile 2009-06-17 14:09:40 UTC (rev 31086) @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src system libroot posix sys ; -UsePrivateHeaders shared ; +UsePrivateHeaders libroot shared ; UsePrivateSystemHeaders ; MergeObject posix_sys.o : Modified: haiku/trunk/src/system/libroot/posix/sys/mkdir.c =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/mkdir.c 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/system/libroot/posix/sys/mkdir.c 2009-06-17 14:09:40 UTC (rev 31086) @@ -1,18 +1,16 @@ /* - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #include -#include #include +#include +#include -extern mode_t __gUmask; - // declared in sys/umask.c - #define RETURN_AND_SET_ERRNO(err) \ if (err < 0) { \ errno = err; \ Modified: haiku/trunk/src/system/libroot/posix/sys/umask.c =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/umask.c 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/system/libroot/posix/sys/umask.c 2009-06-17 14:09:40 UTC (rev 31086) @@ -1,14 +1,16 @@ /* -** Copyright 2004, Axel D?rfler, axeld at pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ + * Copyright 2004-2009, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ #include -#include #include +#include +#include + mode_t __gUmask = 022; // this must be made available to open() and friends Modified: haiku/trunk/src/system/libroot/posix/unistd/open.c =================================================================== --- haiku/trunk/src/system/libroot/posix/unistd/open.c 2009-06-17 14:07:24 UTC (rev 31085) +++ haiku/trunk/src/system/libroot/posix/unistd/open.c 2009-06-17 14:09:40 UTC (rev 31086) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001, Manuel J. Petit. All rights reserved. @@ -13,16 +13,14 @@ #include #include +#include -extern mode_t __gUmask; - // declared in sys/umask.c - - int creat(const char *path, mode_t mode) { - int status = _kern_open(-1, path, O_CREAT | O_TRUNC | O_WRONLY, mode & ~__gUmask); + int status = _kern_open(-1, path, O_CREAT | O_TRUNC | O_WRONLY, + mode & ~__gUmask); // adapt the permissions as required by POSIX if (status < 0) { errno = status; From bonefish at mail.berlios.de Wed Jun 17 16:18:55 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 17 Jun 2009 16:18:55 +0200 Subject: [Haiku-commits] r31087 - in haiku/trunk/src/apps/debugger: . gui/team_window Message-ID: <200906171418.n5HEItkd022189@sheep.berlios.de> Author: bonefish Date: 2009-06-17 16:18:55 +0200 (Wed, 17 Jun 2009) New Revision: 31087 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31087&view=rev Added: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h Log: * Added ImageListView showing the list of images. It will probably eventually become a tree view, showing the source files as subitems of the images. * Added the image list to the team window and changed the layout more towards what it's intended to look like. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-17 14:09:40 UTC (rev 31086) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-17 14:18:55 UTC (rev 31087) @@ -28,6 +28,7 @@ Variant.cpp # gui/team_window + ImageListView.cpp TeamWindow.cpp ThreadListView.cpp Added: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-17 14:09:40 UTC (rev 31086) +++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-17 14:18:55 UTC (rev 31087) @@ -0,0 +1,244 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "ImageListView.h" + +#include + +#include + +#include +#include + +#include +#include + +#include "table/TableColumns.h" + + +enum { + MSG_SYNC_IMAGE_LIST = 'sytl' +}; + + +// #pragma mark - ImagesTableModel + + +class ImageListView::ImagesTableModel : public TableModel { +public: + ImagesTableModel(Team* team) + : + fTeam(team) + { + Update(); + } + + ~ImagesTableModel() + { + fTeam = NULL; + Update(); + } + + bool Update() + { + if (fTeam == NULL) { + for (int32 i = 0; Image* image = fImages.ItemAt(i); i++) + image->RemoveReference(); + fImages.MakeEmpty(); + + return true; + } + + AutoLocker locker(fTeam); + + ImageList::ConstIterator it = fTeam->Images().GetIterator(); + Image* newImage = it.Next(); + int32 index = 0; + + // remove no longer existing images + while (Image* oldImage = fImages.ItemAt(index)) { + if (oldImage == newImage) { + index++; + newImage = it.Next(); + } else { + // TODO: Not particularly efficient! + fImages.RemoveItemAt(index); + oldImage->RemoveReference(); + NotifyRowsRemoved(index, 1); + } + } + + // add new images + int32 countBefore = fImages.CountItems(); + while (newImage != NULL) { + if (!fImages.AddItem(newImage)) + return false; + + newImage->AddReference(); + newImage = it.Next(); + } + + int32 count = fImages.CountItems(); + if (count > countBefore) + NotifyRowsAdded(countBefore, count - countBefore); + + return true; + } + + virtual int32 CountColumns() const + { + return 2; + } + + virtual int32 CountRows() const + { + return fImages.CountItems(); + } + + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + { + Image* image = fImages.ItemAt(rowIndex); + if (image == NULL) + return false; + + switch (columnIndex) { + case 0: + value.SetTo(image->ID()); + return true; + case 1: + value.SetTo(image->Name(), VARIANT_DONT_COPY_DATA); + return true; + default: + return false; + } + } + + Image* ImageAt(int32 index) const + { + return fImages.ItemAt(index); + } + +private: + Team* fTeam; + BObjectList fImages; +}; + + +// #pragma mark - ImageListView + + +ImageListView::ImageListView() + : + BGroupView(B_VERTICAL), + fTeam(NULL), + fImagesTable(NULL), + fImagesTableModel(NULL) +{ + SetName("Images"); +} + + +ImageListView::~ImageListView() +{ + SetTeam(NULL); + fImagesTable->SetTableModel(NULL); + delete fImagesTableModel; +} + + +/*static*/ ImageListView* +ImageListView::Create() +{ + ImageListView* self = new ImageListView; + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; +} + + +void +ImageListView::SetTeam(Team* team) +{ + if (team == fTeam) + return; + + if (fTeam != NULL) { + fTeam->RemoveListener(this); + fImagesTable->SetTableModel(NULL); + delete fImagesTableModel; + fImagesTableModel = NULL; + } + + fTeam = team; + + if (fTeam != NULL) { + fImagesTableModel = new(std::nothrow) ImagesTableModel(fTeam); + fImagesTable->SetTableModel(fImagesTableModel); + fImagesTable->ResizeAllColumnsToPreferred(); + fTeam->AddListener(this); + } +} + + +void +ImageListView::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_SYNC_IMAGE_LIST: + if (fImagesTableModel != NULL) + fImagesTableModel->Update(); + break; + default: + BGroupView::MessageReceived(message); + break; + } +} + + +void +ImageListView::ImageAdded(Team* team, Image* image) +{ + Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this); +} + + +void +ImageListView::ImageRemoved(Team* team, Image* image) +{ + Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this); +} + + +void +ImageListView::TableRowInvoked(Table* table, int32 rowIndex) +{ +// if (fImagesTableModel != NULL) { +// Image* image = fImagesTableModel->ImageAt(rowIndex); +// if (image != NULL) +// fParent->OpenImageWindow(image); +// } +} + + +void +ImageListView::_Init() +{ + fImagesTable = new Table("images list", 0); + AddChild(fImagesTable->ToView()); + + // columns + fImagesTable->AddColumn(new Int32TableColumn(0, "ID", 40, 20, 1000, + B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT)); + fImagesTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_LEFT)); + + fImagesTable->AddTableListener(this); +} Added: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h 2009-06-17 14:09:40 UTC (rev 31086) +++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h 2009-06-17 14:18:55 UTC (rev 31087) @@ -0,0 +1,47 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef IMAGE_LIST_VIEW_H +#define IMAGE_LIST_VIEW_H + +#include + +#include "table/Table.h" +#include "Team.h" + + +class ImageListView : public BGroupView, private Team::Listener, + private TableListener { +public: + ImageListView(); + ~ImageListView(); + + static ImageListView* Create(); + // throws + + void SetTeam(Team* team); + + virtual void MessageReceived(BMessage* message); + +private: + class ImagesTableModel; + +private: + // Team::Listener + virtual void ImageAdded(Team* team, Image* image); + virtual void ImageRemoved(Team* team, Image* image); + + // TableListener + virtual void TableRowInvoked(Table* table, int32 rowIndex); + + void _Init(); + +private: + Team* fTeam; + Table* fImagesTable; + ImagesTableModel* fImagesTableModel; +}; + + +#endif // IMAGE_LIST_VIEW_H Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-17 14:09:40 UTC (rev 31086) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-17 14:18:55 UTC (rev 31087) @@ -8,7 +8,10 @@ #include #include #include +#include +#include +#include "ImageListView.h" #include "Team.h" #include "ThreadListView.h" @@ -18,12 +21,13 @@ TeamWindow::TeamWindow(::Team* team, Listener* listener) : - BWindow(BRect(100, 100, 399, 299), _GetWindowTitle(team).String(), + BWindow(BRect(100, 100, 699, 499), _GetWindowTitle(team).String(), B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), fTeam(team), fListener(listener), fTabView(NULL), - fThreadListView(NULL) + fThreadListView(NULL), + fImageListView(NULL) { } @@ -83,16 +87,26 @@ BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); SetLayout(rootLayout); + BSplitView* mainSplitView = new BSplitView(B_VERTICAL, 3.0f); + BGroupLayoutBuilder(rootLayout) + .Add(mainSplitView); + fTabView = new BTabView("tab view"); + mainSplitView->AddChild(fTabView, 0.4f); - BGroupLayoutBuilder(rootLayout) - .Add(fTabView); - fTabView->AddTab(fThreadListView = ThreadListView::Create()); // fTabView->AddTab(fTeamsPage = new TeamsPage(this)); // fTabView->AddTab(fThreadsPage = new ThreadsPage(this)); + BSplitView* imageAndSourceSplitView = new BSplitView(B_HORIZONTAL, 3.0f); + mainSplitView->AddChild(imageAndSourceSplitView); + + fImageListView = ImageListView::Create(); + imageAndSourceSplitView->AddChild(fImageListView); + imageAndSourceSplitView->AddChild(new BTextView("source view"), 2.0f); + fThreadListView->SetTeam(fTeam); + fImageListView->SetTeam(fTeam); } Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-17 14:09:40 UTC (rev 31086) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-17 14:18:55 UTC (rev 31087) @@ -10,6 +10,7 @@ class BTabView; +class ImageListView; class Team; class ThreadListView; @@ -37,6 +38,7 @@ Listener* fListener; BTabView* fTabView; ThreadListView* fThreadListView; + ImageListView* fImageListView; }; From axeld at mail.berlios.de Wed Jun 17 16:56:59 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Wed, 17 Jun 2009 16:56:59 +0200 Subject: [Haiku-commits] r31088 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906171456.n5HEuxXB026004@sheep.berlios.de> Author: axeld Date: 2009-06-17 16:56:57 +0200 (Wed, 17 Jun 2009) New Revision: 31088 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31088&view=rev Modified: haiku/trunk/headers/os/interface/OutlineListView.h haiku/trunk/src/kits/interface/OutlineListView.cpp Log: * Added layout-friendly constructor. * Reordered functions to match the order in the header (and vice versa). * Removed unused private functions. * Updated the header to follow our coding style. * Cleanup. Modified: haiku/trunk/headers/os/interface/OutlineListView.h =================================================================== --- haiku/trunk/headers/os/interface/OutlineListView.h 2009-06-17 14:18:55 UTC (rev 31087) +++ haiku/trunk/headers/os/interface/OutlineListView.h 2009-06-17 14:56:57 UTC (rev 31088) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _OUTLINE_LIST_VIEW_H @@ -12,129 +12,131 @@ class BOutlineListView : public BListView { - public: +public: BOutlineListView(BRect frame, const char* name, list_view_type type = B_SINGLE_SELECTION_LIST, - uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, + uint32 resizeMode + = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); + BOutlineListView(const char* name, + list_view_type type = B_SINGLE_SELECTION_LIST, + uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS + | B_NAVIGABLE); BOutlineListView(BMessage* archive); - virtual ~BOutlineListView(); + virtual ~BOutlineListView(); - static BArchivable* Instantiate(BMessage* archive); - virtual status_t Archive(BMessage* archive, bool deep = true) const; + static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* archive, bool deep = true) const; - virtual void MouseDown(BPoint where); - virtual void KeyDown(const char* bytes, int32 numBytes); - virtual void FrameMoved(BPoint newPosition); - virtual void FrameResized(float newWidth, float newHeight); - virtual void MouseUp(BPoint where); + virtual void MouseDown(BPoint where); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void FrameMoved(BPoint newPosition); + virtual void FrameResized(float newWidth, float newHeight); + virtual void MouseUp(BPoint where); - virtual bool AddUnder(BListItem* item, BListItem* underItem); + virtual bool AddUnder(BListItem* item, BListItem* underItem); - virtual bool AddItem(BListItem* item); - virtual bool AddItem(BListItem* item, int32 fullListIndex); - virtual bool AddList(BList* newItems); - virtual bool AddList(BList* newItems, int32 fullListIndex); + virtual bool AddItem(BListItem* item); + virtual bool AddItem(BListItem* item, int32 fullListIndex); + virtual bool AddList(BList* newItems); + virtual bool AddList(BList* newItems, int32 fullListIndex); - virtual bool RemoveItem(BListItem* item); - virtual BListItem* RemoveItem(int32 fullListIndex); - virtual bool RemoveItems(int32 fullListIndex, int32 count); + virtual bool RemoveItem(BListItem* item); + virtual BListItem* RemoveItem(int32 fullListIndex); + virtual bool RemoveItems(int32 fullListIndex, int32 count); - BListItem* FullListItemAt(int32 fullListIndex) const; - int32 FullListIndexOf(BPoint point) const; - int32 FullListIndexOf(BListItem* item) const; - BListItem* FullListFirstItem() const; - BListItem* FullListLastItem() const; - bool FullListHasItem(BListItem* item) const; - int32 FullListCountItems() const; - int32 FullListCurrentSelection(int32 index = 0) const; + BListItem* FullListItemAt(int32 fullListIndex) const; + int32 FullListIndexOf(BPoint point) const; + int32 FullListIndexOf(BListItem* item) const; + BListItem* FullListFirstItem() const; + BListItem* FullListLastItem() const; + bool FullListHasItem(BListItem* item) const; + int32 FullListCountItems() const; + int32 FullListCurrentSelection(int32 index = 0) const; - virtual void MakeEmpty(); - bool FullListIsEmpty() const; - void FullListDoForEach(bool (*func)(BListItem* item)); - void FullListDoForEach(bool (*func)(BListItem* item, void *), void*); + virtual void MakeEmpty(); + bool FullListIsEmpty() const; + void FullListDoForEach(bool (*func)(BListItem* item)); + void FullListDoForEach( + bool (*func)(BListItem* item, void*), void*); - BListItem* Superitem(const BListItem* item); + BListItem* Superitem(const BListItem* item); - void Expand(BListItem* item); - void Collapse(BListItem* item); + void Expand(BListItem* item); + void Collapse(BListItem* item); - bool IsExpanded(int32 fullListIndex); + bool IsExpanded(int32 fullListIndex); - virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 what, const char* property); - virtual status_t GetSupportedSuites(BMessage* data); - virtual status_t Perform(perform_code d, void* arg); + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, + const char* property); + virtual status_t GetSupportedSuites(BMessage* data); + virtual status_t Perform(perform_code d, void* arg); - virtual void ResizeToPreferred(); - virtual void GetPreferredSize(float* _width, float* _height); - virtual void MakeFocus(bool focus = true); - virtual void AllAttached(); - virtual void AllDetached(); - virtual void DetachedFromWindow(); + virtual void ResizeToPreferred(); + virtual void GetPreferredSize(float* _width, float* _height); + virtual void MakeFocus(bool focus = true); + virtual void AllAttached(); + virtual void AllDetached(); + virtual void DetachedFromWindow(); - void FullListSortItems(int (*compareFunc)(const BListItem* first, - const BListItem* second)); - void SortItemsUnder(BListItem* underItem, bool oneLevelOnly, - int (*compareFunc)(const BListItem* first, - const BListItem* second)); - int32 CountItemsUnder(BListItem* under, bool oneLevelOnly) const; - BListItem* EachItemUnder(BListItem* underItem, bool oneLevelOnly, - BListItem* (*eachFunc)(BListItem* item, void* arg), - void* arg); - BListItem* ItemUnderAt(BListItem* underItem, bool oneLevelOnly, + void FullListSortItems(int (*compareFunc)( + const BListItem* first, + const BListItem* second)); + void SortItemsUnder(BListItem* underItem, + bool oneLevelOnly, int (*compareFunc)( + const BListItem* first, + const BListItem* second)); + int32 CountItemsUnder(BListItem* under, + bool oneLevelOnly) const; + BListItem* EachItemUnder(BListItem* underItem, + bool oneLevelOnly, BListItem* (*eachFunc)( + BListItem* item, void* arg), void* arg); + BListItem* ItemUnderAt(BListItem* underItem, bool oneLevelOnly, int32 index) const; - protected: - virtual bool DoMiscellaneous(MiscCode code, MiscData* data); - virtual void MessageReceived(BMessage *message); +protected: + virtual bool DoMiscellaneous(MiscCode code, MiscData* data); + virtual void MessageReceived(BMessage* message); - private: - virtual void _ReservedOutlineListView1(); - virtual void _ReservedOutlineListView2(); - virtual void _ReservedOutlineListView3(); - virtual void _ReservedOutlineListView4(); +private: + virtual void _ReservedOutlineListView1(); + virtual void _ReservedOutlineListView2(); + virtual void _ReservedOutlineListView3(); + virtual void _ReservedOutlineListView4(); - typedef BListView _inherited; +protected: + virtual void ExpandOrCollapse(BListItem* underItem, bool expand); + virtual BRect LatchRect(BRect itemRect, int32 level) const; + virtual void DrawLatch(BRect itemRect, int32 level, + bool collapsed, bool highlighted, + bool misTracked); + virtual void DrawItem(BListItem* item, BRect itemRect, + bool complete = false); - int32 FullListIndex(int32 index) const; - int32 ListViewIndex(int32 index) const; +private: + int32 _FullListIndex(int32 index) const; - protected: - virtual void ExpandOrCollapse(BListItem* underItem, bool expand); - virtual BRect LatchRect(BRect itemRect, int32 level) const; - virtual void DrawLatch(BRect itemRect, int32 level, bool collapsed, - bool highlighted, bool misTracked); - virtual void DrawItem(BListItem* item, BRect itemRect, bool complete = false); - - private: - void _PopulateTree(BList* tree, BList& target, + void _PopulateTree(BList* tree, BList& target, int32& firstIndex, bool onlyVisible); - void _SortTree(BList* tree, bool oneLevelOnly, - int (*compareFunc)(const BListItem* a, const BListItem* b)); - void _DestructTree(BList* tree); - BList* _BuildTree(BListItem* underItem, int32& index); + void _SortTree(BList* tree, bool oneLevelOnly, + int (*compareFunc)(const BListItem* a, + const BListItem* b)); + void _DestructTree(BList* tree); + BList* _BuildTree(BListItem* underItem, int32& index); - BListItem* _RemoveItem(BListItem* item, int32 fullListIndex); - bool _SwapItems(int32 first, int32 second); - void _CullInvisibleItems(BList &list); - BListItem* RemoveOne(int32 fullListIndex); + void _CullInvisibleItems(BList &list); + bool _SwapItems(int32 first, int32 second); + BListItem* _RemoveItem(BListItem* item, int32 fullListIndex); - static void TrackInLatchItem(void *); - static void TrackOutLatchItem(void *); - - bool OutlineSwapItems(int32 a, int32 b); - bool OutlineMoveItem(int32 from, int32 to); - bool OutlineReplaceItem(int32 index, BListItem* item); - void CommonMoveItems(int32 from, int32 count, int32 to); - BListItem* _SuperitemForIndex(int32 fullListIndex, int32 level, + BListItem* _SuperitemForIndex(int32 fullListIndex, int32 level, int32* _superIndex = NULL); - int32 _FindPreviousVisibleIndex(int32 fullListIndex); + int32 _FindPreviousVisibleIndex(int32 fullListIndex); - private: - BList fFullList; - uint32 _reserved[2]; +private: + BList fFullList; + uint32 _reserved[2]; }; #endif // _OUTLINE_LIST_VIEW_H Modified: haiku/trunk/src/kits/interface/OutlineListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/OutlineListView.cpp 2009-06-17 14:18:55 UTC (rev 31087) +++ haiku/trunk/src/kits/interface/OutlineListView.cpp 2009-06-17 14:56:57 UTC (rev 31088) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Haiku Inc. + * Copyright 2001-2009, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -12,34 +12,69 @@ //! BOutlineListView represents a "nestable" list view. #include -#include +#include + #include #include -#include +#include #include -const float kLatchHeight = 8.0f; -const float kLatchWidth = 4.0f; +typedef int (*compare_func)(const BListItem* a, const BListItem* b); struct ListItemComparator { - ListItemComparator(int (*compareFunc)(const BListItem *, const BListItem *)) - : fCompareFunc(compareFunc) + ListItemComparator(compare_func compareFunc) + : + fCompareFunc(compareFunc) { } - bool operator()(const BListItem *a, const BListItem *b) const + bool operator()(const BListItem* a, const BListItem* b) const { return fCompareFunc(a, b) < 0; } private: - int (*fCompareFunc)(const BListItem *, const BListItem *); + compare_func fCompareFunc; }; + +const float kLatchHeight = 8.0f; +const float kLatchWidth = 4.0f; + + +static void +_GetSubItems(BList& sourceList, BList& destList, BListItem* parent, int32 start) +{ + for (int32 i = start; i < sourceList.CountItems(); i++) { + BListItem* item = (BListItem*)sourceList.ItemAt(i); + if (item->OutlineLevel() <= parent->OutlineLevel()) + break; + destList.AddItem(item); + } +} + + +static void +_DoSwap(BList& list, int32 firstIndex, int32 secondIndex, BList* firstItems, + BList* secondItems) +{ + BListItem* item = (BListItem*)list.ItemAt(firstIndex); + list.SwapItems(firstIndex, secondIndex); + list.RemoveItems(secondIndex + 1, secondItems->CountItems()); + list.RemoveItems(firstIndex + 1, firstItems->CountItems()); + list.AddList(secondItems, firstIndex + 1); + int32 newIndex = list.IndexOf(item); + if (newIndex + 1 < list.CountItems()) + list.AddList(firstItems, newIndex + 1); + else + list.AddList(firstItems); +} + + // #pragma mark - @@ -50,17 +85,24 @@ } +BOutlineListView::BOutlineListView(const char* name, list_view_type type, + uint32 flags) + : BListView(name, type, flags) +{ +} + + BOutlineListView::BOutlineListView(BMessage* archive) : BListView(archive) { int32 i = 0; BMessage subData; while (archive->FindMessage("_l_full_items", i++, &subData) == B_OK) { - BArchivable *object = instantiate_object(&subData); + BArchivable* object = instantiate_object(&subData); if (!object) continue; - BListItem *item = dynamic_cast(object); + BListItem* item = dynamic_cast(object); if (item) AddItem(item); } @@ -73,7 +115,7 @@ } -BArchivable * +BArchivable* BOutlineListView::Instantiate(BMessage* archive) { if (validate_instantiation(archive, "BOutlineListView")) @@ -97,7 +139,7 @@ status = archive->AddInt32("_lv_type", fListType); if (status == B_OK && deep) { int32 i = 0; - BListItem *item = NULL; + BListItem* item = NULL; while ((item = static_cast(fFullList.ItemAt(i++)))) { BMessage subData; status = item->Archive(&subData, true); @@ -127,7 +169,7 @@ int32 index = IndexOf(point); if (index != -1) { - BListItem *item = ItemAt(index); + BListItem* item = ItemAt(index); if (item->fHasSubitems && LatchRect(ItemFrame(index), item->fLevel).Contains(point)) { @@ -149,7 +191,7 @@ switch (bytes[0]) { case B_RIGHT_ARROW: { - BListItem *item = ItemAt(currentSel); + BListItem* item = ItemAt(currentSel); if (item && item->fHasSubitems) { if (!IsExpanded(currentSel)) Expand(item); @@ -161,7 +203,7 @@ case B_LEFT_ARROW: { - BListItem *item = ItemAt(currentSel); + BListItem* item = ItemAt(currentSel); if (item) { if (item->fHasSubitems) Collapse(item); @@ -248,7 +290,7 @@ // other list, too if (item->fLevel > 0) { - BListItem *super = _SuperitemForIndex(fullListIndex, item->fLevel); + BListItem* super = _SuperitemForIndex(fullListIndex, item->fLevel); if (super == NULL) return true; @@ -290,7 +332,7 @@ return false; for (int32 i = 0; i < newItems->CountItems(); i++) - AddItem((BListItem *)newItems->ItemAt(i), fullListIndex + i); + AddItem((BListItem*)newItems->ItemAt(i), fullListIndex + i); return true; } @@ -327,7 +369,7 @@ } -BListItem * +BListItem* BOutlineListView::FullListItemAt(int32 fullListIndex) const { return (BListItem*)fFullList.ItemAt(fullListIndex); @@ -340,7 +382,7 @@ int32 index = BListView::IndexOf(point); if (index > 0) - index = FullListIndex(index); + index = _FullListIndex(index); return index; } @@ -353,14 +395,14 @@ } -BListItem * +BListItem* BOutlineListView::FullListFirstItem() const { return (BListItem*)fFullList.FirstItem(); } -BListItem * +BListItem* BOutlineListView::FullListLastItem() const { return (BListItem*)fFullList.LastItem(); @@ -368,7 +410,7 @@ bool -BOutlineListView::FullListHasItem(BListItem *item) const +BOutlineListView::FullListHasItem(BListItem* item) const { return fFullList.HasItem(item); } @@ -386,7 +428,7 @@ { int32 i = BListView::CurrentSelection(index); - BListItem *item = BListView::ItemAt(i); + BListItem* item = BListView::ItemAt(i); if (item) return fFullList.IndexOf(item); @@ -424,7 +466,7 @@ } -BListItem * +BListItem* BOutlineListView::Superitem(const BListItem* item) { int32 index = FullListIndexOf((BListItem*)item); @@ -546,7 +588,7 @@ bool BOutlineListView::IsExpanded(int32 fullListIndex) { - BListItem *item = FullListItemAt(fullListIndex); + BListItem* item = FullListItemAt(fullListIndex); if (!item) return false; @@ -554,7 +596,7 @@ } -BHandler * +BHandler* BOutlineListView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, int32 what, const char* property) { @@ -597,8 +639,8 @@ { perform_data_get_height_for_width* data = (perform_data_get_height_for_width*)_data; - BOutlineListView::GetHeightForWidth(data->width, &data->min, &data->max, - &data->preferred); + BOutlineListView::GetHeightForWidth(data->width, &data->min, + &data->max, &data->preferred); return B_OK; } case PERFORM_CODE_SET_LAYOUT: @@ -692,7 +734,8 @@ // Populate to the full list _PopulateTree(tree, fFullList, firstIndex, false); - if (underItem == NULL || (underItem->IsItemVisible() && underItem->IsExpanded())) { + if (underItem == NULL + || (underItem->IsItemVisible() && underItem->IsExpanded())) { // Populate to BListView's list firstIndex = fList.IndexOf(underItem) + 1; lastIndex = firstIndex; @@ -715,91 +758,9 @@ _DestructTree(tree); } -void -BOutlineListView::_PopulateTree(BList* tree, BList& target, - int32& firstIndex, bool onlyVisible) -{ - BListItem** items = (BListItem**)target.Items(); - int32 count = tree->CountItems(); - for (int32 index = 0; index < count; index++) { - BListItem* item = (BListItem*)tree->ItemAtFast(index); - - items[firstIndex++] = item; - - if (item->HasSubitems() && (!onlyVisible || item->IsExpanded())) - _PopulateTree(item->fTemporaryList, target, firstIndex, onlyVisible); - } -} - - -void -BOutlineListView::_SortTree(BList* tree, bool oneLevelOnly, - int (*compareFunc)(const BListItem* a, const BListItem* b)) -{ - BListItem **items = (BListItem **)tree->Items(); - std::sort(items, items + tree->CountItems(), ListItemComparator(compareFunc)); - - if (oneLevelOnly) - return; - - for (int32 index = tree->CountItems(); index-- > 0;) { - BListItem* item = (BListItem*)tree->ItemAt(index); - - if (item->HasSubitems()) - _SortTree(item->fTemporaryList, false, compareFunc); - } -} - - -void -BOutlineListView::_DestructTree(BList* tree) -{ - for (int32 index = tree->CountItems(); index-- > 0;) { - BListItem* item = (BListItem*)tree->ItemAt(index); - - if (item->HasSubitems()) - _DestructTree(item->fTemporaryList); - } - - delete tree; -} - - -BList* -BOutlineListView::_BuildTree(BListItem* underItem, int32& fullIndex) -{ - int32 fullCount = FullListCountItems(); - uint32 level = underItem != NULL ? underItem->OutlineLevel() + 1 : 0; - BList* list = new BList; - if (underItem != NULL) - underItem->fTemporaryList = list; - - while (fullIndex < fullCount) { - BListItem *item = FullListItemAt(fullIndex); - - // If we jump out of the subtree, break out - if (item->fLevel < level) - break; - - // If the level matches, put them into the list - // (we handle the case of a missing sublevel gracefully) - list->AddItem(item); - fullIndex++; - - if (item->HasSubitems()) { - // we're going deeper - _BuildTree(item, fullIndex); - } - } - - return list; -} - - int32 -BOutlineListView::CountItemsUnder(BListItem* underItem, - bool oneLevelOnly) const +BOutlineListView::CountItemsUnder(BListItem* underItem, bool oneLevelOnly) const { int32 i = FullListIndexOf(underItem); if (i == -1) @@ -810,7 +771,7 @@ uint32 baseLevel = underItem->OutlineLevel(); for (; i < FullListCountItems(); i++) { - BListItem *item = FullListItemAt(i); + BListItem* item = FullListItemAt(i); // If we jump out of the subtree, return count if (item->fLevel <= baseLevel) @@ -825,16 +786,16 @@ } -BListItem * -BOutlineListView::EachItemUnder(BListItem *underItem, bool oneLevelOnly, - BListItem *(*eachFunc)(BListItem* item, void* arg), void* arg) +BListItem* +BOutlineListView::EachItemUnder(BListItem* underItem, bool oneLevelOnly, + BListItem* (*eachFunc)(BListItem* item, void* arg), void* arg) { int32 i = IndexOf(underItem); if (i == -1) return NULL; while (i < FullListCountItems()) { - BListItem *item = FullListItemAt(i); + BListItem* item = FullListItemAt(i); // If we jump out of the subtree, return NULL if (item->fLevel < underItem->OutlineLevel()) @@ -854,7 +815,7 @@ } -BListItem * +BListItem* BOutlineListView::ItemUnderAt(BListItem* underItem, bool oneLevelOnly, int32 index) const { @@ -863,7 +824,7 @@ return NULL; while (i < FullListCountItems()) { - BListItem *item = FullListItemAt(i); + BListItem* item = FullListItemAt(i); // If we jump out of the subtree, return NULL if (item->fLevel < underItem->OutlineLevel()) @@ -883,90 +844,8 @@ return NULL; } -static void _GetSubItems(BList &sourceList, BList &destList, - BListItem *parent, int32 start) -{ - for (int32 i = start; i < sourceList.CountItems(); i++) { - BListItem *item = (BListItem *)sourceList.ItemAt(i); - if (item->OutlineLevel() <= parent->OutlineLevel()) - break; - destList.AddItem(item); - } -} -static void -_DoSwap(BList &list, int32 firstIndex, int32 secondIndex, BList *firstItems, - BList *secondItems) -{ - BListItem *item = (BListItem *)list.ItemAt(firstIndex); - list.SwapItems(firstIndex, secondIndex); - list.RemoveItems(secondIndex + 1, secondItems->CountItems()); - list.RemoveItems(firstIndex + 1, firstItems->CountItems()); - list.AddList(secondItems, firstIndex + 1); - int32 newIndex = list.IndexOf(item); - if (newIndex + 1 < list.CountItems()) - list.AddList(firstItems, newIndex + 1); - else - list.AddList(firstItems); -} - -void -BOutlineListView::_CullInvisibleItems(BList &list) -{ - int32 index = 0; - while (index < list.CountItems()) { - if (reinterpret_cast(list.ItemAt(index))->IsItemVisible()) - ++index; - else - list.RemoveItem(index); - } -} - bool -BOutlineListView::_SwapItems(int32 first, int32 second) -{ - // same item, do nothing - if (first == second) - return true; - - // fail, first item out of bounds - if ((first < 0) || (first >= CountItems())) - return false; - - // fail, second item out of bounds - if ((second < 0) || (second >= CountItems())) - return false; - - int32 firstIndex = min_c(first, second); - int32 secondIndex = max_c(first, second); - BListItem *firstItem = ItemAt(firstIndex); - BListItem *secondItem = ItemAt(secondIndex); - BList firstSubItems, secondSubItems; - - if (Superitem(firstItem) != Superitem(secondItem)) - return false; - if (!firstItem->IsItemVisible() || !secondItem->IsItemVisible()) - return false; - - int32 fullFirstIndex = FullListIndex(firstIndex); - int32 fullSecondIndex = FullListIndex(secondIndex); - _GetSubItems(fFullList, firstSubItems, firstItem, fullFirstIndex + 1); - _GetSubItems(fFullList, secondSubItems, secondItem, fullSecondIndex + 1); - _DoSwap(fFullList, fullFirstIndex, fullSecondIndex, &firstSubItems, - &secondSubItems); - - _CullInvisibleItems(firstSubItems); - _CullInvisibleItems(secondSubItems); - _DoSwap(fList, firstIndex, secondIndex, &firstSubItems, - &secondSubItems); - - _RecalcItemTops(firstIndex); - _RescanSelection(firstIndex, secondIndex + secondSubItems.CountItems()); - Invalidate(Bounds()); - return true; -} - -bool BOutlineListView::DoMiscellaneous(MiscCode code, MiscData* data) { if (code == B_SWAP_OP) @@ -989,32 +868,8 @@ void BOutlineListView::_ReservedOutlineListView4() {} -int32 -BOutlineListView::FullListIndex(int32 index) const -{ - BListItem *item = ItemAt(index); - - if (item == NULL) - return -1; - - return FullListIndexOf(item); -} - - -int32 -BOutlineListView::ListViewIndex(int32 index) const -{ - BListItem *item = ItemAt(index); - - if (item == NULL) - return -1; - - return BListView::IndexOf(item); -} - - void -BOutlineListView::ExpandOrCollapse(BListItem *underItem, bool expand) +BOutlineListView::ExpandOrCollapse(BListItem* underItem, bool expand) { } @@ -1081,20 +936,171 @@ if (item->fHasSubitems) DrawLatch(itemRect, item->fLevel, !item->IsExpanded(), false, false); - itemRect.left += (item->fLevel) * 10.0f + 15.0f; + itemRect.left += item->fLevel * 10.0f + 15.0f; item->DrawItem(this, itemRect, complete); } -/*! - \brief Removes a single item from the list and all of its children. +int32 +BOutlineListView::_FullListIndex(int32 index) const +{ + BListItem* item = ItemAt(index); + if (item == NULL) + return -1; + + return FullListIndexOf(item); +} + + +void +BOutlineListView::_PopulateTree(BList* tree, BList& target, + int32& firstIndex, bool onlyVisible) +{ + BListItem** items = (BListItem**)target.Items(); + int32 count = tree->CountItems(); + + for (int32 index = 0; index < count; index++) { + BListItem* item = (BListItem*)tree->ItemAtFast(index); + + items[firstIndex++] = item; + + if (item->HasSubitems() && (!onlyVisible || item->IsExpanded())) + _PopulateTree(item->fTemporaryList, target, firstIndex, onlyVisible); + } +} + + +void +BOutlineListView::_SortTree(BList* tree, bool oneLevelOnly, + int (*compareFunc)(const BListItem* a, const BListItem* b)) +{ + BListItem** items = (BListItem**)tree->Items(); + std::sort(items, items + tree->CountItems(), ListItemComparator(compareFunc)); + + if (oneLevelOnly) + return; + + for (int32 index = tree->CountItems(); index-- > 0;) { + BListItem* item = (BListItem*)tree->ItemAt(index); + + if (item->HasSubitems()) + _SortTree(item->fTemporaryList, false, compareFunc); + } +} + + +void +BOutlineListView::_DestructTree(BList* tree) +{ + for (int32 index = tree->CountItems(); index-- > 0;) { + BListItem* item = (BListItem*)tree->ItemAt(index); + + if (item->HasSubitems()) + _DestructTree(item->fTemporaryList); + } + + delete tree; +} + + +BList* +BOutlineListView::_BuildTree(BListItem* underItem, int32& fullIndex) +{ + int32 fullCount = FullListCountItems(); + uint32 level = underItem != NULL ? underItem->OutlineLevel() + 1 : 0; + BList* list = new BList; + if (underItem != NULL) + underItem->fTemporaryList = list; + + while (fullIndex < fullCount) { + BListItem* item = FullListItemAt(fullIndex); + + // If we jump out of the subtree, break out + if (item->fLevel < level) + break; + + // If the level matches, put them into the list + // (we handle the case of a missing sublevel gracefully) + list->AddItem(item); + fullIndex++; + + if (item->HasSubitems()) { + // we're going deeper + _BuildTree(item, fullIndex); + } + } + + return list; +} + + +void +BOutlineListView::_CullInvisibleItems(BList& list) +{ + int32 index = 0; + while (index < list.CountItems()) { + if (reinterpret_cast(list.ItemAt(index))->IsItemVisible()) + ++index; + else + list.RemoveItem(index); + } +} + + +bool +BOutlineListView::_SwapItems(int32 first, int32 second) +{ + // same item, do nothing + if (first == second) + return true; + + // fail, first item out of bounds + if ((first < 0) || (first >= CountItems())) + return false; + + // fail, second item out of bounds + if ((second < 0) || (second >= CountItems())) + return false; + + int32 firstIndex = min_c(first, second); + int32 secondIndex = max_c(first, second); + BListItem* firstItem = ItemAt(firstIndex); + BListItem* secondItem = ItemAt(secondIndex); + BList firstSubItems, secondSubItems; + + if (Superitem(firstItem) != Superitem(secondItem)) + return false; + if (!firstItem->IsItemVisible() || !secondItem->IsItemVisible()) + return false; + + int32 fullFirstIndex = _FullListIndex(firstIndex); + int32 fullSecondIndex = _FullListIndex(secondIndex); + _GetSubItems(fFullList, firstSubItems, firstItem, fullFirstIndex + 1); + _GetSubItems(fFullList, secondSubItems, secondItem, fullSecondIndex + 1); + _DoSwap(fFullList, fullFirstIndex, fullSecondIndex, &firstSubItems, + &secondSubItems); + + _CullInvisibleItems(firstSubItems); + _CullInvisibleItems(secondSubItems); + _DoSwap(fList, firstIndex, secondIndex, &firstSubItems, + &secondSubItems); + + _RecalcItemTops(firstIndex); + _RescanSelection(firstIndex, secondIndex + secondSubItems.CountItems()); + Invalidate(Bounds()); + return true; +} + + +/*! \brief Removes a single item from the list and all of its children. + Unlike the BeOS version, this one will actually delete the children, too, as there should be no reference left to them. This may cause problems for applications that actually take the misbehaviour of the Be classes into account. */ -BListItem * +BListItem* BOutlineListView::_RemoveItem(BListItem* item, int32 fullIndex) { if (item == NULL || fullIndex < 0 || fullIndex >= FullListCountItems()) @@ -1107,7 +1113,7 @@ if (item->IsItemVisible()) { // remove children, too while (fullIndex + 1 < CountItems()) { - BListItem *subItem = ItemAt(fullIndex + 1); + BListItem* subItem = ItemAt(fullIndex + 1); if (subItem->OutlineLevel() <= level) break; @@ -1133,61 +1139,14 @@ } -BListItem * -BOutlineListView::RemoveOne(int32 fullListIndex) -{ - return NULL; -} - - -void -BOutlineListView::TrackInLatchItem(void *) -{ -} - - -void -BOutlineListView::TrackOutLatchItem(void *) -{ -} - - -bool -BOutlineListView::OutlineSwapItems(int32 a, int32 b) -{ - return false; -} - - -bool [... truncated: 35 lines follow ...] From axeld at mail.berlios.de Wed Jun 17 16:58:26 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Wed, 17 Jun 2009 16:58:26 +0200 Subject: [Haiku-commits] r31089 - haiku/trunk/headers/os/interface Message-ID: <200906171458.n5HEwQpT026085@sheep.berlios.de> Author: axeld Date: 2009-06-17 16:58:24 +0200 (Wed, 17 Jun 2009) New Revision: 31089 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31089&view=rev Modified: haiku/trunk/headers/os/interface/Control.h Log: * Fixed style violations. Modified: haiku/trunk/headers/os/interface/Control.h =================================================================== --- haiku/trunk/headers/os/interface/Control.h 2009-06-17 14:56:57 UTC (rev 31088) +++ haiku/trunk/headers/os/interface/Control.h 2009-06-17 14:58:24 UTC (rev 31089) @@ -1,8 +1,8 @@ /* - * Copyright (c) 2001-2009, Haiku, Inc. All rights reserved. + * Copyright 2001-2009, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. */ - #ifndef _CONTROL_H +#ifndef _CONTROL_H #define _CONTROL_H #include From axeld at mail.berlios.de Wed Jun 17 18:26:21 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Wed, 17 Jun 2009 18:26:21 +0200 Subject: [Haiku-commits] r31090 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906171626.n5HGQLeT000247@sheep.berlios.de> Author: axeld Date: 2009-06-17 18:26:17 +0200 (Wed, 17 Jun 2009) New Revision: 31090 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31090&view=rev Added: haiku/trunk/src/kits/interface/StringItem.cpp Modified: haiku/trunk/headers/os/interface/ListItem.h haiku/trunk/headers/os/interface/StringItem.h haiku/trunk/src/kits/interface/Jamfile haiku/trunk/src/kits/interface/ListItem.cpp Log: * Moved class BStringItem into its own source file. * Changed BStringItem::Update() to set a better baseline offset and height; this should improve vertical text placement. * Fixed a bug in BStringItem::Update(): it used the owner to determine the width, but must use the font passed in instead. * Coding style cleanup. Modified: haiku/trunk/headers/os/interface/ListItem.h =================================================================== --- haiku/trunk/headers/os/interface/ListItem.h 2009-06-17 14:58:24 UTC (rev 31089) +++ haiku/trunk/headers/os/interface/ListItem.h 2009-06-17 16:26:17 UTC (rev 31090) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _LIST_ITEM_H @@ -17,76 +17,81 @@ class BListItem : public BArchivable { - public: +public: BListItem(uint32 outlineLevel = 0, bool expanded = true); BListItem(BMessage* archive); - virtual ~BListItem(); + virtual ~BListItem(); - virtual status_t Archive(BMessage* archive, bool deep = true) const; + virtual status_t Archive(BMessage* archive, bool deep = true) const; - float Height() const; - float Width() const; - bool IsSelected() const; - void Select(); - void Deselect(); + float Height() const; + float Width() const; + bool IsSelected() const; + void Select(); + void Deselect(); - virtual void SetEnabled(bool enabled); - bool IsEnabled() const; + virtual void SetEnabled(bool enabled); + bool IsEnabled() const; - void SetHeight(float height); - void SetWidth(float width); - virtual void DrawItem(BView* owner, BRect frame, + void SetHeight(float height); + void SetWidth(float width); + virtual void DrawItem(BView* owner, BRect frame, bool complete = false) = 0; - virtual void Update(BView* owner, const BFont* font); + virtual void Update(BView* owner, const BFont* font); - virtual status_t Perform(perform_code code, void* arg); + virtual status_t Perform(perform_code code, void* arg); - bool IsExpanded() const; - void SetExpanded(bool expanded); - uint32 OutlineLevel() const; + bool IsExpanded() const; + void SetExpanded(bool expanded); + uint32 OutlineLevel() const; - private: - friend class BOutlineListView; - friend class BListView; - bool HasSubitems() const; +private: + friend class BOutlineListView; + friend class BListView; - virtual void _ReservedListItem1(); - virtual void _ReservedListItem2(); + bool HasSubitems() const; + virtual void _ReservedListItem1(); + virtual void _ReservedListItem2(); + BListItem(const BListItem& item); - BListItem& operator=(const BListItem& item); + BListItem& operator=(const BListItem& item); - bool IsItemVisible() const; - void SetItemVisible(bool visible); - inline float Top() const; - inline float Bottom() const; - void SetTop(float top); - private: - float fTop; - BList* fTemporaryList; - float fWidth; - float fHeight; - uint32 fLevel; - bool fSelected; - bool fEnabled; - bool fExpanded; - bool fHasSubitems : 1; - bool fVisible : 1; + bool IsItemVisible() const; + void SetItemVisible(bool visible); + inline float Top() const; + inline float Bottom() const; + void SetTop(float top); + +private: + float fTop; + BList* fTemporaryList; + float fWidth; + float fHeight; + uint32 fLevel; + bool fSelected; + bool fEnabled; + bool fExpanded; + bool fHasSubitems : 1; + bool fVisible : 1; }; + inline float BListItem::Top(void) const { return fTop; } + inline float BListItem::Bottom(void) const { - return (fTop + ceilf(fHeight) - 1.0); + return fTop + ceilf(fHeight) - 1.0; } + #include // to maintain source compatibility Modified: haiku/trunk/headers/os/interface/StringItem.h =================================================================== --- haiku/trunk/headers/os/interface/StringItem.h 2009-06-17 14:58:24 UTC (rev 31089) +++ haiku/trunk/headers/os/interface/StringItem.h 2009-06-17 16:26:17 UTC (rev 31090) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _STRING_ITEM_H @@ -10,33 +10,34 @@ class BStringItem : public BListItem { - public: - BStringItem(const char* text, uint32 outlineLevel = 0, - bool expanded = true); +public: + BStringItem(const char* text, + uint32 outlineLevel = 0, bool expanded = true); BStringItem(BMessage* archive); - virtual ~BStringItem(); + virtual ~BStringItem(); - static BArchivable* Instantiate(BMessage* archive); - virtual status_t Archive(BMessage* archive, bool deep = true) const; + static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* archive, bool deep = true) const; - virtual void DrawItem(BView* owner, BRect frame, bool complete = false); - virtual void SetText(const char* text); - const char* Text() const; + virtual void DrawItem(BView* owner, BRect frame, + bool complete = false); + virtual void SetText(const char* text); + const char* Text() const; - virtual void Update(BView* owner, const BFont* font); + virtual void Update(BView* owner, const BFont* font); - virtual status_t Perform(perform_code code, void* arg); + virtual status_t Perform(perform_code code, void* arg); - private: - virtual void _ReservedStringItem1(); - virtual void _ReservedStringItem2(); +private: + virtual void _ReservedStringItem1(); + virtual void _ReservedStringItem2(); BStringItem(const BStringItem& item); - BStringItem& operator=(const BStringItem& item); + BStringItem& operator=(const BStringItem& item); - char* fText; - float fBaselineOffset; - uint32 _reserved[2]; + char* fText; + float fBaselineOffset; + uint32 _reserved[2]; }; #endif // _STRING_ITEM_H Modified: haiku/trunk/src/kits/interface/Jamfile =================================================================== --- haiku/trunk/src/kits/interface/Jamfile 2009-06-17 14:58:24 UTC (rev 31089) +++ haiku/trunk/src/kits/interface/Jamfile 2009-06-17 16:26:17 UTC (rev 31090) @@ -114,6 +114,7 @@ SplitLayoutBuilder.cpp SplitView.cpp StatusBar.cpp + StringItem.cpp StringView.cpp TabView.cpp TextControl.cpp Modified: haiku/trunk/src/kits/interface/ListItem.cpp =================================================================== --- haiku/trunk/src/kits/interface/ListItem.cpp 2009-06-17 14:58:24 UTC (rev 31089) +++ haiku/trunk/src/kits/interface/ListItem.cpp 2009-06-17 16:26:17 UTC (rev 31090) @@ -1,67 +1,48 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2008, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: ListItem.cpp -// Author: Ulrich Wimboeck -// Marc Flerackers (mflerackers at androme.be) -// Rene Gollent -// Description: BListItem is the base class for BListView's items, -// BStringItem is a subclass of BListItem which draws a string. -//------------------------------------------------------------------------------ -#include -#include +/* + * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ulrich Wimboeck + * Marc Flerackers (mflerackers at androme.be) + * Rene Gollent + */ #include + #include #include BListItem::BListItem(uint32 level, bool expanded) - : fTop(0.0), - fWidth(0), - fHeight(0), - fLevel(level), - fSelected(false), - fEnabled(true), - fExpanded(expanded), - fHasSubitems(false), - fVisible(true) + : + fTop(0.0), + fWidth(0), + fHeight(0), + fLevel(level), + fSelected(false), + fEnabled(true), + fExpanded(expanded), + fHasSubitems(false), + fVisible(true) { } -BListItem::BListItem(BMessage *data) - : BArchivable(data), - fTop(0.0), - fWidth(0), - fHeight(0), - fLevel(0), - fSelected(false), - fEnabled(true), - fExpanded(false), - fHasSubitems(false), - fVisible(true) +BListItem::BListItem(BMessage* data) + : BArchivable(data), + fTop(0.0), + fWidth(0), + fHeight(0), + fLevel(0), + fSelected(false), + fEnabled(true), + fExpanded(false), + fHasSubitems(false), + fVisible(true) { data->FindBool("_sel", &fSelected); - + if (data->FindBool("_disable", &fEnabled) != B_OK) fEnabled = true; else @@ -78,10 +59,9 @@ status_t -BListItem::Archive(BMessage *archive, bool deep) const +BListItem::Archive(BMessage* archive, bool deep) const { status_t status = BArchivable::Archive(archive, deep); - if (status == B_OK && fSelected) status = archive->AddBool("_sel", true); @@ -162,18 +142,18 @@ void -BListItem::Update(BView *owner, const BFont *font) +BListItem::Update(BView* owner, const BFont* font) { font_height fh; font->GetHeight(&fh); SetWidth(owner->Bounds().Width()); - SetHeight(fh.ascent + fh.descent + fh.leading); + SetHeight(ceilf(fh.ascent + fh.descent + fh.leading)); } status_t -BListItem::Perform(perform_code d, void *arg) +BListItem::Perform(perform_code d, void* arg) { return BArchivable::Perform(d, arg); } @@ -211,174 +191,23 @@ void BListItem::_ReservedListItem2() {} -BListItem::BListItem(const BListItem &item) -{ -} - - -BListItem & -BListItem::operator=(const BListItem &) -{ - return *this; -} - - bool BListItem::IsItemVisible() const { return fVisible; } + void BListItem::SetTop(float top) { fTop = top; } + void BListItem::SetItemVisible(bool visible) { fVisible = visible; } - -// BStringItem -BStringItem::BStringItem(const char *text, uint32 level, bool expanded) - : BListItem(level, expanded), - fText(NULL), - fBaselineOffset(0) -{ - SetText(text); -} - - -BStringItem::BStringItem(BMessage *archive) - : BListItem(archive), - fText(NULL), - fBaselineOffset(0) -{ - const char *string; - - if (archive->FindString("_label", &string) == B_OK) - SetText(string); -} - - -BStringItem::~BStringItem() -{ - free(fText); -} - - -BArchivable * -BStringItem::Instantiate(BMessage *archive) -{ - if (validate_instantiation(archive, "BStringItem")) - return new BStringItem(archive); - else - return NULL; -} - - -status_t -BStringItem::Archive(BMessage *archive, bool deep) const -{ - status_t status = BListItem::Archive(archive); - - if (status == B_OK && fText != NULL) - status = archive->AddString("_label", fText); - - return status; -} - - -void -BStringItem::DrawItem(BView *owner, BRect frame, bool complete) -{ - if (fText == NULL) - return; - - rgb_color highColor = owner->HighColor(); - rgb_color lowColor = owner->LowColor(); - - if (IsSelected() || complete) { - if (IsSelected()) { - owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT)); - owner->SetLowColor(owner->HighColor()); - } else - owner->SetHighColor(lowColor); - - owner->FillRect(frame); - } - - owner->MovePenTo(frame.left, frame.top + fBaselineOffset); - - rgb_color black = {0, 0, 0, 255}; - - if (!IsEnabled()) - owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT)); - else - owner->SetHighColor(black); - - owner->DrawString(fText); - - owner->SetHighColor(highColor); - owner->SetLowColor(lowColor); -} - - -void -BStringItem::SetText(const char *text) -{ - free(fText); - fText = NULL; - - if (text) - fText = strdup(text); -} - - -const char * -BStringItem::Text() const -{ - return fText; -} - - -void -BStringItem::Update(BView *owner, const BFont *font) -{ - if (fText) - SetWidth(owner->StringWidth(fText)); - - font_height fheight; - font->GetHeight(&fheight); - - fBaselineOffset = fheight.ascent + 2 + floorf(fheight.leading / 2); - - SetHeight(ceilf(fheight.ascent) + ceilf(fheight.descent) - + ceilf(fheight.leading) + 4); -} - - -status_t -BStringItem::Perform(perform_code d, void *arg) -{ - return BListItem::Perform(d, arg); -} - - -void BStringItem::_ReservedStringItem1() {} -void BStringItem::_ReservedStringItem2() {} - - -BStringItem::BStringItem(const BStringItem &) -{ -} - - -BStringItem & -BStringItem::operator=(const BStringItem &) -{ - return *this; -} Copied: haiku/trunk/src/kits/interface/StringItem.cpp (from rev 31089, haiku/trunk/src/kits/interface/ListItem.cpp) =================================================================== --- haiku/trunk/src/kits/interface/ListItem.cpp 2009-06-17 14:58:24 UTC (rev 31089) +++ haiku/trunk/src/kits/interface/StringItem.cpp 2009-06-17 16:26:17 UTC (rev 31090) @@ -0,0 +1,158 @@ +/* + * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ulrich Wimboeck + * Marc Flerackers (mflerackers at androme.be) + * Rene Gollent + */ + + +#include + +#include +#include + +#include +#include + + +BStringItem::BStringItem(const char* text, uint32 level, bool expanded) + : BListItem(level, expanded), + fText(NULL), + fBaselineOffset(0) +{ + SetText(text); +} + + +BStringItem::BStringItem(BMessage* archive) + : BListItem(archive), + fText(NULL), + fBaselineOffset(0) +{ + const char* string; + if (archive->FindString("_label", &string) == B_OK) + SetText(string); +} + + +BStringItem::~BStringItem() +{ + free(fText); +} + + +BArchivable* +BStringItem::Instantiate(BMessage* archive) +{ + if (validate_instantiation(archive, "BStringItem")) + return new BStringItem(archive); + + return NULL; +} + + +status_t +BStringItem::Archive(BMessage *archive, bool deep) const +{ + status_t status = BListItem::Archive(archive); + + if (status == B_OK && fText != NULL) + status = archive->AddString("_label", fText); + + return status; +} + + +void +BStringItem::DrawItem(BView *owner, BRect frame, bool complete) +{ + if (fText == NULL) + return; + + rgb_color highColor = owner->HighColor(); + rgb_color lowColor = owner->LowColor(); + + if (IsSelected() || complete) { + if (IsSelected()) { + owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT)); + owner->SetLowColor(owner->HighColor()); + } else + owner->SetHighColor(lowColor); + + owner->FillRect(frame); + } + + owner->MovePenTo(frame.left, frame.top + fBaselineOffset); + + rgb_color black = {0, 0, 0, 255}; + + if (!IsEnabled()) + owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT)); + else + owner->SetHighColor(black); + + owner->DrawString(fText); + + owner->SetHighColor(highColor); + owner->SetLowColor(lowColor); +} + + +void +BStringItem::SetText(const char *text) +{ + free(fText); + fText = NULL; + + if (text) + fText = strdup(text); +} + + +const char * +BStringItem::Text() const +{ + return fText; +} + + +void +BStringItem::Update(BView *owner, const BFont *font) +{ + if (fText) + SetWidth(font->StringWidth(fText)); + + font_height fheight; + font->GetHeight(&fheight); + + fBaselineOffset = 2 + ceilf(fheight.ascent + fheight.leading / 2); + + SetHeight(ceilf(fheight.ascent) + ceilf(fheight.descent) + + ceilf(fheight.leading) + 4); +} + + +status_t +BStringItem::Perform(perform_code d, void *arg) +{ + return BListItem::Perform(d, arg); +} + + +void BStringItem::_ReservedStringItem1() {} +void BStringItem::_ReservedStringItem2() {} + + +BStringItem::BStringItem(const BStringItem &) +{ +} + + +BStringItem & +BStringItem::operator=(const BStringItem &) +{ + return *this; +} From axeld at mail.berlios.de Wed Jun 17 18:50:16 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Wed, 17 Jun 2009 18:50:16 +0200 Subject: [Haiku-commits] r31091 - haiku/trunk/src/kits/interface Message-ID: <200906171650.n5HGoGD3014654@sheep.berlios.de> Author: axeld Date: 2009-06-17 18:50:14 +0200 (Wed, 17 Jun 2009) New Revision: 31091 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31091&view=rev Modified: haiku/trunk/src/kits/interface/View.cpp Log: * Fixed bug that prevented the font state to be properly popped. It could be solved more efficiently by adding a new app_server call for this, though. * Fixed stupid operator precedence bug that caused BView to always archive everything, instead of only those items with their archiving flag set. * Minor cleanup. Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2009-06-17 16:26:17 UTC (rev 31090) +++ haiku/trunk/src/kits/interface/View.cpp 2009-06-17 16:50:14 UTC (rev 31091) @@ -9,16 +9,23 @@ * Ingo Weinhold */ +#include + +#include + #include #include -#include - #include #include #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -35,15 +42,8 @@ #include #include #include -#include #include -#include -#include -#include -#include -#include - #include #include #include @@ -154,13 +154,11 @@ font_flags = font.Flags(); font_aliasing = false; - /* - INFO: We include(invalidate) only B_VIEW_CLIP_REGION_BIT flag - because we should get the clipping region from app_server. - The other flags do not need to be included because the data they - represent is already in sync with app_server - app_server uses the - same init(default) values. - */ + // We only keep the B_VIEW_CLIP_REGION_BIT flag invalidated, + // because we should get the clipping region from app_server. + // The other flags do not need to be included because the data they + // represent is already in sync with app_server - app_server uses the + // same init (default) values. valid_flags = ~B_VIEW_CLIP_REGION_BIT; archiving_flags = B_VIEW_FRAME_BIT | B_VIEW_RESIZE_BIT; @@ -240,9 +238,9 @@ link.Attach(-1); } - // Although we might have a 'local' clipping region, when we call - // BView::GetClippingRegion() we ask for the 'global' one and it - // is kept on server, so we must invalidate B_VIEW_CLIP_REGION_BIT flag + // Although we might have a 'local' clipping region, when we call + // BView::GetClippingRegion() we ask for the 'global' one and it + // is kept on server, so we must invalidate B_VIEW_CLIP_REGION_BIT flag valid_flags = ~B_VIEW_CLIP_REGION_BIT; } @@ -317,16 +315,17 @@ struct BView::LayoutData { LayoutData() - : fMinSize(), - fMaxSize(), - fPreferredSize(), - fAlignment(), - fLayoutInvalidationDisabled(0), - fLayout(NULL), - fLayoutContext(NULL), - fLayoutValid(true), // <- TODO: Rethink this! - fLayoutInProgress(false), - fNeedsRelayout(true) + : + fMinSize(), + fMaxSize(), + fPreferredSize(), + fAlignment(), + fLayoutInvalidationDisabled(0), + fLayout(NULL), + fLayoutContext(NULL), + fLayoutValid(true), // <- TODO: Rethink this! + fLayoutInProgress(false), + fNeedsRelayout(true) { } @@ -470,7 +469,7 @@ if (ret != B_OK) return ret; - if (fState->archiving_flags & B_VIEW_FRAME_BIT) + if ((fState->archiving_flags & B_VIEW_FRAME_BIT) != 0) ret = data->AddRect("_frame", Bounds().OffsetToCopy(fParentOffset)); if (ret == B_OK) @@ -479,13 +478,13 @@ if (ret == B_OK) ret = data->AddInt32("_flags", Flags()); - if (ret == B_OK && fState->archiving_flags & B_VIEW_EVENT_MASK_BIT) { + if (ret == B_OK && (fState->archiving_flags & B_VIEW_EVENT_MASK_BIT) != 0) { ret = data->AddInt32("_evmask", fEventMask); if (ret == B_OK) ret = data->AddInt32("_evmask", fEventOptions); } - if (ret == B_OK && fState->archiving_flags & B_VIEW_FONT_BIT) { + if (ret == B_OK && (fState->archiving_flags & B_VIEW_FONT_BIT) != 0) { BFont font; GetFont(&font); @@ -516,16 +515,16 @@ // ret = data->AddInt32("_dbuf", 1); // } - if (ret == B_OK && fState->archiving_flags & B_VIEW_ORIGIN_BIT) + if (ret == B_OK && (fState->archiving_flags & B_VIEW_ORIGIN_BIT) != 0) ret = data->AddPoint("_origin", Origin()); - if (ret == B_OK && fState->archiving_flags & B_VIEW_PEN_SIZE_BIT) + if (ret == B_OK && (fState->archiving_flags & B_VIEW_PEN_SIZE_BIT) != 0) ret = data->AddFloat("_psize", PenSize()); - if (ret == B_OK && fState->archiving_flags & B_VIEW_PEN_LOCATION_BIT) + if (ret == B_OK && (fState->archiving_flags & B_VIEW_PEN_LOCATION_BIT) != 0) ret = data->AddPoint("_ploc", PenLocation()); - if (ret == B_OK && fState->archiving_flags & B_VIEW_LINE_MODES_BIT) { + if (ret == B_OK && (fState->archiving_flags & B_VIEW_LINE_MODES_BIT) != 0) { ret = data->AddInt16("_lmcapjoin", (int16)LineCapMode()); if (ret == B_OK) ret = data->AddInt16("_lmcapjoin", (int16)LineJoinMode()); @@ -533,7 +532,7 @@ ret = data->AddFloat("_lmmiter", LineMiterLimit()); } - if (ret == B_OK && fState->archiving_flags & B_VIEW_BLENDING_BIT) { + if (ret == B_OK && (fState->archiving_flags & B_VIEW_BLENDING_BIT) != 0) { source_alpha alphaSourceMode; alpha_function alphaFunctionMode; GetBlendingMode(&alphaSourceMode, &alphaFunctionMode); @@ -543,7 +542,7 @@ ret = data->AddInt16("_blend", (int16)alphaFunctionMode); } - if (ret == B_OK && fState->archiving_flags & B_VIEW_DRAWING_MODE_BIT) + if (ret == B_OK && (fState->archiving_flags & B_VIEW_DRAWING_MODE_BIT) != 0) ret = data->AddInt32("_dmod", DrawingMode()); if (deep) { @@ -567,12 +566,15 @@ { STRACE(("BView(%s)::~BView()\n", this->Name())); - if (fOwner) - debugger("Trying to delete a view that belongs to a window. Call RemoveSelf first."); + if (fOwner) { + debugger("Trying to delete a view that belongs to a window. " + "Call RemoveSelf first."); + } RemoveSelf(); - // TODO: see about BShelf! must I delete it here? is it deleted by the window? + // TODO: see about BShelf! must I delete it here? is it deleted by + // the window? // we also delete all our children @@ -627,6 +629,7 @@ point->y += -fBounds.top + fParentOffset.y; } + void BView::ConvertToParent(BPoint *point) const { @@ -658,6 +661,7 @@ point->y += -fParentOffset.y + fBounds.top; } + void BView::ConvertFromParent(BPoint *point) const { @@ -2195,7 +2199,7 @@ if (mask == B_FONT_ALL) { fState->font = *font; } else { - // ToDo: move this into a BFont method + // TODO: move this into a BFont method if (mask & B_FONT_FAMILY_AND_STYLE) fState->font.SetFamilyAndStyle(font->FamilyAndStyle()); @@ -2230,8 +2234,10 @@ _CheckLockAndSwitchCurrent(); fState->UpdateServerFontState(*fOwner->fLink); + fState->valid_flags |= B_VIEW_FONT_BIT; } + fState->archiving_flags |= B_VIEW_FONT_BIT; // TODO: InvalidateLayout() here for convenience? } @@ -2239,6 +2245,15 @@ void BView::GetFont(BFont *font) const { + if (!fState->IsValid(B_VIEW_FONT_BIT)) { + // we don't keep graphics state information, therefor + // we need to ask the server for the origin after PopState() + _CheckOwnerLockAndSwitchCurrent(); + + // TODO: add a font getter! + fState->UpdateFrom(*fOwner->fLink); + } + *font = fState->font; } @@ -5143,6 +5158,7 @@ Flush(); } + void BView::_DrawAfterChildren(BRect updateRect) { From korli at mail.berlios.de Wed Jun 17 20:40:12 2009 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 17 Jun 2009 20:40:12 +0200 Subject: [Haiku-commits] r31092 - in haiku/trunk/src/add-ons/kernel/drivers/network: 3com/dev/mii rtl8139/dev/mii syskonnect/dev/mii via_rhine/dev/mii Message-ID: <200906171840.n5HIeCbS018104@sheep.berlios.de> Author: korli Date: 2009-06-17 20:40:11 +0200 (Wed, 17 Jun 2009) New Revision: 31092 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31092&view=rev Removed: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/miidevs.h haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/miidevs.h haiku/trunk/src/add-ons/kernel/drivers/network/syskonnect/dev/mii/miidevs.h haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/syskonnect/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile Log: delete miidevs headers occurrences and have the drivers use the common generated miidevs header. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile 2009-06-17 16:50:14 UTC (rev 31091) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/Jamfile 2009-06-17 18:40:11 UTC (rev 31092) @@ -15,3 +15,7 @@ ukphy_subr.c ; +ObjectHdrs [ FGristFiles bmtphy$(SUFOBJ) exphy$(SUFOBJ) ukphy$(SUFOBJ) ] + : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) libs compat freebsd_network ] ; +Includes [ FGristFiles bmtphy.c exphy.c ukphy.c ] : miidevs.h ; + Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/3com/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile 2009-06-17 16:50:14 UTC (rev 31091) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/Jamfile 2009-06-17 18:40:11 UTC (rev 31092) @@ -11,3 +11,6 @@ : rlphy.c ; +ObjectHdrs [ FGristFiles rlphy$(SUFOBJ) ] + : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) libs compat freebsd_network ] ; +Includes [ FGristFiles rlphy.c ] : miidevs.h ; Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8139/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/syskonnect/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/syskonnect/dev/mii/Jamfile 2009-06-17 16:50:14 UTC (rev 31091) +++ haiku/trunk/src/add-ons/kernel/drivers/network/syskonnect/dev/mii/Jamfile 2009-06-17 18:40:11 UTC (rev 31092) @@ -15,3 +15,7 @@ ukphy_subr.c ; +ObjectHdrs [ FGristFiles e1000phy$(SUFOBJ) ukphy$(SUFOBJ) xmphy$(SUFOBJ) ] + : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) libs compat freebsd_network ] ; +Includes [ FGristFiles e1000phy.c ukphy.c xmphy.c ] : miidevs.h ; + Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/syskonnect/dev/mii/miidevs.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile 2009-06-17 16:50:14 UTC (rev 31091) +++ haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/Jamfile 2009-06-17 18:40:11 UTC (rev 31092) @@ -14,3 +14,7 @@ ukphy_subr.c ; +ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ukphy$(SUFOBJ) ] + : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) libs compat freebsd_network ] ; +Includes [ FGristFiles ciphy.c ukphy.c ] : miidevs.h ; + Deleted: haiku/trunk/src/add-ons/kernel/drivers/network/via_rhine/dev/mii/miidevs.h From rudolfc at mail.berlios.de Wed Jun 17 21:20:03 2009 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Wed, 17 Jun 2009 21:20:03 +0200 Subject: [Haiku-commits] r31093 - haiku/trunk/src/add-ons/accelerants/nvidia/engine Message-ID: <200906171920.n5HJK3n5020709@sheep.berlios.de> Author: rudolfc Date: 2009-06-17 21:20:02 +0200 (Wed, 17 Jun 2009) New Revision: 31093 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31093&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c Log: added basic analog connected screens detection using EDID fetched info while keeping the old method (load detection) as fallback. This should improve the driver choosing the correct output connector for primary video on some cards. Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c 2009-06-17 18:40:11 UTC (rev 31092) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_dac2.c 2009-06-17 19:20:02 UTC (rev 31093) @@ -12,16 +12,22 @@ display_mode target,float * calc_pclk,uint8 * m_result,uint8 * n_result,uint8 * p_result, uint8 test); /* see if an analog VGA monitor is connected to connector #2 */ -//fixme if possible: on NV40 arch (confirmed NV43) this routine always find a monitor! bool nv_dac2_crt_connected() { uint32 output, dac; bool present; + switch(si->ps.card_type) { /* NOTE: * NV11 can't do this: It will report DAC1 status instead because it HAS no * actual secondary DAC function. */ /* (It DOES have a secondary palette RAM and pixelclock PLL though.) */ + case NV11: + /* on NV40 arch (confirmed NV43) this routine always finds a monitor (doesn't work). */ + case NV43: + LOG(4,("DAC2: no load detection available. reporting no CRT detected on connector #2\n")); + return false; + } /* save output connector setting */ output = DAC2R(OUTPUT); Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c 2009-06-17 18:40:11 UTC (rev 31092) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_info.c 2009-06-17 19:20:02 UTC (rev 31093) @@ -1,7 +1,7 @@ /* Read initialisation information from card */ /* some bits are hacks, where PINS is not known */ /* Author: - Rudolf Cornelissen 7/2003-5/2009 + Rudolf Cornelissen 7/2003-6/2009 */ #define MODULE_BIT 0x00002000 @@ -2196,6 +2196,16 @@ } } +/* notes: + * - Since laptops don't have edid for their internal panels, and we can't switch + * digitally connected external panels to DAC's, we keep needing the info fetched + * from card programming done by the cardBIOS. + * - Because we can only output modes on digitally connected panels upto/including + * the modeline programmed into the GPU by the cardBIOS we don't use the actual + * native modelines fetched via EDID for digitally connected panels. + * - If the BIOS didn't program a modeline in the GPU for a digitally connected panel + * we can't use that panel. + * - The above restrictions exist due to missing nVidia hardware specs. */ static void detect_panels() { /* detect if the BIOS enabled LCD's (internal panels or DVI) or TVout */ @@ -2569,11 +2579,20 @@ /* presetup by the card's BIOS, we can't change this (lack of info) */ if (si->ps.tmds1_active) si->ps.monitors |= 0x01; if (si->ps.tmds2_active) si->ps.monitors |= 0x10; - /* detect analog monitors (confirmed working OK on NV18, NV28 and NV34): */ - /* sense analog monitor on primary connector */ - if (nv_dac_crt_connected()) si->ps.monitors |= 0x02; - /* sense analog monitor on secondary connector */ - if (nv_dac2_crt_connected()) si->ps.monitors |= 0x20; + /* detect analog monitors. First try EDID, else use load sensing. */ + /* (load sensing is confirmed working OK on NV18, NV28 and NV34.) */ + /* primary connector: */ + if (si->ps.con1_screen.have_edid) { + if (!si->ps.con1_screen.digital) si->ps.monitors |= 0x02; + } else { + if (nv_dac_crt_connected()) si->ps.monitors |= 0x02; + } + /* secondary connector */ + if (si->ps.con2_screen.have_edid) { + if (!si->ps.con2_screen.digital) si->ps.monitors |= 0x20; + } else { + if (nv_dac2_crt_connected()) si->ps.monitors |= 0x20; + } /* setup correct output and head use */ //fixme? add TVout (only, so no CRT(s) connected) support... @@ -2680,9 +2699,14 @@ /* presetup by the card's BIOS, we can't change this (lack of info) */ if (si->ps.tmds1_active) si->ps.monitors |= 0x01; if (si->ps.tmds2_active) si->ps.monitors |= 0x10; - /* detect analog monitor (confirmed working OK on NV11): */ - /* sense analog monitor on primary connector */ - if (nv_dac_crt_connected()) si->ps.monitors |= 0x02; + /* detect analog monitors. First try EDID, else use load sensing. */ + /* (load sensing is confirmed working OK on NV11.) */ + /* primary connector: */ + if (si->ps.con1_screen.have_edid) { + if (!si->ps.con1_screen.digital) si->ps.monitors |= 0x02; + } else { + if (nv_dac_crt_connected()) si->ps.monitors |= 0x02; + } /* (sense analog monitor on secondary connector is impossible on NV11) */ /* setup correct output and head use */ @@ -2738,9 +2762,14 @@ { /* presetup by the card's BIOS, we can't change this (lack of info) */ if (si->ps.tmds1_active) si->ps.monitors |= 0x01; - /* detect analog monitor (confirmed working OK on all cards): */ - /* sense analog monitor on primary connector */ - if (nv_dac_crt_connected()) si->ps.monitors |= 0x02; + /* detect analog monitors. First try EDID, else use load sensing. */ + /* (load sensing is confirmed working OK on all cards.) */ + /* primary connector: */ + if (si->ps.con1_screen.have_edid) { + if (!si->ps.con1_screen.digital) si->ps.monitors |= 0x02; + } else { + if (nv_dac_crt_connected()) si->ps.monitors |= 0x02; + } //fixme? add TVout (only, so no CRT connected) support... } From bonefish at mail.berlios.de Wed Jun 17 21:38:51 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 17 Jun 2009 21:38:51 +0200 Subject: [Haiku-commits] r31094 - haiku/trunk/headers/os/interface Message-ID: <200906171938.n5HJcpnI022058@sheep.berlios.de> Author: bonefish Date: 2009-06-17 21:38:51 +0200 (Wed, 17 Jun 2009) New Revision: 31094 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31094&view=rev Added: haiku/trunk/headers/os/interface/LayoutBuilder.h Log: New approach to layout building: * The new builders are templatized and completely inline. * They are easily nestable, which only worked for groups with the old approach. * Added builder for split views. Added: haiku/trunk/headers/os/interface/LayoutBuilder.h =================================================================== --- haiku/trunk/headers/os/interface/LayoutBuilder.h 2009-06-17 19:20:02 UTC (rev 31093) +++ haiku/trunk/headers/os/interface/LayoutBuilder.h 2009-06-17 19:38:51 UTC (rev 31094) @@ -0,0 +1,688 @@ +/* + * Copyright 2009, Haiku Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _LAYOUT_BUILDER_H +#define _LAYOUT_BUILDER_H + +#include +#include +#include +#include +#include +#include + + +namespace BLayoutBuilder { + +template class Base; +template class Group; +template class Grid; +template class Split; + + +template +class Base { +protected: + inline Base(); + +public: + inline void SetParent(ParentBuilder* parent); + // conceptionally private + + inline ParentBuilder& End(); + +protected: + ParentBuilder* fParent; +}; + + +template +class Group : public Base { +public: + typedef Group ThisBuilder; + typedef Group GroupBuilder; + typedef Grid GridBuilder; + typedef Split SplitBuilder; + +public: + inline Group(enum orientation orientation + = B_HORIZONTAL, + float spacing = 0.0f); + inline Group(BGroupLayout* layout); + inline Group(BGroupView* view); + + inline BGroupLayout* Layout() const; + inline BView* View() const; + inline ThisBuilder& GetLayout(BGroupLayout** _layout); + inline ThisBuilder& GetView(BView** _view); + + inline ThisBuilder& Add(BView* view); + inline ThisBuilder& Add(BView* view, float weight); + inline ThisBuilder& Add(BLayoutItem* item); + inline ThisBuilder& Add(BLayoutItem* item, float weight); + + inline GroupBuilder AddGroup(enum orientation orientation, + float spacing = 0.0f, float weight = 1.0f); + inline GridBuilder AddGrid(float horizontalSpacing = 0.0f, + float verticalSpacing = 0.0f, + float weight = 1.0f); + inline SplitBuilder AddSplit(enum orientation orientation, + float spacing = 0.0f, float weight = 1.0f); + + inline ThisBuilder& AddGlue(float weight = 1.0f); + inline ThisBuilder& AddStrut(float size); + + inline ThisBuilder& SetInsets(float left, float top, float right, + float bottom); + + inline operator BGroupLayout*(); + inline operator BView*(); + +private: + BGroupLayout* fLayout; +}; + + +template +class Grid : public Base { +public: + typedef Grid ThisBuilder; + typedef Group GroupBuilder; + typedef Grid GridBuilder; + typedef Split SplitBuilder; + +public: + inline Grid(float horizontalSpacing = 0.0f, + float verticalSpacing = 0.0f); + inline Grid(BGridLayout* layout); + inline Grid(BGridView* view); + + inline BGridLayout* Layout() const; + inline BView* View() const; + inline ThisBuilder& GetLayout(BGridLayout** _layout); + inline ThisBuilder& GetView(BView** _view); + + inline ThisBuilder& Add(BView* view, int32 column, int32 row, + int32 columnCount = 1, int32 rowCount = 1); + inline ThisBuilder& Add(BLayoutItem* item, int32 column, int32 row, + int32 columnCount = 1, int32 rowCount = 1); + + inline GroupBuilder AddGroup(enum orientation orientation, + float spacing, int32 column, int32 row, + int32 columnCount = 1, int32 rowCount = 1); + inline GridBuilder AddGrid(float horizontalSpacing, + float verticalSpacing, int32 column, + int32 row, int32 columnCount = 1, + int32 rowCount = 1); + inline SplitBuilder AddSplit(enum orientation orientation, + float spacing, int32 column, int32 row, + int32 columnCount = 1, int32 rowCount = 1); + + inline ThisBuilder& SetColumnWeight(int32 column, float weight); + inline ThisBuilder& SetRowWeight(int32 row, float weight); + + inline ThisBuilder& SetInsets(float left, float top, float right, + float bottom); + + inline operator BGridLayout*(); + inline operator BView*(); + +private: + BGridLayout* fLayout; +}; + + +template +class Split : public Base { +public: + typedef Split ThisBuilder; + typedef Group GroupBuilder; + typedef Grid GridBuilder; + typedef Split SplitBuilder; + +public: + inline Split(enum orientation orientation + = B_HORIZONTAL, + float spacing = 0.0f); + inline Split(BSplitView* view); + + inline BSplitView* View() const; + inline ThisBuilder& GetView(BSplitView** _view); + + inline ThisBuilder& Add(BView* view); + inline ThisBuilder& Add(BView* view, float weight); + inline ThisBuilder& Add(BLayoutItem* item); + inline ThisBuilder& Add(BLayoutItem* item, float weight); + + inline GroupBuilder AddGroup(enum orientation orientation, + float spacing = 0.0f, float weight = 1.0f); + inline GridBuilder AddGrid(float horizontalSpacing = 0.0f, + float verticalSpacing = 0.0f, + float weight = 1.0f); + inline SplitBuilder AddSplit(enum orientation orientation, + float spacing = 0.0f, float weight = 1.0f); + + inline ThisBuilder& SetCollapsible(bool collapsible); + inline ThisBuilder& SetCollapsible(int32 index, bool collapsible); + inline ThisBuilder& SetCollapsible(int32 first, int32 last, + bool collapsible); + + inline operator BSplitView*(); + +private: + BSplitView* fView; +}; + + +// #pragma mark - Base + + +template +Base::Base() + : + fParent(NULL) +{ +} + + +template +void +Base::SetParent(ParentBuilder* parent) +{ + fParent = parent; +} + + +template +ParentBuilder& +Base::End() +{ + return *fParent; +} + + +// #pragma mark - Group + + +template +Group::Group(enum orientation orientation, float spacing) + : + fLayout((new BGroupView(orientation, spacing))->GroupLayout()) +{ +} + + +template +Group::Group(BGroupLayout* layout) + : + fLayout(layout) +{ +} + + +template +Group::Group(BGroupView* view) + : + fLayout(view->GroupLayout()) +{ +} + + +template +BGroupLayout* +Group::Layout() const +{ + return fLayout; +} + + +template +BView* +Group::View() const +{ + return fLayout->View(); +} + + +template +typename Group::ThisBuilder& +Group::GetLayout(BGroupLayout** _layout) +{ + *_layout = fLayout; + return *this; +} + + +template +typename Group::ThisBuilder& +Group::GetView(BView** _view) +{ + *_view = fLayout->View(); + return *this; +} + + +template +typename Group::ThisBuilder& +Group::Add(BView* view) +{ + fLayout->AddView(view); + return *this; +} + + +template +typename Group::ThisBuilder& +Group::Add(BView* view, float weight) +{ + fLayout->AddView(view, weight); + return *this; +} + + +template +typename Group::ThisBuilder& +Group::Add(BLayoutItem* item) +{ + fLayout->AddItem(item); + return *this; +} + + +template +typename Group::ThisBuilder& +Group::Add(BLayoutItem* item, float weight) +{ + fLayout->AddItem(item, weight); + return *this; +} + + +template +typename Group::GroupBuilder +Group::AddGroup(enum orientation orientation, float spacing, + float weight) +{ + GroupBuilder builder(orientation, spacing); + builder.SetParent(this); + fLayout->AddView(builder.View(), weight); + return builder; +} + + +template +typename Group::GridBuilder +Group::AddGrid(float horizontalSpacing, float verticalSpacing, + float weight) +{ + GridBuilder builder(horizontalSpacing, verticalSpacing); + builder.SetParent(this); + fLayout->AddView(builder.View(), weight); + return builder; +} + + +template +typename Group::SplitBuilder +Group::AddSplit(enum orientation orientation, float spacing, + float weight) +{ + SplitBuilder builder(orientation, spacing); + builder.SetParent(this); + fLayout->AddView(builder.View(), weight); + return builder; +} + + +template +typename Group::ThisBuilder& +Group::AddGlue(float weight) +{ + fLayout->AddItem(BSpaceLayoutItem::CreateGlue(), weight); + return *this; +} + + +template +typename Group::ThisBuilder& +Group::AddStrut(float size) +{ + if (fLayout->Orientation() == B_HORIZONTAL) + fLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(size)); + else + fLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(size)); + + return *this; +} + + +template +typename Group::ThisBuilder& +Group::SetInsets(float left, float top, float right, + float bottom) +{ + fLayout->SetInsets(left, top, right, bottom); + return *this; +} + + +template +Group::operator BGroupLayout*() +{ + return fLayout; +} + + +template +Group::operator BView*() +{ + return fLayout->View(); +} + + +// #pragma mark - Grid + + +template +Grid::Grid(float horizontalSpacing, float verticalSpacing) + : + fLayout((new BGridView(horizontalSpacing, verticalSpacing))->GridLayout()) +{ +} + + +template +Grid::Grid(BGridLayout* layout) + : + fLayout(layout) +{ +} + + +template +Grid::Grid(BGridView* view) + : + fLayout(view->GridLayout()) +{ +} + + +template +BGridLayout* +Grid::Layout() const +{ + return fLayout; +} + + +template +BView* +Grid::View() const +{ + return fLayout->View(); +} + + +template +typename Grid::ThisBuilder& +Grid::GetLayout(BGridLayout** _layout) +{ + *_layout = fLayout; + return *this; +} + + +template +typename Grid::ThisBuilder& +Grid::GetView(BView** _view) +{ + *_view = fLayout->View(); + return *this; +} + + +template +typename Grid::ThisBuilder& +Grid::Add(BView* view, int32 column, int32 row, + int32 columnCount, int32 rowCount) +{ + fLayout->AddView(view, column, row, columnCount, rowCount); + return *this; +} + + +template +typename Grid::ThisBuilder& +Grid::Add(BLayoutItem* item, int32 column, int32 row, + int32 columnCount, int32 rowCount) +{ + fLayout->AddItem(item, column, row, columnCount, rowCount); + return *this; +} + + +template +typename Grid::GroupBuilder +Grid::AddGroup(enum orientation orientation, float spacing, + int32 column, int32 row, int32 columnCount, int32 rowCount) +{ + GroupBuilder builder(orientation, spacing); + builder.SetParent(this); + fLayout->AddView(builder.View(), column, row, columnCount, rowCount); + return builder; +} + + +template +typename Grid::GridBuilder +Grid::AddGrid(float horizontalSpacing, float verticalSpacing, + int32 column, int32 row, int32 columnCount, int32 rowCount) +{ + GridBuilder builder(horizontalSpacing, verticalSpacing); + builder.SetParent(this); + fLayout->AddView(builder.View(), column, row, columnCount, rowCount); + return builder; +} + + +template +typename Grid::SplitBuilder +Grid::AddSplit(enum orientation orientation, float spacing, + int32 column, int32 row, int32 columnCount, int32 rowCount) +{ + SplitBuilder builder(orientation, spacing); + builder.SetParent(this); + fLayout->AddView(builder.View(), column, row, columnCount, rowCount); + return builder; +} + + +template +typename Grid::ThisBuilder& +Grid::SetColumnWeight(int32 column, float weight) +{ + fLayout->SetColumnWeight(column, weight); + return *this; +} + + +template +typename Grid::ThisBuilder& +Grid::SetRowWeight(int32 row, float weight) +{ + fLayout->SetRowWeight(row, weight); + return *this; +} + + +template +typename Grid::ThisBuilder& +Grid::SetInsets(float left, float top, float right, + float bottom) +{ + fLayout->SetInsets(left, top, right, bottom); + return *this; +} + + +template +Grid::operator BGridLayout*() +{ + return fLayout; +} + + +template +Grid::operator BView*() +{ + return fLayout->View(); +} + + +// #pragma mark - Split + + +template +Split::Split(enum orientation orientation, float spacing) + : + fView(new BSplitView(orientation, spacing)) +{ +} + + +template +Split::Split(BSplitView* view) + : + fView(view) +{ +} + + +template +BSplitView* +Split::View() const +{ + return fView; +} + + +template +typename Split::ThisBuilder& +Split::GetView(BSplitView** _view) +{ + *_view = fView; + return *this; +} + + +template +typename Split::ThisBuilder& +Split::Add(BView* view) +{ + fView->AddChild(view); + return *this; +} + + +template +typename Split::ThisBuilder& +Split::Add(BView* view, float weight) +{ + fView->AddChild(view, weight); + return *this; +} + + +template +typename Split::ThisBuilder& +Split::Add(BLayoutItem* item) +{ + fView->AddChild(item); + return *this; +} + + +template +typename Split::ThisBuilder& +Split::Add(BLayoutItem* item, float weight) +{ + fView->AddChild(item, weight); + return *this; +} + + +template +typename Split::GroupBuilder +Split::AddGroup(enum orientation orientation, float spacing, + float weight) +{ + GroupBuilder builder(orientation, spacing); + builder.SetParent(this); + fView->AddChild(builder.View(), weight); + return builder; +} + + +template +typename Split::GridBuilder +Split::AddGrid(float horizontalSpacing, float verticalSpacing, + float weight) +{ + GridBuilder builder(horizontalSpacing, verticalSpacing); + builder.SetParent(this); + fView->AddChild(builder.View(), weight); + return builder; +} + + +template +typename Split::SplitBuilder +Split::AddSplit(enum orientation orientation, float spacing, + float weight) +{ + SplitBuilder builder(orientation, spacing); + builder.SetParent(this); + fView->AddChild(builder.View(), weight); + return builder; +} + + +template +typename Split::ThisBuilder& +Split::SetCollapsible(bool collapsible) +{ + fView->SetCollapsible(collapsible); + return *this; +} + + +template +typename Split::ThisBuilder& +Split::SetCollapsible(int32 index, bool collapsible) +{ + fView->SetCollapsible(index, collapsible); + return *this; +} + + +template +typename Split::ThisBuilder& +Split::SetCollapsible(int32 first, int32 last, bool collapsible) +{ + fView->SetCollapsible(first, last, collapsible); + return *this; +} + + +template +Split::operator BSplitView*() +{ + return fView; +} + + +} // namespace BLayoutBuilder + + +#endif // _LAYOUT_BUILDER_H From bonefish at mail.berlios.de Wed Jun 17 21:42:11 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 17 Jun 2009 21:42:11 +0200 Subject: [Haiku-commits] r31095 - haiku/trunk/src/apps/debugger/gui/team_window Message-ID: <200906171942.n5HJgBdR022424@sheep.berlios.de> Author: bonefish Date: 2009-06-17 21:42:11 +0200 (Wed, 17 Jun 2009) New Revision: 31095 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31095&view=rev Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h Log: * Removed the title creator method. Just set the title in the constructor instead. * Used the new layout builders. Now that's how layout code should look. :-) Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-17 19:38:51 UTC (rev 31094) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-17 19:42:11 UTC (rev 31095) @@ -5,7 +5,7 @@ #include "TeamWindow.h" -#include +#include #include #include #include @@ -21,14 +21,18 @@ TeamWindow::TeamWindow(::Team* team, Listener* listener) : - BWindow(BRect(100, 100, 699, 499), _GetWindowTitle(team).String(), - B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), + BWindow(BRect(100, 100, 699, 499), "Team", B_DOCUMENT_WINDOW, + B_ASYNCHRONOUS_CONTROLS), fTeam(team), fListener(listener), fTabView(NULL), fThreadListView(NULL), fImageListView(NULL) { + BString name = team->Name(); + if (team->ID() >= 0) + name << " (" << team->ID() << ")"; + SetTitle(name.String()); } @@ -71,40 +75,25 @@ } -/*static*/ BString -TeamWindow::_GetWindowTitle(::Team* team) -{ - BString name = team->Name(); - if (team->ID() >= 0) - name << " (" << team->ID() << ")"; - return name; -} - - void TeamWindow::_Init() { BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); SetLayout(rootLayout); - BSplitView* mainSplitView = new BSplitView(B_VERTICAL, 3.0f); - BGroupLayoutBuilder(rootLayout) - .Add(mainSplitView); + BLayoutBuilder::Group<>(rootLayout) + .AddSplit(B_VERTICAL, 3.0f) + .Add(fTabView = new BTabView("tab view"), 0.4f) + .AddSplit(B_HORIZONTAL, 3.0f) + .Add(fImageListView = ImageListView::Create()) + .Add(new BTextView("source view"), 2.0f) + .End() + .End(); - fTabView = new BTabView("tab view"); - mainSplitView->AddChild(fTabView, 0.4f); - fTabView->AddTab(fThreadListView = ThreadListView::Create()); // fTabView->AddTab(fTeamsPage = new TeamsPage(this)); // fTabView->AddTab(fThreadsPage = new ThreadsPage(this)); - BSplitView* imageAndSourceSplitView = new BSplitView(B_HORIZONTAL, 3.0f); - mainSplitView->AddChild(imageAndSourceSplitView); - - fImageListView = ImageListView::Create(); - imageAndSourceSplitView->AddChild(fImageListView); - imageAndSourceSplitView->AddChild(new BTextView("source view"), 2.0f); - fThreadListView->SetTeam(fTeam); fImageListView->SetTeam(fTeam); } Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-17 19:38:51 UTC (rev 31094) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-17 19:42:11 UTC (rev 31095) @@ -30,7 +30,6 @@ virtual bool QuitRequested(); private: - static BString _GetWindowTitle(::Team* team); void _Init(); private: From bonefish at mail.berlios.de Thu Jun 18 02:23:17 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 18 Jun 2009 02:23:17 +0200 Subject: [Haiku-commits] r31096 - haiku/trunk/src/apps/debuganalyzer/gui/table Message-ID: <200906180023.n5I0NHLB026223@sheep.berlios.de> Author: bonefish Date: 2009-06-18 02:23:16 +0200 (Thu, 18 Jun 2009) New Revision: 31096 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31096&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h Log: Added selection support to Table. Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp 2009-06-17 19:42:11 UTC (rev 31095) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp 2009-06-18 00:23:16 UTC (rev 31096) @@ -82,3 +82,24 @@ { BColumnListView::ResizeAllColumnsToPreferred(); } + + +list_view_type +AbstractTable::SelectionMode() const +{ + return BColumnListView::SelectionMode(); +} + + +void +AbstractTable::SetSelectionMode(list_view_type type) +{ + BColumnListView::SetSelectionMode(type); +} + + +void +AbstractTable::DeselectAll() +{ + BColumnListView::DeselectAll(); +} Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-17 19:42:11 UTC (rev 31095) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-18 00:23:16 UTC (rev 31096) @@ -33,6 +33,10 @@ void ResizeColumnToPreferred(int32 index); void ResizeAllColumnsToPreferred(); + list_view_type SelectionMode() const; + void SetSelectionMode(list_view_type type); + void DeselectAll(); + protected: class AbstractColumn; Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-17 19:42:11 UTC (rev 31095) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-18 00:23:16 UTC (rev 31096) @@ -93,6 +93,83 @@ } +// #pragma mark - TableSelectionModel + +TableSelectionModel::TableSelectionModel(Table* table) + : + fTable(table), + fRows(NULL), + fRowCount(-1) +{ +} + + +TableSelectionModel::~TableSelectionModel() +{ + delete[] fRows; +} + + +int32 +TableSelectionModel::CountRows() +{ + _Update(); + + return fRowCount; +} + + +int32 +TableSelectionModel::RowAt(int32 index) +{ + _Update(); + + return index >= 0 && index < fRowCount ? fRows[index] : -1; +} + + +void +TableSelectionModel::_SelectionChanged() +{ + if (fRowCount >= 0) { + fRowCount = -1; + delete[] fRows; + fRows = NULL; + } +} + + +void +TableSelectionModel::_Update() +{ + if (fRowCount >= 0) + return; + + // count the rows + fRowCount = 0; + BRow* row = NULL; + while ((row = fTable->CurrentSelection(row)) != NULL) + fRowCount++; + + if (fRowCount == 0) + return; + + // allocate row array + fRows = new(std::nothrow) int32[fRowCount]; + if (fRows == NULL) { + fRowCount = 0; + return; + } + + // get the rows + row = NULL; + int32 index = 0; + while ((row = fTable->CurrentSelection(row)) != NULL) + fRows[index++] = fTable->_ModelIndexOfRow(row); +} + + + // #pragma mark - TableListener @@ -102,6 +179,12 @@ void +TableListener::TableSelectionChanged(Table* table) +{ +} + + +void TableListener::TableRowInvoked(Table* table, int32 rowIndex) { } @@ -233,7 +316,9 @@ bool showHorizontalScrollbar) : AbstractTable(name, flags, borderStyle, showHorizontalScrollbar), - fModel(NULL) + fModel(NULL), + fSelectionModel(this), + fIgnoreSelectionChange(0) { } @@ -242,7 +327,9 @@ border_style borderStyle, bool showHorizontalScrollbar) : AbstractTable(name, flags, borderStyle, showHorizontalScrollbar), - fModel(NULL) + fModel(NULL), + fSelectionModel(this), + fIgnoreSelectionChange(0) { SetTableModel(model); } @@ -287,6 +374,38 @@ } +TableSelectionModel* +Table::SelectionModel() +{ + return &fSelectionModel; +} + + +void +Table::SelectRow(int32 rowIndex, bool extendSelection) +{ + BRow* row = fRows.ItemAt(rowIndex); + if (row == NULL) + return; + + if (!extendSelection) { + fIgnoreSelectionChange++; + DeselectAll(); + fIgnoreSelectionChange--; + } + + AddToSelection(row); +} + + +void +Table::DeselectRow(int32 rowIndex) +{ + if (BRow* row = fRows.ItemAt(rowIndex)) + Deselect(row); +} + + bool Table::AddTableListener(TableListener* listener) { @@ -301,6 +420,22 @@ } +void +Table::SelectionChanged() +{ + if (fIgnoreSelectionChange > 0) + return; + + fSelectionModel._SelectionChanged(); + + if (!fListeners.IsEmpty()) { + int32 listenerCount = fListeners.CountItems(); + for (int32 i = listenerCount - 1; i >= 0; i--) + fListeners.ItemAt(i)->TableSelectionChanged(this); + } +} + + AbstractTable::AbstractColumn* Table::CreateColumn(TableColumn* column) { @@ -367,15 +502,25 @@ if (fListeners.IsEmpty()) return; - BRow* row = CurrentSelection(); - if (row == NULL) + int32 index = _ModelIndexOfRow(CurrentSelection()); + if (index < 0) return; + int32 listenerCount = fListeners.CountItems(); + for (int32 i = listenerCount - 1; i >= 0; i--) + fListeners.ItemAt(i)->TableRowInvoked(this, index); +} + + +int32 +Table::_ModelIndexOfRow(BRow* row) +{ + if (row == NULL) + return -1; + TableField* field = dynamic_cast(row->GetField(0)); if (field == NULL) - return; + return -1; - int32 listenerCount = fListeners.CountItems(); - for (int32 i = listenerCount - 1; i >= 0; i--) - fListeners.ItemAt(i)->TableRowInvoked(this, field->RowIndex()); + return field->RowIndex(); } Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-17 19:42:11 UTC (rev 31095) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-18 00:23:16 UTC (rev 31096) @@ -55,10 +55,33 @@ }; +class TableSelectionModel { +public: + TableSelectionModel(Table* table); + ~TableSelectionModel(); + + int32 CountRows(); + int32 RowAt(int32 index); + +private: + friend class Table; + +private: + void _SelectionChanged(); + void _Update(); + +private: + Table* fTable; + int32* fRows; + int32 fRowCount; +}; + + class TableListener { public: virtual ~TableListener(); + virtual void TableSelectionChanged(Table* table); virtual void TableRowInvoked(Table* table, int32 rowIndex); }; @@ -77,10 +100,17 @@ void SetTableModel(TableModel* model); TableModel* GetTableModel() const { return fModel; } + TableSelectionModel* SelectionModel(); + + void SelectRow(int32 rowIndex, bool extendSelection); + void DeselectRow(int32 rowIndex); + bool AddTableListener(TableListener* listener); void RemoveTableListener(TableListener* listener); protected: + virtual void SelectionChanged(); + virtual AbstractColumn* CreateColumn(TableColumn* column); private: @@ -92,16 +122,22 @@ private: class Column; + friend class TableSelectionModel; + typedef BObjectList ListenerList; typedef BObjectList RowList; private: virtual void ItemInvoked(); + int32 _ModelIndexOfRow(BRow* row); + private: TableModel* fModel; RowList fRows; + TableSelectionModel fSelectionModel; ListenerList fListeners; + int32 fIgnoreSelectionChange; }; From bonefish at mail.berlios.de Thu Jun 18 02:35:14 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 18 Jun 2009 02:35:14 +0200 Subject: [Haiku-commits] r31097 - in haiku/trunk/src/apps/debugger: . gui/team_window Message-ID: <200906180035.n5I0ZEDs027102@sheep.berlios.de> Author: bonefish Date: 2009-06-18 02:35:12 +0200 (Thu, 18 Jun 2009) New Revision: 31097 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31097&view=rev Added: haiku/trunk/src/apps/debugger/MessageCodes.h haiku/trunk/src/apps/debugger/TeamDebugModel.cpp haiku/trunk/src/apps/debugger/TeamDebugModel.h Modified: haiku/trunk/src/apps/debugger/Image.cpp haiku/trunk/src/apps/debugger/Image.h haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h haiku/trunk/src/apps/debugger/Thread.cpp haiku/trunk/src/apps/debugger/Thread.h haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.h Log: * Changed the layout of the team window. Trying a single window approach. * Added Run/Step* buttons. * Added some handling for selection in the thread list. * Extended listener mechanisms all over the place (in models and views). * The team debugger now gets the initial states for the team's threads. Modified: haiku/trunk/src/apps/debugger/Image.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Image.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Image.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -6,8 +6,9 @@ #include "Image.h" -Image::Image(const image_info& imageInfo) +Image::Image(Team* team,const image_info& imageInfo) : + fTeam(team), fInfo(imageInfo) { } Modified: haiku/trunk/src/apps/debugger/Image.h =================================================================== --- haiku/trunk/src/apps/debugger/Image.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Image.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -11,18 +11,24 @@ #include +class Team; + + class Image : public Referenceable, public DoublyLinkedListLinkImpl { public: - Image(const image_info& imageInfo); + Image(Team* team, const image_info& imageInfo); ~Image(); status_t Init(); + + Team* GetTeam() const { return fTeam; } image_id ID() const { return fInfo.id; } const char* Name() const { return fInfo.name; } const image_info& Info() const { return fInfo; } private: + Team* fTeam; image_info fInfo; }; Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 00:35:12 UTC (rev 31097) @@ -20,8 +20,9 @@ ElfFile.cpp Image.cpp + Team.cpp TeamDebugger.cpp - Team.cpp + TeamDebugModel.cpp Thread.cpp # DebugAnalyzer:util Added: haiku/trunk/src/apps/debugger/MessageCodes.h =================================================================== --- haiku/trunk/src/apps/debugger/MessageCodes.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/MessageCodes.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -0,0 +1,17 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef MESSAGE_CODES_H +#define MESSAGE_CODES_H + + +enum { + MSG_THREAD_RUN = 'run_', + MSG_THREAD_STEP_OVER = 'stov', + MSG_THREAD_STEP_INTO = 'stin', + MSG_THREAD_STEP_OUT = 'stou' +}; + + +#endif // MESSAGE_CODES_H Modified: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -7,7 +7,9 @@ #include +#include + // #pragma mark - Team @@ -53,7 +55,7 @@ status_t Team::AddThread(const thread_info& threadInfo, Thread** _thread) { - Thread* thread = new(std::nothrow) Thread(threadInfo.thread); + Thread* thread = new(std::nothrow) Thread(this, threadInfo.thread); if (thread == NULL) return B_NO_MEMORY; @@ -134,7 +136,7 @@ status_t Team::AddImage(const image_info& imageInfo, Image** _image) { - Image* image = new(std::nothrow) Image(imageInfo); + Image* image = new(std::nothrow) Image(this, imageInfo); if (image == NULL) return B_NO_MEMORY; @@ -197,6 +199,7 @@ void Team::AddListener(Listener* listener) { + AutoLocker locker(this); fListeners.Add(listener); } @@ -204,6 +207,7 @@ void Team::RemoveListener(Listener* listener) { + AutoLocker locker(this); fListeners.Remove(listener); } @@ -213,7 +217,7 @@ { for (ListenerList::Iterator it = fListeners.GetIterator(); Listener* listener = it.Next();) { - listener->ThreadAdded(this, thread); + listener->ThreadAdded(ThreadEvent(TEAM_EVENT_THREAD_ADDED, thread)); } } @@ -223,7 +227,7 @@ { for (ListenerList::Iterator it = fListeners.GetIterator(); Listener* listener = it.Next();) { - listener->ThreadRemoved(this, thread); + listener->ThreadRemoved(ThreadEvent(TEAM_EVENT_THREAD_REMOVED, thread)); } } @@ -233,7 +237,7 @@ { for (ListenerList::Iterator it = fListeners.GetIterator(); Listener* listener = it.Next();) { - listener->ImageAdded(this, image); + listener->ImageAdded(ImageEvent(TEAM_EVENT_IMAGE_ADDED, image)); } } @@ -243,37 +247,71 @@ { for (ListenerList::Iterator it = fListeners.GetIterator(); Listener* listener = it.Next();) { - listener->ImageRemoved(this, image); + listener->ImageRemoved(ImageEvent(TEAM_EVENT_IMAGE_REMOVED, image)); } } +// #pragma mark - Event + + +Team::Event::Event(uint32 type, Team* team) + : + fEventType(type), + fTeam(team) +{ +} + + +// #pragma mark - ThreadEvent + + +Team::ThreadEvent::ThreadEvent(uint32 type, Thread* thread) + : + Event(type, thread->GetTeam()), + fThread(thread) +{ +} + + +// #pragma mark - ImageEvent + + +Team::ImageEvent::ImageEvent(uint32 type, Image* image) + : + Event(type, image->GetTeam()), + fImage(image) +{ +} + + // #pragma mark - Listener + Team::Listener::~Listener() { } void -Team::Listener::ThreadAdded(Team* team, Thread* thread) +Team::Listener::ThreadAdded(const Team::ThreadEvent& event) { } void -Team::Listener::ThreadRemoved(Team* team, Thread* thread) +Team::Listener::ThreadRemoved(const Team::ThreadEvent& event) { } void -Team::Listener::ImageAdded(Team* team, Image* image) +Team::Listener::ImageAdded(const Team::ImageEvent& event) { } void -Team::Listener::ImageRemoved(Team* team, Image* image) +Team::Listener::ImageRemoved(const Team::ImageEvent& event) { } Modified: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -11,8 +11,20 @@ #include "Thread.h" +// team event types +enum { + TEAM_EVENT_THREAD_ADDED, + TEAM_EVENT_THREAD_REMOVED, + TEAM_EVENT_IMAGE_ADDED, + TEAM_EVENT_IMAGE_REMOVED +}; + + class Team : public BLocker { public: + class Event; + class ThreadEvent; + class ImageEvent; class Listener; public: @@ -65,15 +77,50 @@ }; +class Team::Event { +public: + Event(uint32 type, Team* team); + + uint32 EventType() const { return fEventType; } + Team* GetTeam() const { return fTeam; } + +protected: + uint32 fEventType; + Team* fTeam; +}; + + +class Team::ThreadEvent : public Event { +public: + ThreadEvent(uint32 type, Thread* thread); + + Thread* GetThread() const { return fThread; } + +protected: + Thread* fThread; +}; + + +class Team::ImageEvent : public Event { +public: + ImageEvent(uint32 type, Image* image); + + Image* GetImage() const { return fImage; } + +protected: + Image* fImage; +}; + + class Team::Listener : public DoublyLinkedListLinkImpl { public: virtual ~Listener(); - virtual void ThreadAdded(Team* team, Thread* thread); - virtual void ThreadRemoved(Team* team, Thread* thread); + virtual void ThreadAdded(const Team::ThreadEvent& event); + virtual void ThreadRemoved(const Team::ThreadEvent& event); - virtual void ImageAdded(Team* team, Image* image); - virtual void ImageRemoved(Team* team, Image* image); + virtual void ImageAdded(const Team::ImageEvent& event); + virtual void ImageRemoved(const Team::ImageEvent& event); }; Added: haiku/trunk/src/apps/debugger/TeamDebugModel.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugModel.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/TeamDebugModel.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -0,0 +1,67 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "TeamDebugModel.h" + +#include + +#include + + +// #pragma mark - TeamDebugModel + + +TeamDebugModel::TeamDebugModel(Team* team) + : + fTeam(team) +{ +} + + +TeamDebugModel::~TeamDebugModel() +{ +} + + +status_t +TeamDebugModel::Init() +{ + return B_OK; +} + + +void +TeamDebugModel::AddListener(Listener* listener) +{ + AutoLocker locker(this); + fListeners.Add(listener); +} + + +void +TeamDebugModel::RemoveListener(Listener* listener) +{ + AutoLocker locker(this); + fListeners.Remove(listener); +} + + +// #pragma mark - Event + + +TeamDebugModel::Event::Event(uint32 type, TeamDebugModel* model) + : + fEventType(type), + fModel(model) +{ +} + + +// #pragma mark - Listener + + +TeamDebugModel::Listener::~Listener() +{ +} Added: haiku/trunk/src/apps/debugger/TeamDebugModel.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugModel.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/TeamDebugModel.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -0,0 +1,68 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef TEAM_DEBUG_MODEL_H +#define TEAM_DEBUG_MODEL_H + +#include "Team.h" + + +// team debug model event types +//enum { +// TEAM_EVENT_THREAD_ADDED +//}; + + +class TeamDebugModel { +public: + class Event; + class Listener; + +public: + TeamDebugModel(Team* team); + ~TeamDebugModel(); + + status_t Init(); + + bool Lock() { return fTeam->Lock(); } + void Unlock() { fTeam->Unlock(); } + + Team* GetTeam() const { return fTeam; } + + void AddListener(Listener* listener); + void RemoveListener(Listener* listener); + +private: + typedef DoublyLinkedList ListenerList; + +private: + Team* fTeam; + ListenerList fListeners; +}; + + +class TeamDebugModel::Event { +public: + Event(uint32 type, TeamDebugModel* model); + + uint32 EventType() const { return fEventType; } + TeamDebugModel* Model() const { return fModel; } + +protected: + uint32 fEventType; + TeamDebugModel* fModel; +}; + + + +class TeamDebugModel::Listener + : public DoublyLinkedListLinkImpl { +public: + virtual ~Listener(); + +// virtual void ThreadAdded(const Team::ThreadEvent& event); +}; + + +#endif // TEAM_DEBUG_MODEL_H Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -16,12 +16,14 @@ #include "debug_utils.h" #include "Team.h" +#include "TeamDebugModel.h" TeamDebugger::TeamDebugger() : BLooper("team debugger"), fTeam(NULL), + fDebugModel(NULL), fTeamID(-1), fDebuggerPort(-1), fNubPort(-1), @@ -29,6 +31,7 @@ fTeamWindow(NULL), fTerminating(false) { + fDebugContext.reply_port = -1; } @@ -46,6 +49,9 @@ if (fDebugEventListener >= 0) wait_for_thread(fDebugEventListener, NULL); + destroy_debug_context(&fDebugContext); + + delete fDebugModel; delete fTeam; } @@ -72,6 +78,15 @@ fTeam->SetName(teamInfo.args); // TODO: Set a better name! + // create the team debug model + fDebugModel = new(std::nothrow) TeamDebugModel(fTeam); + if (fDebugModel == NULL) + return B_NO_MEMORY; + + error = fDebugModel->Init(); + if (error != B_OK) + return error; + // create debugger port char buffer[128]; snprintf(buffer, sizeof(buffer), "team %ld debugger", fTeamID); @@ -99,9 +114,12 @@ thread_info threadInfo; int32 cookie = 0; while (get_next_thread_info(fTeamID, &cookie, &threadInfo) == B_OK) { - error = fTeam->AddThread(threadInfo); + ::Thread* thread; + error = fTeam->AddThread(threadInfo, &thread); if (error != B_OK) return error; + + _UpdateThreadState(thread); } image_info imageInfo; @@ -128,7 +146,7 @@ // create the team window try { - fTeamWindow = TeamWindow::Create(fTeam, this); + fTeamWindow = TeamWindow::Create(fDebugModel, this); } catch (...) { // TODO: Notify the user! fprintf(stderr, "Error: Failed to create team window!\n"); @@ -303,3 +321,28 @@ fTeam->RemoveImage(message.info.id); return false; } + + +void +TeamDebugger::_UpdateThreadState(::Thread* thread) +{ + debug_nub_get_cpu_state message; + message.reply_port = fDebugContext.reply_port; + message.thread = thread->ID(); + + debug_nub_get_cpu_state_reply reply; + + status_t error = send_debug_message(&fDebugContext, + B_DEBUG_MESSAGE_GET_CPU_STATE, &message, sizeof(message), &reply, + sizeof(reply)); + + uint32 newState = THREAD_STATE_UNKNOWN; + if (error == B_OK) { + if (reply.error == B_OK) + newState = THREAD_STATE_STOPPED; + else if (reply.error == B_BAD_THREAD_STATE) + newState = THREAD_STATE_RUNNING; + } + + thread->SetState(newState); +} Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -15,6 +15,7 @@ class Team; +class TeamDebugModel; class TeamDebugger : public DoublyLinkedListLinkImpl, @@ -47,8 +48,11 @@ bool _HandleImageDeleted( const debug_image_deleted& message); + void _UpdateThreadState(::Thread* thread); + private: ::Team* fTeam; + TeamDebugModel* fDebugModel; team_id fTeamID; port_id fDebuggerPort; port_id fNubPort; Modified: haiku/trunk/src/apps/debugger/Thread.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -6,9 +6,11 @@ #include "Thread.h" -Thread::Thread(thread_id threadID) +Thread::Thread(Team* team, thread_id threadID) : - fID(threadID) + fTeam(team), + fID(threadID), + fState(THREAD_STATE_UNKNOWN) { } @@ -30,3 +32,10 @@ { fName = name; } + + +void +Thread::SetState(uint32 state) +{ + fState = state; +} Modified: haiku/trunk/src/apps/debugger/Thread.h =================================================================== --- haiku/trunk/src/apps/debugger/Thread.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/Thread.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -12,22 +12,37 @@ #include +class Team; + + +enum { + THREAD_STATE_UNKNOWN, + THREAD_STATE_RUNNING, + THREAD_STATE_STOPPED +}; + + class Thread : public Referenceable, public DoublyLinkedListLinkImpl { public: - Thread(thread_id threadID); + Thread(Team* team, thread_id threadID); ~Thread(); status_t Init(); - thread_id ID() const { return fID; } + Team* GetTeam() const { return fTeam; } + thread_id ID() const { return fID; } const char* Name() const { return fName.String(); } void SetName(const BString& name); + uint32 State() const { return fState; } + void SetState(uint32 state); private: + Team* fTeam; thread_id fID; BString fName; + uint32 fState; }; Modified: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -204,14 +204,14 @@ void -ImageListView::ImageAdded(Team* team, Image* image) +ImageListView::ImageAdded(const Team::ImageEvent& event) { Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this); } void -ImageListView::ImageRemoved(Team* team, Image* image) +ImageListView::ImageRemoved(const Team::ImageEvent& event) { Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this); } Modified: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -29,8 +29,8 @@ private: // Team::Listener - virtual void ImageAdded(Team* team, Image* image); - virtual void ImageRemoved(Team* team, Image* image); + virtual void ImageAdded(const Team::ImageEvent& event); + virtual void ImageRemoved(const Team::ImageEvent& event); // TableListener virtual void TableRowInvoked(Table* table, int32 rowIndex); Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -5,6 +5,9 @@ #include "TeamWindow.h" +#include + +#include #include #include #include @@ -12,23 +15,29 @@ #include #include "ImageListView.h" -#include "Team.h" -#include "ThreadListView.h" +#include "MessageCodes.h" +#include "TeamDebugModel.h" // #pragma mark - TeamWindow -TeamWindow::TeamWindow(::Team* team, Listener* listener) +TeamWindow::TeamWindow(TeamDebugModel* debugModel, Listener* listener) : - BWindow(BRect(100, 100, 699, 499), "Team", B_DOCUMENT_WINDOW, + BWindow(BRect(100, 100, 899, 699), "Team", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), - fTeam(team), + fDebugModel(debugModel), + fActiveThread(NULL), fListener(listener), fTabView(NULL), fThreadListView(NULL), - fImageListView(NULL) + fImageListView(NULL), + fRunButton(NULL), + fStepOverButton(NULL), + fStepIntoButton(NULL), + fStepOutButton(NULL) { + ::Team* team = debugModel->GetTeam(); BString name = team->Name(); if (team->ID() >= 0) name << " (" << team->ID() << ")"; @@ -42,9 +51,9 @@ /*static*/ TeamWindow* -TeamWindow::Create(::Team* team, Listener* listener) +TeamWindow::Create(TeamDebugModel* debugModel, Listener* listener) { - TeamWindow* self = new TeamWindow(team, listener); + TeamWindow* self = new TeamWindow(debugModel, listener); try { self->_Init(); @@ -61,6 +70,18 @@ TeamWindow::MessageReceived(BMessage* message) { switch (message->what) { + case MSG_THREAD_RUN: +printf("MSG_THREAD_RUN\n"); + break; + case MSG_THREAD_STEP_OVER: +printf("MSG_THREAD_STEP_OVER\n"); + break; + case MSG_THREAD_STEP_INTO: +printf("MSG_THREAD_STEP_INTO\n"); + break; + case MSG_THREAD_STEP_OUT: +printf("MSG_THREAD_STEP_OUT\n"); + break; default: BWindow::MessageReceived(message); break; @@ -76,6 +97,13 @@ void +TeamWindow::ThreadSelectionChanged(::Thread* thread) +{ + _SetActiveThread(thread); +} + + +void TeamWindow::_Init() { BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); @@ -84,21 +112,96 @@ BLayoutBuilder::Group<>(rootLayout) .AddSplit(B_VERTICAL, 3.0f) .Add(fTabView = new BTabView("tab view"), 0.4f) - .AddSplit(B_HORIZONTAL, 3.0f) - .Add(fImageListView = ImageListView::Create()) - .Add(new BTextView("source view"), 2.0f) + .AddGroup(B_VERTICAL, 4.0f) + .AddGroup(B_HORIZONTAL, 4.0f) + .Add(fRunButton = new BButton("Run")) + .Add(fStepOverButton = new BButton("Step Over")) + .Add(fStepIntoButton = new BButton("Step Into")) + .Add(fStepOutButton = new BButton("Step Out")) + .AddGlue() + .End() + .AddSplit(B_HORIZONTAL, 3.0f) + .Add(new BTextView("source view"), 3.0f) + .Add(new BTextView("variables view")) + .End() .End() .End(); - - fTabView->AddTab(fThreadListView = ThreadListView::Create()); -// fTabView->AddTab(fTeamsPage = new TeamsPage(this)); -// fTabView->AddTab(fThreadsPage = new ThreadsPage(this)); - fThreadListView->SetTeam(fTeam); - fImageListView->SetTeam(fTeam); + // add threads tab + BSplitView* threadGroup = new BSplitView(B_HORIZONTAL); + threadGroup->SetName("Threads"); + fTabView->AddTab(threadGroup); + BLayoutBuilder::Split<>(threadGroup) + .Add(fThreadListView = ThreadListView::Create(this)) + .Add(new BTextView("stack frames")); + + // add images tab + BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL); + imagesGroup->SetName("Images"); + fTabView->AddTab(imagesGroup); + BLayoutBuilder::Split<>(imagesGroup) + .Add(fImageListView = ImageListView::Create()) + .Add(new BTextView("source files")); + + fThreadListView->SetTeam(fDebugModel->GetTeam()); + fImageListView->SetTeam(fDebugModel->GetTeam()); + + fRunButton->SetMessage(new BMessage(MSG_THREAD_RUN)); + fStepOverButton->SetMessage(new BMessage(MSG_THREAD_STEP_OVER)); + fStepIntoButton->SetMessage(new BMessage(MSG_THREAD_STEP_INTO)); + fStepOutButton->SetMessage(new BMessage(MSG_THREAD_STEP_OUT)); + fRunButton->SetTarget(this); + fStepOverButton->SetTarget(this); + fRunButton->SetTarget(this); + fStepOutButton->SetTarget(this); + + _UpdateRunButtons(); } +void +TeamWindow::_SetActiveThread(::Thread* thread) +{ + if (thread == fActiveThread) + return; + + fActiveThread = thread; + + _UpdateRunButtons(); +} + + +void +TeamWindow::_UpdateRunButtons() +{ + uint32 threadState = fActiveThread != NULL + ? fActiveThread->State() : THREAD_STATE_UNKNOWN; + + switch (threadState) { + case THREAD_STATE_UNKNOWN: + fRunButton->SetEnabled(false); + fStepOverButton->SetEnabled(false); + fStepIntoButton->SetEnabled(false); + fStepOutButton->SetEnabled(false); + break; + case THREAD_STATE_RUNNING: + fRunButton->SetLabel("Stop"); + fRunButton->SetEnabled(true); + fStepOverButton->SetEnabled(false); + fStepIntoButton->SetEnabled(false); + fStepOutButton->SetEnabled(false); + break; + case THREAD_STATE_STOPPED: + fRunButton->SetLabel("Run"); + fRunButton->SetEnabled(true); + fStepOverButton->SetEnabled(true); + fStepIntoButton->SetEnabled(true); + fStepOutButton->SetEnabled(true); + break; + } +} + + // #pragma mark - Listener Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-18 00:35:12 UTC (rev 31097) @@ -8,36 +8,52 @@ #include #include +#include "ThreadListView.h" + +class BButton; class BTabView; class ImageListView; class Team; -class ThreadListView; +class TeamDebugModel; -class TeamWindow : public BWindow { +class TeamWindow : public BWindow, private ThreadListView::Listener { public: class Listener; public: - TeamWindow(::Team* team, Listener* listener); + TeamWindow(TeamDebugModel* debugModel, + Listener* listener); ~TeamWindow(); - static TeamWindow* Create(::Team* team, Listener* listener); + static TeamWindow* Create(TeamDebugModel* debugModel, + Listener* listener); // throws virtual void MessageReceived(BMessage* message); virtual bool QuitRequested(); private: + // ThreadListView::Listener + virtual void ThreadSelectionChanged(::Thread* thread); + void _Init(); + void _SetActiveThread(::Thread* thread); + void _UpdateRunButtons(); + private: - ::Team* fTeam; + TeamDebugModel* fDebugModel; + ::Thread* fActiveThread; Listener* fListener; BTabView* fTabView; ThreadListView* fThreadListView; ImageListView* fImageListView; + BButton* fRunButton; + BButton* fStepOverButton; + BButton* fStepIntoButton; + BButton* fStepOutButton; }; Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-18 00:23:16 UTC (rev 31096) +++ haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-18 00:35:12 UTC (rev 31097) @@ -129,12 +129,13 @@ // #pragma mark - ThreadListView -ThreadListView::ThreadListView() +ThreadListView::ThreadListView(Listener* listener) : BGroupView(B_VERTICAL), fTeam(NULL), fThreadsTable(NULL), - fThreadsTableModel(NULL) + fThreadsTableModel(NULL), + fListener(listener) { SetName("Threads"); } @@ -149,9 +150,9 @@ /*static*/ ThreadListView* [... truncated: 128 lines follow ...] From anevilyak at gmail.com Thu Jun 18 16:08:31 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 18 Jun 2009 09:08:31 -0500 Subject: [Haiku-commits] r30975 - in haiku/trunk: headers/private/kernel src/system/kernel/fs src/system/kernel/vm In-Reply-To: <200906051552.n55FqxBH016759@sheep.berlios.de> References: <200906051552.n55FqxBH016759@sheep.berlios.de> Message-ID: Hi Axel, On Fri, Jun 5, 2009 at 10:52 AM, axeld at BerliOS wrote: > ? ? ? ? ? ? ? ?TRACE(("trying to mount boot partition: %s\n", path.Path())); > ? ? ? ? ? ? ? ?gBootDevice = _kern_mount("/boot", path.Path(), fsName, 0, NULL, 0); > - ? ? ? ? ? ? ? if (gBootDevice >= B_OK) > + ? ? ? ? ? ? ? if (gBootDevice >= B_OK) { > + ? ? ? ? ? ? ? ? ? ? ? gReadOnlyBootDevice = true; > ? ? ? ? ? ? ? ? ? ? ? ?break; > + ? ? ? ? ? ? ? } > ? ? ? ?} Isn't this marking the boot device as read only in all cases, and thus preventing a swap file from ever being created? Regards, Rene From axeld at mail.berlios.de Thu Jun 18 16:29:16 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 18 Jun 2009 16:29:16 +0200 Subject: [Haiku-commits] r31098 - haiku/trunk/src/system/kernel/fs Message-ID: <200906181429.n5IETGde025680@sheep.berlios.de> Author: axeld Date: 2009-06-18 16:29:15 +0200 (Thu, 18 Jun 2009) New Revision: 31098 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31098&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp Log: * Fixed stupid typo with big consequences as pointed out by Rene. Thanks! Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2009-06-18 00:35:12 UTC (rev 31097) +++ haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2009-06-18 14:29:15 UTC (rev 31098) @@ -447,7 +447,7 @@ if (bootPartition->GetPath(&path) != B_OK) panic("could not get boot device!\n"); - const char *fsName = NULL; + const char* fsName = NULL; bool readOnly = false; if (strcmp(bootPartition->ContentType(), "ISO9660 File System") == 0) { fsName = "iso9660:write_overlay:attribute_overlay"; @@ -457,7 +457,7 @@ TRACE(("trying to mount boot partition: %s\n", path.Path())); gBootDevice = _kern_mount("/boot", path.Path(), fsName, 0, NULL, 0); if (gBootDevice >= B_OK) { - gReadOnlyBootDevice = true; + gReadOnlyBootDevice = readOnly; break; } } From ingo_weinhold at gmx.de Thu Jun 18 16:30:47 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 18 Jun 2009 16:30:47 +0200 Subject: [Haiku-commits] r30975 - in haiku/trunk: headers/private/kernel src/system/kernel/fs src/system/kernel/vm In-Reply-To: References: <200906051552.n55FqxBH016759@sheep.berlios.de> Message-ID: <20090618143047.17620@gmx.net> -------- Original-Nachricht -------- > Datum: Thu, 18 Jun 2009 09:08:31 -0500 > Von: Rene Gollent > On Fri, Jun 5, 2009 at 10:52 AM, axeld at BerliOS > wrote: > > TRACE(("trying to mount boot partition: %s\n", > path.Path())); > > gBootDevice = _kern_mount("/boot", path.Path(), > fsName, 0, NULL, 0); > > - if (gBootDevice >= B_OK) > > + if (gBootDevice >= B_OK) { > > + gReadOnlyBootDevice = true; > > break; > > + } > > } > > Isn't this marking the boot device as read only in all cases, and thus > preventing a swap file from ever being created? It doesn't seem to be reset anywhere, so I'd say that's indeed the problem. CU, Ingo PS: A stylistic remark: The popular ">= B_OK" comparison is not really correct, since _kern_mount() (and many other functions) doesn't ever return B_OK. It either returns a value >= 0 on success or a negative error code on failure. From axeld at mail.berlios.de Thu Jun 18 19:19:38 2009 From: axeld at mail.berlios.de (axeld at mail.berlios.de) Date: Thu, 18 Jun 2009 19:19:38 +0200 Subject: [Haiku-commits] r31099 - haiku/trunk/src/apps/aboutsystem Message-ID: <200906181719.n5IHJcOs016149@sheep.berlios.de> Author: axeld Date: 2009-06-18 19:19:32 +0200 (Thu, 18 Jun 2009) New Revision: 31099 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31099&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp haiku/trunk/src/apps/aboutsystem/HyperTextView.cpp haiku/trunk/src/apps/aboutsystem/HyperTextView.h Log: * Changed the whole thing to use the layout engine, which makes it work okay with larger font sizes. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2009-06-18 14:29:15 UTC (rev 31098) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2009-06-18 17:19:32 UTC (rev 31099) @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -67,71 +68,102 @@ class AboutApp : public BApplication { - public: +public: AboutApp(); }; class AboutWindow : public BWindow { - public: - AboutWindow(); +public: + AboutWindow(); - virtual bool QuitRequested(); + virtual bool QuitRequested(); }; +class LogoView : public BView { +public: + LogoView(); + virtual ~LogoView(); + + virtual BSize MinSize(); + virtual BSize MaxSize(); + + virtual void Draw(BRect updateRect); + +private: + BBitmap* fLogo; +}; + +class CropView : public BView { +public: + CropView(BView* target, int32 left, int32 top, + int32 right, int32 bottom); + virtual ~CropView(); + + virtual BSize MinSize(); + virtual BSize MaxSize(); + + virtual void DoLayout(); + +private: + BView* fTarget; + int32 fCropLeft; + int32 fCropTop; + int32 fCropRight; + int32 fCropBottom; +}; + class AboutView : public BView { public: - AboutView(const BRect& frame); - ~AboutView(); + AboutView(); + ~AboutView(); - virtual void AttachedToWindow(); - virtual void Pulse(); + virtual void AttachedToWindow(); + virtual void Pulse(); - virtual void FrameResized(float width, float height); - virtual void Draw(BRect updateRect); - virtual void MessageReceived(BMessage* msg); - virtual void MouseDown(BPoint point); + virtual void MessageReceived(BMessage* msg); + virtual void MouseDown(BPoint point); - void AddCopyrightEntry(const char* name, - const char* text, - const StringVector& licenses, - const char* url); - void AddCopyrightEntry(const char* name, - const char* text, const char* url = NULL); - void PickRandomHaiku(); + void AddCopyrightEntry(const char* name, + const char* text, + const StringVector& licenses, + const char* url); + void AddCopyrightEntry(const char* name, + const char* text, const char* url = NULL); + void PickRandomHaiku(); private: - typedef std::map PackageCreditMap; + typedef std::map PackageCreditMap; private: - status_t _GetLicensePath(const char* license, - BPath& path); - void _AddCopyrightsFromAttribute(); - void _AddPackageCredit(const PackageCredit& package); - void _AddPackageCreditEntries(); + BView* _CreateLabel(const char* name, const char* label); + BView* _CreateCreditsView(); + status_t _GetLicensePath(const char* license, + BPath& path); + void _AddCopyrightsFromAttribute(); + void _AddPackageCredit(const PackageCredit& package); + void _AddPackageCreditEntries(); - BStringView* fMemView; - BTextView* fUptimeView; - BView* fInfoView; - HyperTextView* fCreditsView; + BStringView* fMemView; + BTextView* fUptimeView; + BView* fInfoView; + HyperTextView* fCreditsView; - BBitmap* fLogo; + BBitmap* fLogo; - BPoint fDrawPoint; - - bigtime_t fLastActionTime; - BMessageRunner* fScrollRunner; - PackageCreditMap fPackageCredits; + bigtime_t fLastActionTime; + BMessageRunner* fScrollRunner; + PackageCreditMap fPackageCredits; }; // #pragma mark - -AboutApp::AboutApp(void) +AboutApp::AboutApp() : BApplication("application/x-vnd.Haiku-About") { - AboutWindow *window = new AboutWindow(); + AboutWindow* window = new AboutWindow(); window->Show(); } @@ -141,11 +173,16 @@ AboutWindow::AboutWindow() : BWindow(BRect(0, 0, 500, 300), "About This System", B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE) + B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE) { - AboutView *view = new AboutView(Bounds()); - AddChild(view); + SetLayout(new BGroupLayout(B_VERTICAL)); + AddChild(new AboutView()); + // Make sure we take the minimal window size into account when centering + BSize size = GetLayout()->MinSize(); + ResizeTo(max_c(size.width, Bounds().Width()), + max_c(size.height, Bounds().Height())); + MoveTo((BScreen().Frame().Width() - Bounds().Width()) / 2, (BScreen().Frame().Height() - Bounds().Height()) / 2 ); } @@ -159,59 +196,137 @@ } -AboutView::AboutView(const BRect &rect) - : BView(rect, "aboutview", B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED), - fLastActionTime(system_time()), - fScrollRunner(NULL) +// #pragma mark - LogoView + + +LogoView::LogoView() + : BView("logo", B_WILL_DRAW) { fLogo = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "haikulogo.png"); - if (fLogo) { - fDrawPoint.x = (225-fLogo->Bounds().Width()) / 2; - fDrawPoint.y = 0; + SetViewColor(255, 255, 255); +} + + +LogoView::~LogoView() +{ + delete fLogo; +} + + +BSize +LogoView::MinSize() +{ + if (fLogo == NULL) + return BSize(0, 0); + + return BSize(fLogo->Bounds().Width(), fLogo->Bounds().Height()); +} + + +BSize +LogoView::MaxSize() +{ + if (fLogo == NULL) + return BSize(0, 0); + + return BSize(B_SIZE_UNLIMITED, fLogo->Bounds().Height()); +} + + +void +LogoView::Draw(BRect updateRect) +{ + if (fLogo != NULL) { + DrawBitmap(fLogo, + BPoint((Bounds().Width() - fLogo->Bounds().Width()) / 2, 0)); } +} - // Begin Construction of System Information controls - font_height height; - float labelHeight, textHeight; +// #pragma mark - CropView - system_info systemInfo; - get_system_info(&systemInfo); - be_plain_font->GetHeight(&height); - textHeight = height.ascent + height.descent + height.leading; +CropView::CropView(BView* target, int32 left, int32 top, int32 right, + int32 bottom) + : BView("crop view", 0), + fTarget(target), + fCropLeft(left), + fCropTop(top), + fCropRight(right), + fCropBottom(bottom) +{ + AddChild(target); +} - be_bold_font->GetHeight(&height); - labelHeight = height.ascent + height.descent + height.leading; - BRect r(0, 0, 225, Bounds().bottom); - if (fLogo) - r.OffsetBy(0, fLogo->Bounds().Height()); +CropView::~CropView() +{ +} - fInfoView = new BView(r, "infoview", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, - B_WILL_DRAW); - fInfoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - fInfoView->SetLowColor(fInfoView->ViewColor()); - fInfoView->SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); - AddChild(fInfoView); - // Add all the various labels for system infomation +BSize +CropView::MinSize() +{ + if (fTarget == NULL) + return BSize(); - BStringView *stringView; + BSize size = fTarget->MinSize(); + if (size.width != B_SIZE_UNSET) + size.width -= fCropLeft + fCropRight; + if (size.height != B_SIZE_UNSET) + size.height -= fCropTop + fCropBottom; - // OS Version - r.Set(5, 5, 224, labelHeight + 5); - stringView = new BStringView(r, "oslabel", "Version:"); - stringView->SetFont(be_bold_font); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + return size; +} - // we update "labelHeight" to the actual height of the string view - labelHeight = stringView->Bounds().Height(); - r.OffsetBy(0, labelHeight); - r.bottom = r.top + textHeight; +BSize +CropView::MaxSize() +{ + if (fTarget == NULL) + return BSize(); + BSize size = fTarget->MaxSize(); + if (size.width != B_SIZE_UNSET) + size.width -= fCropLeft + fCropRight; + if (size.height != B_SIZE_UNSET) + size.height -= fCropTop + fCropBottom; + + return size; +} + + +void +CropView::DoLayout() +{ + BView::DoLayout(); + + if (fTarget == NULL) + return; + + fTarget->MoveTo(-fCropLeft, -fCropTop); + fTarget->ResizeTo(Bounds().Width() + fCropLeft + fCropRight, + Bounds().Height() + fCropTop + fCropBottom); +} + + +// #pragma mark - AboutView + + +AboutView::AboutView() + : BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED), + fLastActionTime(system_time()), + fScrollRunner(NULL) +{ + // Begin Construction of System Information controls + + system_info systemInfo; + get_system_info(&systemInfo); + + // Create all the various labels for system infomation + + // OS Version + char string[1024]; strcpy(string, "Unknown"); @@ -244,9 +359,9 @@ } } - stringView = new BStringView(r, "ostext", string); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + BStringView* versionView = new BStringView("ostext", string); + versionView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); // GCC version #if __GNUC__ != 2 @@ -255,118 +370,301 @@ snprintf(string, sizeof(string), "GCC %d", __GNUC__); - stringView = new BStringView(r, "gcctext", string); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + BStringView* gccView = new BStringView("gcctext", string); + gccView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); #endif // CPU count, type and clock speed - r.OffsetBy(0, textHeight * 1.5); - r.bottom = r.top + labelHeight; + char processorLabel[256]; + if (systemInfo.cpu_count > 1) { + snprintf(processorLabel, sizeof(processorLabel), "%ld Processors:", + systemInfo.cpu_count); + } else + strlcpy(processorLabel, "Processor:", sizeof(processorLabel)); - if (systemInfo.cpu_count > 1) - sprintf(string, "%ld Processors:", systemInfo.cpu_count); - else - strcpy(string, "Processor:"); - - stringView = new BStringView(r, "cpulabel", string); - stringView->SetFont(be_bold_font); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); - BString cpuType; cpuType << get_cpu_vendor_string(systemInfo.cpu_type) << " " << get_cpu_model_string(&systemInfo); - r.OffsetBy(0, labelHeight); - r.bottom = r.top + textHeight; - stringView = new BStringView(r, "cputext", cpuType.String()); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + BStringView* cpuView = new BStringView("cputext", cpuType.String()); + cpuView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); - r.OffsetBy(0, textHeight); - r.bottom = r.top + textHeight; - int32 clockSpeed = get_rounded_cpu_speed(); if (clockSpeed < 1000) sprintf(string,"%ld MHz", clockSpeed); else sprintf(string,"%.2f GHz", clockSpeed / 1000.0f); - stringView = new BStringView(r, "mhztext", string); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + BStringView* frequencyView = new BStringView("frequencytext", string); + frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); // RAM - r.OffsetBy(0, textHeight * 1.5); - r.bottom = r.top + labelHeight; - stringView = new BStringView(r, "ramlabel", "Memory:"); - stringView->SetFont(be_bold_font); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + fMemView = new BStringView("ramtext", + MemUsageToString(string, sizeof(string), &systemInfo)); + fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); - r.OffsetBy(0, labelHeight); - r.bottom = r.top + textHeight; - - fMemView = new BStringView(r, "ramtext", ""); - fInfoView->AddChild(fMemView); - fMemView->SetText(MemUsageToString(string, sizeof(string), &systemInfo)); - // Kernel build time/date - r.OffsetBy(0, textHeight * 1.5); - r.bottom = r.top + labelHeight; - stringView = new BStringView(r, "kernellabel", "Kernel:"); - stringView->SetFont(be_bold_font); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); - - r.OffsetBy(0, labelHeight); - r.bottom = r.top + textHeight; - snprintf(string, sizeof(string), "%s %s", systemInfo.kernel_build_date, systemInfo.kernel_build_time); - stringView = new BStringView(r, "kerneltext", string); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); + BStringView* kernelView = new BStringView("kerneltext", string); + kernelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); // Uptime - r.OffsetBy(0, textHeight * 1.5); - r.bottom = r.top + labelHeight; - stringView = new BStringView(r, "uptimelabel", "Time Running:"); - stringView->SetFont(be_bold_font); - fInfoView->AddChild(stringView); - stringView->ResizeToPreferred(); - - r.OffsetBy(0, labelHeight); - r.bottom = r.top + textHeight * 3; - - fUptimeView = new BTextView(r, "uptimetext", r.OffsetToCopy(0,0), B_FOLLOW_ALL); + fUptimeView = new BTextView("uptimetext"); fUptimeView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fUptimeView->MakeEditable(false); fUptimeView->MakeSelectable(false); fUptimeView->SetWordWrap(true); - fInfoView->AddChild(fUptimeView); - // string width changes, so we don't do ResizeToPreferred() fUptimeView->SetText(UptimeToString(string, sizeof(string))); + const float offset = 5; + + SetLayout(new BGroupLayout(B_HORIZONTAL)); + + BLayoutBuilder::Group<>((BGroupLayout*)GetLayout()) + .AddGroup(B_VERTICAL) + .Add(new LogoView()) + .AddGroup(B_VERTICAL) + .Add(_CreateLabel("oslabel", "Version:")) + .Add(versionView) +#if __GNUC__ != 2 + .Add(gccView) +#endif + .AddStrut(offset) + .Add(_CreateLabel("cpulabel", processorLabel)) + .Add(cpuView) + .Add(frequencyView) + .AddStrut(offset) + .Add(_CreateLabel("memlabel", "Memory:")) + .Add(fMemView) + .AddStrut(offset) + .Add(_CreateLabel("kernellabel", "Kernel:")) + .Add(kernelView) + .AddStrut(offset) + .Add(_CreateLabel("uptimelabel", "Time Running:")) + .Add(fUptimeView) + .SetInsets(5, 5, 5, 5) + .End() + // TODO: investigate: adding this causes the time to be cut + //.AddGlue() + .End() + .Add(_CreateCreditsView()); + + float min = fMemView->MinSize().width * 1.1f; + fCreditsView->SetExplicitMinSize(BSize(min, min)); +} + + +AboutView::~AboutView() +{ + delete fScrollRunner; +} + + +void +AboutView::AttachedToWindow() +{ + BView::AttachedToWindow(); + Window()->SetPulseRate(500000); + SetEventMask(B_POINTER_EVENTS); +} + + +void +AboutView::MouseDown(BPoint point) +{ + BRect r(92, 26, 105, 31); + if (r.Contains(point)) { + printf("Easter Egg\n"); + PickRandomHaiku(); + } + + if (Bounds().Contains(point)) { + fLastActionTime = system_time(); + delete fScrollRunner; + fScrollRunner = NULL; + } +} + + +void +AboutView::Pulse() +{ + char string[255]; + system_info info; + get_system_info(&info); + fUptimeView->SetText(UptimeToString(string, sizeof(string))); + fMemView->SetText(MemUsageToString(string, sizeof(string), &info)); + + if (fScrollRunner == NULL && system_time() > fLastActionTime + 10000000) { + BMessage message(SCROLL_CREDITS_VIEW); + //fScrollRunner = new BMessageRunner(this, &message, 25000, -1); + } +} + + +void +AboutView::MessageReceived(BMessage *msg) +{ + switch (msg->what) { + case SCROLL_CREDITS_VIEW: + { + BScrollBar *scrollBar = fCreditsView->ScrollBar(B_VERTICAL); + if (scrollBar == NULL) + break; + float max, min; + scrollBar->GetRange(&min, &max); + if (scrollBar->Value() < max) + fCreditsView->ScrollBy(0, 1); + + break; + } + + default: + BView::MessageReceived(msg); + break; + } +} + + +void +AboutView::AddCopyrightEntry(const char *name, const char *text, + const char *url) +{ + AddCopyrightEntry(name, text, StringVector(), url); +} + + +void +AboutView::AddCopyrightEntry(const char *name, const char *text, + const StringVector& licenses, const char *url) +{ + BFont font(be_bold_font); + //font.SetSize(be_bold_font->Size()); + font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); + + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuYellow); + fCreditsView->Insert(name); + fCreditsView->Insert("\n"); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); + fCreditsView->Insert(text); + fCreditsView->Insert("\n"); + + if (licenses.CountStrings() > 0) { + if (licenses.CountStrings() > 1) + fCreditsView->Insert("Licenses: "); + else + fCreditsView->Insert("License: "); + + for (int32 i = 0; i < licenses.CountStrings(); i++) { + const char* license = licenses.StringAt(i); + + if (i > 0) + fCreditsView->Insert(", "); + + BPath licensePath; + if (_GetLicensePath(license, licensePath) == B_OK) { + fCreditsView->InsertHyperText(license, + new OpenFileAction(licensePath.Path())); + } else + fCreditsView->Insert(license); + } + + fCreditsView->Insert("\n"); + } + + if (url) { + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); + fCreditsView->InsertHyperText(url, new URLAction(url)); + fCreditsView->Insert("\n"); + } + fCreditsView->Insert("\n"); +} + + +void +AboutView::PickRandomHaiku() +{ + BFile fortunes( +#ifdef __HAIKU__ + "/etc/fortunes/Haiku", +#else + "data/etc/fortunes/Haiku", +#endif + B_READ_ONLY); + struct stat st; + if (fortunes.InitCheck() < B_OK) + return; + if (fortunes.GetStat(&st) < B_OK) + return; + char *buff = (char *)malloc((size_t)st.st_size + 1); + if (!buff) + return; + buff[(size_t)st.st_size] = '\0'; + BList haikuList; + if (fortunes.Read(buff, (size_t)st.st_size) == (ssize_t)st.st_size) { + char *p = buff; + while (p && *p) { + char *e = strchr(p, '%'); + BString *s = new BString(p, e ? (e - p) : -1); + haikuList.AddItem(s); + p = e; + if (p && (*p == '%')) + p++; + if (p && (*p == '\n')) + p++; + } + } + free(buff); + if (haikuList.CountItems() < 1) + return; + BString *s = (BString *)haikuList.ItemAt(rand() % haikuList.CountItems()); + BFont font(be_bold_font); + font.SetSize(be_bold_font->Size()); + font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); + fCreditsView->SelectAll(); + fCreditsView->Delete(); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kDarkGrey); + fCreditsView->Insert(s->String()); + fCreditsView->Insert("\n"); + while ((s = (BString *)haikuList.RemoveItem((int32)0))) { + delete s; + } +} + + +BView* +AboutView::_CreateLabel(const char* name, const char* label) +{ + BStringView* labelView = new BStringView(name, label); + labelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, + B_ALIGN_VERTICAL_UNSET)); + labelView->SetFont(be_bold_font); + return labelView; +} + + +BView* +AboutView::_CreateCreditsView() +{ // Begin construction of the credits view - r = Bounds(); - r.left += fInfoView->Bounds().right + 1; - r.right -= B_V_SCROLL_BAR_WIDTH; - - fCreditsView = new HyperTextView(r, "credits", - r.OffsetToCopy(0, 0).InsetByCopy(5, 5), B_FOLLOW_ALL); - fCreditsView->SetFlags(fCreditsView->Flags() | B_FRAME_EVENTS ); + fCreditsView = new HyperTextView("credits"); + fCreditsView->SetFlags(fCreditsView->Flags() | B_FRAME_EVENTS); fCreditsView->SetStylable(true); fCreditsView->MakeEditable(false); fCreditsView->SetWordWrap(true); + fCreditsView->SetInsets(5, 5, 5, 5); - BScrollView *creditsScroller = new BScrollView("creditsScroller", - fCreditsView, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true, + BScrollView* creditsScroller = new BScrollView("creditsScroller", + fCreditsView, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_PLAIN_BORDER); - AddChild(creditsScroller); // Haiku copyright BFont font(be_bold_font); @@ -375,6 +673,7 @@ fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert("Haiku\n"); + char string[1024]; time_t time = ::time(NULL); struct tm* tm = localtime(&time); int32 year = tm->tm_year + 1900; @@ -857,205 +1156,11 @@ _AddCopyrightsFromAttribute(); _AddPackageCreditEntries(); -} - -AboutView::~AboutView(void) -{ - delete fScrollRunner; + return new CropView(creditsScroller, 0, 1, 1, 1); } -void -AboutView::AttachedToWindow(void) -{ - BView::AttachedToWindow(); - Window()->SetPulseRate(500000); - SetEventMask(B_POINTER_EVENTS); -} - - -void -AboutView::MouseDown(BPoint pt) -{ - BRect r(92, 26, 105, 31); - if (r.Contains(pt)) { - printf("Easter Egg\n"); - PickRandomHaiku(); - } - - if (Bounds().Contains(pt)) { - fLastActionTime = system_time(); - delete fScrollRunner; - fScrollRunner = NULL; - } -} - - -void -AboutView::FrameResized(float width, float height) -{ - BRect r = fCreditsView->Bounds(); - r.OffsetTo(B_ORIGIN); - r.InsetBy(3, 3); - fCreditsView->SetTextRect(r); -} - - -void -AboutView::Draw(BRect update) -{ - if (fLogo) - DrawBitmap(fLogo, fDrawPoint); -} - - -void -AboutView::Pulse(void) -{ - char string[255]; - system_info info; - get_system_info(&info); - fUptimeView->SetText(UptimeToString(string, sizeof(string))); - fMemView->SetText(MemUsageToString(string, sizeof(string), &info)); - - if (fScrollRunner == NULL && (system_time() > fLastActionTime + 10000000)) { - BMessage message(SCROLL_CREDITS_VIEW); - //fScrollRunner = new BMessageRunner(this, &message, 300000, -1); - } -} - - -void -AboutView::MessageReceived(BMessage *msg) -{ - switch (msg->what) { - case SCROLL_CREDITS_VIEW: - { - BScrollBar *scrollBar = fCreditsView->ScrollBar(B_VERTICAL); - if (scrollBar == NULL) - break; - float max, min; - scrollBar->GetRange(&min, &max); - if (scrollBar->Value() < max) - fCreditsView->ScrollBy(0, 5); - - break; - } - - default: - BView::MessageReceived(msg); - break; - } -} - - -void -AboutView::AddCopyrightEntry(const char *name, const char *text, - const char *url) -{ - AddCopyrightEntry(name, text, StringVector(), url); -} - - -void -AboutView::AddCopyrightEntry(const char *name, const char *text, - const StringVector& licenses, const char *url) -{ - BFont font(be_bold_font); - //font.SetSize(be_bold_font->Size()); - font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); - - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuYellow); - fCreditsView->Insert(name); - fCreditsView->Insert("\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); - fCreditsView->Insert(text); - fCreditsView->Insert("\n"); - - if (licenses.CountStrings() > 0) { - if (licenses.CountStrings() > 1) - fCreditsView->Insert("Licenses: "); - else - fCreditsView->Insert("License: "); - - for (int32 i = 0; i < licenses.CountStrings(); i++) { - const char* license = licenses.StringAt(i); - - if (i > 0) - fCreditsView->Insert(", "); - - BPath licensePath; - if (_GetLicensePath(license, licensePath) == B_OK) { - fCreditsView->InsertHyperText(license, - new OpenFileAction(licensePath.Path())); - } else - fCreditsView->Insert(license); - } - - fCreditsView->Insert("\n"); - } - - if (url) { - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); - fCreditsView->InsertHyperText(url, new URLAction(url)); - fCreditsView->Insert("\n"); - } - fCreditsView->Insert("\n"); -} - - -void -AboutView::PickRandomHaiku() -{ - BFile fortunes( -#ifdef __HAIKU__ - "/etc/fortunes/Haiku", -#else - "data/etc/fortunes/Haiku", -#endif - B_READ_ONLY); - struct stat st; - if (fortunes.InitCheck() < B_OK) - return; - if (fortunes.GetStat(&st) < B_OK) - return; - char *buff = (char *)malloc((size_t)st.st_size + 1); - if (!buff) - return; - buff[(size_t)st.st_size] = '\0'; - BList haikuList; - if (fortunes.Read(buff, (size_t)st.st_size) == (ssize_t)st.st_size) { - char *p = buff; - while (p && *p) { - char *e = strchr(p, '%'); - BString *s = new BString(p, e ? (e - p) : -1); - haikuList.AddItem(s); - p = e; - if (p && (*p == '%')) - p++; - if (p && (*p == '\n')) - p++; - } - } - free(buff); - if (haikuList.CountItems() < 1) - return; - BString *s = (BString *)haikuList.ItemAt(rand() % haikuList.CountItems()); - BFont font(be_bold_font); - font.SetSize(be_bold_font->Size()); - font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); - fCreditsView->SelectAll(); - fCreditsView->Delete(); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kDarkGrey); - fCreditsView->Insert(s->String()); - fCreditsView->Insert("\n"); - while ((s = (BString *)haikuList.RemoveItem((int32)0))) { - delete s; - } -} - - status_t AboutView::_GetLicensePath(const char* license, BPath& path) { Modified: haiku/trunk/src/apps/aboutsystem/HyperTextView.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/HyperTextView.cpp 2009-06-18 14:29:15 UTC (rev 31098) +++ haiku/trunk/src/apps/aboutsystem/HyperTextView.cpp 2009-06-18 17:19:32 UTC (rev 31099) @@ -86,7 +86,14 @@ }; +HyperTextView::HyperTextView(const char* name, uint32 flags) + : + BTextView(name, flags), + fActionInfos(new ActionInfoList(100, true)) +{ +} + HyperTextView::HyperTextView(BRect frame, const char* name, BRect textRect, uint32 resizeMask, uint32 flags) : Modified: haiku/trunk/src/apps/aboutsystem/HyperTextView.h =================================================================== --- haiku/trunk/src/apps/aboutsystem/HyperTextView.h 2009-06-18 14:29:15 UTC (rev 31098) +++ haiku/trunk/src/apps/aboutsystem/HyperTextView.h 2009-06-18 17:19:32 UTC (rev 31099) @@ -29,6 +29,9 @@ class HyperTextView : public BTextView { public: + HyperTextView(const char* name, + uint32 flags = B_WILL_DRAW + | B_PULSE_NEEDED); HyperTextView(BRect frame, const char* name, BRect textRect, uint32 resizeMask, uint32 flags = B_WILL_DRAW From axeld at pinc-software.de Thu Jun 18 19:23:17 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 18 Jun 2009 19:23:17 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r30975_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_src/system/kernel/fs__src/system/kernel/vm?= In-Reply-To: <20090618143047.17620@gmx.net> Message-ID: <37554990485-BeMail@zon> "Ingo Weinhold" wrote: > PS: A stylistic remark: The popular ">= B_OK" comparison is not > really correct, since _kern_mount() > (and many other functions) doesn't ever return B_OK. It either returns a value >= 0 on success or a > negative error code on failure Which really is the same, isn't it? :-) Bye, Axel. From ingo_weinhold at gmx.de Thu Jun 18 19:46:03 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 18 Jun 2009 19:46:03 +0200 Subject: [Haiku-commits] r30975 - in haiku/trunk: headers/private/kernel src/system/kernel/fs src/system/kernel/vm In-Reply-To: <37554990485-BeMail@zon> References: <37554990485-BeMail@zon> Message-ID: <20090618174603.17610@gmx.net> -------- Original-Nachricht -------- > Datum: Thu, 18 Jun 2009 19:23:17 +0200 CEST > Von: "Axel D?rfler" > "Ingo Weinhold" wrote: > > PS: A stylistic remark: The popular ">= B_OK" comparison is not > > really correct, since _kern_mount() > (and many other functions) > doesn't ever return B_OK. It either returns a value >= 0 on success or > a > negative error code on failure > > Which really is the same, isn't it? :-) B_OK has value 0, if that's what you mean, but so do NULL and a dozen other unrelated constants, and you wouldn't compare with any of those in such a case either. CU, Ingo From bonefish at mail.berlios.de Thu Jun 18 19:57:39 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 18 Jun 2009 19:57:39 +0200 Subject: [Haiku-commits] r31100 - in haiku/trunk/src/apps/debugger: . debugger_interface Message-ID: <200906181757.n5IHvdkc017004@sheep.berlios.de> Author: bonefish Date: 2009-06-18 19:57:37 +0200 (Thu, 18 Jun 2009) New Revision: 31100 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31100&view=rev Added: haiku/trunk/src/apps/debugger/CpuState.cpp haiku/trunk/src/apps/debugger/CpuState.h haiku/trunk/src/apps/debugger/ImageInfo.cpp haiku/trunk/src/apps/debugger/ImageInfo.h haiku/trunk/src/apps/debugger/ThreadInfo.cpp haiku/trunk/src/apps/debugger/ThreadInfo.h haiku/trunk/src/apps/debugger/debugger_interface/ haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h Modified: haiku/trunk/src/apps/debugger/Image.cpp haiku/trunk/src/apps/debugger/Image.h haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h Log: Moved all interaction with the kernel/debugger interface into new class DebuggerInterface. This will simplify adding support for remote debugging eventually. Added: haiku/trunk/src/apps/debugger/CpuState.cpp =================================================================== --- haiku/trunk/src/apps/debugger/CpuState.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/CpuState.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,11 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "CpuState.h" + + +CpuState::~CpuState() +{ +} Added: haiku/trunk/src/apps/debugger/CpuState.h =================================================================== --- haiku/trunk/src/apps/debugger/CpuState.h 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/CpuState.h 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,19 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef CPU_STATE_H +#define CPU_STATE_H + +#include + +#include + + +class CpuState : public Referenceable { +public: + virtual ~CpuState(); +}; + + +#endif // CPU_STATE_H Modified: haiku/trunk/src/apps/debugger/Image.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Image.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/Image.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -6,7 +6,7 @@ #include "Image.h" -Image::Image(Team* team,const image_info& imageInfo) +Image::Image(Team* team,const ImageInfo& imageInfo) : fTeam(team), fInfo(imageInfo) Modified: haiku/trunk/src/apps/debugger/Image.h =================================================================== --- haiku/trunk/src/apps/debugger/Image.h 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/Image.h 2009-06-18 17:57:37 UTC (rev 31100) @@ -10,26 +10,28 @@ #include #include +#include "ImageInfo.h" + class Team; class Image : public Referenceable, public DoublyLinkedListLinkImpl { public: - Image(Team* team, const image_info& imageInfo); + Image(Team* team, const ImageInfo& imageInfo); ~Image(); status_t Init(); - + Team* GetTeam() const { return fTeam; } - image_id ID() const { return fInfo.id; } - const char* Name() const { return fInfo.name; } - const image_info& Info() const { return fInfo; } + image_id ID() const { return fInfo.ImageID(); } + const char* Name() const { return fInfo.Name(); } + const ImageInfo& Info() const { return fInfo; } private: Team* fTeam; - image_info fInfo; + ImageInfo fInfo; }; Added: haiku/trunk/src/apps/debugger/ImageInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/ImageInfo.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/ImageInfo.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,41 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "ImageInfo.h" + + +ImageInfo::ImageInfo() + : + fTeam(-1), + fImage(-1), + fName() +{ +} + +ImageInfo::ImageInfo(const ImageInfo& other) + : + fTeam(other.fTeam), + fImage(other.fImage), + fName(other.fName) +{ +} + + +ImageInfo::ImageInfo(team_id team, image_id image, const BString& name) + : + fTeam(team), + fImage(image), + fName(name) +{ +} + + +void +ImageInfo::SetTo(team_id team, image_id image, const BString& name) +{ + fTeam = team; + fImage = image; + fName = name; +} Added: haiku/trunk/src/apps/debugger/ImageInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/ImageInfo.h 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/ImageInfo.h 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,33 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef IMAGE_INFO_H +#define IMAGE_INFO_H + +#include +#include + + +class ImageInfo { +public: + ImageInfo(); + ImageInfo(const ImageInfo& other); + ImageInfo(team_id team, image_id image, + const BString& name); + + void SetTo(team_id team, image_id image, + const BString& name); + + team_id TeamID() const { return fTeam; } + image_id ImageID() const { return fImage; } + const char* Name() const { return fName.String(); } + +private: + thread_id fTeam; + image_id fImage; + BString fName; +}; + + +#endif // IMAGE_INFO_H Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 17:57:37 UTC (rev 31100) @@ -6,6 +6,7 @@ UsePrivateHeaders debug interface kernel shared ; UsePrivateSystemHeaders ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) debugger_interface ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ; local debugAnalyzerSources @@ -16,14 +17,16 @@ SubDirHdrs [ FDirName $(debugAnalyzerSources) util ] ; Application Debugger : + CpuState.cpp Debugger.cpp - ElfFile.cpp - +# ElfFile.cpp Image.cpp + ImageInfo.cpp Team.cpp TeamDebugger.cpp TeamDebugModel.cpp Thread.cpp + ThreadInfo.cpp # DebugAnalyzer:util Variant.cpp @@ -33,6 +36,10 @@ TeamWindow.cpp ThreadListView.cpp + # debugger_interface + DebugEvent.cpp + DebuggerInterface.cpp + # DWARF # attribute_classes.cpp # AttributeValue.cpp Modified: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -50,12 +50,13 @@ fThreads.Add(thread); _NotifyThreadAdded(thread); } - + + status_t -Team::AddThread(const thread_info& threadInfo, Thread** _thread) +Team::AddThread(const ThreadInfo& threadInfo, Thread** _thread) { - Thread* thread = new(std::nothrow) Thread(this, threadInfo.thread); + Thread* thread = new(std::nothrow) Thread(this, threadInfo.ThreadID()); if (thread == NULL) return B_NO_MEMORY; @@ -65,7 +66,7 @@ return error; } - thread->SetName(threadInfo.name); + thread->SetName(threadInfo.Name()); AddThread(thread); if (_thread != NULL) @@ -75,15 +76,6 @@ } -status_t -Team::AddThread(thread_id threadID, Thread** _thread) -{ - thread_info threadInfo; - status_t error = get_thread_info(threadID, &threadInfo); - return error == B_OK ? AddThread(threadInfo, _thread) : error; -} - - void Team::RemoveThread(Thread* thread) { @@ -134,7 +126,7 @@ status_t -Team::AddImage(const image_info& imageInfo, Image** _image) +Team::AddImage(const ImageInfo& imageInfo, Image** _image) { Image* image = new(std::nothrow) Image(this, imageInfo); if (image == NULL) Modified: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-18 17:57:37 UTC (rev 31100) @@ -8,7 +8,9 @@ #include #include "Image.h" +#include "ImageInfo.h" #include "Thread.h" +#include "ThreadInfo.h" // team event types @@ -39,17 +41,15 @@ void SetName(const BString& name); void AddThread(Thread* thread); - status_t AddThread(const thread_info& threadInfo, + status_t AddThread(const ThreadInfo& threadInfo, Thread** _thread = NULL); - status_t AddThread(thread_id threadID, - Thread** _thread = NULL); void RemoveThread(Thread* thread); bool RemoveThread(thread_id threadID); Thread* ThreadByID(thread_id threadID) const; const ThreadList& Threads() const; void AddImage(Image* image); - status_t AddImage(const image_info& imageInfo, + status_t AddImage(const ImageInfo& imageInfo, Image** _image = NULL); void RemoveImage(Image* image); bool RemoveImage(image_id imageID); Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -15,6 +15,8 @@ #include "debug_utils.h" +#include "CpuState.h" +#include "DebuggerInterface.h" #include "Team.h" #include "TeamDebugModel.h" @@ -25,13 +27,11 @@ fTeam(NULL), fDebugModel(NULL), fTeamID(-1), - fDebuggerPort(-1), - fNubPort(-1), + fDebuggerInterface(NULL), fDebugEventListener(-1), fTeamWindow(NULL), fTerminating(false) { - fDebugContext.reply_port = -1; } @@ -41,18 +41,16 @@ fTerminating = true; - if (fDebuggerPort >= 0) - delete_port(fDebuggerPort); + fDebuggerInterface->Close(); locker.Unlock(); if (fDebugEventListener >= 0) wait_for_thread(fDebugEventListener, NULL); - destroy_debug_context(&fDebugContext); - delete fDebugModel; delete fTeam; + delete fDebuggerInterface; } @@ -87,54 +85,52 @@ if (error != B_OK) return error; - // create debugger port - char buffer[128]; - snprintf(buffer, sizeof(buffer), "team %ld debugger", fTeamID); - fDebuggerPort = create_port(100, buffer); - if (fDebuggerPort < 0) - return fDebuggerPort; + // create debugger interface + fDebuggerInterface = new(std::nothrow) DebuggerInterface(fTeamID); + if (fDebuggerInterface == NULL) + return B_NO_MEMORY; - // install as team debugger - fNubPort = install_team_debugger(fTeamID, fDebuggerPort); - if (fNubPort < 0) - return fNubPort; - - // init debug context - error = init_debug_context(&fDebugContext, fTeamID, fNubPort); + error = fDebuggerInterface->Init(); if (error != B_OK) return error; // set team debugging flags - set_team_debugging_flags(fNubPort, + fDebuggerInterface->SetTeamDebuggingFlags( B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_IMAGES); // get the initial state of the team AutoLocker< ::Team> teamLocker(fTeam); - thread_info threadInfo; - int32 cookie = 0; - while (get_next_thread_info(fTeamID, &cookie, &threadInfo) == B_OK) { - ::Thread* thread; - error = fTeam->AddThread(threadInfo, &thread); - if (error != B_OK) - return error; + { + BObjectList threadInfos(20, true); + status_t error = fDebuggerInterface->GetThreadInfos(threadInfos); + for (int32 i = 0; ThreadInfo* info = threadInfos.ItemAt(i); i++) { + ::Thread* thread; + error = fTeam->AddThread(*info, &thread); + if (error != B_OK) + return error; - _UpdateThreadState(thread); + _UpdateThreadState(thread); + } } - image_info imageInfo; - cookie = 0; - while (get_next_image_info(fTeamID, &cookie, &imageInfo) == B_OK) { - error = fTeam->AddImage(imageInfo); - if (error != B_OK) - return error; + { + BObjectList imageInfos(20, true); + status_t error = fDebuggerInterface->GetImageInfos(imageInfos); + for (int32 i = 0; ImageInfo* info = imageInfos.ItemAt(i); i++) { + error = fTeam->AddImage(*info); + if (error != B_OK) + return error; + } } // create the debug event listener + char buffer[128]; snprintf(buffer, sizeof(buffer), "team %ld debug listener", fTeamID); fDebugEventListener = spawn_thread(_DebugEventListenerEntry, buffer, B_NORMAL_PRIORITY, this); - if (fDebugEventListener < 0) +// if (fDebugEventListener < 0) + if (fDebugEventListener < NULL) return fDebugEventListener; resume_thread(fDebugEventListener); @@ -191,31 +187,27 @@ TeamDebugger::_DebugEventListener() { while (!fTerminating) { - // read the next message - debug_debugger_message_data message; - int32 messageCode; - ssize_t size = read_port(fDebuggerPort, &messageCode, &message, - sizeof(message)); - if (size < 0) { - if (size == B_INTERRUPTED) - continue; -// TODO: Error handling! + // get the next event + DebugEvent* event; + status_t error = fDebuggerInterface->GetNextDebugEvent(event); + if (error != B_OK) break; - } + // TODO: Error handling! - if (message.origin.team != fTeamID) { -printf("TeamDebugger for team %ld: received message from team %ld!\n", fTeamID, -message.origin.team); + + if (event->Team() != fTeamID) { +printf("TeamDebugger for team %ld: received event from team %ld!\n", fTeamID, +event->Team()); continue; } - _HandleDebuggerMessage(messageCode, message); + _HandleDebuggerMessage(event); - if (messageCode == B_DEBUGGER_MESSAGE_TEAM_DELETED - || messageCode == B_DEBUGGER_MESSAGE_TEAM_EXEC) { - // TODO:... - break; - } +// if (event->EventType() == B_DEBUGGER_MESSAGE_TEAM_DELETED +// || event->EventType() == B_DEBUGGER_MESSAGE_TEAM_EXEC) { +// // TODO:... +// break; +// } } return B_OK; @@ -223,51 +215,54 @@ void -TeamDebugger::_HandleDebuggerMessage(int32 messageCode, - const debug_debugger_message_data& message) +TeamDebugger::_HandleDebuggerMessage(DebugEvent* event) { -printf("TeamDebugger::_HandleDebuggerMessage(): %ld\n", messageCode); +printf("TeamDebugger::_HandleDebuggerMessage(): %d\n", event->EventType()); bool handled = false; - switch (messageCode) { + switch (event->EventType()) { case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: -printf("B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: thread: %ld\n", message.origin.thread); +printf("B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: thread: %ld\n", event->Thread()); break; case B_DEBUGGER_MESSAGE_DEBUGGER_CALL: -printf("B_DEBUGGER_MESSAGE_DEBUGGER_CALL: thread: %ld\n", message.origin.thread); +printf("B_DEBUGGER_MESSAGE_DEBUGGER_CALL: thread: %ld\n", event->Thread()); break; case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: -printf("B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: thread: %ld\n", message.origin.thread); +printf("B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: thread: %ld\n", event->Thread()); break; case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: -printf("B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: thread: %ld\n", message.origin.thread); +printf("B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: thread: %ld\n", event->Thread()); break; case B_DEBUGGER_MESSAGE_SINGLE_STEP: -printf("B_DEBUGGER_MESSAGE_SINGLE_STEP: thread: %ld\n", message.origin.thread); +printf("B_DEBUGGER_MESSAGE_SINGLE_STEP: thread: %ld\n", event->Thread()); break; case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: -printf("B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: thread: %ld\n", message.origin.thread); +printf("B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: thread: %ld\n", event->Thread()); break; - case B_DEBUGGER_MESSAGE_TEAM_CREATED: -printf("B_DEBUGGER_MESSAGE_TEAM_CREATED: team: %ld\n", message.team_created.new_team); - break; +// case B_DEBUGGER_MESSAGE_TEAM_CREATED: +//printf("B_DEBUGGER_MESSAGE_TEAM_CREATED: team: %ld\n", message.team_created.new_team); +// break; case B_DEBUGGER_MESSAGE_TEAM_DELETED: -printf("B_DEBUGGER_MESSAGE_TEAM_DELETED: team: %ld\n", message.origin.team); +printf("B_DEBUGGER_MESSAGE_TEAM_DELETED: team: %ld\n", event->Team()); break; case B_DEBUGGER_MESSAGE_TEAM_EXEC: -printf("B_DEBUGGER_MESSAGE_TEAM_EXEC: team: %ld\n", message.origin.team); +printf("B_DEBUGGER_MESSAGE_TEAM_EXEC: team: %ld\n", event->Team()); break; case B_DEBUGGER_MESSAGE_THREAD_CREATED: - handled = _HandleThreadCreated(message.thread_created); + handled = _HandleThreadCreated( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_THREAD_DELETED: - handled = _HandleThreadDeleted(message.thread_deleted); + handled = _HandleThreadDeleted( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_IMAGE_CREATED: - handled = _HandleImageCreated(message.image_created); + handled = _HandleImageCreated( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_IMAGE_DELETED: - handled = _HandleImageDeleted(message.image_deleted); + handled = _HandleImageDeleted( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_PRE_SYSCALL: case B_DEBUGGER_MESSAGE_POST_SYSCALL: @@ -277,48 +272,54 @@ // not interested break; default: - printf("TeamDebugger for team %ld: unknown message from kernel: " - "%ld\n", fTeamID, messageCode); + printf("TeamDebugger for team %ld: unknown event type: " + "%d\n", fTeamID, event->EventType()); break; } - if (!handled && message.origin.thread >= 0 && message.origin.nub_port >= 0) - continue_thread(message.origin.nub_port, message.origin.thread); + if (!handled && event->ThreadStopped()) + fDebuggerInterface->ContinueThread(event->Thread()); } bool -TeamDebugger::_HandleThreadCreated(const debug_thread_created& message) +TeamDebugger::_HandleThreadCreated(ThreadCreatedEvent* event) { AutoLocker< ::Team> locker(fTeam); - fTeam->AddThread(message.new_thread); + + ThreadInfo info; + status_t error = fDebuggerInterface->GetThreadInfo(event->NewThread(), + info); + if (error == B_OK) + fTeam->AddThread(info); + return false; } bool -TeamDebugger::_HandleThreadDeleted(const debug_thread_deleted& message) +TeamDebugger::_HandleThreadDeleted(ThreadDeletedEvent* event) { AutoLocker< ::Team> locker(fTeam); - fTeam->RemoveThread(message.origin.thread); + fTeam->RemoveThread(event->Thread()); return false; } bool -TeamDebugger::_HandleImageCreated(const debug_image_created& message) +TeamDebugger::_HandleImageCreated(ImageCreatedEvent* event) { AutoLocker< ::Team> locker(fTeam); - fTeam->AddImage(message.info); + fTeam->AddImage(event->GetImageInfo()); return false; } bool -TeamDebugger::_HandleImageDeleted(const debug_image_deleted& message) +TeamDebugger::_HandleImageDeleted(ImageDeletedEvent* event) { AutoLocker< ::Team> locker(fTeam); - fTeam->RemoveImage(message.info.id); + fTeam->RemoveImage(event->GetImageInfo().ImageID()); return false; } @@ -326,23 +327,15 @@ void TeamDebugger::_UpdateThreadState(::Thread* thread) { - debug_nub_get_cpu_state message; - message.reply_port = fDebugContext.reply_port; - message.thread = thread->ID(); + CpuState* state = NULL; + status_t error = fDebuggerInterface->GetCpuState(thread->ID(), state); - debug_nub_get_cpu_state_reply reply; - - status_t error = send_debug_message(&fDebugContext, - B_DEBUG_MESSAGE_GET_CPU_STATE, &message, sizeof(message), &reply, - sizeof(reply)); - uint32 newState = THREAD_STATE_UNKNOWN; if (error == B_OK) { - if (reply.error == B_OK) - newState = THREAD_STATE_STOPPED; - else if (reply.error == B_BAD_THREAD_STATE) - newState = THREAD_STATE_RUNNING; - } + newState = THREAD_STATE_STOPPED; + state->RemoveReference(); + } else if (error == B_BAD_THREAD_STATE) + newState = THREAD_STATE_RUNNING; thread->SetState(newState); } Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-18 17:57:37 UTC (rev 31100) @@ -11,9 +11,11 @@ #include #include +#include "DebugEvent.h" #include "TeamWindow.h" +class DebuggerInterface; class Team; class TeamDebugModel; @@ -36,17 +38,16 @@ static status_t _DebugEventListenerEntry(void* data); status_t _DebugEventListener(); - void _HandleDebuggerMessage(int32 messageCode, - const debug_debugger_message_data& message); + void _HandleDebuggerMessage(DebugEvent* event); bool _HandleThreadCreated( - const debug_thread_created& message); + ThreadCreatedEvent* event); bool _HandleThreadDeleted( - const debug_thread_deleted& message); + ThreadDeletedEvent* event); bool _HandleImageCreated( - const debug_image_created& message); + ImageCreatedEvent* event); bool _HandleImageDeleted( - const debug_image_deleted& message); + ImageDeletedEvent* event); void _UpdateThreadState(::Thread* thread); @@ -54,9 +55,8 @@ ::Team* fTeam; TeamDebugModel* fDebugModel; team_id fTeamID; - port_id fDebuggerPort; port_id fNubPort; - debug_context fDebugContext; + DebuggerInterface* fDebuggerInterface; thread_id fDebugEventListener; TeamWindow* fTeamWindow; volatile bool fTerminating; Added: haiku/trunk/src/apps/debugger/ThreadInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/ThreadInfo.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/ThreadInfo.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,42 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "ThreadInfo.h" + + +ThreadInfo::ThreadInfo() + : + fTeam(-1), + fThread(-1), + fName() +{ +} + + +ThreadInfo::ThreadInfo(const ThreadInfo& other) + : + fTeam(other.fTeam), + fThread(other.fThread), + fName(other.fName) +{ +} + + +ThreadInfo::ThreadInfo(team_id team, thread_id thread, const BString& name) + : + fTeam(team), + fThread(thread), + fName(name) +{ +} + + +void +ThreadInfo::SetTo(team_id team, thread_id thread, const BString& name) +{ + fTeam = team; + fThread = thread; + fName = name; +} Added: haiku/trunk/src/apps/debugger/ThreadInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/ThreadInfo.h 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/ThreadInfo.h 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,33 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef THREAD_INFO_H +#define THREAD_INFO_H + +#include +#include + + +class ThreadInfo { +public: + ThreadInfo(); + ThreadInfo(const ThreadInfo& other); + ThreadInfo(team_id team, thread_id thread, + const BString& name); + + void SetTo(team_id team, thread_id thread, + const BString& name); + + team_id TeamID() const { return fTeam; } + thread_id ThreadID() const { return fThread; } + const char* Name() const { return fName.String(); } + +private: + team_id fTeam; + thread_id fThread; + BString fName; +}; + + +#endif // THREAD_INFO_H Added: haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.cpp 2009-06-18 17:19:32 UTC (rev 31099) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.cpp 2009-06-18 17:57:37 UTC (rev 31100) @@ -0,0 +1,201 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "DebugEvent.h" + +#include "CpuState.h" + + +// #pragma mark - DebugEvent + + +DebugEvent::DebugEvent(debug_debugger_message eventType, team_id team, + thread_id thread) + : + fEventType(eventType), + fTeam(team), + fThread(thread), + fThreadStopped(false) +{ +} + + +DebugEvent::~DebugEvent() +{ +} + + +void +DebugEvent::SetThreadStopped(bool stopped) +{ + fThreadStopped = stopped; +} + + +// #pragma mark - CpuStateEvent + + +CpuStateEvent::CpuStateEvent(debug_debugger_message eventType, team_id team, + thread_id thread, CpuState* state) + : + DebugEvent(eventType, team, thread), + fCpuState(state) +{ + if (fCpuState != NULL) + fCpuState->AddReference(); +} + + +CpuStateEvent::~CpuStateEvent() +{ + if (fCpuState != NULL) + fCpuState->RemoveReference(); +} + + +// #pragma mark - ThreadDebuggedEvent + + +ThreadDebuggedEvent::ThreadDebuggedEvent(team_id team, thread_id thread) + : + DebugEvent(B_DEBUGGER_MESSAGE_THREAD_DEBUGGED, team, thread) +{ +} + + +// #pragma mark - DebuggerCallEvent + + +DebuggerCallEvent::DebuggerCallEvent(team_id team, thread_id thread, + target_addr_t message) + : + DebugEvent(B_DEBUGGER_MESSAGE_DEBUGGER_CALL, team, thread), + fMessage(message) +{ +} + + +// #pragma mark - BreakpointHitEvent + + +BreakpointHitEvent::BreakpointHitEvent(team_id team, thread_id thread, + CpuState* state) + : + CpuStateEvent(B_DEBUGGER_MESSAGE_BREAKPOINT_HIT, team, thread, state) +{ +} + + +// #pragma mark - WatchpointHitEvent + + +WatchpointHitEvent::WatchpointHitEvent(team_id team, thread_id thread, + CpuState* state) + : + CpuStateEvent(B_DEBUGGER_MESSAGE_WATCHPOINT_HIT, team, thread, state) +{ +} + + + +// #pragma mark - SingleStepEvent + + +SingleStepEvent::SingleStepEvent(team_id team, thread_id thread, + CpuState* state) + : + CpuStateEvent(B_DEBUGGER_MESSAGE_SINGLE_STEP, team, thread, state) +{ +} + + +// #pragma mark - ExceptionOccurredEvent + + +ExceptionOccurredEvent::ExceptionOccurredEvent(team_id team, thread_id thread, + uint32 exception) + : + DebugEvent(B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED, team, thread), + fException(exception) +{ +} + + +// #pragma mark - TeamDeletedEvent + + +TeamDeletedEvent::TeamDeletedEvent(team_id team, thread_id thread) + : + DebugEvent(B_DEBUGGER_MESSAGE_TEAM_DELETED, team, thread) +{ +} + + +// #pragma mark - TeamExecEvent + + +TeamExecEvent::TeamExecEvent(team_id team, thread_id thread) + : + DebugEvent(B_DEBUGGER_MESSAGE_TEAM_EXEC, team, thread) +{ +} + + +// #pragma mark - ThreadCreatedEvent + + +ThreadCreatedEvent::ThreadCreatedEvent(team_id team, thread_id thread, + thread_id newThread) + : + DebugEvent(B_DEBUGGER_MESSAGE_THREAD_CREATED, team, thread), + fNewThread(newThread) +{ +} + + +// #pragma mark - ThreadDeletedEvent + + +ThreadDeletedEvent::ThreadDeletedEvent(team_id team, thread_id thread) + : + DebugEvent(B_DEBUGGER_MESSAGE_THREAD_DELETED, team, thread) +{ +} + + +// #pragma mark - ImageCreatedEvent + + +ImageCreatedEvent::ImageCreatedEvent(team_id team, thread_id thread, + const ImageInfo& info) + : + DebugEvent(B_DEBUGGER_MESSAGE_IMAGE_CREATED, team, thread), + fInfo(info) +{ +} + + +// #pragma mark - ImageDeletedEvent + + +ImageDeletedEvent::ImageDeletedEvent(team_id team, thread_id thread, + const ImageInfo& info) + : + DebugEvent(B_DEBUGGER_MESSAGE_IMAGE_DELETED, team, thread), + fInfo(info) +{ +} + + [... truncated: 553 lines follow ...] From czeidler at mail.berlios.de Thu Jun 18 20:18:57 2009 From: czeidler at mail.berlios.de (czeidler at mail.berlios.de) Date: Thu, 18 Jun 2009 20:18:57 +0200 Subject: [Haiku-commits] r31101 - in haiku/trunk: headers/os/drivers src/add-ons/kernel/bus_managers/acpi Message-ID: <200906181818.n5IIIvvX019075@sheep.berlios.de> Author: czeidler Date: 2009-06-18 20:18:40 +0200 (Thu, 18 Jun 2009) New Revision: 31101 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31101&view=rev Modified: haiku/trunk/headers/os/drivers/ACPI.h haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_module.c haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_priv.h haiku/trunk/src/add-ons/kernel/bus_managers/acpi/oshaiku.c Log: - Add some more acpi function to the acpi module and acpi device module. Need this functions for the embedded controller and battery driver. - Now also use the acpi handle to call a function and not use the path to get a handle and then call the function. Modified: haiku/trunk/headers/os/drivers/ACPI.h =================================================================== --- haiku/trunk/headers/os/drivers/ACPI.h 2009-06-18 17:57:37 UTC (rev 31100) +++ haiku/trunk/headers/os/drivers/ACPI.h 2009-06-18 18:18:40 UTC (rev 31101) @@ -15,55 +15,30 @@ #define B_ACPI_MODULE_NAME "bus_managers/acpi/v1" -struct acpi_module_info { - module_info info; +/* This must be uint64 for 64 bit! */ +typedef uint32 acpi_physical_address; +typedef uint32 acpi_io_address; +typedef uint32 acpi_size; - /* Fixed Event Management */ +/* Actually a ptr to a NS Node */ +typedef void * acpi_handle; - void (*enable_fixed_event)(uint32 event); - void (*disable_fixed_event)(uint32 event); +#ifndef __ACTYPES_H__ - uint32 (*fixed_event_status) (uint32 event); - /* Returns 1 if event set, 0 otherwise */ - void (*reset_fixed_event) (uint32 event); +/* Address Space (Operation Region) Types */ - status_t (*install_fixed_event_handler)(uint32 event, - interrupt_handler *handler, void *data); - status_t (*remove_fixed_event_handler)(uint32 event, - interrupt_handler *handler); - - /* Namespace Access */ - - status_t (*get_next_entry)(uint32 objectType, const char *base, - char *result, size_t length, void **_counter); - status_t (*get_device)(const char *hid, uint32 index, char *result, - size_t resultLength); - - status_t (*get_device_hid)(const char *path, char *hid, size_t hidLength); - uint32 (*get_object_type)(const char *path); - status_t (*get_object)(const char *path, - acpi_object_type **_returnValue); - status_t (*get_object_typed)(const char *path, - acpi_object_type **_returnValue, uint32 objectType); - - /* Control method execution and data acquisition */ - - status_t (*evaluate_object)(const char *object, - acpi_object_type *returnValue, size_t bufferLength); - status_t (*evaluate_method)(const char *object, const char *method, - acpi_object_type *returnValue, size_t bufferLength, - acpi_object_type *args, int numArgs); - - /* Power state setting */ - - status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void), - size_t size); - status_t (*enter_sleep_state)(uint8 state); +enum { + ACPI_ADR_SPACE_SYSTEM_MEMORY = 0, + ACPI_ADR_SPACE_SYSTEM_IO = 1, + ACPI_ADR_SPACE_PCI_CONFIG = 2, + ACPI_ADR_SPACE_EC = 3, + ACPI_ADR_SPACE_SMBUS = 4, + ACPI_ADR_SPACE_CMOS = 5, + ACPI_ADR_SPACE_PCI_BAR_TARGET = 6, + ACPI_ADR_SPACE_DATA_TABLE = 7, + ACPI_ADR_SPACE_FIXED_HARDWARE = 127 }; - -#ifndef __ACTYPES_H__ - /* ACPI fixed event types */ enum { @@ -91,7 +66,8 @@ ACPI_TYPE_POWER, ACPI_TYPE_PROCESSOR, ACPI_TYPE_THERMAL, - ACPI_TYPE_BUFFER_FIELD + ACPI_TYPE_BUFFER_FIELD, + ACPI_TYPE_LOCAL_REFERENCE = 0x14 }; /* ACPI control method arg type */ @@ -112,6 +88,12 @@ uint32 count; acpi_object_type *objects; } package; + struct + { + uint32 type; + uint32 actual_type; + acpi_handle handle; + } reference; struct { uint32 cpu_id; int pblk_address; @@ -124,8 +106,127 @@ } data; }; + +/* + * List of objects, used as a parameter list for control method evaluation + */ +typedef struct acpi_objects { + uint32 count; + acpi_object_type *pointer; +} acpi_objects; + + +typedef struct acpi_data { + acpi_size length; /* Length in bytes of the buffer */ + void *pointer; /* pointer to buffer */ +} acpi_data; + + +enum { + ACPI_ALLOCATE_BUFFER = -1, +}; + + #endif // __ACTYPES_H__ + +typedef uint32 (*acpi_event_handler)(void *Context); + +typedef status_t (*acpi_adr_space_handler)(uint32 function, + acpi_physical_address address, uint32 bitWidth, int *value, + void *handlerContext, void *regionContext); + +typedef status_t (*acpi_adr_space_setup)(acpi_handle regionHandle, + uint32 function, void *handlerContext, void **regionContext); + +typedef void (*acpi_notify_handler)(acpi_handle device, uint32 value, + void *context); + + +struct acpi_module_info { + module_info info; + + status_t (*get_handle)(acpi_handle parent, char *pathname, + acpi_handle *retHandle); + + /* Global Lock */ + + status_t (*acquire_global_lock)(uint16 timeout, uint32 *handle); + status_t (*release_global_lock)(uint32 handle); + + /* Notify Handler */ + + status_t (*install_notify_handler)(acpi_handle device, + uint32 handlerType, acpi_notify_handler handler, + void *context); + status_t (*remove_notify_handler)(acpi_handle device, + uint32 handlerType, acpi_notify_handler handler); + + /* GPE Handler */ + + status_t (*enable_gpe)(acpi_handle handle, uint32 gpeNumber, + uint32 flags); + status_t (*set_gpe_type)(acpi_handle handle, uint32 gpeNumber, + uint8 type); + status_t (*install_gpe_handler)(acpi_handle handle, uint32 gpeNumber, + uint32 type, acpi_event_handler handler, void *data); + status_t (*remove_gpe_handler)(acpi_handle handle, uint32 gpeNumber, + acpi_event_handler address); + + /* Address Space Handler */ + + status_t (*install_address_space_handler)(acpi_handle handle, + uint32 spaceId, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *data); + status_t (*remove_address_space_handler)(acpi_handle handle, + uint32 spaceId, + acpi_adr_space_handler handler); + + /* Fixed Event Management */ + + void (*enable_fixed_event)(uint32 event); + void (*disable_fixed_event)(uint32 event); + + uint32 (*fixed_event_status) (uint32 event); + /* Returns 1 if event set, 0 otherwise */ + void (*reset_fixed_event) (uint32 event); + + status_t (*install_fixed_event_handler)(uint32 event, + interrupt_handler *handler, void *data); + status_t (*remove_fixed_event_handler)(uint32 event, + interrupt_handler *handler); + + /* Namespace Access */ + + status_t (*get_next_entry)(uint32 objectType, const char *base, + char *result, size_t length, void **_counter); + status_t (*get_device)(const char *hid, uint32 index, char *result, + size_t resultLength); + + status_t (*get_device_hid)(const char *path, char *hid, + size_t hidLength); + uint32 (*get_object_type)(const char *path); + status_t (*get_object)(const char *path, + acpi_object_type **_returnValue); + status_t (*get_object_typed)(const char *path, + acpi_object_type **_returnValue, uint32 objectType); + + /* Control method execution and data acquisition */ + + status_t (*evaluate_object)(const char* object, + acpi_object_type *returnValue, size_t bufferLength); + status_t (*evaluate_method)(acpi_handle handle, const char *method, + acpi_objects *args, acpi_data *returnValue); + + /* Power state setting */ + + status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void), + size_t size); + status_t (*enter_sleep_state)(uint8 state); +}; + + /* Sleep states */ enum { @@ -143,12 +244,29 @@ #define ACPI_DEVICE_TYPE_ITEM "acpi/type" -typedef struct acpi_device_info *acpi_device; +typedef struct acpi_device_cookie *acpi_device; // Interface to one ACPI device. typedef struct acpi_device_module_info { driver_module_info info; + /* Notify Handler */ + + status_t (*install_notify_handler)(acpi_device device, + uint32 handlerType, acpi_notify_handler handler, + void *context); + status_t (*remove_notify_handler)(acpi_device device, + uint32 handlerType, acpi_notify_handler handler); + + /* Address Space Handler */ + status_t (*install_address_space_handler)(acpi_device device, + uint32 spaceId, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *data); + status_t (*remove_address_space_handler)(acpi_device device, + uint32 spaceId, + acpi_adr_space_handler handler); + /* Namespace Access */ uint32 (*get_object_type)(acpi_device device); status_t (*get_object)(acpi_device device, const char *path, @@ -156,8 +274,7 @@ /* Control method execution and data acquisition */ status_t (*evaluate_method)(acpi_device device, const char *method, - acpi_object_type *returnValue, size_t bufferLength, - acpi_object_type *args, int numArgs); + acpi_objects *args, acpi_data *returnValue); } acpi_device_module_info; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c 2009-06-18 17:57:37 UTC (rev 31100) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c 2009-06-18 18:18:40 UTC (rev 31101) @@ -1,4 +1,5 @@ /* + * Copyright 2009, Clemens Zeidler, haiku at clemens-zeidler.de * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. * Copyright 2006, Bryan Varner. All rights reserved. * Copyright 2005, Nathan Whitehorn. All rights reserved. @@ -171,6 +172,98 @@ } +status_t +get_handle(acpi_handle parent, char *pathname, acpi_handle *retHandle) +{ + return AcpiGetHandle(parent, pathname, retHandle) == AE_OK + ? B_OK : B_ERROR; +} + + +status_t +acquire_global_lock(uint16 timeout, uint32 *handle) +{ + return AcpiAcquireGlobalLock(timeout, (UINT32*)handle) == AE_OK + ? B_OK : B_ERROR; +} + + +status_t +release_global_lock(uint32 handle) +{ + return AcpiReleaseGlobalLock(handle) == AE_OK ? B_OK : B_ERROR; +} + + +status_t +install_notify_handler(acpi_handle device, uint32 handlerType, + acpi_notify_handler handler, void *context) +{ + return AcpiInstallNotifyHandler(device, handlerType, + (ACPI_NOTIFY_HANDLER)handler, context) == AE_OK ? B_OK : B_ERROR; +} + + +status_t +remove_notify_handler(acpi_handle device, uint32 handlerType, + acpi_notify_handler handler) +{ + return AcpiRemoveNotifyHandler(device, handlerType, + (ACPI_NOTIFY_HANDLER)handler) == AE_OK ? B_OK : B_ERROR; +} + + +status_t +enable_gpe(acpi_handle handle, uint32 gpeNumber, uint32 flags) +{ + return AcpiEnableGpe(handle, gpeNumber, flags) == AE_OK ? B_OK : B_ERROR; +} + + +status_t +set_gpe_type(acpi_handle handle, uint32 gpeNumber, uint8 type) +{ + return AcpiSetGpeType(handle, gpeNumber, type) == AE_OK ? B_OK : B_ERROR; +} + + +status_t +install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type, + acpi_event_handler handler, void *data) +{ + return AcpiInstallGpeHandler(handle, gpeNumber, type, + (ACPI_EVENT_HANDLER)handler, data) == AE_OK ? B_OK : B_ERROR; +} + + +status_t +remove_gpe_handler(acpi_handle handle, uint32 gpeNumber, + acpi_event_handler address) +{ + return AcpiRemoveGpeHandler(handle, gpeNumber, (ACPI_EVENT_HANDLER)address) + == AE_OK ? B_OK : B_ERROR; +} + + +status_t +install_address_space_handler(acpi_handle handle, uint32 spaceId, + acpi_adr_space_handler handler, acpi_adr_space_setup setup, void *data) +{ + return AcpiInstallAddressSpaceHandler(handle, spaceId, + (ACPI_ADR_SPACE_HANDLER)handler, (ACPI_ADR_SPACE_SETUP)setup, data) + == AE_OK ? B_OK : B_ERROR; +} + + +status_t +remove_address_space_handler(acpi_handle handle, uint32 spaceId, + acpi_adr_space_handler handler) +{ + return AcpiRemoveAddressSpaceHandler(handle, spaceId, + (ACPI_ADR_SPACE_HANDLER)handler) == AE_OK ? B_OK : B_ERROR; +} + + void enable_fixed_event(uint32 event) { @@ -391,29 +484,16 @@ status_t -evaluate_method(const char* object, const char* method, - acpi_object_type *returnValue, size_t bufferLength, acpi_object_type *args, - int numArgs) +evaluate_method(acpi_handle handle, const char* method, + acpi_objects *args, acpi_data *returnValue) { - ACPI_BUFFER buffer; ACPI_STATUS status; - ACPI_OBJECT_LIST acpiArgs; - ACPI_HANDLE handle; - - if (AcpiGetHandle(NULL, (ACPI_STRING)object, &handle) != AE_OK) - return B_ENTRY_NOT_FOUND; - - buffer.Pointer = returnValue; - buffer.Length = bufferLength; - - acpiArgs.Count = numArgs; - acpiArgs.Pointer = (ACPI_OBJECT *)args; - + status = AcpiEvaluateObject(handle, (ACPI_STRING)method, - args != NULL ? &acpiArgs : NULL, returnValue != NULL ? &buffer : NULL); + (ACPI_OBJECT_LIST*)args, (ACPI_BUFFER*)returnValue); if (status == AE_BUFFER_OVERFLOW) dprintf("evaluate_method: the passed buffer is too small!\n"); - + return status == AE_OK ? B_OK : B_ERROR; } @@ -475,6 +555,17 @@ acpi_std_ops }, + get_handle, + acquire_global_lock, + release_global_lock, + install_notify_handler, + remove_notify_handler, + enable_gpe, + set_gpe_type, + install_gpe_handler, + remove_gpe_handler, + install_address_space_handler, + remove_address_space_handler, enable_fixed_event, disable_fixed_event, fixed_event_status, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c 2009-06-18 17:57:37 UTC (rev 31100) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_device.c 2009-06-18 18:18:40 UTC (rev 31101) @@ -1,4 +1,5 @@ /* + * Copyright 2009, Clemens Zeidler. All rights reserved. * Copyright 2006, J?r?me Duval. All rights reserved. * * Distributed under the terms of the MIT License. @@ -9,16 +10,41 @@ #include #include "acpi_priv.h" +#include "acpi.h" -// information about one ACPI device -typedef struct acpi_device_info { - char *path; // path - uint32 type; // type - device_node *node; - char name[32]; // name (for fast log) -} acpi_device_info; +static status_t +acpi_install_notify_handler(acpi_device device, uint32 handlerType, + acpi_notify_handler handler, void *context) +{ + return install_notify_handler(device->handle, handlerType, handler, + context); +} +static status_t +acpi_remove_notify_handler(acpi_device device, uint32 handlerType, + acpi_notify_handler handler) +{ + return remove_notify_handler(device->handle, handlerType, handler); +} + + +static status_t +acpi_install_address_space_handler(acpi_device device, uint32 spaceId, + acpi_adr_space_handler handler, acpi_adr_space_setup setup, void *data) +{ + return install_address_space_handler(device->handle, spaceId, handler, + setup, data); +} + +static status_t +acpi_remove_address_space_handler(acpi_device device, uint32 spaceId, + acpi_adr_space_handler handler) +{ + return remove_address_space_handler(device->handle, spaceId, handler); +} + + static uint32 acpi_get_object_type(acpi_device device) { @@ -39,18 +65,19 @@ static status_t -acpi_evaluate_method(acpi_device device, const char *method, acpi_object_type *return_value, - size_t buf_len, acpi_object_type *args, int num_args) +acpi_evaluate_method(acpi_device device, const char *method, + acpi_objects *args, acpi_data *returnValue) { - return evaluate_method(device->path, method, return_value, buf_len, args, num_args); + return evaluate_method(device->handle, method, args, returnValue); } static status_t acpi_device_init_driver(device_node *node, void **cookie) { + ACPI_HANDLE handle; const char *path; - acpi_device_info *device; + acpi_device_cookie *device; status_t status = B_OK; uint32 type; @@ -62,9 +89,13 @@ device = malloc(sizeof(*device)); if (device == NULL) return B_NO_MEMORY; - + memset(device, 0, sizeof(*device)); + if (AcpiGetHandle(NULL, (ACPI_STRING)path, &handle) != AE_OK) + return B_ENTRY_NOT_FOUND; + + device->handle = handle; device->path = strdup(path); device->type = type; device->node = node; @@ -81,7 +112,7 @@ static void acpi_device_uninit_driver(void *cookie) { - acpi_device_info *device = cookie; + acpi_device_cookie *device = cookie; free(device->path); free(device); @@ -100,6 +131,7 @@ return B_BAD_VALUE; } + acpi_device_module_info gACPIDeviceModule = { { { @@ -116,6 +148,10 @@ NULL, // rescan devices NULL, // device removed }, + acpi_install_notify_handler, + acpi_remove_notify_handler, + acpi_install_address_space_handler, + acpi_remove_address_space_handler, acpi_get_object_type, acpi_get_object, acpi_evaluate_method, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_module.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_module.c 2009-06-18 17:57:37 UTC (rev 31100) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_module.c 2009-06-18 18:18:40 UTC (rev 31101) @@ -1,4 +1,5 @@ /* + * Copyright 2009, Clemens Zeidler. All rights reserved. * Copyright 2006, J?r?me Duval. All rights reserved. * * Distributed under the terms of the MIT License. @@ -22,7 +23,6 @@ device_manager_info *gDeviceManager = NULL; pci_module_info *gPCIManager = NULL; -dpc_module_info *gDPC = NULL; module_dependency module_dependencies[] = { {B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager}, @@ -217,6 +217,17 @@ NULL, // device removed }, + get_handle, + acquire_global_lock, + release_global_lock, + install_notify_handler, + remove_notify_handler, + enable_gpe, + set_gpe_type, + install_gpe_handler, + remove_gpe_handler, + install_address_space_handler, + remove_address_space_handler, enable_fixed_event, disable_fixed_event, fixed_event_status, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_priv.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_priv.h 2009-06-18 17:57:37 UTC (rev 31100) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/acpi_priv.h 2009-06-18 18:18:40 UTC (rev 31101) @@ -1,10 +1,14 @@ /* + * Copyright 2009, Clemens Zeidler. All rights reserved. * Copyright 2006, J?r?me Duval. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef __ACPI_PRIV_H__ #define __ACPI_PRIV_H__ +#include +__BEGIN_DECLS + #include #include #include @@ -21,11 +25,56 @@ extern device_manager_info *gDeviceManager; +// information about one ACPI device +typedef struct acpi_device_cookie { + char *path; // path + acpi_handle handle; + uint32 type; // type + device_node *node; + char name[32]; // name (for fast log) +} acpi_device_cookie; + // ACPI root. typedef struct acpi_root_info { driver_module_info info; + + status_t (*get_handle)(acpi_handle parent, char *pathname, + acpi_handle *retHandle); + + /* Global Lock */ + status_t (*acquire_global_lock)(uint16 timeout, uint32 *handle); + status_t (*release_global_lock)(uint32 handle); + /* Notify Handler */ + + status_t (*install_notify_handler)(acpi_handle device, + uint32 handlerType, acpi_notify_handler handler, + void *context); + status_t (*remove_notify_handler)(acpi_handle device, + uint32 handlerType, acpi_notify_handler handler); + + /* GPE Handler */ + + status_t (*enable_gpe)(acpi_handle handle, uint32 gpeNumber, + uint32 flags); + status_t (*set_gpe_type)(acpi_handle handle, uint32 gpeNumber, + uint8 type); + status_t (*install_gpe_handler)(acpi_handle handle, uint32 gpeNumber, + uint32 type, acpi_event_handler handler, void *data); + status_t (*remove_gpe_handler)(acpi_handle handle, uint32 gpeNumber, + acpi_event_handler address); + + /* Address Space Handler */ + + status_t (*install_address_space_handler)(acpi_handle handle, + uint32 spaceId, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, void *data); + status_t (*remove_address_space_handler)(acpi_handle handle, + uint32 spaceId, + acpi_adr_space_handler handler); + /* Fixed Event Management */ void (*enable_fixed_event) (uint32 event); @@ -56,11 +105,10 @@ /* Control method execution and data acquisition */ - status_t (*evaluate_object)(const char *object, + status_t (*evaluate_object)(const char* object, acpi_object_type *returnValue, size_t bufferLength); - status_t (*evaluate_method)(const char *object, const char *method, - acpi_object_type *returnValue, size_t bufferLength, - acpi_object_type *args, int numArgs); + status_t (*evaluate_method)(acpi_handle handle, const char *method, + acpi_objects *args, acpi_data *returnValue); } acpi_root_info; @@ -71,6 +119,28 @@ extern acpi_device_module_info gACPIDeviceModule; +status_t get_handle(acpi_handle parent, char *pathname, acpi_handle *retHandle); + +status_t acquire_global_lock(uint16 timeout, uint32 *handle); +status_t release_global_lock(uint32 handle); + +status_t install_notify_handler(acpi_handle device, uint32 handlerType, + acpi_notify_handler handler, void *context); +status_t remove_notify_handler(acpi_handle device, uint32 handlerType, + acpi_notify_handler handler); + +status_t enable_gpe(acpi_handle handle, uint32 gpeNumber, uint32 flags); +status_t set_gpe_type(acpi_handle handle, uint32 gpeNumber, uint8 type); +status_t install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type, + acpi_event_handler handler, void *data); +status_t remove_gpe_handler(acpi_handle handle, uint32 gpeNumber, + acpi_event_handler address); + +status_t install_address_space_handler(acpi_handle handle, uint32 spaceId, + acpi_adr_space_handler handler, acpi_adr_space_setup setup, void *data); +status_t remove_address_space_handler(acpi_handle handle, uint32 spaceId, + acpi_adr_space_handler handler); + void enable_fixed_event(uint32 event); void disable_fixed_event(uint32 event); @@ -92,10 +162,11 @@ status_t get_object_typed(const char *path, acpi_object_type **return_value, uint32 object_type); -status_t evaluate_object(const char *object, acpi_object_type *returnValue, +status_t evaluate_object(const char* object, acpi_object_type *returnValue, size_t bufferLength); -status_t evaluate_method(const char *object, const char *method, - acpi_object_type *returnValue, size_t bufferLength, acpi_object_type *args, - int numArgs); +status_t evaluate_method(acpi_handle handle, const char *method, + acpi_objects *args, acpi_data *returnValue); +__END_DECLS + #endif /* __ACPI_PRIV_H__ */ Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/oshaiku.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/oshaiku.c 2009-06-18 17:57:37 UTC (rev 31100) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/oshaiku.c 2009-06-18 18:18:40 UTC (rev 31101) @@ -125,14 +125,14 @@ #include #include #include - + #ifdef _KERNEL_MODE #include #include #include extern pci_module_info *gPCIManager; #include -extern dpc_module_info *gDPC; +dpc_module_info *gDPC = NULL; extern void *gDPCHandle; #endif From czeidler at mail.berlios.de Thu Jun 18 20:30:13 2009 From: czeidler at mail.berlios.de (czeidler at mail.berlios.de) Date: Thu, 18 Jun 2009 20:30:13 +0200 Subject: [Haiku-commits] r31102 - in haiku/trunk/src/add-ons/kernel/drivers/power: . acpi_embedded_controller Message-ID: <200906181830.n5IIUDhx020117@sheep.berlios.de> Author: czeidler Date: 2009-06-18 20:30:06 +0200 (Thu, 18 Jun 2009) New Revision: 31102 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31102&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/ haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/Jamfile haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.cpp haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.h haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/acpi_embedded_controller.cpp haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/acpi_embedded_controller.h Modified: haiku/trunk/src/add-ons/kernel/drivers/power/Jamfile Log: Embedded Controller driver, used the BSD driver as base. Thanks to Ithamar for pointing out that I need this driver to read the acpi battery status which now works for me (driver coming soon). My laptop now really switch off on shutdown :-) Modified: haiku/trunk/src/add-ons/kernel/drivers/power/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/power/Jamfile 2009-06-18 18:18:40 UTC (rev 31101) +++ haiku/trunk/src/add-ons/kernel/drivers/power/Jamfile 2009-06-18 18:30:06 UTC (rev 31102) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel drivers power ; SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_button ; +SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_embedded_controller ; SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_lid ; SubInclude HAIKU_TOP src add-ons kernel drivers power acpi_thermal ; SubInclude HAIKU_TOP src add-ons kernel drivers power enhanced_speedstep ; Added: haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/Jamfile 2009-06-18 18:18:40 UTC (rev 31101) +++ haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/Jamfile 2009-06-18 18:30:06 UTC (rev 31102) @@ -0,0 +1,11 @@ +SubDir HAIKU_TOP src add-ons kernel drivers power acpi_embedded_controller ; + + +UsePrivateHeaders kernel ; + +KernelAddon acpi_embedded_controller : + acpi_embedded_controller.cpp + SmallResourceData.cpp + ; + +Depends acpi_embedded_controller : acpi ; Added: haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.cpp 2009-06-18 18:18:40 UTC (rev 31101) +++ haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.cpp 2009-06-18 18:30:06 UTC (rev 31102) @@ -0,0 +1,114 @@ +/* + * Copyright 2009, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Clemens Zeidler, haiku at clemens-zeidler.de + */ + +#include "SmallResourceData.h" + +#include + +//#define TRACE_SMALLRESOURCEDATA +#ifdef TRACE_SMALLRESOURCEDATA +# define TRACE(x...) dprintf("Small Resource Data: "x) +#else +# define TRACE(x...) +#endif + + +void +io_port::Print() +{ + dprintf("io_port:\n"); + int i = (deviceAddresses16Bit ? 1 : 0); + dprintf("deviceAddresses16Bit %i\n", i); + dprintf("minimumBase %i\n", minimumBase); + dprintf("maximumBase %i\n", maximumBase); + dprintf("minimumBaseAlignment %i\n", minimumBaseAlignment); + dprintf("contigiuousIOPorts %i\n", contigiuousIOPorts); +} + + +SmallResourceData::SmallResourceData(acpi_device_module_info* acpi, + acpi_device acpiCookie, char* method) +{ + acpi_data buffer; + buffer.pointer = NULL; + buffer.length = ACPI_ALLOCATE_BUFFER; + + fStatus = acpi->evaluate_method(acpiCookie, method, NULL, &buffer); + + if (fStatus != B_OK) + return; + + fBuffer = (acpi_object_type*)buffer.pointer; + + if (fBuffer[0].object_type != ACPI_TYPE_BUFFER) { + fStatus = B_ERROR; + return; + } + + fResourcePointer = (int8*)fBuffer[0].data.buffer.buffer; + fBufferSize = fBuffer[0].data.buffer.length; + fRemainingBufferSize = fBufferSize; + + // ToDo: Check checksum of the endtag. The sum of all databytes + checksum + // is zero. See section 6.4.2.8. +} + + +SmallResourceData::~SmallResourceData() +{ + if (InitCheck() == B_OK) + free(fBuffer); +} + + +status_t +SmallResourceData::InitCheck() +{ + return fStatus; +} + + +int8 +SmallResourceData::GetType() +{ + return *fResourcePointer; +} + + +status_t +SmallResourceData::ReadIOPort(io_port* ioPort) +{ + const size_t packageSize = 8; + + if (fRemainingBufferSize < packageSize) + return B_ERROR; + if (fResourcePointer[0] != kIOPort) + return B_ERROR; + + ioPort->deviceAddresses16Bit = (fResourcePointer[1] == 1); + + int16 tmp; + tmp = fResourcePointer[3]; + tmp = tmp << 8; + tmp |= fResourcePointer[2]; + ioPort->minimumBase = tmp; + + tmp = fResourcePointer[5]; + tmp = tmp << 8; + tmp |= fResourcePointer[4]; + ioPort->maximumBase = tmp; + + ioPort->minimumBaseAlignment = fResourcePointer[6]; + ioPort->contigiuousIOPorts = fResourcePointer[7]; + + fResourcePointer += packageSize; + fRemainingBufferSize -= packageSize; + TRACE("SmallResourceData: remaining buffer size %i\n", + int(fRemainingBufferSize)); + return B_OK; +} Added: haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.h 2009-06-18 18:18:40 UTC (rev 31101) +++ haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/SmallResourceData.h 2009-06-18 18:30:06 UTC (rev 31102) @@ -0,0 +1,61 @@ +/* + * Copyright 2009, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Clemens Zeidler, haiku at clemens-zeidler.de + */ + +#ifndef SMALLRESOURCEDATA_H +#define SMALLRESOURCEDATA_H + +#include +#include + + +enum resource_type +{ + kIOPort = 0x47, + kEndTag = 0x78 +}; + + +struct io_port +{ + void Print(); + //! The logical device decodes 16-bit addresses. + bool deviceAddresses16Bit; + + uint16 minimumBase; + uint16 maximumBase; + uint8 minimumBaseAlignment; + uint8 contigiuousIOPorts; +}; + + +/*! ToDo: implement also the other resource data, see acpi section 6.2.4 */ +class SmallResourceData +{ +public: + SmallResourceData(acpi_device_module_info* acpi, + acpi_device acpiCookie, char* method); + ~SmallResourceData(); + + status_t InitCheck(); + + int8 GetType(); + /*! Get resource data and jump to the next resource. */ + status_t ReadIOPort(io_port* ioPort); + +private: + acpi_object_type* fBuffer; + size_t fBufferSize; + size_t fRemainingBufferSize; + + int8* fResourcePointer; + + status_t fStatus; +}; + + +#endif Added: haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/acpi_embedded_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/acpi_embedded_controller.cpp 2009-06-18 18:18:40 UTC (rev 31101) +++ haiku/trunk/src/add-ons/kernel/drivers/power/acpi_embedded_controller/acpi_embedded_controller.cpp 2009-06-18 18:30:06 UTC (rev 31102) @@ -0,0 +1,937 @@ +/*- + * Copyright (c) 2009 Clemens Zeidler + * Copyright (c) 2003-2007 Nate Lawson + * Copyright (c) 2000 Michael Smith + * Copyright (c) 2000 BSDi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "acpi_embedded_controller.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "SmallResourceData.h" + +#define ACPI_EC_DRIVER_NAME "drivers/power/acpi_embedded_controller/driver_v1" + +#define ACPI_EC_DEVICE_NAME "drivers/power/acpi_embedded_controller/device_v1" + +/* Base Namespace devices are published to */ +#define ACPI_EC_BASENAME "power/embedded_controller/%d" + +// name of pnp generator of path ids +#define ACPI_EC_PATHID_GENERATOR "embedded_controller/path_id" + +device_manager_info *gDeviceManager = NULL; + +pci_module_info *gPCIManager = NULL; + + +uint8 +bus_space_read_1(int address) +{ + return gPCIManager->read_io_8(address); +} + + +void +bus_space_write_1(int address, uint8 v) +{ + gPCIManager->write_io_8(address, v); +} + + +status_t +acpi_GetInteger(acpi_device_module_info* acpi, acpi_device& acpiCookie, + char* path, int* number) +{ + status_t status; + acpi_data buf; + acpi_object_type object; + buf.pointer = &object; + buf.length = sizeof(acpi_object_type); + /* + * Assume that what we've been pointed at is an Integer object, or + * a method that will return an Integer. + */ + status = acpi->evaluate_method(acpiCookie, path, NULL, &buf); + + if (status == B_OK) { + if (object.object_type == ACPI_TYPE_INTEGER) + *number = object.data.integer; + else + status = B_ERROR; + } + return status; +} + + +acpi_handle +acpi_GetReference(acpi_module_info* acpi, acpi_handle scope, + acpi_object_type *obj) +{ + acpi_handle h; + + if (obj == NULL) + return (NULL); + + switch (obj->object_type) { + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_ANY: + h = obj->data.reference.handle; + break; + case ACPI_TYPE_STRING: + /* + * The String object usually contains a fully-qualified path, so + * scope can be NULL. + * + * XXX This may not always be the case. + */ + if (acpi->get_handle(scope, obj->data.string.string, &h) != B_OK) + h = NULL; + break; + default: + h = NULL; + break; + } + + return (h); +} + + +int +acpi_PkgInt(acpi_object_type *res, int idx, int *dst) +{ + acpi_object_type *obj; + + obj = &res->data.package.objects[idx]; + if (obj == NULL || obj->object_type != ACPI_TYPE_INTEGER) + return (EINVAL); + *dst = obj->data.integer; + + return (0); +} + + +int +acpi_PkgInt32(acpi_object_type *res, int idx, uint32 *dst) +{ + int tmp; + int error; + + error = acpi_PkgInt(res, idx, &tmp); + if (error == 0) + *dst = (uint32)tmp; + + return (error); +} + + +static status_t +embedded_controller_open(void *initCookie, const char *path, int flags, void** cookie) +{ + acpi_ec_softc *device = (acpi_ec_softc*)initCookie; + *cookie = device; + + return B_OK; +} + + +static status_t +embedded_controller_close(void* cookie) +{ + return B_OK; +} + + +static status_t +embedded_controller_read(void* _cookie, off_t position, void *buffer, size_t* numBytes) +{ + return B_IO_ERROR; +} + + +static status_t +embedded_controller_write(void* cookie, off_t position, const void* buffer, size_t* numBytes) +{ + return B_IO_ERROR; +} + + +status_t +embedded_controller_control(void* _cookie, uint32 op, void* arg, size_t len) +{ + return B_ERROR; +} + + +static status_t +embedded_controller_free(void* cookie) +{ + return B_OK; +} + + +// #pragma mark - driver module API + +int32 +acpi_get_type(device_node* dev) +{ + const char *bus; + if (gDeviceManager->get_attr_string(dev, B_DEVICE_BUS, &bus, false)) + return -1; + + if (strcmp(bus, "acpi")) + return -1; + + uint32 deviceType; + if (gDeviceManager->get_attr_uint32(dev, ACPI_DEVICE_TYPE_ITEM, + &deviceType, false) != B_OK) + return -1; + + return deviceType; +} + + +static float +embedded_controller_support(device_node *dev) +{ + static char *ec_ids[] = { "PNP0C09", NULL }; + + /* Check that this is a device. */ + if (acpi_get_type(dev) != ACPI_TYPE_DEVICE) + return 0.; + + const char *name; + if (gDeviceManager->get_attr_string(dev, ACPI_DEVICE_HID_ITEM, &name, + false) != B_OK || strcmp(name, ec_ids[0])) + return 0.0; + + TRACE("supported device found %s\n", name); + return 0.6; +} + + +static status_t +embedded_controller_register_device(device_node *node) +{ + device_attr attrs[] = { + { B_DEVICE_PRETTY_NAME, B_STRING_TYPE, + { string: "ACPI embedded controller" }}, + { NULL } + }; + + return gDeviceManager->register_node(node, ACPI_EC_DRIVER_NAME, attrs, + NULL, NULL); +} + + +static status_t +embedded_controller_init_driver(device_node *dev, void **_driverCookie) +{ + TRACE("init driver\n"); + acpi_ec_softc *sc; + sc = (acpi_ec_softc*)malloc(sizeof(acpi_ec_softc)); + memset(sc, 0, sizeof(acpi_ec_softc)); + + *_driverCookie = sc; + sc->ec_dev = dev; + + sc->ec_condition_var.Init(NULL, "ec condition variable"); + + device_node *parent; + parent = gDeviceManager->get_parent_node(dev); + gDeviceManager->get_driver(parent, (driver_module_info **)&sc->ec_acpi, + (void **)&sc->ec_handle); + gDeviceManager->put_node(parent); + + SmallResourceData resourceData(sc->ec_acpi, sc->ec_handle, "_CRS"); + if (resourceData.InitCheck() != B_OK) { + TRACE("failed to read _CRS resource\n") ; + return B_ERROR; + } + io_port portData; + + if (get_module(B_ACPI_MODULE_NAME, (module_info**)&sc->ec_acpi_module) != B_OK) + return B_ERROR; + + // DPC module + if (gDPC == NULL && get_module(B_DPC_MODULE_NAME, + (module_info **)&gDPC) != B_OK) { + dprintf("failed to get dpc module for os execution\n"); + return B_ERROR; + } + + if (gDPCHandle == NULL) { + if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task", + B_NORMAL_PRIORITY) != B_OK) { + dprintf("failed to create os execution queue\n"); + return B_ERROR; + } + } + + acpi_data buf; + buf.pointer = NULL; + buf.length = ACPI_ALLOCATE_BUFFER; + + + /* + * Read the unit ID to check for duplicate attach and the + * global lock value to see if we should acquire it when + * accessing the EC. + */ + + status_t status; + status = acpi_GetInteger(sc->ec_acpi, sc->ec_handle, "_UID", &sc->ec_uid); + if (status != B_OK) + sc->ec_uid = 0; + status = acpi_GetInteger(sc->ec_acpi, sc->ec_handle, "_GLK", &sc->ec_glk); + if (status != B_OK) + sc->ec_glk = 0; + + /* + * Evaluate the _GPE method to find the GPE bit used by the EC to + * signal status (SCI). If it's a package, it contains a reference + * and GPE bit, similar to _PRW. + */ + status = sc->ec_acpi->evaluate_method(sc->ec_handle, "_GPE", NULL, &buf); + if (status != B_OK) { + TRACE("can't evaluate _GPE\n"); + goto error; + } + + acpi_object_type* obj; + obj = (acpi_object_type*)buf.pointer; + if (obj == NULL) + goto error; + + switch (obj->object_type) { + case ACPI_TYPE_INTEGER: + sc->ec_gpehandle = NULL; + sc->ec_gpebit = obj->data.integer; + break; + case ACPI_TYPE_PACKAGE: + if (!ACPI_PKG_VALID(obj, 2)) + goto error; + sc->ec_gpehandle = + acpi_GetReference(sc->ec_acpi_module, NULL, + &obj->data.package.objects[0]); + if (sc->ec_gpehandle == NULL || + acpi_PkgInt32(obj, 1, (uint32*)&sc->ec_gpebit) != 0) + goto error; + break; + default: + TRACE("_GPE has invalid type %i\n", int(obj->object_type)); + goto error; + } + + sc->ec_suspending = FALSE; + + /* Attach bus resources for data and command/status ports. */ + sc->ec_data_rid = 0; + if (resourceData.ReadIOPort(&portData) != B_OK) + goto error; + + sc->ec_data_pci_address = portData.minimumBase; + + sc->ec_csr_rid = 1; + if (resourceData.ReadIOPort(&portData) != B_OK) + goto error; + + sc->ec_csr_pci_address = portData.minimumBase; + + /* + * Install a handler for this EC's GPE bit. We want edge-triggered + * behavior. + */ + TRACE("attaching GPE handler\n"); + status = sc->ec_acpi_module->install_gpe_handler(sc->ec_gpehandle, + sc->ec_gpebit, ACPI_GPE_EDGE_TRIGGERED, &EcGpeHandler, sc); + if (status != B_OK) { + TRACE("can't install ec GPE handler\n"); + goto error; + } + + /* + * Install address space handler + */ + TRACE("attaching address space handler\n"); + status = sc->ec_acpi->install_address_space_handler(sc->ec_handle, + ACPI_ADR_SPACE_EC, &EcSpaceHandler, &EcSpaceSetup, sc); + if (status != B_OK) { + TRACE("can't install address space handler\n"); + goto error; + } + + /* Enable runtime GPEs for the handler. */ + status = sc->ec_acpi_module->set_gpe_type(sc->ec_gpehandle, sc->ec_gpebit, + ACPI_GPE_TYPE_RUNTIME); + if (status != B_OK) { + TRACE("AcpiSetGpeType failed.\n"); + goto error; + } + status = sc->ec_acpi_module->enable_gpe(sc->ec_gpehandle, sc->ec_gpebit, + ACPI_NOT_ISR); + if (status != B_OK) { + TRACE("AcpiEnableGpe failed.\n"); + goto error; + } + + return (0); + +error: + if (buf.pointer) + free(buf.pointer); + + sc->ec_acpi_module->remove_gpe_handler(sc->ec_gpehandle, sc->ec_gpebit, + &EcGpeHandler); + sc->ec_acpi->remove_address_space_handler(sc->ec_handle, ACPI_ADR_SPACE_EC, + EcSpaceHandler); + + return (ENXIO); +} + + +static void +embedded_controller_uninit_driver(void *driverCookie) +{ + acpi_ec_softc* sc = (struct acpi_ec_softc *)driverCookie; + free(sc); + put_module(B_ACPI_MODULE_NAME); + put_module(B_DPC_MODULE_NAME); +} + + +static status_t +embedded_controller_register_child_devices(void *_cookie) +{ + device_node *node = ((acpi_ec_softc*)_cookie)->ec_dev; + + int pathID = gDeviceManager->create_id(ACPI_EC_PATHID_GENERATOR); + if (pathID < 0) { + TRACE("register_child_device couldn't create a path_id\n"); + return B_ERROR; + } + + char name[128]; + snprintf(name, sizeof(name), ACPI_EC_BASENAME, pathID); + + return gDeviceManager->publish_device(node, name, ACPI_EC_DEVICE_NAME); +} + + +static status_t +embedded_controller_init_device(void *driverCookie, void **cookie) +{ + return B_ERROR; +} + + +static void +embedded_controller_uninit_device(void *_cookie) +{ + acpi_ec_softc *device = (acpi_ec_softc*)_cookie; + free(device); +} + + +module_dependency module_dependencies[] = { + { B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager }, + { B_PCI_MODULE_NAME, (module_info **)&gPCIManager}, + {} +}; + + +driver_module_info embedded_controller_driver_module = { + { + ACPI_EC_DRIVER_NAME, + 0, + NULL + }, + + embedded_controller_support, + embedded_controller_register_device, + embedded_controller_init_driver, + embedded_controller_uninit_driver, + embedded_controller_register_child_devices, + NULL, // rescan + NULL, // removed +}; + + +struct device_module_info embedded_controller_device_module = { + { + ACPI_EC_DEVICE_NAME, + 0, + NULL + }, + + embedded_controller_init_device, + embedded_controller_uninit_device, + NULL, + + embedded_controller_open, + embedded_controller_close, + embedded_controller_free, + embedded_controller_read, + embedded_controller_write, + NULL, + embedded_controller_control, + + NULL, + NULL +}; + + +module_info *modules[] = { + (module_info *)&embedded_controller_driver_module, + (module_info *)&embedded_controller_device_module, + NULL +}; + + +static void +EcGpeQueryHandler(void *context) +{ + struct acpi_ec_softc *sc = (struct acpi_ec_softc *)context; + uint8 data; + status_t status; + char qxx[5]; + + ASSERT(context != NULL);//, ("EcGpeQueryHandler called with NULL")); + + /* Serialize user access with EcSpaceHandler(). */ + status = EcLock(sc); + if (status != B_OK) { + TRACE("GpeQuery lock error.\n"); + return; + } + + /* + * Send a query command to the EC to find out which _Qxx call it + * wants to make. This command clears the SCI bit and also the + * interrupt source since we are edge-triggered. To prevent the GPE + * that may arise from running the query from causing another query + * to be queued, we clear the pending flag only after running it. + */ + status = EcCommand(sc, EC_COMMAND_QUERY); + sc->ec_sci_pend = FALSE; + if (status != B_OK) { + EcUnlock(sc); + TRACE("GPE query failed.\n"); + return; + } + data = EC_GET_DATA(sc); + + /* + * We have to unlock before running the _Qxx method below since that + * method may attempt to read/write from EC address space, causing + * recursive acquisition of the lock. + */ + EcUnlock(sc); + + /* Ignore the value for "no outstanding event". (13.3.5) */ + TRACE("ec query ok,%s running _Q%02X\n", Data ? "" : " not", data); + if (data == 0) + return; + + /* Evaluate _Qxx to respond to the controller. */ + snprintf(qxx, sizeof(qxx), "_Q%02X", data); + AcpiUtStrupr(qxx); + status = sc->ec_acpi->evaluate_method(sc->ec_handle, qxx, NULL, NULL); + if (status != B_OK) { + TRACE("evaluation of query method %s failed\n", qxx); + } +} + +/* + * The GPE handler is called when IBE/OBF or SCI events occur. We are + * called from an unknown lock context. + */ +static uint32 +EcGpeHandler(void *context) +{ + struct acpi_ec_softc *sc = (acpi_ec_softc*)context; + status_t status; + EC_STATUS EcStatus; + + ASSERT(context != NULL);//, ("EcGpeHandler called with NULL")); + TRACE("ec gpe handler start\n"); + + /* + * Notify EcWaitEvent() that the status register is now fresh. If we + * didn't do this, it wouldn't be possible to distinguish an old IBE + * from a new one, for example when doing a write transaction (writing + * address and then data values.) + */ + atomic_add(&sc->ec_gencount, 1); + sc->ec_condition_var.NotifyAll(); + /* + * If the EC_SCI bit of the status register is set, queue a query handler. + * It will run the query and _Qxx method later, under the lock. + */ + EcStatus = EC_GET_CSR(sc); + if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) { + TRACE("ec gpe queueing query handler\n"); + status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, context); + if (status == B_OK) + sc->ec_sci_pend = TRUE; + else + dprintf("EcGpeHandler: queuing GPE query handler failed\n"); + } + return (0); +} + + +static status_t +EcSpaceSetup(acpi_handle region, uint32 function, void *context, + void **regionContext) +{ + /* + * If deactivating a region, always set the output to NULL. Otherwise, + * just pass the context through. + */ + if (function == ACPI_REGION_DEACTIVATE) + *regionContext = NULL; + else + *regionContext = context; + + return B_OK; +} + + +static status_t +EcSpaceHandler(uint32 function, acpi_physical_address address, uint32 width, + int *value, void *context, void *regionContext) +{ + TRACE("enter EcSpaceHandler\n"); + struct acpi_ec_softc *sc = (struct acpi_ec_softc *)context; + status_t status; + uint8 ecAddr, ecData; + uint32 i; + + if (width % 8 != 0 || value == NULL || context == NULL) + return B_BAD_VALUE; + if (address + (width / 8) - 1 > 0xFF) + return B_BAD_ADDRESS; + + if (function == ACPI_READ) + *value = 0; + ecAddr = address; + status = B_ERROR; + + /* + * If booting, check if we need to run the query handler. If so, we + * we call it directly here since our thread taskq is not active yet. + */ + /*if (cold || rebooting || sc->ec_suspending) { + if ((EC_GET_CSR(sc) & EC_EVENT_SCI)) { + //CTR0(KTR_ACPI, "ec running gpe handler directly"); + EcGpeQueryHandler(sc); + } + }*/ + + /* Serialize with EcGpeQueryHandler() at transaction granularity. */ + status = EcLock(sc); + if (status != B_OK) + return (status); + + /* Perform the transaction(s), based on width. */ + for (i = 0; i < width; i += 8, ecAddr++) { + switch (function) { + case ACPI_READ: + status = EcRead(sc, ecAddr, &ecData); + if (status == B_OK) + *value |= ((int)ecData) << i; + break; + case ACPI_WRITE: + ecData = (uint8)((*value) >> i); + status = EcWrite(sc, ecAddr, &ecData); + break; + default: + TRACE("invalid EcSpaceHandler function\n"); + status = B_BAD_VALUE; + break; + } + if (status != B_OK) + break; + } + + EcUnlock(sc); + return (status); +} + +static status_t +EcCheckStatus(struct acpi_ec_softc *sc, const char *msg, EC_EVENT event) +{ + status_t status = B_ERROR; + EC_STATUS ec_status; + + ec_status = EC_GET_CSR(sc); + if (sc->ec_burstactive && !(ec_status & EC_FLAG_BURST_MODE)) { + TRACE("ec burst disabled in waitevent (%s)\n", msg); + sc->ec_burstactive = false; + } + if (EVENT_READY(event, ec_status)) { + TRACE("ec %s wait ready, status %#x\n", msg, ec_status); + status = B_OK; + } + return (status); +} + +static status_t +EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT event, int32 gen_count) +{ + status_t status = B_ERROR; + int32 count, i; + + // int need_poll = cold || rebooting || ec_polled_mode || sc->ec_suspending; + int need_poll = ec_polled_mode || sc->ec_suspending; + + /* + * The main CPU should be much faster than the EC. So the status should + * be "not ready" when we start waiting. But if the main CPU is really + * slow, it's possible we see the current "ready" response. Since that + * can't be distinguished from the previous response in polled mode, + * this is a potential issue. We really should have interrupts enabled + * during boot so there is no ambiguity in polled mode. + * + * If this occurs, we add an additional delay before actually entering + * the status checking loop, hopefully to allow the EC to go to work + * and produce a non-stale status. + */ + if (need_poll) { + static int once; + + if (EcCheckStatus(sc, "pre-check", event) == B_OK) { + if (!once) { + TRACE("warning: EC done before starting event wait\n"); + once = 1; + } + spin(10); + } + } + + /* Wait for event by polling or GPE (interrupt). */ + if (need_poll) { + count = (ec_timeout * 1000) / EC_POLL_DELAY; + if (count == 0) + count = 1; + for (i = 0; i < count; i++) { + status = EcCheckStatus(sc, "poll", event); + if (status == B_OK) + break; + spin(EC_POLL_DELAY); + } + } else { + // ToDo: scale timeout for slow cpu see BSD code... + count = ec_timeout; + + /* + * Wait for the GPE to signal the status changed, checking the + * status register each time we get one. It's possible to get a + * GPE for an event we're not interested in here (i.e., SCI for + * EC query). + */ + for (i = 0; i < count; i++) { + if (gen_count != sc->ec_gencount) { + /* + * Record new generation count. It's possible the GPE was + * just to notify us that a query is needed and we need to + * wait for a second GPE to signal the completion of the + * event we are actually waiting for. + */ + gen_count = sc->ec_gencount; + status = EcCheckStatus(sc, "sleep", event); + if (status == B_OK) + break; + } + sc->ec_condition_var.Wait(); [... truncated: 480 lines follow ...] From bonefish at mail.berlios.de Thu Jun 18 21:05:08 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 18 Jun 2009 21:05:08 +0200 Subject: [Haiku-commits] r31103 - haiku/trunk/src/apps/debugger Message-ID: <200906181905.n5IJ589Q025030@sheep.berlios.de> Author: bonefish Date: 2009-06-18 21:05:05 +0200 (Thu, 18 Jun 2009) New Revision: 31103 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31103&view=rev Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp Log: Accidentally checked in. Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 18:30:06 UTC (rev 31102) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 19:05:05 UTC (rev 31103) @@ -129,8 +129,7 @@ snprintf(buffer, sizeof(buffer), "team %ld debug listener", fTeamID); fDebugEventListener = spawn_thread(_DebugEventListenerEntry, buffer, B_NORMAL_PRIORITY, this); -// if (fDebugEventListener < 0) - if (fDebugEventListener < NULL) + if (fDebugEventListener < 0) return fDebugEventListener; resume_thread(fDebugEventListener); From bonefish at mail.berlios.de Thu Jun 18 21:57:47 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 18 Jun 2009 21:57:47 +0200 Subject: [Haiku-commits] r31104 - in haiku/trunk/src/apps/debugger: . arch arch/x86 debugger_interface Message-ID: <200906181957.n5IJvlGY030884@sheep.berlios.de> Author: bonefish Date: 2009-06-18 21:57:46 +0200 (Thu, 18 Jun 2009) New Revision: 31104 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31104&view=rev Added: haiku/trunk/src/apps/debugger/arch/ haiku/trunk/src/apps/debugger/arch/Architecture.cpp haiku/trunk/src/apps/debugger/arch/Architecture.h haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h haiku/trunk/src/apps/debugger/arch/CpuState.cpp haiku/trunk/src/apps/debugger/arch/CpuState.h haiku/trunk/src/apps/debugger/arch/StackFrame.cpp haiku/trunk/src/apps/debugger/arch/StackFrame.h haiku/trunk/src/apps/debugger/arch/StackTrace.cpp haiku/trunk/src/apps/debugger/arch/StackTrace.h haiku/trunk/src/apps/debugger/arch/x86/ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h Removed: haiku/trunk/src/apps/debugger/CpuState.cpp haiku/trunk/src/apps/debugger/CpuState.h Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/Thread.cpp haiku/trunk/src/apps/debugger/Thread.h haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h Log: Beginnings of the architecture abstraction. Deleted: haiku/trunk/src/apps/debugger/CpuState.cpp Deleted: haiku/trunk/src/apps/debugger/CpuState.h Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 19:57:46 UTC (rev 31104) @@ -6,6 +6,8 @@ UsePrivateHeaders debug interface kernel shared ; UsePrivateSystemHeaders ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) arch ] ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) arch x86 ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) debugger_interface ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ; @@ -17,7 +19,6 @@ SubDirHdrs [ FDirName $(debugAnalyzerSources) util ] ; Application Debugger : - CpuState.cpp Debugger.cpp # ElfFile.cpp Image.cpp @@ -28,17 +29,27 @@ Thread.cpp ThreadInfo.cpp - # DebugAnalyzer:util - Variant.cpp + # arch + Architecture.cpp + CpuState.cpp + StackFrame.cpp + StackTrace.cpp + # arch/x86 + ArchitectureX86.cpp + CpuStateX86.cpp + + # debugger_interface + DebugEvent.cpp + DebuggerInterface.cpp + # gui/team_window ImageListView.cpp TeamWindow.cpp ThreadListView.cpp - # debugger_interface - DebugEvent.cpp - DebuggerInterface.cpp + # DebugAnalyzer:util + Variant.cpp # DWARF # attribute_classes.cpp Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -337,4 +337,5 @@ newState = THREAD_STATE_RUNNING; thread->SetState(newState); + thread->SetCpuState(state); } Modified: haiku/trunk/src/apps/debugger/Thread.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -5,18 +5,27 @@ #include "Thread.h" +#include "CpuState.h" +#include "StackTrace.h" + Thread::Thread(Team* team, thread_id threadID) : fTeam(team), fID(threadID), - fState(THREAD_STATE_UNKNOWN) + fState(THREAD_STATE_UNKNOWN), + fCpuState(NULL), + fStackTrace(NULL) { } Thread::~Thread() { + if (fCpuState != NULL) + fCpuState->RemoveReference(); + if (fStackTrace != NULL) + fStackTrace->RemoveReference(); } @@ -37,5 +46,45 @@ void Thread::SetState(uint32 state) { + if (state == fState) + return; + fState = state; + + // unset CPU state and stack trace, if the thread isn't stopped + if (fState != THREAD_STATE_STOPPED) { + SetCpuState(NULL); + SetStackTrace(NULL); + } } + + +void +Thread::SetCpuState(CpuState* state) +{ + if (state == fCpuState) + return; + + if (fCpuState != NULL) + fCpuState->RemoveReference(); + + fCpuState = state; + + if (fCpuState != NULL) + fCpuState->AddReference(); +} + +void +Thread::SetStackTrace(StackTrace* trace) +{ + if (trace == fStackTrace) + return; + + if (fStackTrace != NULL) + fStackTrace->RemoveReference(); + + fStackTrace = trace; + + if (fStackTrace != NULL) + fStackTrace->AddReference(); +} Modified: haiku/trunk/src/apps/debugger/Thread.h =================================================================== --- haiku/trunk/src/apps/debugger/Thread.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/Thread.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -12,6 +12,8 @@ #include +class CpuState; +class StackTrace; class Team; @@ -38,11 +40,19 @@ uint32 State() const { return fState; } void SetState(uint32 state); + CpuState* GetCpuState() const { return fCpuState; } + void SetCpuState(CpuState* state); + + StackTrace* GetStackTrace() const { return fStackTrace; } + void SetStackTrace(StackTrace* trace); + private: Team* fTeam; thread_id fID; BString fName; uint32 fState; + CpuState* fCpuState; + StackTrace* fStackTrace; }; Added: haiku/trunk/src/apps/debugger/arch/Architecture.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,18 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Architecture.h" + + +Architecture::Architecture(DebuggerInterface* debuggerInterface) + : + fDebuggerInterface(debuggerInterface) +{ +} + + +Architecture::~Architecture() +{ +} Added: haiku/trunk/src/apps/debugger/arch/Architecture.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,31 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef ARCHITECTURE_H +#define ARCHITECTURE_H + +#include + +#include + + +class CpuState; +class DebuggerInterface; + + +class Architecture : public Referenceable { +public: + Architecture( + DebuggerInterface* debuggerInterface); + virtual ~Architecture(); + + virtual status_t CreateCpuState(const void* cpuStateData, + size_t size, CpuState*& _state) = 0; + +protected: + DebuggerInterface* fDebuggerInterface; +}; + + +#endif // ARCHITECTURE_H Added: haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,13 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef ARCHITECTURE_TYPES_H +#define ARCHITECTURE_TYPES_H + + +typedef uint64 target_addr_t; + + + +#endif // ARCHITECTURE_TYPES_H Copied: haiku/trunk/src/apps/debugger/arch/CpuState.cpp (from rev 31100, haiku/trunk/src/apps/debugger/CpuState.cpp) Copied: haiku/trunk/src/apps/debugger/arch/CpuState.h (from rev 31100, haiku/trunk/src/apps/debugger/CpuState.h) Added: haiku/trunk/src/apps/debugger/arch/StackFrame.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackFrame.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/StackFrame.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,11 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "StackFrame.h" + + +StackFrame::~StackFrame() +{ +} Added: haiku/trunk/src/apps/debugger/arch/StackFrame.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackFrame.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/StackFrame.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,35 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef STACK_FRAME_H +#define STACK_FRAME_H + +#include + +#include +#include + +#include "ArchitectureTypes.h" + + +class CpuState; + + +class StackFrame : public Referenceable, + public DoublyLinkedListLinkImpl { +public: + virtual ~StackFrame(); + + virtual CpuState* GetCpuState() const = 0; + + virtual target_addr_t FrameAddress() const = 0; + virtual target_addr_t ReturnAddress() const = 0; + virtual target_addr_t PreviousFrameAddress() const = 0; +}; + + +typedef DoublyLinkedList StackFrameList; + + +#endif // STACK_FRAME_H Added: haiku/trunk/src/apps/debugger/arch/StackTrace.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackTrace.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/StackTrace.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,25 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "StackTrace.h" + + +StackTrace::StackTrace() +{ +} + + +StackTrace::~StackTrace() +{ + while (StackFrame* frame = fStackFrames.RemoveHead()) + frame->RemoveReference(); +} + + +void +StackTrace::AddFrame(StackFrame* frame) +{ + fStackFrames.Add(frame); +} Added: haiku/trunk/src/apps/debugger/arch/StackTrace.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackTrace.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/StackTrace.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,31 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef STACK_TRACE_H +#define STACK_TRACE_H + +#include "StackFrame.h" + + +class StackTrace : public Referenceable { +public: + StackTrace(); + virtual ~StackTrace(); + + void AddFrame(StackFrame* frame); + // takes over reference + + const StackFrameList& Frames() const { return fStackFrames; } + + StackFrame* TopFrame() const + { return fStackFrames.Head(); } + StackFrame* BottomFrame() const + { return fStackFrames.Tail(); } + +private: + StackFrameList fStackFrames; +}; + + +#endif // STACK_TRACE_H Added: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,39 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "ArchitectureX86.h" + +#include + +#include "CpuStateX86.h" + + +ArchitectureX86::ArchitectureX86(DebuggerInterface* debuggerInterface) + : + Architecture(debuggerInterface) +{ +} + + +ArchitectureX86::~ArchitectureX86() +{ +} + + +status_t +ArchitectureX86::CreateCpuState(const void* cpuStateData, size_t size, + CpuState*& _state) +{ + if (size != sizeof(debug_cpu_state_x86)) + return B_BAD_VALUE; + + CpuStateX86* state = new(std::nothrow) CpuStateX86( + *(const debug_cpu_state_x86*)cpuStateData); + if (state == NULL) + return B_NO_MEMORY; + + _state = state; + return B_OK; +} Added: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,22 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef ARCHITECTURE_X86_H +#define ARCHITECTURE_X86_H + +#include "Architecture.h" + + +class ArchitectureX86 : public Architecture { +public: + ArchitectureX86( + DebuggerInterface* debuggerInterface); + virtual ~ArchitectureX86(); + + virtual status_t CreateCpuState(const void* cpuStateData, + size_t size, CpuState*& _state); +}; + + +#endif // ARCHITECTURE_X86_H Added: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,18 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "CpuStateX86.h" + + +CpuStateX86::CpuStateX86(const debug_cpu_state_x86& state) + : + fState(state) +{ +} + + +CpuStateX86::~CpuStateX86() +{ +} Added: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -0,0 +1,29 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef CPU_STATE_X86_H +#define CPU_STATE_X86_H + +#include + +#include "CpuState.h" + + +typedef debug_cpu_state debug_cpu_state_x86; + // TODO: Should be defined by ! + + +class CpuStateX86 : public CpuState { +public: + CpuStateX86(const debug_cpu_state_x86& state); + virtual ~CpuStateX86(); + + const debug_cpu_state_x86 State() const { return fState; } + +private: + debug_cpu_state_x86 fState; +}; + + +#endif // CPU_STATE_X86_H Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -7,12 +7,10 @@ #include +#include "ArchitectureTypes.h" #include "ImageInfo.h" -typedef uint64 target_addr_t; - // TODO: Define elsewhere! - class CpuState; Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 19:57:46 UTC (rev 31104) @@ -11,6 +11,7 @@ #include "debug_utils.h" +#include "ArchitectureX86.h" #include "CpuState.h" #include "DebugEvent.h" #include "ImageInfo.h" @@ -21,7 +22,8 @@ : fTeamID(teamID), fDebuggerPort(-1), - fNubPort(-1) + fNubPort(-1), + fArchitecture(NULL) { fDebugContext.reply_port = -1; } @@ -29,6 +31,8 @@ DebuggerInterface::~DebuggerInterface() { + fArchitecture->RemoveReference(); + destroy_debug_context(&fDebugContext); Close(); @@ -38,6 +42,16 @@ status_t DebuggerInterface::Init() { + // create the architecture +#ifdef ARCH_x86 + fArchitecture = new(std::nothrow) ArchitectureX86(this); +#else + return B_UNSUPPORTED; +#endif + + if (fArchitecture == NULL) + return B_NO_MEMORY; + // create debugger port char buffer[128]; snprintf(buffer, sizeof(buffer), "team %ld debugger", fTeamID); @@ -211,20 +225,47 @@ (target_addr_t)message.debugger_call.message); break; case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: + { + CpuState* state = NULL; + status_t error = fArchitecture->CreateCpuState( + &message.breakpoint_hit.cpu_state, + sizeof(debug_cpu_state), state); + if (error != B_OK) + return error; + event = new(std::nothrow) BreakpointHitEvent(message.origin.team, - message.origin.thread, NULL); - // TODO: CpuState! + message.origin.thread, state); + state->RemoveReference(); break; + } case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: + { + CpuState* state = NULL; + status_t error = fArchitecture->CreateCpuState( + &message.watchpoint_hit.cpu_state, + sizeof(debug_cpu_state), state); + if (error != B_OK) + return error; + event = new(std::nothrow) WatchpointHitEvent(message.origin.team, - message.origin.thread, NULL); - // TODO: CpuState! + message.origin.thread, state); + state->RemoveReference(); break; + } case B_DEBUGGER_MESSAGE_SINGLE_STEP: + { + CpuState* state = NULL; + status_t error = fArchitecture->CreateCpuState( + &message.single_step.cpu_state, + sizeof(debug_cpu_state), state); + if (error != B_OK) + return error; + event = new(std::nothrow) SingleStepEvent(message.origin.team, - message.origin.thread, NULL); - // TODO: CpuState! + message.origin.thread, state); + state->RemoveReference(); break; + } case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: event = new(std::nothrow) ExceptionOccurredEvent( message.origin.team, message.origin.thread, Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-18 19:05:05 UTC (rev 31103) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-18 19:57:46 UTC (rev 31104) @@ -11,6 +11,7 @@ #include +class Architecture; class CpuState; class DebugEvent; class ImageInfo; @@ -25,6 +26,9 @@ status_t Init(); void Close(); + Architecture* GetArchitecture() const + { return fArchitecture; } + virtual status_t GetNextDebugEvent(DebugEvent*& _event); virtual status_t SetTeamDebuggingFlags(uint32 flags); @@ -50,6 +54,8 @@ port_id fDebuggerPort; port_id fNubPort; debug_context fDebugContext; + // TODO: Use a debug context pool! + Architecture* fArchitecture; }; #endif // DEBUGGER_INTERFACE_H From czeidler at mail.berlios.de Thu Jun 18 22:02:49 2009 From: czeidler at mail.berlios.de (czeidler at mail.berlios.de) Date: Thu, 18 Jun 2009 22:02:49 +0200 Subject: [Haiku-commits] r31105 - haiku/trunk/build/jam Message-ID: <200906182002.n5IK2n24031849@sheep.berlios.de> Author: czeidler Date: 2009-06-18 22:02:45 +0200 (Thu, 18 Jun 2009) New Revision: 31105 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31105&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add embbedded controller driver to the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-18 19:57:46 UTC (rev 31104) +++ haiku/trunk/build/jam/HaikuImage 2009-06-18 20:02:45 UTC (rev 31105) @@ -204,6 +204,7 @@ # drivers AddNewDriversToHaikuImage disk scsi : scsi_cd scsi_disk ; AddNewDriversToHaikuImage power : $(X86_ONLY)enhanced_speedstep ; +AddNewDriversToHaikuImage power : $(X86_ONLY)acpi_embedded_controller ; # legacy drivers AddDriversToHaikuImage : console dprintf $(X86_ONLY)keyboard null From joe.prostko+haiku at gmail.com Thu Jun 18 22:48:41 2009 From: joe.prostko+haiku at gmail.com (Joseph Prostko) Date: Thu, 18 Jun 2009 16:48:41 -0400 Subject: [Haiku-commits] r31099 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <200906181719.n5IHJcOs016149@sheep.berlios.de> References: <200906181719.n5IHJcOs016149@sheep.berlios.de> Message-ID: <7e5795b0906181348s7276d7dcoaf796827b09a9f75@mail.gmail.com> On Thu, Jun 18, 2009 at 1:19 PM, wrote: > Author: axeld > Date: 2009-06-18 19:19:32 +0200 (Thu, 18 Jun 2009) > New Revision: 31099 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31099&view=rev > > Modified: > ? haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp > ? haiku/trunk/src/apps/aboutsystem/HyperTextView.cpp > ? haiku/trunk/src/apps/aboutsystem/HyperTextView.h > Log: > * Changed the whole thing to use the layout engine, which makes it work okay > ?with larger font sizes. > > > Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp > This revision breaks the GCC4 build (at least for me). Here's the output: C++ /home/joe/haiku/trunk/generated-gcc-4.4.1/objects/haiku/x86/release/apps/aboutsystem/AboutSystem.o /home/joe/haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp: In constructor 'AboutView::AboutView()': /home/joe/haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp:368: error: 'r' was not declared in this scope /home/joe/haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp:368: error: 'textHeight' was not declared in this scope - joe From axeld at mail.berlios.de Thu Jun 18 22:58:42 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 18 Jun 2009 22:58:42 +0200 Subject: [Haiku-commits] r31106 - haiku/trunk/src/apps/aboutsystem Message-ID: <200906182058.n5IKwgEx006851@sheep.berlios.de> Author: axeld Date: 2009-06-18 22:58:42 +0200 (Thu, 18 Jun 2009) New Revision: 31106 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31106&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: * Removed accidental leftover in a GCC4 only codepath. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2009-06-18 20:02:45 UTC (rev 31105) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2009-06-18 20:58:42 UTC (rev 31106) @@ -365,9 +365,6 @@ // GCC version #if __GNUC__ != 2 - r.OffsetBy(0, textHeight); - r.bottom = r.top + textHeight; - snprintf(string, sizeof(string), "GCC %d", __GNUC__); BStringView* gccView = new BStringView("gcctext", string); From axeld at pinc-software.de Thu Jun 18 22:58:33 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 18 Jun 2009 22:58:33 +0200 CEST Subject: [Haiku-commits] r31099 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <7e5795b0906181348s7276d7dcoaf796827b09a9f75@mail.gmail.com> Message-ID: <50471006563-BeMail@zon> Joseph Prostko wrote: > This revision breaks the GCC4 build (at least for me). Here's the > output: Thanks for the note, should be fixed now. Bye, Axel. From bonefish at mail.berlios.de Thu Jun 18 23:45:15 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 18 Jun 2009 23:45:15 +0200 Subject: [Haiku-commits] r31107 - in haiku/trunk/src/apps/debugger: . debugger_interface gui/team_window Message-ID: <200906182145.n5ILjFPY011518@sheep.berlios.de> Author: bonefish Date: 2009-06-18 23:45:14 +0200 (Thu, 18 Jun 2009) New Revision: 31107 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31107&view=rev Modified: haiku/trunk/src/apps/debugger/MessageCodes.h haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h haiku/trunk/src/apps/debugger/Thread.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h Log: * Added notifications for thread state/CPU state/stack trace changes. The team window listens for those and updates the buttons correctly. * Added basic handling for the thread stopping debug events in the team debugger. * Forward the thread run/stop/step requests to the team debugger and actually run/stop/step the thread. Running/stopping works, all three stepping actions just step by a single instruction ATM, though. Modified: haiku/trunk/src/apps/debugger/MessageCodes.h =================================================================== --- haiku/trunk/src/apps/debugger/MessageCodes.h 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/MessageCodes.h 2009-06-18 21:45:14 UTC (rev 31107) @@ -7,10 +7,15 @@ enum { - MSG_THREAD_RUN = 'run_', - MSG_THREAD_STEP_OVER = 'stov', - MSG_THREAD_STEP_INTO = 'stin', - MSG_THREAD_STEP_OUT = 'stou' + MSG_THREAD_RUN = 'run_', + MSG_THREAD_STOP = 'stop', + MSG_THREAD_STEP_OVER = 'stov', + MSG_THREAD_STEP_INTO = 'stin', + MSG_THREAD_STEP_OUT = 'stou', + + MSG_THREAD_STATE_CHANGED = 'tsch', + MSG_THREAD_CPU_STATE_CHANGED = 'tcsc', + MSG_THREAD_STACK_TRACE_CHANGED = 'tstc' }; Modified: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-18 21:45:14 UTC (rev 31107) @@ -205,6 +205,39 @@ void +Team::NotifyThreadStateChanged(Thread* thread) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ThreadStateChanged( + ThreadEvent(TEAM_EVENT_THREAD_STATE_CHANGED, thread)); + } +} + + +void +Team::NotifyThreadCpuStateChanged(Thread* thread) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ThreadCpuStateChanged( + ThreadEvent(TEAM_EVENT_THREAD_CPU_STATE_CHANGED, thread)); + } +} + + +void +Team::NotifyThreadStackTraceChanged(Thread* thread) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + Listener* listener = it.Next();) { + listener->ThreadStackTraceChanged( + ThreadEvent(TEAM_EVENT_THREAD_STACK_TRACE_CHANGED, thread)); + } +} + + +void Team::_NotifyThreadAdded(Thread* thread) { for (ListenerList::Iterator it = fListeners.GetIterator(); @@ -307,3 +340,21 @@ Team::Listener::ImageRemoved(const Team::ImageEvent& event) { } + + +void +Team::Listener::ThreadStateChanged(const Team::ThreadEvent& event) +{ +} + + +void +Team::Listener::ThreadCpuStateChanged(const Team::ThreadEvent& event) +{ +} + + +void +Team::Listener::ThreadStackTraceChanged(const Team::ThreadEvent& event) +{ +} Modified: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-18 21:45:14 UTC (rev 31107) @@ -18,7 +18,11 @@ TEAM_EVENT_THREAD_ADDED, TEAM_EVENT_THREAD_REMOVED, TEAM_EVENT_IMAGE_ADDED, - TEAM_EVENT_IMAGE_REMOVED + TEAM_EVENT_IMAGE_REMOVED, + + TEAM_EVENT_THREAD_STATE_CHANGED, + TEAM_EVENT_THREAD_CPU_STATE_CHANGED, + TEAM_EVENT_THREAD_STACK_TRACE_CHANGED }; @@ -59,6 +63,11 @@ void AddListener(Listener* listener); void RemoveListener(Listener* listener); + // service methods for Thread + void NotifyThreadStateChanged(Thread* thread); + void NotifyThreadCpuStateChanged(Thread* thread); + void NotifyThreadStackTraceChanged(Thread* thread); + private: typedef DoublyLinkedList ListenerList; @@ -121,6 +130,13 @@ virtual void ImageAdded(const Team::ImageEvent& event); virtual void ImageRemoved(const Team::ImageEvent& event); + + virtual void ThreadStateChanged( + const Team::ThreadEvent& event); + virtual void ThreadCpuStateChanged( + const Team::ThreadEvent& event); + virtual void ThreadStackTraceChanged( + const Team::ThreadEvent& event); }; Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-18 21:45:14 UTC (rev 31107) @@ -17,6 +17,7 @@ #include "CpuState.h" #include "DebuggerInterface.h" +#include "MessageCodes.h" #include "Team.h" #include "TeamDebugModel.h" @@ -168,6 +169,19 @@ TeamDebugger::MessageReceived(BMessage* message) { switch (message->what) { + case MSG_THREAD_RUN: + case MSG_THREAD_STOP: + case MSG_THREAD_STEP_OVER: + case MSG_THREAD_STEP_INTO: + case MSG_THREAD_STEP_OUT: + { + int32 threadID; + if (message->FindInt32("thread", &threadID) != B_OK) + break; + + _HandleThreadAction(threadID, message->what); + break; + } default: BLooper::MessageReceived(message); break; @@ -175,6 +189,24 @@ } +void +TeamDebugger::ThreadActionRequested(TeamWindow* window, thread_id threadID, + uint32 action) +{ + BMessage message(action); + message.AddInt32("thread", threadID); + PostMessage(&message); +} + + +bool +TeamDebugger::TeamWindowQuitRequested(TeamWindow* window) +{ + // TODO:... + return true; +} + + /*static*/ status_t TeamDebugger::_DebugEventListenerEntry(void* data) { @@ -222,30 +254,43 @@ switch (event->EventType()) { case B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: printf("B_DEBUGGER_MESSAGE_THREAD_DEBUGGED: thread: %ld\n", event->Thread()); + handled = _HandleThreadDebugged( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_DEBUGGER_CALL: printf("B_DEBUGGER_MESSAGE_DEBUGGER_CALL: thread: %ld\n", event->Thread()); + handled = _HandleDebuggerCall( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: printf("B_DEBUGGER_MESSAGE_BREAKPOINT_HIT: thread: %ld\n", event->Thread()); + handled = _HandleBreakpointHit( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: printf("B_DEBUGGER_MESSAGE_WATCHPOINT_HIT: thread: %ld\n", event->Thread()); + handled = _HandleWatchpointHit( + dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_SINGLE_STEP: printf("B_DEBUGGER_MESSAGE_SINGLE_STEP: thread: %ld\n", event->Thread()); + handled = _HandleSingleStep(dynamic_cast(event)); break; case B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: printf("B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED: thread: %ld\n", event->Thread()); + handled = _HandleExceptionOccurred( + dynamic_cast(event)); break; // case B_DEBUGGER_MESSAGE_TEAM_CREATED: //printf("B_DEBUGGER_MESSAGE_TEAM_CREATED: team: %ld\n", message.team_created.new_team); // break; case B_DEBUGGER_MESSAGE_TEAM_DELETED: + // TODO: Handle! printf("B_DEBUGGER_MESSAGE_TEAM_DELETED: team: %ld\n", event->Team()); break; case B_DEBUGGER_MESSAGE_TEAM_EXEC: printf("B_DEBUGGER_MESSAGE_TEAM_EXEC: team: %ld\n", event->Team()); + // TODO: Handle! break; case B_DEBUGGER_MESSAGE_THREAD_CREATED: handled = _HandleThreadCreated( @@ -282,6 +327,70 @@ bool +TeamDebugger::_HandleThreadStopped(thread_id threadID, CpuState* cpuState) +{ + // get the thread + AutoLocker< ::Team> locker(fTeam); + ::Thread* thread = fTeam->ThreadByID(threadID); + if (thread == NULL) + return false; + + // update the thread state + thread->SetState(THREAD_STATE_STOPPED); + + if (cpuState != NULL) { + thread->SetCpuState(cpuState); + } else { + // TODO: Trigger updating the CPU state! + } + + return true; +} + + +bool +TeamDebugger::_HandleThreadDebugged(ThreadDebuggedEvent* event) +{ + return _HandleThreadStopped(event->Thread(), NULL); +} + + +bool +TeamDebugger::_HandleDebuggerCall(DebuggerCallEvent* event) +{ + return _HandleThreadStopped(event->Thread(), NULL); +} + + +bool +TeamDebugger::_HandleBreakpointHit(BreakpointHitEvent* event) +{ + return _HandleThreadStopped(event->Thread(), event->GetCpuState()); +} + + +bool +TeamDebugger::_HandleWatchpointHit(WatchpointHitEvent* event) +{ + return _HandleThreadStopped(event->Thread(), event->GetCpuState()); +} + + +bool +TeamDebugger::_HandleSingleStep(SingleStepEvent* event) +{ + return _HandleThreadStopped(event->Thread(), event->GetCpuState()); +} + + +bool +TeamDebugger::_HandleExceptionOccurred(ExceptionOccurredEvent* event) +{ + return _HandleThreadStopped(event->Thread(), NULL); +} + + +bool TeamDebugger::_HandleThreadCreated(ThreadCreatedEvent* event) { AutoLocker< ::Team> locker(fTeam); @@ -339,3 +448,53 @@ thread->SetState(newState); thread->SetCpuState(state); } + + +void +TeamDebugger::_HandleThreadAction(thread_id threadID, uint32 action) +{ + AutoLocker< ::Team> locker(fTeam); + + ::Thread* thread = fTeam->ThreadByID(threadID); + if (thread == NULL || thread->State() == THREAD_STATE_UNKNOWN) + return; + + // When stop is requested, thread must be running, otherwise stopped. + if (action == MSG_THREAD_STOP + ? thread->State() != THREAD_STATE_RUNNING + : thread->State() != THREAD_STATE_STOPPED) { + return; + } + + // When continuing the thread update thread state before actually issuing + // the command, since we need to unlock. + if (action != MSG_THREAD_STOP) + thread->SetState(THREAD_STATE_RUNNING); + + locker.Unlock(); + + switch (action) { + case MSG_THREAD_RUN: +printf("MSG_THREAD_RUN\n"); + fDebuggerInterface->ContinueThread(threadID); + break; + case MSG_THREAD_STOP: +printf("MSG_THREAD_STOP\n"); + fDebuggerInterface->StopThread(threadID); + break; + case MSG_THREAD_STEP_OVER: +printf("MSG_THREAD_STEP_OVER\n"); + fDebuggerInterface->SingleStepThread(threadID); + break; + case MSG_THREAD_STEP_INTO: +printf("MSG_THREAD_STEP_INTO\n"); + fDebuggerInterface->SingleStepThread(threadID); + break; + case MSG_THREAD_STEP_OUT: +printf("MSG_THREAD_STEP_OUT\n"); + fDebuggerInterface->SingleStepThread(threadID); + break; + +// TODO: Handle stepping correctly! + } +} Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-18 21:45:14 UTC (rev 31107) @@ -34,12 +34,32 @@ private: virtual void MessageReceived(BMessage* message); + // TeamWindow::Listener + virtual void ThreadActionRequested(TeamWindow* window, + thread_id threadID, uint32 action); + virtual bool TeamWindowQuitRequested(TeamWindow* window); + private: static status_t _DebugEventListenerEntry(void* data); status_t _DebugEventListener(); void _HandleDebuggerMessage(DebugEvent* event); + bool _HandleThreadStopped(thread_id threadID, + CpuState* cpuState); + + bool _HandleThreadDebugged( + ThreadDebuggedEvent* event); + bool _HandleDebuggerCall( + DebuggerCallEvent* event); + bool _HandleBreakpointHit( + BreakpointHitEvent* event); + bool _HandleWatchpointHit( + WatchpointHitEvent* event); + bool _HandleSingleStep( + SingleStepEvent* event); + bool _HandleExceptionOccurred( + ExceptionOccurredEvent* event); bool _HandleThreadCreated( ThreadCreatedEvent* event); bool _HandleThreadDeleted( @@ -51,6 +71,9 @@ void _UpdateThreadState(::Thread* thread); + void _HandleThreadAction(thread_id threadID, + uint32 action); + private: ::Team* fTeam; TeamDebugModel* fDebugModel; Modified: haiku/trunk/src/apps/debugger/Thread.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/Thread.cpp 2009-06-18 21:45:14 UTC (rev 31107) @@ -7,6 +7,7 @@ #include "CpuState.h" #include "StackTrace.h" +#include "Team.h" Thread::Thread(Team* team, thread_id threadID) @@ -56,6 +57,8 @@ SetCpuState(NULL); SetStackTrace(NULL); } + + fTeam->NotifyThreadStateChanged(this); } @@ -72,8 +75,11 @@ if (fCpuState != NULL) fCpuState->AddReference(); + + fTeam->NotifyThreadCpuStateChanged(this); } + void Thread::SetStackTrace(StackTrace* trace) { @@ -87,4 +93,6 @@ if (fStackTrace != NULL) fStackTrace->AddReference(); + + fTeam->NotifyThreadStackTraceChanged(this); } Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 21:45:14 UTC (rev 31107) @@ -132,6 +132,26 @@ status_t +DebuggerInterface::StopThread(thread_id thread) +{ + return debug_thread(thread); +} + + +status_t +DebuggerInterface::SingleStepThread(thread_id thread) +{ + debug_nub_continue_thread continueMessage; + continueMessage.thread = thread; + continueMessage.handle_event = B_THREAD_DEBUG_HANDLE_EVENT; + continueMessage.single_step = true; + + return write_port(fNubPort, B_DEBUG_MESSAGE_CONTINUE_THREAD, + &continueMessage, sizeof(continueMessage)); +} + + +status_t DebuggerInterface::GetThreadInfos(BObjectList& infos) { thread_info threadInfo; Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-18 21:45:14 UTC (rev 31107) @@ -34,6 +34,8 @@ virtual status_t SetTeamDebuggingFlags(uint32 flags); virtual status_t ContinueThread(thread_id thread); + virtual status_t StopThread(thread_id thread); + virtual status_t SingleStepThread(thread_id thread); virtual status_t GetThreadInfos(BObjectList& infos); virtual status_t GetImageInfos(BObjectList& infos); Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-18 21:45:14 UTC (rev 31107) @@ -14,6 +14,8 @@ #include #include +#include + #include "ImageListView.h" #include "MessageCodes.h" #include "TeamDebugModel.h" @@ -42,11 +44,14 @@ if (team->ID() >= 0) name << " (" << team->ID() << ")"; SetTitle(name.String()); + + team->AddListener(this); } TeamWindow::~TeamWindow() { + fDebugModel->GetTeam()->RemoveListener(this); } @@ -71,17 +76,28 @@ { switch (message->what) { case MSG_THREAD_RUN: -printf("MSG_THREAD_RUN\n"); - break; + case MSG_THREAD_STOP: case MSG_THREAD_STEP_OVER: -printf("MSG_THREAD_STEP_OVER\n"); - break; case MSG_THREAD_STEP_INTO: -printf("MSG_THREAD_STEP_INTO\n"); - break; case MSG_THREAD_STEP_OUT: -printf("MSG_THREAD_STEP_OUT\n"); + if (fActiveThread != NULL) { + fListener->ThreadActionRequested(this, fActiveThread->ID(), + message->what); + } break; + + case MSG_THREAD_STATE_CHANGED: + { + int32 threadID; + if (message->FindInt32("thread", &threadID) != B_OK) + break; + + _HandleThreadStateChanged(threadID); + break; + } +// case MSG_THREAD_CPU_STATE_CHANGED: +// case MSG_THREAD_STACK_TRACE_CHANGED: + default: BWindow::MessageReceived(message); break; @@ -104,6 +120,33 @@ void +TeamWindow::ThreadStateChanged(const Team::ThreadEvent& event) +{ + BMessage message(MSG_THREAD_STATE_CHANGED); + message.AddInt32("thread", event.GetThread()->ID()); + PostMessage(&message); +} + + +void +TeamWindow::ThreadCpuStateChanged(const Team::ThreadEvent& event) +{ +// BMessage message(MSG_THREAD_CPU_STATE_CHANGED); +// message.AddInt32("thread", event.GetThread()->ID()); +// PostMessage(&message); +} + + +void +TeamWindow::ThreadStackTraceChanged(const Team::ThreadEvent& event) +{ +// BMessage message(MSG_THREAD_STACK_TRACE_CHANGED); +// message.AddInt32("thread", event.GetThread()->ID()); +// PostMessage(&message); +} + + +void TeamWindow::_Init() { BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); @@ -155,6 +198,7 @@ fRunButton->SetTarget(this); fStepOutButton->SetTarget(this); + AutoLocker locker(fDebugModel); _UpdateRunButtons(); } @@ -167,6 +211,7 @@ fActiveThread = thread; + AutoLocker locker(fDebugModel); _UpdateRunButtons(); } @@ -186,6 +231,7 @@ break; case THREAD_STATE_RUNNING: fRunButton->SetLabel("Stop"); + fRunButton->SetMessage(new BMessage(MSG_THREAD_STOP)); fRunButton->SetEnabled(true); fStepOverButton->SetEnabled(false); fStepIntoButton->SetEnabled(false); @@ -193,6 +239,7 @@ break; case THREAD_STATE_STOPPED: fRunButton->SetLabel("Run"); + fRunButton->SetMessage(new BMessage(MSG_THREAD_RUN)); fRunButton->SetEnabled(true); fStepOverButton->SetEnabled(true); fStepIntoButton->SetEnabled(true); @@ -202,16 +249,21 @@ } +void +TeamWindow::_HandleThreadStateChanged(thread_id threadID) +{ + // ATM we're only interested in the currently selected thread + if (fActiveThread == NULL || threadID != fActiveThread->ID()) + return; + + AutoLocker locker(fDebugModel); + _UpdateRunButtons(); +} + + // #pragma mark - Listener TeamWindow::Listener::~Listener() { } - - -bool -TeamWindow::Listener::TeamWindowQuitRequested(TeamWindow* window) -{ - return true; -} Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-18 20:58:42 UTC (rev 31106) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-18 21:45:14 UTC (rev 31107) @@ -8,17 +8,18 @@ #include #include +#include "Team.h" #include "ThreadListView.h" class BButton; class BTabView; class ImageListView; -class Team; class TeamDebugModel; -class TeamWindow : public BWindow, private ThreadListView::Listener { +class TeamWindow : public BWindow, private ThreadListView::Listener, + Team::Listener { public: class Listener; @@ -38,11 +39,21 @@ // ThreadListView::Listener virtual void ThreadSelectionChanged(::Thread* thread); + // Team::Listener + virtual void ThreadStateChanged( + const Team::ThreadEvent& event); + virtual void ThreadCpuStateChanged( + const Team::ThreadEvent& event); + virtual void ThreadStackTraceChanged( + const Team::ThreadEvent& event); + void _Init(); void _SetActiveThread(::Thread* thread); void _UpdateRunButtons(); + void _HandleThreadStateChanged(thread_id threadID); + private: TeamDebugModel* fDebugModel; ::Thread* fActiveThread; @@ -61,7 +72,9 @@ public: virtual ~Listener(); - virtual bool TeamWindowQuitRequested(TeamWindow* window); + virtual void ThreadActionRequested(TeamWindow* window, + thread_id threadID, uint32 action) = 0; + virtual bool TeamWindowQuitRequested(TeamWindow* window) = 0; }; From bonefish at mail.berlios.de Fri Jun 19 00:37:17 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 00:37:17 +0200 Subject: [Haiku-commits] r31108 - haiku/trunk/src/apps/debugger/debugger_interface Message-ID: <200906182237.n5IMbHLf018374@sheep.berlios.de> Author: bonefish Date: 2009-06-19 00:37:16 +0200 (Fri, 19 Jun 2009) New Revision: 31108 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31108&view=rev Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h Log: We can't only use a single debug context, if we want to allow multiple threads to play with us without blocking. Implemented a pool of debug contexts instead. Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 21:45:14 UTC (rev 31107) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 22:37:16 UTC (rev 31108) @@ -9,6 +9,11 @@ #include +#include + +#include +#include + #include "debug_utils.h" #include "ArchitectureX86.h" @@ -18,14 +23,211 @@ #include "ThreadInfo.h" +// number of debug contexts the pool does initially create +static const int kInitialDebugContextCount = 3; + +// maximum number of debug contexts in the pool +static const int kMaxDebugContextCount = 10; + + +struct DebuggerInterface::DebugContext : debug_context, + DoublyLinkedListLinkImpl { + DebugContext() + { + team = -1; + nub_port = -1; + reply_port = -1; + } + + ~DebugContext() + { + if (reply_port >= 0) + destroy_debug_context(this); + } + + status_t Init(team_id team, port_id nubPort) + { + return init_debug_context(this, team, nubPort); + } + + void Close() + { + if (reply_port >= 0) { + destroy_debug_context(this); + team = -1; + nub_port = -1; + reply_port = -1; + } + } +}; + + +struct DebuggerInterface::DebugContextPool { + DebugContextPool(team_id team, port_id nubPort) + : + fLock("debug context pool"), + fTeam(team), + fNubPort(nubPort), + fBlockSem(-1), + fContextCount(0), + fWaiterCount(0), + fClosed(false) + { + } + + ~DebugContextPool() + { + AutoLocker locker(fLock); + + while (DebugContext* context = fFreeContexts.RemoveHead()) + delete context; + + if (fBlockSem >= 0) + delete_sem(fBlockSem); + } + + status_t Init() + { + status_t error = fLock.InitCheck(); + if (error != B_OK) + return error; + + fBlockSem = create_sem(0, "debug context pool block"); + if (fBlockSem < 0) + return fBlockSem; + + for (int i = 0; i < kInitialDebugContextCount; i++) { + DebugContext* context; + error = _CreateDebugContext(context); + if (error != B_OK) + return error; + + fFreeContexts.Add(context); + } + + return B_OK; + } + + void Close() + { + AutoLocker locker(fLock); + fClosed = true; + + for (DebugContextList::Iterator it = fFreeContexts.GetIterator(); + DebugContext* context = it.Next();) { + context->Close(); + } + + for (DebugContextList::Iterator it = fUsedContexts.GetIterator(); + DebugContext* context = it.Next();) { + context->Close(); + } + } + + DebugContext* GetContext() + { + AutoLocker locker(fLock); + DebugContext* context = fFreeContexts.RemoveHead(); + + if (context == NULL) { + if (fContextCount >= kMaxDebugContextCount + || _CreateDebugContext(context) != B_OK) { + // wait for a free context + while (context == NULL) { + fWaiterCount++; + locker.Unlock(); + while (acquire_sem(fBlockSem) != B_OK); + locker.Lock(); + context = fFreeContexts.RemoveHead(); + } + } + } + + fUsedContexts.Add(context); + + return context; + } + + void PutContext(DebugContext* context) + { + AutoLocker locker(fLock); + fUsedContexts.Remove(context); + fFreeContexts.Add(context); + + if (fWaiterCount > 0) + release_sem(fBlockSem); + } + +private: + typedef DoublyLinkedList DebugContextList; + +private: + status_t _CreateDebugContext(DebugContext*& _context) + { + DebugContext* context = new(std::nothrow) DebugContext; + if (context == NULL) + return B_NO_MEMORY; + + if (!fClosed) { + status_t error = context->Init(fTeam, fNubPort); + if (error != B_OK) { + delete context; + return error; + } + } + + fContextCount++; + + _context = context; + return B_OK; + } + +private: + BLocker fLock; + team_id fTeam; + port_id fNubPort; + sem_id fBlockSem; + int32 fContextCount; + int32 fWaiterCount; + DebugContextList fFreeContexts; + DebugContextList fUsedContexts; + bool fClosed; +}; + + +struct DebuggerInterface::DebugContextGetter { + DebugContextGetter(DebugContextPool* pool) + : + fPool(pool), + fContext(pool->GetContext()) + { + } + + ~DebugContextGetter() + { + fPool->PutContext(fContext); + } + + DebugContext* Context() const + { + return fContext; + } + +private: + DebugContextPool* fPool; + DebugContext* fContext; +}; + +// #pragma mark - DebuggerInterface + DebuggerInterface::DebuggerInterface(team_id teamID) : fTeamID(teamID), fDebuggerPort(-1), fNubPort(-1), + fDebugContextPool(NULL), fArchitecture(NULL) { - fDebugContext.reply_port = -1; } @@ -33,9 +235,9 @@ { fArchitecture->RemoveReference(); - destroy_debug_context(&fDebugContext); + Close(); - Close(); + delete fDebugContextPool; } @@ -64,8 +266,12 @@ if (fNubPort < 0) return fNubPort; - // init debug context - status_t error = init_debug_context(&fDebugContext, fTeamID, fNubPort); + // create debug context pool + fDebugContextPool = new(std::nothrow) DebugContextPool(fTeamID, fNubPort); + if (fDebugContextPool == NULL) + return B_NO_MEMORY; + + status_t error = fDebugContextPool->Init(); if (error != B_OK) return error; @@ -203,13 +409,15 @@ status_t DebuggerInterface::GetCpuState(thread_id thread, CpuState*& _state) { + DebugContextGetter contextGetter(fDebugContextPool); + debug_nub_get_cpu_state message; - message.reply_port = fDebugContext.reply_port; + message.reply_port = contextGetter.Context()->reply_port; message.thread = thread; debug_nub_get_cpu_state_reply reply; - status_t error = send_debug_message(&fDebugContext, + status_t error = send_debug_message(contextGetter.Context(), B_DEBUG_MESSAGE_GET_CPU_STATE, &message, sizeof(message), &reply, sizeof(reply)); if (error != B_OK) Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-18 21:45:14 UTC (rev 31107) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-18 22:37:16 UTC (rev 31108) @@ -47,6 +47,11 @@ // returns a reference to the caller private: + struct DebugContext; + struct DebugContextPool; + struct DebugContextGetter; + +private: status_t _CreateDebugEvent(int32 messageCode, const debug_debugger_message_data& message, bool& _ignore, DebugEvent*& _event); @@ -55,8 +60,7 @@ team_id fTeamID; port_id fDebuggerPort; port_id fNubPort; - debug_context fDebugContext; - // TODO: Use a debug context pool! + DebugContextPool* fDebugContextPool; Architecture* fArchitecture; }; From bonefish at mail.berlios.de Fri Jun 19 02:05:46 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 02:05:46 +0200 Subject: [Haiku-commits] r31109 - in haiku/trunk/src/apps/debugger: . arch arch/x86 debugger_interface Message-ID: <200906190005.n5J05kWi028845@sheep.berlios.de> Author: bonefish Date: 2009-06-19 02:05:45 +0200 (Fri, 19 Jun 2009) New Revision: 31109 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31109&view=rev Added: haiku/trunk/src/apps/debugger/arch/Register.cpp haiku/trunk/src/apps/debugger/arch/Register.h Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/arch/Architecture.cpp haiku/trunk/src/apps/debugger/arch/Architecture.h haiku/trunk/src/apps/debugger/arch/CpuState.h haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp Log: More work on the architecture abstraction, particularly regarding information about what registers the architecture has and how to get them from the CpuState. Implemented the respective x86 part. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 00:05:45 UTC (rev 31109) @@ -32,6 +32,7 @@ # arch Architecture.cpp CpuState.cpp + Register.cpp StackFrame.cpp StackTrace.cpp Modified: haiku/trunk/src/apps/debugger/arch/Architecture.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-19 00:05:45 UTC (rev 31109) @@ -16,3 +16,10 @@ Architecture::~Architecture() { } + + +status_t +Architecture::Init() +{ + return B_OK; +} Modified: haiku/trunk/src/apps/debugger/arch/Architecture.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-19 00:05:45 UTC (rev 31109) @@ -12,6 +12,7 @@ class CpuState; class DebuggerInterface; +class Register; class Architecture : public Referenceable { @@ -20,6 +21,11 @@ DebuggerInterface* debuggerInterface); virtual ~Architecture(); + virtual status_t Init(); + + virtual int32 CountRegisters() const = 0; + virtual const Register* Registers() const = 0; + virtual status_t CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state) = 0; Modified: haiku/trunk/src/apps/debugger/arch/CpuState.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-19 00:05:45 UTC (rev 31109) @@ -9,10 +9,18 @@ #include +#include "Variant.h" + +class Register; + + class CpuState : public Referenceable { public: virtual ~CpuState(); + + virtual bool GetRegisterValue(const Register* reg, + Variant& _value) = 0; }; Added: haiku/trunk/src/apps/debugger/arch/Register.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/Register.cpp 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/Register.cpp 2009-06-19 00:05:45 UTC (rev 31109) @@ -0,0 +1,29 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Register.h" + + +Register::Register(int32 index, const char* name, register_format format, + uint32 bitSize, register_type type) + : + fIndex(index), + fName(name), + fFormat(format), + fBitSize(bitSize), + fType(type) +{ +} + + +Register::Register(const Register& other) + : + fIndex(other.fIndex), + fName(other.fName), + fFormat(other.fFormat), + fBitSize(other.fBitSize), + fType(other.fType) +{ +} Added: haiku/trunk/src/apps/debugger/arch/Register.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Register.h 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/Register.h 2009-06-19 00:05:45 UTC (rev 31109) @@ -0,0 +1,49 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef REGISTER_H +#define REGISTER_H + +#include + + +enum register_format { + REGISTER_FORMAT_INTEGER, + REGISTER_FORMAT_FLOAT +}; + +enum register_type { + REGISTER_TYPE_PROGRAM_COUNTER, + REGISTER_TYPE_STACK_POINTER, + REGISTER_TYPE_GENERAL_PURPOSE, + REGISTER_TYPE_SPECIAL_PURPOSE, + REGISTER_TYPE_EXTENDED +}; + + +class Register { +public: + Register(int32 index, const char* name, + register_format format, uint32 bitSize, + register_type type); + // name will not be cloned + Register(const Register& other); + + int32 Index() const { return fIndex; } + const char* Name() const { return fName; } + register_format Format() const { return fFormat; } + uint32 BitSize() const { return fBitSize; } + register_type Type() const { return fType; } + +private: + int32 fIndex; + const char* fName; + register_format fFormat; + uint32 fBitSize; + register_type fType; + +}; + + +#endif // REGISTER_H Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-19 00:05:45 UTC (rev 31109) @@ -23,6 +23,65 @@ status_t +ArchitectureX86::Init() +{ + try { + _AddIntegerRegister(X86_REGISTER_EIP, "eip", 32, + REGISTER_TYPE_PROGRAM_COUNTER); + _AddIntegerRegister(X86_REGISTER_ESP, "esp", 32, + REGISTER_TYPE_STACK_POINTER); + _AddIntegerRegister(X86_REGISTER_EBP, "ebp", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + + _AddIntegerRegister(X86_REGISTER_EAX, "eax", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_EBX, "ebx", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_ECX, "ecx", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_EDX, "edx", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + + _AddIntegerRegister(X86_REGISTER_ESI, "esi", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_EDI, "edi", 32, + REGISTER_TYPE_GENERAL_PURPOSE); + + _AddIntegerRegister(X86_REGISTER_CS, "cs", 16, + REGISTER_TYPE_SPECIAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_DS, "ds", 16, + REGISTER_TYPE_SPECIAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_ES, "es", 16, + REGISTER_TYPE_SPECIAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_FS, "fs", 16, + REGISTER_TYPE_SPECIAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_GS, "gs", 16, + REGISTER_TYPE_SPECIAL_PURPOSE); + _AddIntegerRegister(X86_REGISTER_SS, "ss", 16, + REGISTER_TYPE_SPECIAL_PURPOSE); + } catch (std::bad_alloc) { + return B_NO_MEMORY; + } + + return B_OK; +} + + +int32 +ArchitectureX86::CountRegisters() const +{ + return fRegisters.Count(); +} + + +const Register* +ArchitectureX86::Registers() const +{ + return fRegisters.Elements(); +} + + +status_t ArchitectureX86::CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state) { @@ -37,3 +96,20 @@ _state = state; return B_OK; } + + +void +ArchitectureX86::_AddRegister(int32 index, const char* name, + register_format format, uint32 bitSize, register_type type) +{ + if (!fRegisters.Add(Register(index, name, format, bitSize, type))) + throw std::bad_alloc(); +} + + +void +ArchitectureX86::_AddIntegerRegister(int32 index, const char* name, + uint32 bitSize, register_type type) +{ + _AddRegister(index, name, REGISTER_FORMAT_INTEGER, bitSize, type); +} Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-19 00:05:45 UTC (rev 31109) @@ -6,6 +6,8 @@ #define ARCHITECTURE_X86_H #include "Architecture.h" +#include "Array.h" +#include "Register.h" class ArchitectureX86 : public Architecture { @@ -14,8 +16,24 @@ DebuggerInterface* debuggerInterface); virtual ~ArchitectureX86(); + virtual status_t Init(); + + virtual int32 CountRegisters() const; + virtual const Register* Registers() const; + virtual status_t CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state); + +private: + void _AddRegister(int32 index, const char* name, + register_format format, uint32 bitSize, + register_type type); + void _AddIntegerRegister(int32 index, + const char* name, uint32 bitSize, + register_type type); + +private: + Array fRegisters; }; Modified: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-19 00:05:45 UTC (rev 31109) @@ -5,14 +5,88 @@ #include "CpuStateX86.h" +#include "Register.h" + CpuStateX86::CpuStateX86(const debug_cpu_state_x86& state) : - fState(state) + fSetRegisters() { + SetIntRegister(X86_REGISTER_EIP, state.eip); + SetIntRegister(X86_REGISTER_ESP, state.user_esp); + SetIntRegister(X86_REGISTER_EBP, state.ebp); + SetIntRegister(X86_REGISTER_EAX, state.eax); + SetIntRegister(X86_REGISTER_EBX, state.ebx); + SetIntRegister(X86_REGISTER_ECX, state.ecx); + SetIntRegister(X86_REGISTER_EDX, state.edx); + SetIntRegister(X86_REGISTER_ESI, state.esi); + SetIntRegister(X86_REGISTER_EDI, state.edi); + SetIntRegister(X86_REGISTER_CS, state.cs); + SetIntRegister(X86_REGISTER_DS, state.ds); + SetIntRegister(X86_REGISTER_ES, state.es); + SetIntRegister(X86_REGISTER_FS, state.fs); + SetIntRegister(X86_REGISTER_GS, state.gs); + SetIntRegister(X86_REGISTER_SS, state.user_ss); } CpuStateX86::~CpuStateX86() { } + + +bool +CpuStateX86::GetRegisterValue(const Register* reg, Variant& _value) +{ + int32 index = reg->Index(); + if (!IsRegisterSet(index)) + return false; + + if (index >= X86_INT_REGISTER_END) + return false; + + if (reg->BitSize() == 16) + _value.SetTo((uint16)fIntRegisters[index]); + else + _value.SetTo(fIntRegisters[index]); + + return true; +} + + +bool +CpuStateX86::IsRegisterSet(int32 index) const +{ + return index >= 0 && index < X86_REGISTER_COUNT && fSetRegisters[index]; +} + + +uint32 +CpuStateX86::IntRegisterValue(int32 index) const +{ + if (!IsRegisterSet(index) || index >= X86_INT_REGISTER_END) + return 0; + + return fIntRegisters[index]; +} + + +void +CpuStateX86::SetIntRegister(int32 index, uint32 value) +{ + if (index < 0 || index >= X86_INT_REGISTER_END) + return; + + fIntRegisters[index] = value; + fSetRegisters[index] = 1; +} + + +void +CpuStateX86::UnsetRegister(int32 index) +{ + if (index < 0 || index >= X86_REGISTER_COUNT) + return; + + fSetRegisters[index] = 0; +} Modified: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-19 00:05:45 UTC (rev 31109) @@ -5,6 +5,8 @@ #ifndef CPU_STATE_X86_H #define CPU_STATE_X86_H +#include + #include #include "CpuState.h" @@ -13,16 +15,50 @@ typedef debug_cpu_state debug_cpu_state_x86; // TODO: Should be defined by ! +enum { + X86_REGISTER_EIP = 0, + X86_REGISTER_ESP, + X86_REGISTER_EBP, + X86_REGISTER_EAX, + X86_REGISTER_EBX, + X86_REGISTER_ECX, + X86_REGISTER_EDX, + + X86_REGISTER_ESI, + X86_REGISTER_EDI, + + X86_REGISTER_CS, + X86_REGISTER_DS, + X86_REGISTER_ES, + X86_REGISTER_FS, + X86_REGISTER_GS, + X86_REGISTER_SS, + + X86_INT_REGISTER_END, + X86_REGISTER_COUNT +}; + + class CpuStateX86 : public CpuState { public: CpuStateX86(const debug_cpu_state_x86& state); virtual ~CpuStateX86(); - const debug_cpu_state_x86 State() const { return fState; } + virtual bool GetRegisterValue(const Register* reg, + Variant& _value); + bool IsRegisterSet(int32 index) const; + uint32 IntRegisterValue(int32 index) const; + void SetIntRegister(int32 index, uint32 value); + void UnsetRegister(int32 index); + private: - debug_cpu_state_x86 fState; + typedef std::bitset RegisterBitSet; + +private: + uint32 fIntRegisters[X86_REGISTER_COUNT]; + RegisterBitSet fSetRegisters; }; Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-18 22:37:16 UTC (rev 31108) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-19 00:05:45 UTC (rev 31109) @@ -254,6 +254,10 @@ if (fArchitecture == NULL) return B_NO_MEMORY; + status_t error = fArchitecture->Init(); + if (error != B_OK) + return error; + // create debugger port char buffer[128]; snprintf(buffer, sizeof(buffer), "team %ld debugger", fTeamID); @@ -271,7 +275,7 @@ if (fDebugContextPool == NULL) return B_NO_MEMORY; - status_t error = fDebugContextPool->Init(); + error = fDebugContextPool->Init(); if (error != B_OK) return error; @@ -425,13 +429,8 @@ if (reply.error != B_OK) return reply.error; - // TODO: Correctly create the state... - CpuState* state = new(std::nothrow) CpuState; - if (state == NULL) - return B_NO_MEMORY; - - _state = state; - return B_OK; + return fArchitecture->CreateCpuState(&reply.cpu_state, + sizeof(debug_cpu_state), _state); } From phoudoin at mail.berlios.de Fri Jun 19 03:31:52 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Fri, 19 Jun 2009 03:31:52 +0200 Subject: [Haiku-commits] r31110 - haiku/trunk/build/jam Message-ID: <200906190131.n5J1Vqar004983@sheep.berlios.de> Author: phoudoin Date: 2009-06-19 03:31:51 +0200 (Fri, 19 Jun 2009) New Revision: 31110 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31110&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: libnetwork.so, libnetapi.so and libGL.so aliases were not symlinks but duplicates. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-19 00:05:45 UTC (rev 31109) +++ haiku/trunk/build/jam/HaikuImage 2009-06-19 01:31:51 UTC (rev 31110) @@ -235,10 +235,10 @@ local lib ; for lib in $(SYSTEM_LIBS_LIBNETWORK_ALIASES) { - AddFilesToHaikuHybridImage system lib : libnetwork.so : $(lib) : true ; + AddSymlinkToHaikuHybridImage system lib : libnetwork.so : $(lib) ; } -AddFilesToHaikuHybridImage system lib : libbnetapi.so : libnetapi.so : true ; +AddSymlinkToHaikuHybridImage system lib : libbnetapi.so : libnetapi.so ; # libGL.so has GLU (like BeOS) *and* GLUT API built-in SYSTEM_LIBS_LIBGL_ALIASES @@ -247,7 +247,7 @@ if $(TARGET_ARCH) = x86 { local lib ; for lib in $(SYSTEM_LIBS_LIBGL_ALIASES) { - AddFilesToHaikuHybridImage system lib : libGL.so : $(lib) : true ; + AddSymlinkToHaikuHybridImage system lib : libGL.so : $(lib) ; } } From phoudoin at mail.berlios.de Fri Jun 19 04:04:41 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Fri, 19 Jun 2009 04:04:41 +0200 Subject: [Haiku-commits] r31111 - haiku/trunk/build/jam Message-ID: <200906190204.n5J24fCF007146@sheep.berlios.de> Author: phoudoin Date: 2009-06-19 04:04:39 +0200 (Fri, 19 Jun 2009) New Revision: 31111 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31111&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/OptionalPackages Log: Fixed missing libs "aliases" symlinks in DevelopmentMin package. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-19 01:31:51 UTC (rev 31110) +++ haiku/trunk/build/jam/HaikuImage 2009-06-19 02:04:39 UTC (rev 31111) @@ -250,6 +250,8 @@ AddSymlinkToHaikuHybridImage system lib : libGL.so : $(lib) ; } } +SYSTEM_LIBS_ALIASES + = $(SYSTEM_LIBS_LIBNETWORK_ALIASES) libnetapi.so $(SYSTEM_LIBS_LIBGL_ALIASES) ; # servers AddFilesToHaikuImage system servers : $(SYSTEM_SERVERS) ; Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2009-06-19 01:31:51 UTC (rev 31110) +++ haiku/trunk/build/jam/OptionalPackages 2009-06-19 02:04:39 UTC (rev 31111) @@ -317,7 +317,7 @@ # library symlinks local lib ; - for lib in $(SYSTEM_LIBS) libglut.so { + for lib in $(SYSTEM_LIBS) $(SYSTEM_LIBS_ALIASES) { AddSymlinkToHaikuHybridImage $(abiDirTokens) lib : /system/lib $(lib:BS) : : true ; } From phoudoin at mail.berlios.de Fri Jun 19 04:06:32 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Fri, 19 Jun 2009 04:06:32 +0200 Subject: [Haiku-commits] r31112 - haiku/trunk/build/jam Message-ID: <200906190206.n5J26Wt5007310@sheep.berlios.de> Author: phoudoin Date: 2009-06-19 04:06:30 +0200 (Fri, 19 Jun 2009) New Revision: 31112 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31112&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Typo cleanup. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-19 02:04:39 UTC (rev 31111) +++ haiku/trunk/build/jam/HaikuImage 2009-06-19 02:06:30 UTC (rev 31112) @@ -250,6 +250,7 @@ AddSymlinkToHaikuHybridImage system lib : libGL.so : $(lib) ; } } + SYSTEM_LIBS_ALIASES = $(SYSTEM_LIBS_LIBNETWORK_ALIASES) libnetapi.so $(SYSTEM_LIBS_LIBGL_ALIASES) ; From axeld at mail.berlios.de Fri Jun 19 10:23:13 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 19 Jun 2009 10:23:13 +0200 Subject: [Haiku-commits] r31113 - in haiku/trunk: headers/private/kernel headers/private/system src/system/kernel src/system/kernel/vm src/system/libroot/posix/sys src/system/runtime_loader Message-ID: <200906190823.n5J8NDaW019161@sheep.berlios.de> Author: axeld Date: 2009-06-19 10:23:11 +0200 (Fri, 19 Jun 2009) New Revision: 31113 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31113&view=rev Modified: haiku/trunk/headers/private/kernel/vm.h haiku/trunk/headers/private/system/syscalls.h haiku/trunk/src/system/kernel/elf.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/libroot/posix/sys/mman.cpp haiku/trunk/src/system/runtime_loader/images.cpp Log: * Added an "unmapAddressRange" argument to the file mapping syscall. This is the first part of making the runtime loader behave itself; it should already make Clockwerk run okay with any number of translators (even if not all of them will work yet). Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2009-06-19 02:06:30 UTC (rev 31112) +++ haiku/trunk/headers/private/kernel/vm.h 2009-06-19 08:23:11 UTC (rev 31113) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -67,7 +67,7 @@ uint32 addressSpec, addr_t size, uint32 protection, addr_t phys_addr); area_id vm_map_file(team_id aid, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 protection, uint32 mapping, - int fd, off_t offset); + bool unmapAddressRange, int fd, off_t offset); struct VMCache *vm_area_get_locked_cache(struct vm_area *area); void vm_area_put_locked_cache(struct VMCache *cache); area_id vm_create_null_area(team_id team, const char *name, void **address, @@ -87,7 +87,7 @@ int32 vm_test_map_activation(struct vm_page *page, bool *_modified); void vm_clear_map_flags(struct vm_page *page, uint32 flags); void vm_remove_all_page_mappings(struct vm_page *page, uint32 *_flags); -bool vm_unmap_page(struct vm_area* area, addr_t virtualAddress, +bool vm_unmap_page(struct vm_area* area, addr_t virtualAddress, bool preserveModified); status_t vm_unmap_pages(struct vm_area *area, addr_t base, size_t length, bool preserveModified); @@ -121,7 +121,8 @@ status_t _user_delete_area(area_id area); area_id _user_map_file(const char *uname, void **uaddress, int addressSpec, - size_t size, int protection, int mapping, int fd, off_t offset); + size_t size, int protection, int mapping, bool unmapAddressRange, + int fd, off_t offset); status_t _user_unmap_memory(void *address, size_t size); status_t _user_set_memory_protection(void* address, size_t size, int protection); Modified: haiku/trunk/headers/private/system/syscalls.h =================================================================== --- haiku/trunk/headers/private/system/syscalls.h 2009-06-19 02:06:30 UTC (rev 31112) +++ haiku/trunk/headers/private/system/syscalls.h 2009-06-19 08:23:11 UTC (rev 31113) @@ -140,21 +140,27 @@ extern status_t _kern_suspend_thread(thread_id thread); extern status_t _kern_resume_thread(thread_id thread); extern status_t _kern_rename_thread(thread_id thread, const char *newName); -extern status_t _kern_set_thread_priority(thread_id thread, int32 newPriority); +extern status_t _kern_set_thread_priority(thread_id thread, + int32 newPriority); extern status_t _kern_kill_thread(thread_id thread); extern void _kern_exit_thread(status_t returnValue); extern void _kern_thread_yield(void); -extern status_t _kern_wait_for_thread(thread_id thread, status_t *_returnCode); +extern status_t _kern_wait_for_thread(thread_id thread, + status_t *_returnCode); extern bool _kern_has_data(thread_id thread); -extern status_t _kern_send_data(thread_id thread, int32 code, const void *buffer, size_t bufferSize); -extern int32 _kern_receive_data(thread_id *_sender, void *buffer, size_t bufferSize); +extern status_t _kern_send_data(thread_id thread, int32 code, + const void *buffer, size_t bufferSize); +extern int32 _kern_receive_data(thread_id *_sender, void *buffer, + size_t bufferSize); extern int64 _kern_restore_signal_frame(); extern status_t _kern_get_thread_info(thread_id id, thread_info *info); -extern status_t _kern_get_next_thread_info(team_id team, int32 *cookie, thread_info *info); +extern status_t _kern_get_next_thread_info(team_id team, int32 *cookie, + thread_info *info); extern status_t _kern_get_team_info(team_id id, team_info *info); extern status_t _kern_get_next_team_info(int32 *cookie, team_info *info); -extern status_t _kern_get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size); +extern status_t _kern_get_team_usage_info(team_id team, int32 who, + team_usage_info *info, size_t size); extern status_t _kern_block_thread(uint32 flags, bigtime_t timeout); extern status_t _kern_unblock_thread(thread_id thread, status_t status); @@ -189,8 +195,10 @@ extern status_t _kern_unregister_image(image_id id); extern void _kern_image_relocated(image_id id); extern void _kern_loading_app_failed(status_t error); -extern status_t _kern_get_image_info(image_id id, image_info *info, size_t size); -extern status_t _kern_get_next_image_info(team_id team, int32 *cookie, image_info *info, size_t size); +extern status_t _kern_get_image_info(image_id id, image_info *info, + size_t size); +extern status_t _kern_get_next_image_info(team_id team, int32 *cookie, + image_info *info, size_t size); extern status_t _kern_read_kernel_image_symbols(image_id id, struct Elf32_Sym* symbolTable, int32* _symbolCount, char* stringTable, size_t* _stringTableSize, @@ -198,19 +206,24 @@ // VFS functions extern dev_t _kern_mount(const char *path, const char *device, - const char *fs_name, uint32 flags, const char *args, size_t argsLength); + const char *fs_name, uint32 flags, const char *args, + size_t argsLength); extern status_t _kern_unmount(const char *path, uint32 flags); extern status_t _kern_read_fs_info(dev_t device, struct fs_info *info); -extern status_t _kern_write_fs_info(dev_t device, const struct fs_info *info, int mask); +extern status_t _kern_write_fs_info(dev_t device, const struct fs_info *info, + int mask); extern dev_t _kern_next_device(int32 *_cookie); extern status_t _kern_sync(void); extern status_t _kern_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf, char *userPath, size_t pathLength); extern status_t _kern_normalize_path(const char* userPath, bool traverseLink, char* buffer); -extern int _kern_open_entry_ref(dev_t device, ino_t inode, const char *name, int openMode, int perms); -extern int _kern_open(int fd, const char *path, int openMode, int perms); -extern int _kern_open_dir_entry_ref(dev_t device, ino_t inode, const char *name); +extern int _kern_open_entry_ref(dev_t device, ino_t inode, + const char *name, int openMode, int perms); +extern int _kern_open(int fd, const char *path, int openMode, + int perms); +extern int _kern_open_dir_entry_ref(dev_t device, ino_t inode, + const char *name); extern int _kern_open_dir(int fd, const char *path); extern int _kern_open_parent_dir(int fd, char *name, size_t nameLength); @@ -218,7 +231,8 @@ extern status_t _kern_fsync(int fd); extern status_t _kern_flock(int fd, int op); extern off_t _kern_seek(int fd, off_t pos, int seekType); -extern status_t _kern_create_dir_entry_ref(dev_t device, ino_t inode, const char *name, int perms); +extern status_t _kern_create_dir_entry_ref(dev_t device, ino_t inode, + const char *name, int perms); extern status_t _kern_create_dir(int fd, const char *path, int perms); extern status_t _kern_remove_dir(int fd, const char *path); extern status_t _kern_read_link(int fd, const char *path, char *buffer, @@ -235,30 +249,39 @@ extern ssize_t _kern_select(int numfds, struct fd_set *readSet, struct fd_set *writeSet, struct fd_set *errorSet, bigtime_t timeout, const sigset_t *sigMask); -extern ssize_t _kern_poll(struct pollfd *fds, int numfds, bigtime_t timeout); +extern ssize_t _kern_poll(struct pollfd *fds, int numFDs, + bigtime_t timeout); extern int _kern_open_attr_dir(int fd, const char *path); -extern int _kern_create_attr(int fd, const char *name, uint32 type, int openMode); +extern int _kern_create_attr(int fd, const char *name, uint32 type, + int openMode); extern int _kern_open_attr(int fd, const char *name, int openMode); extern status_t _kern_remove_attr(int fd, const char *name); -extern status_t _kern_rename_attr(int fromFile, const char *fromName, int toFile, const char *toName); +extern status_t _kern_rename_attr(int fromFile, const char *fromName, + int toFile, const char *toName); extern int _kern_open_index_dir(dev_t device); -extern status_t _kern_create_index(dev_t device, const char *name, uint32 type, uint32 flags); -extern status_t _kern_read_index_stat(dev_t device, const char *name, struct stat *stat); +extern status_t _kern_create_index(dev_t device, const char *name, + uint32 type, uint32 flags); +extern status_t _kern_read_index_stat(dev_t device, const char *name, + struct stat *stat); extern status_t _kern_remove_index(dev_t device, const char *name); extern status_t _kern_getcwd(char *buffer, size_t size); extern status_t _kern_setcwd(int fd, const char *path); -extern int _kern_open_query(dev_t device, const char *query, size_t queryLength, - uint32 flags, port_id port, int32 token); +extern int _kern_open_query(dev_t device, const char *query, + size_t queryLength, uint32 flags, port_id port, + int32 token); // file descriptor functions -extern ssize_t _kern_read(int fd, off_t pos, void *buffer, size_t bufferSize); -extern ssize_t _kern_readv(int fd, off_t pos, const struct iovec *vecs, size_t count); -extern ssize_t _kern_write(int fd, off_t pos, const void *buffer, size_t bufferSize); +extern ssize_t _kern_read(int fd, off_t pos, void *buffer, + size_t bufferSize); +extern ssize_t _kern_readv(int fd, off_t pos, const struct iovec *vecs, + size_t count); +extern ssize_t _kern_write(int fd, off_t pos, const void *buffer, + size_t bufferSize); extern ssize_t _kern_writev(int fd, off_t pos, const struct iovec *vecs, size_t count); extern status_t _kern_ioctl(int fd, ulong cmd, void *data, size_t length); -extern ssize_t _kern_read_dir(int fd, struct dirent *buffer, size_t bufferSize, - uint32 maxCount); +extern ssize_t _kern_read_dir(int fd, struct dirent *buffer, + size_t bufferSize, uint32 maxCount); extern status_t _kern_rewind_dir(int fd); extern status_t _kern_read_stat(int fd, const char *path, bool traverseLink, struct stat *stat, size_t statSize); @@ -320,34 +343,43 @@ // time functions extern status_t _kern_set_real_time_clock(uint32 time); -extern status_t _kern_set_timezone(int32 timezoneOffset, bool daylightSavingTime); -extern status_t _kern_get_timezone(int32 *_timezoneOffset, bool *_daylightSavingTime); -extern status_t _kern_set_tzfilename(const char *filename, size_t length, bool isGMT); -extern status_t _kern_get_tzfilename(char *filename, size_t length, bool *_isGMT); +extern status_t _kern_set_timezone(int32 timezoneOffset, + bool daylightSavingTime); +extern status_t _kern_get_timezone(int32 *_timezoneOffset, + bool *_daylightSavingTime); +extern status_t _kern_set_tzfilename(const char *filename, size_t length, + bool isGMT); +extern status_t _kern_get_tzfilename(char *filename, size_t length, + bool *_isGMT); extern bigtime_t _kern_system_time(); extern status_t _kern_snooze_etc(bigtime_t time, int timebase, int32 flags); // area functions -extern area_id _kern_create_area(const char *name, void **address, uint32 addressSpec, - size_t size, uint32 lock, uint32 protection); +extern area_id _kern_create_area(const char *name, void **address, + uint32 addressSpec, size_t size, uint32 lock, + uint32 protection); extern status_t _kern_delete_area(area_id area); extern area_id _kern_area_for(void *address); extern area_id _kern_find_area(const char *name); extern status_t _kern_get_area_info(area_id area, area_info *info); -extern status_t _kern_get_next_area_info(team_id team, int32 *cookie, area_info *info); +extern status_t _kern_get_next_area_info(team_id team, int32 *cookie, + area_info *info); extern status_t _kern_resize_area(area_id area, size_t newSize); -extern area_id _kern_transfer_area(area_id area, void **_address, uint32 addressSpec, - team_id target); -extern status_t _kern_set_area_protection(area_id area, uint32 newProtection); -extern area_id _kern_clone_area(const char *name, void **_address, uint32 addressSpec, - uint32 protection, area_id sourceArea); -extern status_t _kern_reserve_heap_address_range(addr_t* _address, uint32 addressSpec, - addr_t size); +extern area_id _kern_transfer_area(area_id area, void **_address, + uint32 addressSpec, team_id target); +extern status_t _kern_set_area_protection(area_id area, + uint32 newProtection); +extern area_id _kern_clone_area(const char *name, void **_address, + uint32 addressSpec, uint32 protection, + area_id sourceArea); +extern status_t _kern_reserve_heap_address_range(addr_t* _address, + uint32 addressSpec, addr_t size); extern area_id _kern_map_file(const char *name, void **address, int addressSpec, size_t size, int protection, - int mapping, int fd, off_t offset); + int mapping, bool unmapAddressRange, int fd, + off_t offset); extern status_t _kern_unmap_memory(void *address, size_t size); extern status_t _kern_set_memory_protection(void *address, size_t size, int protection); @@ -361,14 +393,18 @@ extern status_t _kern_delete_port(port_id id); extern port_id _kern_find_port(const char *port_name); extern status_t _kern_get_port_info(port_id id, struct port_info *info); -extern status_t _kern_get_next_port_info(team_id team, int32 *cookie, struct port_info *info); -extern ssize_t _kern_port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout); +extern status_t _kern_get_next_port_info(team_id team, int32 *cookie, + struct port_info *info); +extern ssize_t _kern_port_buffer_size_etc(port_id port, uint32 flags, + bigtime_t timeout); extern int32 _kern_port_count(port_id port); -extern ssize_t _kern_read_port_etc(port_id port, int32 *msgCode, void *msgBuffer, - size_t bufferSize, uint32 flags, bigtime_t timeout); +extern ssize_t _kern_read_port_etc(port_id port, int32 *msgCode, + void *msgBuffer, size_t bufferSize, uint32 flags, + bigtime_t timeout); extern status_t _kern_set_port_owner(port_id port, team_id team); -extern status_t _kern_write_port_etc(port_id port, int32 msgCode, const void *msgBuffer, - size_t bufferSize, uint32 flags, bigtime_t timeout); +extern status_t _kern_write_port_etc(port_id port, int32 msgCode, + const void *msgBuffer, size_t bufferSize, uint32 flags, + bigtime_t timeout); extern status_t _kern_writev_port_etc(port_id id, int32 msgCode, const struct iovec *msgVecs, size_t vecCount, size_t bufferSize, uint32 flags, bigtime_t timeout); @@ -403,7 +439,8 @@ /* atomic_* ops (needed for CPUs that don't support them directly) */ #ifdef ATOMIC_FUNCS_ARE_SYSCALLS extern int32 _kern_atomic_set(vint32 *value, int32 newValue); -extern int32 _kern_atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst); +extern int32 _kern_atomic_test_and_set(vint32 *value, int32 newValue, + int32 testAgainst); extern int32 _kern_atomic_add(vint32 *value, int32 addValue); extern int32 _kern_atomic_and(vint32 *value, int32 andValue); extern int32 _kern_atomic_or(vint32 *value, int32 orValue); @@ -412,7 +449,8 @@ #ifdef ATOMIC64_FUNCS_ARE_SYSCALLS extern int64 _kern_atomic_set64(vint64 *value, int64 newValue); -extern int64 _kern_atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst); +extern int64 _kern_atomic_test_and_set64(vint64 *value, int64 newValue, + int64 testAgainst); extern int64 _kern_atomic_add64(vint64 *value, int64 addValue); extern int64 _kern_atomic_and64(vint64 *value, int64 andValue); extern int64 _kern_atomic_or64(vint64 *value, int64 orValue); @@ -438,7 +476,8 @@ sem_id counterSem); extern status_t _kern_unregister_messaging_service(); -extern void _kern_clear_caches(void *address, size_t length, uint32 flags); +extern void _kern_clear_caches(void *address, size_t length, + uint32 flags); extern bool _kern_cpu_enabled(int32 cpu); extern status_t _kern_set_cpu_enabled(int32 cpu, bool enabled); Modified: haiku/trunk/src/system/kernel/elf.cpp =================================================================== --- haiku/trunk/src/system/kernel/elf.cpp 2009-06-19 02:06:30 UTC (rev 31112) +++ haiku/trunk/src/system/kernel/elf.cpp 2009-06-19 08:23:11 UTC (rev 31113) @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001, Travis Geiselbrecht. All rights reserved. @@ -1802,7 +1802,7 @@ id = vm_map_file(team->id, regionName, (void **)®ionAddress, B_EXACT_ADDRESS, fileUpperBound, - B_READ_AREA | B_WRITE_AREA, REGION_PRIVATE_MAP, + B_READ_AREA | B_WRITE_AREA, REGION_PRIVATE_MAP, false, fd, ROUNDOWN(programHeaders[i].p_offset, B_PAGE_SIZE)); if (id < B_OK) { dprintf("error mapping file data: %s!\n", strerror(id)); @@ -1850,7 +1850,7 @@ id = vm_map_file(team->id, regionName, (void **)®ionAddress, B_EXACT_ADDRESS, segmentSize, - B_READ_AREA | B_EXECUTE_AREA, REGION_PRIVATE_MAP, + B_READ_AREA | B_EXECUTE_AREA, REGION_PRIVATE_MAP, false, fd, ROUNDOWN(programHeaders[i].p_offset, B_PAGE_SIZE)); if (id < B_OK) { dprintf("error mapping file text: %s!\n", strerror(id)); Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2009-06-19 02:06:30 UTC (rev 31112) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2009-06-19 08:23:11 UTC (rev 31113) @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -2252,8 +2252,8 @@ */ static area_id _vm_map_file(team_id team, const char* name, void** _address, - uint32 addressSpec, size_t size, uint32 protection, uint32 mapping, int fd, - off_t offset, bool kernel) + uint32 addressSpec, size_t size, uint32 protection, uint32 mapping, + bool unmapAddressRange, int fd, off_t offset, bool kernel) { // TODO: for binary files, we want to make sure that they get the // copy of a file at a given time, ie. later changes should not @@ -2267,10 +2267,11 @@ if (mapping == REGION_NO_PRIVATE_MAP) protection |= B_SHARED_AREA; + if (addressSpec != B_EXACT_ADDRESS) + unmapAddressRange = false; if (fd < 0) { - uint32 flags = addressSpec == B_EXACT_ADDRESS - ? CREATE_AREA_UNMAP_ADDRESS_RANGE : 0; + uint32 flags = unmapAddressRange ? CREATE_AREA_UNMAP_ADDRESS_RANGE : 0; return vm_create_anonymous_area(team, name, _address, addressSpec, size, B_NO_LOCK, protection, flags, kernel); } @@ -2345,7 +2346,7 @@ vm_area* area; status = map_backing_store(locker.AddressSpace(), cache, _address, offset, size, addressSpec, 0, protection, mapping, &area, name, - addressSpec == B_EXACT_ADDRESS, kernel); + unmapAddressRange, kernel); if (status != B_OK || mapping == REGION_PRIVATE_MAP) { // map_backing_store() cannot know we no longer need the ref @@ -2374,13 +2375,14 @@ area_id vm_map_file(team_id aid, const char* name, void** address, uint32 addressSpec, - addr_t size, uint32 protection, uint32 mapping, int fd, off_t offset) + addr_t size, uint32 protection, uint32 mapping, bool unmapAddressRange, + int fd, off_t offset) { if (!arch_vm_supports_protection(protection)) return B_NOT_SUPPORTED; return _vm_map_file(aid, name, address, addressSpec, size, protection, - mapping, fd, offset, true); + mapping, unmapAddressRange, fd, offset, true); } @@ -6148,7 +6150,8 @@ area_id _user_map_file(const char* userName, void** userAddress, int addressSpec, - size_t size, int protection, int mapping, int fd, off_t offset) + size_t size, int protection, int mapping, bool unmapAddressRange, int fd, + off_t offset) { char name[B_OS_NAME_LENGTH]; void* address; @@ -6173,7 +6176,8 @@ | (protection & B_WRITE_AREA ? B_KERNEL_WRITE_AREA : 0); area = _vm_map_file(vm_current_user_address_space_id(), name, &address, - addressSpec, size, protection, mapping, fd, offset, false); + addressSpec, size, protection, mapping, unmapAddressRange, fd, offset, + false); if (area < B_OK) return area; Modified: haiku/trunk/src/system/libroot/posix/sys/mman.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/mman.cpp 2009-06-19 02:06:30 UTC (rev 31112) +++ haiku/trunk/src/system/libroot/posix/sys/mman.cpp 2009-06-19 08:23:11 UTC (rev 31113) @@ -125,7 +125,7 @@ // ask the kernel to map area_id area = _kern_map_file("mmap area", &address, addressSpec, - length, areaProtection, mapping, fd, offset); + length, areaProtection, mapping, true, fd, offset); if (area < 0) { errno = area; return MAP_FAILED; Modified: haiku/trunk/src/system/runtime_loader/images.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/images.cpp 2009-06-19 02:06:30 UTC (rev 31112) +++ haiku/trunk/src/system/runtime_loader/images.cpp 2009-06-19 08:23:11 UTC (rev 31113) @@ -1,6 +1,6 @@ /* * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold at gmx.de. - * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2003-2009, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2002, Manuel J. Petit. All rights reserved. @@ -306,7 +306,8 @@ image->regions[i].id = _kern_map_file(regionName, (void**)&loadAddress, addressSpecifier, image->regions[i].vmsize, B_READ_AREA | B_WRITE_AREA, - REGION_PRIVATE_MAP, fd, PAGE_BASE(image->regions[i].fdstart)); + REGION_PRIVATE_MAP, false, fd, + PAGE_BASE(image->regions[i].fdstart)); if (image->regions[i].id < 0) return image->regions[i].id; From ingo_weinhold at gmx.de Fri Jun 19 11:36:18 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 19 Jun 2009 11:36:18 +0200 Subject: [Haiku-commits] r31111 - haiku/trunk/build/jam In-Reply-To: <200906190204.n5J24fCF007146@sheep.berlios.de> References: <200906190204.n5J24fCF007146@sheep.berlios.de> Message-ID: <20090619113618.412.1@knochen-vm.localdomain> On 2009-06-19 at 04:04:41 [+0200], phoudoin at mail.berlios.de wrote: > Author: phoudoin > Date: 2009-06-19 04:04:39 +0200 (Fri, 19 Jun 2009) > New Revision: 31111 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31111&view=rev > > Modified: > haiku/trunk/build/jam/HaikuImage > haiku/trunk/build/jam/OptionalPackages > Log: > Fixed missing libs "aliases" symlinks in DevelopmentMin package. > > > Modified: haiku/trunk/build/jam/HaikuImage > =================================================================== > --- haiku/trunk/build/jam/HaikuImage 2009-06-19 01:31:51 UTC (rev 31110) > +++ haiku/trunk/build/jam/HaikuImage 2009-06-19 02:04:39 UTC (rev 31111) > @@ -250,6 +250,8 @@ > AddSymlinkToHaikuHybridImage system lib : libGL.so : $(lib) ; > } > } > +SYSTEM_LIBS_ALIASES > + = $(SYSTEM_LIBS_LIBNETWORK_ALIASES) libnetapi.so > $(SYSTEM_LIBS_LIBGL_ALIASES) ; > > # servers > AddFilesToHaikuImage system servers : $(SYSTEM_SERVERS) ; > > Modified: haiku/trunk/build/jam/OptionalPackages > =================================================================== > --- haiku/trunk/build/jam/OptionalPackages 2009-06-19 01:31:51 UTC (rev > 31110) > +++ haiku/trunk/build/jam/OptionalPackages 2009-06-19 02:04:39 UTC (rev > 31111) > @@ -317,7 +317,7 @@ > > # library symlinks > local lib ; > - for lib in $(SYSTEM_LIBS) libglut.so { > + for lib in $(SYSTEM_LIBS) $(SYSTEM_LIBS_ALIASES) { > AddSymlinkToHaikuHybridImage $(abiDirTokens) lib > : /system/lib $(lib:BS) : : true ; > } At least the libnetwork aliases are not supposed to be there. Not sure about the others. CU, Ingo From superstippi at gmx.de Fri Jun 19 12:01:28 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 19 Jun 2009 12:01:28 +0200 Subject: [Haiku-commits] r31113 - in haiku/trunk: headers/private/kernel headers/private/system src/system/kernel src/system/kernel/vm src/system/libroot/posix/sys src/system/runtime_loader In-Reply-To: <200906190823.n5J8NDaW019161@sheep.berlios.de> References: <200906190823.n5J8NDaW019161@sheep.berlios.de> Message-ID: <20090619120128.391.1@bepc.1245404999.fake> On 2009-06-19 at 10:23:13 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2009-06-19 10:23:11 +0200 (Fri, 19 Jun 2009) New Revision: 31113 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31113&view=rev > > Modified: > haiku/trunk/headers/private/kernel/vm.h > haiku/trunk/headers/private/system/syscalls.h > haiku/trunk/src/system/kernel/elf.cpp > haiku/trunk/src/system/kernel/vm/vm.cpp > haiku/trunk/src/system/libroot/posix/sys/mman.cpp > haiku/trunk/src/system/runtime_loader/images.cpp > Log: > * Added an "unmapAddressRange" argument to the file mapping syscall. This > is > the first part of making the runtime loader behave itself; it should > already make Clockwerk run okay with any number of translators (even if > not all of them will work yet). Do I read the patch correctly in that some add-ons will now fail to load, because they cannot be mapped at the exact address? The "even if not all of them will work yet" part? Thanks a lot for looking into this! Best regards, -Stephan From axeld at mail.berlios.de Fri Jun 19 12:17:43 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 19 Jun 2009 12:17:43 +0200 Subject: [Haiku-commits] r31114 - haiku/trunk/src/tools/gensyscalls Message-ID: <200906191017.n5JAHhia030391@sheep.berlios.de> Author: axeld Date: 2009-06-19 12:17:42 +0200 (Fri, 19 Jun 2009) New Revision: 31114 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31114&view=rev Modified: haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp Log: * Fixed warnings. * Automatic whitespace cleanup. Modified: haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp =================================================================== --- haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp 2009-06-19 08:23:11 UTC (rev 31113) +++ haiku/trunk/src/tools/gensyscalls/gensyscalls.cpp 2009-06-19 10:17:42 UTC (rev 31114) @@ -19,30 +19,33 @@ using std::vector; -// usage -const char *kUsage = -"Usage: gensyscalls [ -c ] [ -d ] [ -n ]\n" -" [ -t
Defaults resets everything to default values.
Revert brings back the settings that were active when you started the Fonts preferences.
] [ -s ]\n" -"\n" -"The command is able to generate several syscalls related source files.\n" -"\n" -" - Output: The assembly source file implementing the\n" -" actual syscalls.\n" -" - Output: The C source file to be included by the\n" -" syscall dispatcher source file.\n" -" - Output: The C/assembly include files defining the\n" -" syscall numbers.\n" -"
- Output: A C source file containing an array with\n" -" infos about the syscalls\n" -" - Output: A C source file for strace support.\n" -; // print_usage -static -void +static void print_usage(bool error) { - fprintf((error ? stderr : stdout), kUsage); + fprintf(error ? stderr : stdout, + "Usage: gensyscalls [ -c ] [ -d ] [ -n " + "]\n" + " [ -t
] [ -s ]\n" + "\n" + "The command is able to generate several syscalls related source " + "files.\n" + "\n" + " - Output: The assembly source file " + "implementing the\n" + " actual syscalls.\n" + " - Output: The C source file to be included by " + "the\n" + " syscall dispatcher source file.\n" + " - Output: The C/assembly include files " + "defining the\n" + " syscall numbers.\n" + "
- Output: A C source file containing an array " + "with\n" + " infos about the syscalls\n" + " - Output: A C source file for strace " + "support.\n"); } @@ -90,7 +93,7 @@ Syscall::~Syscall() { delete fReturnType; - + int count = CountParameters(); for (int i = 0; i < count; i++) delete ParameterAt(i); @@ -278,7 +281,7 @@ ofstream file(filename, ofstream::out | ofstream::trunc); if (!file.is_open()) throw IOException(string("Failed to open `") + filename + "'."); - + // output the syscalls definitions for (int i = 0; i < fSyscallCount; i++) { const Syscall* syscall = fSyscallVector->SyscallAt(i); @@ -466,7 +469,7 @@ << "(void)handler;" << endl; int chunkSize = (fSyscallCount + 19) / 20; - + // iterate through the syscalls for (int i = 0; i < fSyscallCount; i++) { const Syscall* syscall = fSyscallVector->SyscallAt(i); @@ -535,14 +538,14 @@ // pointer type // check, if it is a string constant ("const char *" or // "char const *") - if (_GetTypeCodeTokenize(typeName) == "const" + if ((_GetTypeCodeTokenize(typeName) == "const" && _GetTypeCodeTokenize(typeName) == "char" && _GetTypeCodeTokenize(typeName) == "*" - && _GetTypeCodeTokenize(typeName) == "" - || _GetTypeCodeTokenize(typeName) == "char" + && _GetTypeCodeTokenize(typeName) == "") + || (_GetTypeCodeTokenize(typeName) == "char" && _GetTypeCodeTokenize(typeName) == "const" && _GetTypeCodeTokenize(typeName) == "*" - && _GetTypeCodeTokenize(typeName) == "") { + && _GetTypeCodeTokenize(typeName) == "")) { return "B_STRING_TYPE"; } From axeld at pinc-software.de Fri Jun 19 12:19:07 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 19 Jun 2009 12:19:07 +0200 CEST Subject: [Haiku-commits] r31113 - in haiku/trunk: headers/private/kernel headers/private/system src/system/kernel src/system/kernel/vm src/system/libroot/posix/sys src/system/runtime_loader In-Reply-To: <20090619120128.391.1@bepc.1245404999.fake> Message-ID: <13750937239-BeMail@zon> Stephan Assmus wrote: > Do I read the patch correctly in that some add-ons will now fail to > load, > because they cannot be mapped at the exact address? The "even if not > all of > them will work yet" part? Thanks a lot for looking into this! Exactly. I'm currently working on that part, too :-) Bye, Axel. From axeld at mail.berlios.de Fri Jun 19 13:09:23 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 19 Jun 2009 13:09:23 +0200 Subject: [Haiku-commits] r31115 - in haiku/trunk: headers/private/kernel headers/private/system src/kits/app src/system/kernel/vm src/system/libroot/posix/malloc src/system/runtime_loader Message-ID: <200906191109.n5JB9Nh3025466@sheep.berlios.de> Author: axeld Date: 2009-06-19 13:09:21 +0200 (Fri, 19 Jun 2009) New Revision: 31115 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31115&view=rev Modified: haiku/trunk/headers/private/kernel/vm.h haiku/trunk/headers/private/system/syscalls.h haiku/trunk/src/kits/app/ServerMemoryAllocator.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/libroot/posix/malloc/arch-specific.cpp haiku/trunk/src/system/runtime_loader/images.cpp Log: * Renamed _kern_reserve_heap_address_range() to _kern_reserve_address_range(), and added a _kern_unreserve_address_range() as well. * The runtime loader now reserves the space needed for all its areas first to make sure there is enough space left for all areas of a single image. * This also fixes the final part of bug #4008. * Minor cleanup. Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2009-06-19 10:17:42 UTC (rev 31114) +++ haiku/trunk/headers/private/kernel/vm.h 2009-06-19 11:09:21 UTC (rev 31115) @@ -139,8 +139,9 @@ status_t _user_set_area_protection(area_id area, uint32 newProtection); area_id _user_clone_area(const char *name, void **_address, uint32 addressSpec, uint32 protection, area_id sourceArea); -status_t _user_reserve_heap_address_range(addr_t* userAddress, uint32 addressSpec, +status_t _user_reserve_address_range(addr_t* userAddress, uint32 addressSpec, addr_t size); +status_t _user_unreserve_address_range(addr_t address, addr_t size); #ifdef __cplusplus } Modified: haiku/trunk/headers/private/system/syscalls.h =================================================================== --- haiku/trunk/headers/private/system/syscalls.h 2009-06-19 10:17:42 UTC (rev 31114) +++ haiku/trunk/headers/private/system/syscalls.h 2009-06-19 11:09:21 UTC (rev 31115) @@ -373,8 +373,9 @@ extern area_id _kern_clone_area(const char *name, void **_address, uint32 addressSpec, uint32 protection, area_id sourceArea); -extern status_t _kern_reserve_heap_address_range(addr_t* _address, +extern status_t _kern_reserve_address_range(addr_t* _address, uint32 addressSpec, addr_t size); +extern status_t _kern_unreserve_address_range(addr_t address, addr_t size); extern area_id _kern_map_file(const char *name, void **address, int addressSpec, size_t size, int protection, Modified: haiku/trunk/src/kits/app/ServerMemoryAllocator.cpp =================================================================== --- haiku/trunk/src/kits/app/ServerMemoryAllocator.cpp 2009-06-19 10:17:42 UTC (rev 31114) +++ haiku/trunk/src/kits/app/ServerMemoryAllocator.cpp 2009-06-19 11:09:21 UTC (rev 31115) @@ -1,13 +1,12 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Axel D?rfler, axeld at pinc-software.de */ -/*! - Note, this class don't provide any locking whatsoever - you are +/*! Note, this class don't provide any locking whatsoever - you are supposed to have a BPrivate::AppServerLink object around which does the necessary locking. However, this is not enforced in the methods here, you have to @@ -74,14 +73,16 @@ if (!readOnly) { // reserve 128 MB of space for the area base = (void*)0x60000000; - status = _kern_reserve_heap_address_range((addr_t*)&base, - B_BASE_ADDRESS, 128 * 1024 * 1024); + status = _kern_reserve_address_range((addr_t*)&base, B_BASE_ADDRESS, + 128 * 1024 * 1024); addressSpec = status == B_OK ? B_EXACT_ADDRESS : B_BASE_ADDRESS; } #endif - mapping->local_area = clone_area(readOnly ? "server read-only memory" : "server_memory", - &base, addressSpec, B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA), serverArea); + mapping->local_area = clone_area(readOnly + ? "server read-only memory" : "server_memory", + &base, addressSpec, + B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA), serverArea); if (mapping->local_area < B_OK) { status = mapping->local_area; @@ -118,7 +119,8 @@ status_t -ServerMemoryAllocator::AreaAndBaseFor(area_id serverArea, area_id& _area, uint8*& _base) +ServerMemoryAllocator::AreaAndBaseFor(area_id serverArea, area_id& _area, + uint8*& _base) { for (int32 i = fAreas.CountItems(); i-- > 0;) { area_mapping* mapping = (area_mapping*)fAreas.ItemAt(i); Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2009-06-19 10:17:42 UTC (rev 31114) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2009-06-19 11:09:21 UTC (rev 31115) @@ -1632,7 +1632,7 @@ } status = insert_area(addressSpace, _virtualAddress, addressSpec, size, area); - if (status < B_OK) + if (status != B_OK) goto err2; // attach the cache to the area @@ -1741,7 +1741,7 @@ status_t status = insert_area(locker.AddressSpace(), _address, addressSpec, size, area); - if (status < B_OK) { + if (status != B_OK) { free(area); return status; } @@ -5907,8 +5907,7 @@ status_t -_user_reserve_heap_address_range(addr_t* userAddress, uint32 addressSpec, - addr_t size) +_user_reserve_address_range(addr_t* userAddress, uint32 addressSpec, addr_t size) { // filter out some unavailable values (for userland) switch (addressSpec) { @@ -5920,16 +5919,16 @@ addr_t address; if (!IS_USER_ADDRESS(userAddress) - || user_memcpy(&address, userAddress, sizeof(address)) < B_OK) + || user_memcpy(&address, userAddress, sizeof(address)) != B_OK) return B_BAD_ADDRESS; status_t status = vm_reserve_address_range( vm_current_user_address_space_id(), (void**)&address, addressSpec, size, RESERVED_AVOID_BASE); - if (status < B_OK) + if (status != B_OK) return status; - if (user_memcpy(userAddress, &address, sizeof(address)) < B_OK) { + if (user_memcpy(userAddress, &address, sizeof(address)) != B_OK) { vm_unreserve_address_range(vm_current_user_address_space_id(), (void*)address, size); return B_BAD_ADDRESS; @@ -5939,6 +5938,14 @@ } +status_t +_user_unreserve_address_range(addr_t address, addr_t size) +{ + return vm_unreserve_address_range(vm_current_user_address_space_id(), + (void*)address, size); +} + + area_id _user_area_for(void* address) { Modified: haiku/trunk/src/system/libroot/posix/malloc/arch-specific.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/malloc/arch-specific.cpp 2009-06-19 10:17:42 UTC (rev 31114) +++ haiku/trunk/src/system/libroot/posix/malloc/arch-specific.cpp 2009-06-19 11:09:21 UTC (rev 31115) @@ -88,7 +88,7 @@ // for it. They may get reclaimed by other areas, though, but the maximum // size of the heap is guaranteed until the space is really needed. sHeapBase = (void *)0x18000000; - status_t status = _kern_reserve_heap_address_range((addr_t *)&sHeapBase, + status_t status = _kern_reserve_address_range((addr_t *)&sHeapBase, B_EXACT_ADDRESS, 0x48000000); sHeapArea = create_area("heap", (void **)&sHeapBase, Modified: haiku/trunk/src/system/runtime_loader/images.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/images.cpp 2009-06-19 10:17:42 UTC (rev 31114) +++ haiku/trunk/src/system/runtime_loader/images.cpp 2009-06-19 11:09:21 UTC (rev 31115) @@ -154,6 +154,30 @@ } +/*! Finds the load address and address specifier of the given image region. +*/ +static void +get_image_region_load_address(image_t* image, uint32 index, int32 lastDelta, + bool fixed, addr_t& loadAddress, uint32& addressSpecifier) +{ + if (image->dynamic_ptr != 0 && !fixed) { + // relocatable image... we can afford to place wherever + if (index == 0) { + // but only the first segment gets a free ride + loadAddress = RLD_PROGRAM_BASE; + addressSpecifier = B_BASE_ADDRESS; + } else { + loadAddress = image->regions[index].vmstart + lastDelta; + addressSpecifier = B_EXACT_ADDRESS; + } + } else { + // not relocatable, put it where it asks or die trying + loadAddress = image->regions[index].vmstart; + addressSpecifier = B_EXACT_ADDRESS; + } +} + + // #pragma mark - @@ -260,74 +284,95 @@ else baseName = path; + // determine how much space we need for all loaded segments + + addr_t reservedAddress = 0; + addr_t loadAddress; + size_t reservedSize = 0; + size_t length = 0; + uint32 addressSpecifier = B_ANY_ADDRESS; + for (uint32 i = 0; i < image->num_regions; i++) { - char regionName[B_OS_NAME_LENGTH]; - addr_t loadAddress; - uint32 addressSpecifier; - // for BeOS compatibility: if we load an old BeOS executable, we // have to relocate it, if possible - we recognize it because the // vmstart is set to 0 (hopefully always) if (fixed && image->regions[i].vmstart == 0) fixed = false; + uint32 regionAddressSpecifier; + get_image_region_load_address(image, i, + loadAddress - image->regions[i - 1].vmstart, fixed, + loadAddress, regionAddressSpecifier); + if (i == 0) { + reservedAddress = loadAddress; + addressSpecifier = regionAddressSpecifier; + } + + length += TO_PAGE_SIZE(image->regions[i].vmsize + + (loadAddress % B_PAGE_SIZE)); + + size_t size = TO_PAGE_SIZE(loadAddress + image->regions[i].vmsize) + - reservedAddress; + if (size > reservedSize) + reservedSize = size; + } + + // Check whether the segments have an unreasonable amount of unused space + // inbetween. + if (reservedSize > length + 8 * 1024) + return B_BAD_DATA; + + // reserve that space and allocate the areas from that one + if (_kern_reserve_address_range(&reservedAddress, addressSpecifier, + reservedSize) != B_OK) + return B_NO_MEMORY; + + for (uint32 i = 0; i < image->num_regions; i++) { + char regionName[B_OS_NAME_LENGTH]; + snprintf(regionName, sizeof(regionName), "%s_seg%lu%s", baseName, i, (image->regions[i].flags & RFLAG_RW) ? "rw" : "ro"); - if (image->dynamic_ptr && !fixed) { - // relocatable image... we can afford to place wherever - if (i == 0) { - // but only the first segment gets a free ride - loadAddress = RLD_PROGRAM_BASE; - addressSpecifier = B_BASE_ADDRESS; - } else { - loadAddress = image->regions[i].vmstart - + image->regions[i-1].delta; - addressSpecifier = B_EXACT_ADDRESS; - } - } else { - // not relocatable, put it where it asks or die trying - loadAddress = image->regions[i].vmstart; - addressSpecifier = B_EXACT_ADDRESS; - } + get_image_region_load_address(image, i, image->regions[i - 1].delta, + fixed, loadAddress, addressSpecifier); - if (image->regions[i].flags & RFLAG_ANON) { + // If the image position is arbitrary, we must let it point to the start + // of the reserved address range. + if (addressSpecifier != B_EXACT_ADDRESS) + loadAddress = reservedAddress; + + if ((image->regions[i].flags & RFLAG_ANON) != 0) { image->regions[i].id = _kern_create_area(regionName, - (void**)&loadAddress, addressSpecifier, + (void**)&loadAddress, B_EXACT_ADDRESS, image->regions[i].vmsize, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); - if (image->regions[i].id < 0) + if (image->regions[i].id < 0) { + _kern_unreserve_address_range(reservedAddress, reservedSize); return image->regions[i].id; - - image->regions[i].delta = loadAddress - image->regions[i].vmstart; - image->regions[i].vmstart = loadAddress; + } } else { image->regions[i].id = _kern_map_file(regionName, - (void**)&loadAddress, addressSpecifier, + (void**)&loadAddress, B_EXACT_ADDRESS, image->regions[i].vmsize, B_READ_AREA | B_WRITE_AREA, REGION_PRIVATE_MAP, false, fd, PAGE_BASE(image->regions[i].fdstart)); - if (image->regions[i].id < 0) + if (image->regions[i].id < 0) { + _kern_unreserve_address_range(reservedAddress, reservedSize); return image->regions[i].id; + } TRACE(("\"%s\" at %p, 0x%lx bytes (%s)\n", path, (void *)loadAddress, image->regions[i].vmsize, image->regions[i].flags & RFLAG_RW ? "rw" : "read-only")); - image->regions[i].delta = loadAddress - image->regions[i].vmstart; - image->regions[i].vmstart = loadAddress; - // handle trailer bits in data segment if (image->regions[i].flags & RFLAG_RW) { - addr_t startClearing; - addr_t toClear; - - startClearing = image->regions[i].vmstart + addr_t startClearing = loadAddress + PAGE_OFFSET(image->regions[i].start) + image->regions[i].size; - toClear = image->regions[i].vmsize + addr_t toClear = image->regions[i].vmsize - PAGE_OFFSET(image->regions[i].start) - image->regions[i].size; @@ -336,9 +381,12 @@ memset((void *)startClearing, 0, toClear); } } + + image->regions[i].delta = loadAddress - image->regions[i].vmstart; + image->regions[i].vmstart = loadAddress; } - if (image->dynamic_ptr) + if (image->dynamic_ptr != 0) image->dynamic_ptr += image->regions[0].delta; return B_OK; From superstippi at gmx.de Fri Jun 19 14:58:55 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 19 Jun 2009 14:58:55 +0200 Subject: [Haiku-commits] r31115 - in haiku/trunk: headers/private/kernel headers/private/system src/kits/app src/system/kernel/vm src/system/libroot/posix/malloc src/system/runtime_loader In-Reply-To: <200906191109.n5JB9Nh3025466@sheep.berlios.de> References: <200906191109.n5JB9Nh3025466@sheep.berlios.de> Message-ID: <20090619145855.2336.1@bepc.1245415938.fake> On 2009-06-19 at 13:09:23 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2009-06-19 13:09:21 +0200 (Fri, 19 Jun 2009) New Revision: 31115 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31115&view=rev > > Modified: > haiku/trunk/headers/private/kernel/vm.h > haiku/trunk/headers/private/system/syscalls.h > haiku/trunk/src/kits/app/ServerMemoryAllocator.cpp > haiku/trunk/src/system/kernel/vm/vm.cpp > haiku/trunk/src/system/libroot/posix/malloc/arch-specific.cpp > haiku/trunk/src/system/runtime_loader/images.cpp > Log: > * Renamed _kern_reserve_heap_address_range() to > _kern_reserve_address_range(), > and added a _kern_unreserve_address_range() as well. > * The runtime loader now reserves the space needed for all its areas first > to make sure there is enough space left for all areas of a single image. > * This also fixes the final part of bug #4008. It doesn't seem to be the only thing this fixes, although it may still be one and the same bug. From my testing with Clockwerk, I could also reproduce a situation where decoder plug-ins for clips needed to be opened on program start up, since the playlist would open such that a clip would immediately need to be rendered on the canvas. These clips would often display black while a second instace of the clip later in the timeline would display correctly. From when I had all sorts of debugging output in libmedia.so, I could see that actual plug-in loading was were it failed for the first instance. This is no longer the case and clips seem to display reliably. It could also be that they failed to load because of the corruption. Great job, Axel, thanks a lot! Best regards, -Stephan From bonefish at mail.berlios.de Fri Jun 19 17:09:56 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 17:09:56 +0200 Subject: [Haiku-commits] r31116 - haiku/trunk/src/apps/debugger Message-ID: <200906191509.n5JF9um4003610@sheep.berlios.de> Author: bonefish Date: 2009-06-19 17:09:56 +0200 (Fri, 19 Jun 2009) New Revision: 31116 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31116&view=rev Added: haiku/trunk/src/apps/debugger/Jobs.cpp haiku/trunk/src/apps/debugger/Jobs.h haiku/trunk/src/apps/debugger/Worker.cpp haiku/trunk/src/apps/debugger/Worker.h Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h Log: * Implemented Worker class, which executes Jobs in a separate thread. * Implemented a job for getting a thread's CPU state. * The team debugger uses a worker now. ATM only for getting the CPU state for stopped threads. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 15:09:56 UTC (rev 31116) @@ -23,11 +23,13 @@ # ElfFile.cpp Image.cpp ImageInfo.cpp + Jobs.cpp Team.cpp TeamDebugger.cpp TeamDebugModel.cpp Thread.cpp ThreadInfo.cpp + Worker.cpp # arch Architecture.cpp Added: haiku/trunk/src/apps/debugger/Jobs.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-19 15:09:56 UTC (rev 31116) @@ -0,0 +1,54 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Jobs.h" + +#include + +#include "CpuState.h" +#include "DebuggerInterface.h" +#include "Team.h" +#include "Thread.h" + + +GetCpuStateJob::GetCpuStateJob(DebuggerInterface* debuggerInterface, + Thread* thread) + : + fDebuggerInterface(debuggerInterface), + fThread(thread) +{ + fThread->AddReference(); +} + + +GetCpuStateJob::~GetCpuStateJob() +{ + fThread->RemoveReference(); +} + + +JobKey +GetCpuStateJob::Key() const +{ + return JobKey(fThread, JOB_TYPE_GET_CPU_STATE); +} + + +status_t +GetCpuStateJob::Do() +{ + CpuState* state; + status_t error = fDebuggerInterface->GetCpuState(fThread->ID(), state); + if (error != B_OK) + return error; + Reference reference(state); + + AutoLocker locker(fThread->GetTeam()); + + if (fThread->State() == THREAD_STATE_STOPPED) + fThread->SetCpuState(state); + + return B_OK; +} Added: haiku/trunk/src/apps/debugger/Jobs.h =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.h 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/Jobs.h 2009-06-19 15:09:56 UTC (rev 31116) @@ -0,0 +1,37 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef JOBS_H +#define JOBS_H + +#include "Worker.h" + + +class DebuggerInterface; +class Thread; + + +// job types +enum { + JOB_TYPE_GET_CPU_STATE +}; + + +class GetCpuStateJob : public Job { +public: + GetCpuStateJob( + DebuggerInterface* debuggerInterface, + Thread* thread); + virtual ~GetCpuStateJob(); + + virtual JobKey Key() const; + virtual status_t Do(); + +private: + DebuggerInterface* fDebuggerInterface; + Thread* fThread; +}; + + +#endif // JOBS_H Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-19 15:09:56 UTC (rev 31116) @@ -17,6 +17,7 @@ #include "CpuState.h" #include "DebuggerInterface.h" +#include "Jobs.h" #include "MessageCodes.h" #include "Team.h" #include "TeamDebugModel.h" @@ -29,6 +30,7 @@ fDebugModel(NULL), fTeamID(-1), fDebuggerInterface(NULL), + fWorker(NULL), fDebugEventListener(-1), fTeamWindow(NULL), fTerminating(false) @@ -43,15 +45,17 @@ fTerminating = true; fDebuggerInterface->Close(); + fWorker->ShutDown(); locker.Unlock(); if (fDebugEventListener >= 0) wait_for_thread(fDebugEventListener, NULL); + delete fDebuggerInterface; + delete fWorker; delete fDebugModel; delete fTeam; - delete fDebuggerInterface; } @@ -86,6 +90,15 @@ if (error != B_OK) return error; + // create our worker + fWorker = new(std::nothrow) Worker; + if (fWorker == NULL) + return B_NO_MEMORY; + + error = fWorker->Init(); + if (error != B_OK) + return error; + // create debugger interface fDebuggerInterface = new(std::nothrow) DebuggerInterface(fTeamID); if (fDebuggerInterface == NULL) @@ -207,6 +220,27 @@ } +void +TeamDebugger::JobDone(Job* job) +{ +printf("TeamDebugger::JobDone(%p)\n", job); +} + + +void +TeamDebugger::JobFailed(Job* job) +{ +printf("TeamDebugger::JobFailed(%p)\n", job); +} + + +void +TeamDebugger::JobAborted(Job* job) +{ +printf("TeamDebugger::JobAborted(%p)\n", job); +} + + /*static*/ status_t TeamDebugger::_DebugEventListenerEntry(void* data) { @@ -335,15 +369,8 @@ if (thread == NULL) return false; - // update the thread state - thread->SetState(THREAD_STATE_STOPPED); + _SetThreadState(thread, THREAD_STATE_STOPPED, cpuState); - if (cpuState != NULL) { - thread->SetCpuState(cpuState); - } else { - // TODO: Trigger updating the CPU state! - } - return true; } @@ -435,22 +462,46 @@ void TeamDebugger::_UpdateThreadState(::Thread* thread) { - CpuState* state = NULL; - status_t error = fDebuggerInterface->GetCpuState(thread->ID(), state); + CpuState* cpuState = NULL; + status_t error = fDebuggerInterface->GetCpuState(thread->ID(), cpuState); uint32 newState = THREAD_STATE_UNKNOWN; if (error == B_OK) { newState = THREAD_STATE_STOPPED; - state->RemoveReference(); + cpuState->RemoveReference(); } else if (error == B_BAD_THREAD_STATE) newState = THREAD_STATE_RUNNING; - thread->SetState(newState); - thread->SetCpuState(state); + _SetThreadState(thread, newState, cpuState); } void +TeamDebugger::_SetThreadState(::Thread* thread, uint32 state, + CpuState* cpuState) +{ + // update the thread state + uint32 oldState = thread->State(); + thread->SetState(state); + + // cancel jobs for this thread + if (oldState == THREAD_STATE_STOPPED) + fWorker->AbortJob(JobKey(thread, JOB_TYPE_GET_CPU_STATE)); + + if (state == THREAD_STATE_STOPPED) { + if (cpuState != NULL) { + thread->SetCpuState(cpuState); + } else { + // trigger updating the CPU state + fWorker->ScheduleJob(new(std::nothrow) GetCpuStateJob( + fDebuggerInterface, thread), + this); + } + } +} + + +void TeamDebugger::_HandleThreadAction(thread_id threadID, uint32 action) { AutoLocker< ::Team> locker(fTeam); @@ -469,7 +520,7 @@ // When continuing the thread update thread state before actually issuing // the command, since we need to unlock. if (action != MSG_THREAD_STOP) - thread->SetState(THREAD_STATE_RUNNING); + _SetThreadState(thread, THREAD_STATE_RUNNING, NULL); locker.Unlock(); Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-19 15:09:56 UTC (rev 31116) @@ -13,6 +13,7 @@ #include "DebugEvent.h" #include "TeamWindow.h" +#include "Worker.h" class DebuggerInterface; @@ -21,7 +22,7 @@ class TeamDebugger : public DoublyLinkedListLinkImpl, - private BLooper, private TeamWindow::Listener { + private BLooper, private TeamWindow::Listener, private JobListener { public: TeamDebugger(); ~TeamDebugger(); @@ -39,6 +40,11 @@ thread_id threadID, uint32 action); virtual bool TeamWindowQuitRequested(TeamWindow* window); + // JobListener + virtual void JobDone(Job* job); + virtual void JobFailed(Job* job); + virtual void JobAborted(Job* job); + private: static status_t _DebugEventListenerEntry(void* data); status_t _DebugEventListener(); @@ -70,6 +76,8 @@ ImageDeletedEvent* event); void _UpdateThreadState(::Thread* thread); + void _SetThreadState(::Thread* thread, uint32 state, + CpuState* cpuState); void _HandleThreadAction(thread_id threadID, uint32 action); @@ -80,6 +88,7 @@ team_id fTeamID; port_id fNubPort; DebuggerInterface* fDebuggerInterface; + Worker* fWorker; thread_id fDebugEventListener; TeamWindow* fTeamWindow; volatile bool fTerminating; Added: haiku/trunk/src/apps/debugger/Worker.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Worker.cpp 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/Worker.cpp 2009-06-19 15:09:56 UTC (rev 31116) @@ -0,0 +1,443 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Worker.h" + +#include +#include + + +// #pragma mark - JobListener + + +JobListener::~JobListener() +{ +} + + +void +JobListener::JobDone(Job* job) +{ +} + + +void +JobListener::JobFailed(Job* job) +{ +} + + +void +JobListener::JobAborted(Job* job) +{ +} + + +// #pragma mark - Job + + +Job::Job() + : + fWorker(NULL), + fState(JOB_STATE_UNSCHEDULED), + fDependency(NULL), + fWaitStatus(JOB_DEPENDENCY_NOT_FOUND), + fListeners(10) +{ +} + + +Job::~Job() +{ +} + + +job_wait_status +Job::WaitFor(const JobKey& key) +{ + return fWorker->WaitForJob(this, key); +} + + +void +Job::SetWorker(Worker* worker) +{ + fWorker = worker; +} + + +void +Job::SetState(job_state state) +{ + fState = state; +} + + +void +Job::SetDependency(Job* job) +{ + fDependency = job; +} + + +void +Job::SetWaitStatus(job_wait_status status) +{ + fWaitStatus = status; +} + + +status_t +Job::AddListener(JobListener* listener) +{ + return fListeners.AddItem(listener) ? B_OK : B_NO_MEMORY; +} + + +void +Job::RemoveListener(JobListener* listener) +{ + fListeners.RemoveItem(listener); +} + + +void +Job::NotifyListeners() +{ + int32 count = fListeners.CountItems(); + for (int32 i = count - 1; i >= 0; i--) { + JobListener* listener = fListeners.ItemAt(i); + switch (fState) { + case JOB_STATE_SUCCEEDED: + listener->JobDone(this); + break; + case JOB_STATE_FAILED: + listener->JobFailed(this); + break; + case JOB_STATE_ABORTED: + default: + listener->JobAborted(this); + break; + } + } +} + + +// #pragma mark - Worker + + +Worker::Worker() + : + fLock("worker"), + fWorkerThread(-1), + fTerminating(false) +{ +} + + +Worker::~Worker() +{ + ShutDown(); + + if (fWorkerThread >= 0) + wait_for_thread(fWorkerThread, NULL); +} + + +status_t +Worker::Init() +{ + // check lock + status_t error = fLock.InitCheck(); + if (error != B_OK) + return error; + + // init jobs table + error = fJobs.Init(); + if (error != B_OK) + return error; + + // create semaphore for the worker + fWorkToDoSem = create_sem(0, "work to do"); + if (fWorkToDoSem < 0) + return fWorkToDoSem; + + // spawn worker thread + fWorkerThread = spawn_thread(_WorkerLoopEntry, "worker", B_NORMAL_PRIORITY, + this); + if (fWorkerThread < 0) + return fWorkerThread; + + resume_thread(fWorkerThread); + + return B_OK; +} + + +void +Worker::ShutDown() +{ + AutoLocker locker(this); + + if (fTerminating) + return; + + fTerminating = true; + + // abort all jobs + Job* job = fJobs.Clear(true); + while (job != NULL) { + Job* nextJob = static_cast*>(job)->fNext; + _AbortJob(job, false); + job = nextJob; + + } + + // let the work thread terminate + delete_sem(fWorkToDoSem); + fWorkToDoSem = -1; +} + + +status_t +Worker::ScheduleJob(Job* job, JobListener* listener) +{ + if (job == NULL) + return B_NO_MEMORY; + + ObjectDeleter jobDeleter(job); + AutoLocker locker(this); + + if (fTerminating) + return B_ERROR; + + if (listener != NULL) { + status_t error = job->AddListener(listener); + if (error != B_OK) + return error; + } + + bool notify = fUnscheduledJobs.IsEmpty() && fAbortedJobs.IsEmpty(); + + job->SetWorker(this); + job->SetState(JOB_STATE_UNSCHEDULED); + fJobs.Insert(job); + fUnscheduledJobs.Add(job); + jobDeleter.Detach(); + + if (notify) + release_sem(fWorkToDoSem); + + return B_OK; +} + + +void +Worker::AbortJob(const JobKey& key) +{ + AutoLocker locker(this); + + Job* job = fJobs.Lookup(key); + if (job == NULL) + return; + + _AbortJob(job, true); +} + + +status_t +Worker::AddListener(const JobKey& key, JobListener* listener) +{ + AutoLocker locker(this); + + Job* job = fJobs.Lookup(key); + if (job == NULL) + return B_ENTRY_NOT_FOUND; + + return job->AddListener(listener); +} + + +void +Worker::RemoveListener(const JobKey& key, JobListener* listener) +{ + AutoLocker locker(this); + + if (Job* job = fJobs.Lookup(key)) + job->RemoveListener(listener); +} + + +job_wait_status +Worker::WaitForJob(Job* waitingJob, const JobKey& key) +{ + AutoLocker locker(this); + + // don't wait when the game is over anyway + if (fTerminating || waitingJob->State() == JOB_STATE_ABORTED) + return JOB_DEPENDENCY_ABORTED; + + Job* job = fJobs.Lookup(key); + if (job == NULL) + return JOB_DEPENDENCY_NOT_FOUND; + + waitingJob->SetWaitStatus(JOB_DEPENDENCY_ACTIVE); + waitingJob->SetDependency(job); + job->DependentJobs().Add(waitingJob); + + // TODO: Continuations would be nice. For the time being we have to use + // recursion. Disadvantages are that we'll use more stack and that aborting + // a job waiting for a dependency won't abort the job before the dependency + // is done. + locker.Unlock(); + _ProcessJobs(job); + locker.Lock(); + + // ignore the actual wait status when the game is over anyway + if (fTerminating || waitingJob->State() == JOB_STATE_ABORTED) + return JOB_DEPENDENCY_ABORTED; + + return waitingJob->WaitStatus(); +} + + +/*static*/ status_t +Worker::_WorkerLoopEntry(void* data) +{ + return ((Worker*)data)->_WorkerLoop(); +} + + +status_t +Worker::_WorkerLoop() +{ + _ProcessJobs(NULL); + + // clean up aborted jobs + AutoLocker locker(this); + while (Job* job = fAbortedJobs.RemoveHead()) + _FinishJob(job); + + return B_OK; +} + + +void +Worker::_ProcessJobs(Job* finalJob) +{ + while (true) { + AutoLocker locker(this); + + // wait for next job + if (fUnscheduledJobs.IsEmpty() && fAbortedJobs.IsEmpty()) { + locker.Unlock(); + + status_t error = acquire_sem(fWorkToDoSem); + if (error != B_OK) { + if (error == B_INTERRUPTED) + continue; + break; + } + + locker.Lock(); + } + + // clean up aborted jobs + while (Job* job = fAbortedJobs.RemoveHead()) { + _FinishJob(job); + + if (job == finalJob) + break; + } + + // process the next job + if (Job* job = fUnscheduledJobs.RemoveHead()) { + job->SetState(JOB_STATE_ACTIVE); + + locker.Unlock(); + status_t error = job->Do(); + locker.Lock(); + + if (job->State() == JOB_STATE_ACTIVE) { + job->SetState( + error == B_OK ? JOB_STATE_SUCCEEDED : JOB_STATE_FAILED); + } + + _FinishJob(job); + + if (job == finalJob) + break; + } + } +} + + +void +Worker::_AbortJob(Job* job, bool removeFromTable) +{ + switch (job->State()) { + case JOB_STATE_ABORTED: + return; + + case JOB_STATE_UNSCHEDULED: + fUnscheduledJobs.Remove(job); + fAbortedJobs.Add(job); + break; + + case JOB_STATE_WAITING: + job->Dependency()->DependentJobs().Remove(job); + job->SetDependency(NULL); + break; + + case JOB_STATE_ACTIVE: + case JOB_STATE_FAILED: + case JOB_STATE_SUCCEEDED: + default: + break; + } + + job->SetState(JOB_STATE_ABORTED); + if (removeFromTable) + fJobs.Remove(job); +} + + +void +Worker::_FinishJob(Job* job) +{ + // wake up dependent jobs + if (!job->DependentJobs().IsEmpty()) { + job_wait_status waitStatus; + switch (job->State()) { + case JOB_STATE_ABORTED: + waitStatus = JOB_DEPENDENCY_ABORTED; + break; + case JOB_STATE_FAILED: + waitStatus = JOB_DEPENDENCY_FAILED; + break; + case JOB_STATE_SUCCEEDED: + waitStatus = JOB_DEPENDENCY_SUCCEEDED; + break; + + case JOB_STATE_UNSCHEDULED: + case JOB_STATE_WAITING: + case JOB_STATE_ACTIVE: + default: + // should never happen + waitStatus = JOB_DEPENDENCY_NOT_FOUND; + break; + } + + while (Job* dependentJob = job->DependentJobs().RemoveHead()) { + dependentJob->SetDependency(NULL); + dependentJob->SetWaitStatus(waitStatus); + } + } + + if (job->State() != JOB_STATE_ABORTED) + fJobs.Remove(job); + job->NotifyListeners(); + delete job; +} Added: haiku/trunk/src/apps/debugger/Worker.h =================================================================== --- haiku/trunk/src/apps/debugger/Worker.h 2009-06-19 11:09:21 UTC (rev 31115) +++ haiku/trunk/src/apps/debugger/Worker.h 2009-06-19 15:09:56 UTC (rev 31116) @@ -0,0 +1,206 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef WORKER_H +#define WORKER_H + +#include + +#include +#include +#include + + +class Job; +class Worker; + + +enum job_state { + JOB_STATE_UNSCHEDULED, + JOB_STATE_WAITING, + JOB_STATE_ACTIVE, + JOB_STATE_ABORTED, + JOB_STATE_FAILED, + JOB_STATE_SUCCEEDED +}; + +enum job_wait_status { + JOB_DEPENDENCY_NOT_FOUND, + JOB_DEPENDENCY_SUCCEEDED, + JOB_DEPENDENCY_FAILED, + JOB_DEPENDENCY_ABORTED, + JOB_DEPENDENCY_ACTIVE + // internal only +}; + + +struct JobKey { + void* object; + uint32 type; + + JobKey(void* object, uint32 type) + : + object(object), + type(type) + { + } + + JobKey(const JobKey& other) + : + object(other.object), + type(other.type) + { + } + + JobKey& operator=(const JobKey& other) + { + object = other.object; + type = other.type; + return *this; + } + + bool operator==(const JobKey& other) const + { + return object == other.object && type == other.type; + } + + size_t HashValue() const + { + return (size_t)(addr_t)object ^ (size_t)type; + } +}; + + +class JobListener { +public: + virtual ~JobListener(); + + virtual void JobDone(Job* job); + virtual void JobFailed(Job* job); + virtual void JobAborted(Job* job); +}; + + +typedef DoublyLinkedList JobList; + + +class Job : public DoublyLinkedListLinkImpl, public HashTableLink { +public: + Job(); + virtual ~Job(); + + virtual JobKey Key() const = 0; + virtual status_t Do() = 0; + + Worker* GetWorker() const { return fWorker; } + job_state State() const { return fState; } + +protected: + job_wait_status WaitFor(const JobKey& key); + +private: + friend class Worker; + +private: + void SetWorker(Worker* worker); + void SetState(job_state state); + + Job* Dependency() const { return fDependency; } + void SetDependency(Job* job); + + JobList& DependentJobs() { return fDependentJobs; } + + job_wait_status WaitStatus() const { return fWaitStatus; } + void SetWaitStatus(job_wait_status status); + + status_t AddListener(JobListener* listener); + void RemoveListener(JobListener* listener); + void NotifyListeners(); + +private: + typedef BObjectList ListenerList; + +private: + Worker* fWorker; + job_state fState; + Job* fDependency; + JobList fDependentJobs; + job_wait_status fWaitStatus; + ListenerList fListeners; +}; + + +class Worker { +public: + Worker(); + ~Worker(); + + status_t Init(); + void ShutDown(); + + bool Lock() { return fLock.Lock(); } + void Unlock() { fLock.Unlock(); } + + status_t ScheduleJob(Job* job, + JobListener* listener = NULL); + // always takes over ownership + void AbortJob(const JobKey& key); + + status_t AddListener(const JobKey& key, + JobListener* listener); + void RemoveListener(const JobKey& key, + JobListener* listener); + +private: + friend class Job; + + struct JobHashDefinition { + typedef JobKey KeyType; + typedef Job ValueType; + + size_t HashKey(const JobKey& key) const + { + return key.HashValue(); + } + + size_t Hash(Job* value) const + { + return HashKey(value->Key()); + } + + bool Compare(const JobKey& key, Job *value) const + { + return value->Key() == key; + } + + HashTableLink* GetLink(Job* value) const + { + return value; + } + }; + + typedef OpenHashTable JobTable; + +private: + job_wait_status WaitForJob(Job* waitingJob, const JobKey& key); + + static status_t _WorkerLoopEntry(void* data); + status_t _WorkerLoop(); + + void _ProcessJobs(Job* finalJob); + void _AbortJob(Job* job, bool removeFromTable); + void _FinishJob(Job* job); + +private: + BLocker fLock; + JobTable fJobs; + JobList fUnscheduledJobs; + JobList fAbortedJobs; + sem_id fWorkToDoSem; + thread_id fWorkerThread; + volatile bool fTerminating; +}; + + +#endif // WORKER_H From bonefish at mail.berlios.de Fri Jun 19 17:17:58 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 17:17:58 +0200 Subject: [Haiku-commits] r31117 - haiku/trunk/src/apps/debugger Message-ID: <200906191517.n5JFHwji005403@sheep.berlios.de> Author: bonefish Date: 2009-06-19 17:17:58 +0200 (Fri, 19 Jun 2009) New Revision: 31117 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31117&view=rev Modified: haiku/trunk/src/apps/debugger/TeamDebugModel.cpp haiku/trunk/src/apps/debugger/TeamDebugModel.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp Log: Added Architecture and DebuggerInterface to the TeamDebugModel. Modified: haiku/trunk/src/apps/debugger/TeamDebugModel.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugModel.cpp 2009-06-19 15:09:56 UTC (rev 31116) +++ haiku/trunk/src/apps/debugger/TeamDebugModel.cpp 2009-06-19 15:17:58 UTC (rev 31117) @@ -13,9 +13,12 @@ // #pragma mark - TeamDebugModel -TeamDebugModel::TeamDebugModel(Team* team) +TeamDebugModel::TeamDebugModel(Team* team, DebuggerInterface* debuggerInterface, + Architecture* architecture) : - fTeam(team) + fTeam(team), + fDebuggerInterface(debuggerInterface), + fArchitecture(architecture) { } Modified: haiku/trunk/src/apps/debugger/TeamDebugModel.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugModel.h 2009-06-19 15:09:56 UTC (rev 31116) +++ haiku/trunk/src/apps/debugger/TeamDebugModel.h 2009-06-19 15:17:58 UTC (rev 31117) @@ -14,13 +14,19 @@ //}; +class Architecture; +class DebuggerInterface; + + class TeamDebugModel { public: class Event; class Listener; public: - TeamDebugModel(Team* team); + TeamDebugModel(Team* team, + DebuggerInterface* debuggerInterface, + Architecture* architecture); ~TeamDebugModel(); status_t Init(); @@ -29,6 +35,10 @@ void Unlock() { fTeam->Unlock(); } Team* GetTeam() const { return fTeam; } + DebuggerInterface* GetDebuggerInterface() const + { return fDebuggerInterface; } + Architecture* GetArchitecture() const + { return fArchitecture; } void AddListener(Listener* listener); void RemoveListener(Listener* listener); @@ -38,6 +48,8 @@ private: Team* fTeam; + DebuggerInterface* fDebuggerInterface; + Architecture* fArchitecture; ListenerList fListeners; }; Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-19 15:09:56 UTC (rev 31116) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-19 15:17:58 UTC (rev 31117) @@ -81,15 +81,6 @@ fTeam->SetName(teamInfo.args); // TODO: Set a better name! - // create the team debug model - fDebugModel = new(std::nothrow) TeamDebugModel(fTeam); - if (fDebugModel == NULL) - return B_NO_MEMORY; - - error = fDebugModel->Init(); - if (error != B_OK) - return error; - // create our worker fWorker = new(std::nothrow) Worker; if (fWorker == NULL) @@ -108,6 +99,16 @@ if (error != B_OK) return error; + // create the team debug model + fDebugModel = new(std::nothrow) TeamDebugModel(fTeam, fDebuggerInterface, + fDebuggerInterface->GetArchitecture()); + if (fDebugModel == NULL) + return B_NO_MEMORY; + + error = fDebugModel->Init(); + if (error != B_OK) + return error; + // set team debugging flags fDebuggerInterface->SetTeamDebuggingFlags( B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_IMAGES); From bonefish at mail.berlios.de Fri Jun 19 17:28:01 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 17:28:01 +0200 Subject: [Haiku-commits] r31118 - in haiku/trunk: headers/os/interface src/apps/debugger/gui/team_window Message-ID: <200906191528.n5JFS19P006131@sheep.berlios.de> Author: bonefish Date: 2009-06-19 17:28:00 +0200 (Fri, 19 Jun 2009) New Revision: 31118 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31118&view=rev Modified: haiku/trunk/headers/os/interface/LayoutBuilder.h haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp Log: Added constructor versions of the Group and Grid layout builders that take a BWindow* parameter. They set the newly created layout on the window, which saves the API user to do that. Modified: haiku/trunk/headers/os/interface/LayoutBuilder.h =================================================================== --- haiku/trunk/headers/os/interface/LayoutBuilder.h 2009-06-19 15:17:58 UTC (rev 31117) +++ haiku/trunk/headers/os/interface/LayoutBuilder.h 2009-06-19 15:28:00 UTC (rev 31118) @@ -11,6 +11,7 @@ #include #include #include +#include namespace BLayoutBuilder { @@ -49,6 +50,9 @@ inline Group(enum orientation orientation = B_HORIZONTAL, float spacing = 0.0f); + inline Group(BWindow* window, + enum orientation orientation = B_HORIZONTAL, + float spacing = 0.0f); inline Group(BGroupLayout* layout); inline Group(BGroupView* view); @@ -95,6 +99,9 @@ public: inline Grid(float horizontalSpacing = 0.0f, float verticalSpacing = 0.0f); + inline Grid(BWindow* window, + float horizontalSpacing = 0.0f, + float verticalSpacing = 0.0f); inline Grid(BGridLayout* layout); inline Grid(BGridView* view); @@ -214,6 +221,16 @@ template +Group::Group(BWindow* window, enum orientation orientation, + float spacing) + : + fLayout((new BGroupView(orientation, spacing))->GroupLayout()) +{ + window->SetLayout(fLayout); +} + + +template Group::Group(BGroupLayout* layout) : fLayout(layout) @@ -393,6 +410,16 @@ template +Grid::Grid(BWindow* window, float horizontalSpacing, + float verticalSpacing) + : + fLayout((new BGridView(horizontalSpacing, verticalSpacing))->GridLayout()) +{ + window->SetLayout(fLayout); +} + + +template Grid::Grid(BGridLayout* layout) : fLayout(layout) Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-19 15:17:58 UTC (rev 31117) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-19 15:28:00 UTC (rev 31118) @@ -149,10 +149,7 @@ void TeamWindow::_Init() { - BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); - SetLayout(rootLayout); - - BLayoutBuilder::Group<>(rootLayout) + BLayoutBuilder::Group<>(this, B_VERTICAL) .AddSplit(B_VERTICAL, 3.0f) .Add(fTabView = new BTabView("tab view"), 0.4f) .AddGroup(B_VERTICAL, 4.0f) From philippe.houdoin at gmail.com Fri Jun 19 17:35:45 2009 From: philippe.houdoin at gmail.com (Philippe Houdoin) Date: Fri, 19 Jun 2009 17:35:45 +0200 Subject: [Haiku-commits] r31111 - haiku/trunk/build/jam Message-ID: Hi Ingo, >> # library symlinks >> local lib ; >> - for lib in $(SYSTEM_LIBS) libglut.so { >> + for lib in $(SYSTEM_LIBS) $(SYSTEM_LIBS_ALIASES) { >> AddSymlinkToHaikuHybridImage $(abiDirTokens) lib >> : /system/lib $(lib:BS) : : true ; >> } > > At least the libnetwork aliases are not supposed to be there. Not sure about > the others. I wasn't sure either. I guess only the official Haiku libraries should be there, right, not the ones that are workarounds for binary/backward compatibility issues which will goes away in a future release after R1 ? libglut.so is a new official one under Haiku, while libGLU.so was already built-in into libGL.so, as we still do. The issue is do we split them ins three images to avoid aliases except for backward compatibilty, or do we offer the easiest road for GLUT & GLU-based apps porters? I'm for make libglut.so and libGLU.so libraries officially supported by Haiku directly under these names. If aliasing libGL.so to accomplish that is considered too hack-ish, I'll extract from libGL.these two libraries and make them actual ones, not aliases. Bye. Philippe. From bonefish at mail.berlios.de Fri Jun 19 19:27:01 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 19:27:01 +0200 Subject: [Haiku-commits] r31119 - haiku/trunk/src/apps/debuganalyzer/util Message-ID: <200906191727.n5JHR1uT003857@sheep.berlios.de> Author: bonefish Date: 2009-06-19 19:26:59 +0200 (Fri, 19 Jun 2009) New Revision: 31119 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31119&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/util/Variant.cpp haiku/trunk/src/apps/debuganalyzer/util/Variant.h Log: Added Is{Number,Integer,Float}() methods. Modified: haiku/trunk/src/apps/debuganalyzer/util/Variant.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/util/Variant.cpp 2009-06-19 15:28:00 UTC (rev 31118) +++ haiku/trunk/src/apps/debuganalyzer/util/Variant.cpp 2009-06-19 17:26:59 UTC (rev 31119) @@ -64,6 +64,59 @@ } +bool +Variant::IsNumber() const +{ + switch (fType) { + case B_INT8_TYPE: + case B_UINT8_TYPE: + case B_INT16_TYPE: + case B_UINT16_TYPE: + case B_INT32_TYPE: + case B_UINT32_TYPE: + case B_INT64_TYPE: + case B_UINT64_TYPE: + case B_FLOAT_TYPE: + case B_DOUBLE_TYPE: + return true; + default: + return false; + } +} + + +bool +Variant::IsInteger() const +{ + switch (fType) { + case B_INT8_TYPE: + case B_UINT8_TYPE: + case B_INT16_TYPE: + case B_UINT16_TYPE: + case B_INT32_TYPE: + case B_UINT32_TYPE: + case B_INT64_TYPE: + case B_UINT64_TYPE: + return true; + default: + return false; + } +} + + +bool +Variant::IsFloat() const +{ + switch (fType) { + case B_FLOAT_TYPE: + case B_DOUBLE_TYPE: + return true; + default: + return false; + } +} + + int8 Variant::ToInt8() const { Modified: haiku/trunk/src/apps/debuganalyzer/util/Variant.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/util/Variant.h 2009-06-19 15:28:00 UTC (rev 31118) +++ haiku/trunk/src/apps/debuganalyzer/util/Variant.h 2009-06-19 17:26:59 UTC (rev 31119) @@ -55,6 +55,11 @@ type_code Type() const { return fType; } + bool IsNumber() const; + bool IsInteger() const; + bool IsFloat() const; + // floating point, not just float + int8 ToInt8() const; uint8 ToUInt8() const; int16 ToInt16() const; From bonefish at mail.berlios.de Fri Jun 19 19:28:35 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 19:28:35 +0200 Subject: [Haiku-commits] r31120 - haiku/trunk/src/apps/debuganalyzer/gui/table Message-ID: <200906191728.n5JHSZhw005775@sheep.berlios.de> Author: bonefish Date: 2009-06-19 19:28:33 +0200 (Fri, 19 Jun 2009) New Revision: 31120 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31120&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h Log: Added missing TableRowsChanged() to TableModelListener and made Table handle it, too. Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-19 17:26:59 UTC (rev 31119) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-19 17:28:33 UTC (rev 31120) @@ -51,6 +51,13 @@ } +void +TableModelListener::TableRowsChanged(TableModel* model, int32 rowIndex, + int32 count) +{ +} + + // #pragma mark - TableModel @@ -93,6 +100,16 @@ } +void +TableModel::NotifyRowsChanged(int32 rowIndex, int32 count) +{ + for (ListenerList::Iterator it = fListeners.GetIterator(); + TableModelListener* listener = it.Next();) { + listener->TableRowsChanged(this, rowIndex, count); + } +} + + // #pragma mark - TableSelectionModel TableSelectionModel::TableSelectionModel(Table* table) @@ -497,6 +514,17 @@ void +Table::TableRowsChanged(TableModel* model, int32 rowIndex, int32 count) +{ + int32 endIndex = rowIndex + count; + for (int32 i = rowIndex; i < endIndex; i++) { + if (BRow* row = fRows.ItemAt(i)) + UpdateRow(row); + } +} + + +void Table::ItemInvoked() { if (fListeners.IsEmpty()) Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-19 17:26:59 UTC (rev 31119) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-19 17:28:33 UTC (rev 31120) @@ -28,6 +28,8 @@ int32 rowIndex, int32 count); virtual void TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count); + virtual void TableRowsChanged(TableModel* model, + int32 rowIndex, int32 count); }; @@ -49,6 +51,7 @@ protected: void NotifyRowsAdded(int32 rowIndex, int32 count); void NotifyRowsRemoved(int32 rowIndex, int32 count); + void NotifyRowsChanged(int32 rowIndex, int32 count); protected: ListenerList fListeners; @@ -118,6 +121,8 @@ int32 rowIndex, int32 count); virtual void TableRowsRemoved(TableModel* model, int32 rowIndex, int32 count); + virtual void TableRowsChanged(TableModel* model, + int32 rowIndex, int32 count); private: class Column; From bonefish at mail.berlios.de Fri Jun 19 19:29:39 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 19:29:39 +0200 Subject: [Haiku-commits] r31121 - haiku/trunk/src/apps/debugger Message-ID: <200906191729.n5JHTdYC007578@sheep.berlios.de> Author: bonefish Date: 2009-06-19 19:29:39 +0200 (Fri, 19 Jun 2009) New Revision: 31121 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31121&view=rev Modified: haiku/trunk/src/apps/debugger/Jobs.cpp Log: We already have a reference and want to get rid of it. Modified: haiku/trunk/src/apps/debugger/Jobs.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-19 17:28:33 UTC (rev 31120) +++ haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-19 17:29:39 UTC (rev 31121) @@ -43,7 +43,7 @@ status_t error = fDebuggerInterface->GetCpuState(fThread->ID(), state); if (error != B_OK) return error; - Reference reference(state); + Reference reference(state, true); AutoLocker locker(fThread->GetTeam()); From bonefish at mail.berlios.de Fri Jun 19 19:31:25 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 19:31:25 +0200 Subject: [Haiku-commits] r31122 - haiku/trunk/src/apps/debugger/gui/team_window Message-ID: <200906191731.n5JHVPgW009958@sheep.berlios.de> Author: bonefish Date: 2009-06-19 19:31:24 +0200 (Fri, 19 Jun 2009) New Revision: 31122 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31122&view=rev Added: haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.h Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h Log: Added view to show registers. Doesn't look particularly nice, but seems to work. Added: haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp 2009-06-19 17:29:39 UTC (rev 31121) +++ haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp 2009-06-19 17:31:24 UTC (rev 31122) @@ -0,0 +1,248 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "RegisterView.h" + +#include + +#include + +#include "table/TableColumns.h" + +#include "Architecture.h" +#include "CpuState.h" +#include "Register.h" + + +// #pragma mark - RegisterValueColumn + + +class RegisterView::RegisterValueColumn : public StringTableColumn { +public: + RegisterValueColumn(int32 modelIndex, const char* title, float width, + float minWidth, float maxWidth, uint32 truncate = B_TRUNCATE_MIDDLE, + alignment align = B_ALIGN_RIGHT) + : + StringTableColumn(modelIndex, title, width, minWidth, maxWidth, + truncate, align) + { + } + +protected: + virtual BField* PrepareField(const Variant& value) const + { + char buffer[64]; + return StringTableColumn::PrepareField( + Variant(_ToString(value, buffer, sizeof(buffer)), + VARIANT_DONT_COPY_DATA)); + } + + virtual int CompareValues(const Variant& a, const Variant& b) + { + // If neither value is a number, compare the strings. If only one value + // is a number, it is considered to be greater. + if (!a.IsNumber()) { + if (b.IsNumber()) + return -1; + char bufferA[64]; + char bufferB[64]; + return StringTableColumn::CompareValues( + Variant(_ToString(a, bufferA, sizeof(bufferA)), + VARIANT_DONT_COPY_DATA), + Variant(_ToString(b, bufferB, sizeof(bufferB)), + VARIANT_DONT_COPY_DATA)); + } + + if (!b.IsNumber()) + return 1; + + // If either value is floating point, we compare floating point values. + if (a.IsFloat() || b.IsFloat()) { + double valueA = a.ToDouble(); + double valueB = b.ToDouble(); + return valueA < valueB ? -1 : (valueA == valueB ? 0 : 1); + } + + uint64 valueA = a.ToUInt64(); + uint64 valueB = b.ToUInt64(); + return valueA < valueB ? -1 : (valueA == valueB ? 0 : 1); + } + +private: + const char* _ToString(const Variant& value, char* buffer, + size_t bufferSize) const + { + if (!value.IsNumber()) + return value.ToString(); + + switch (value.Type()) { + case B_FLOAT_TYPE: + case B_DOUBLE_TYPE: + snprintf(buffer, bufferSize, "%g", value.ToDouble()); + break; + case B_INT8_TYPE: + case B_UINT8_TYPE: + snprintf(buffer, bufferSize, "0x%02x", value.ToUInt8()); + break; + case B_INT16_TYPE: + case B_UINT16_TYPE: + snprintf(buffer, bufferSize, "0x%04x", value.ToUInt16()); + break; + case B_INT32_TYPE: + case B_UINT32_TYPE: + snprintf(buffer, bufferSize, "0x%08lx", value.ToUInt32()); + break; + case B_INT64_TYPE: + case B_UINT64_TYPE: + default: + snprintf(buffer, bufferSize, "0x%016llx", value.ToUInt64()); + break; + } + + return buffer; + } +}; + + +// #pragma mark - RegisterTableModel + + +class RegisterView::RegisterTableModel : public TableModel { +public: + RegisterTableModel(Architecture* architecture) + : + fArchitecture(architecture), + fCpuState(NULL) + { + } + + ~RegisterTableModel() + { + } + + void SetCpuState(CpuState* cpuState) + { + fCpuState = cpuState; + + NotifyRowsChanged(0, CountRows()); + } + + virtual int32 CountColumns() const + { + return 2; + } + + virtual int32 CountRows() const + { + return fArchitecture->CountRegisters(); + } + + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + { + if (rowIndex < 0 || rowIndex >= fArchitecture->CountRegisters()) + return false; + + const Register* reg = fArchitecture->Registers() + rowIndex; + + switch (columnIndex) { + case 0: + value.SetTo(reg->Name(), VARIANT_DONT_COPY_DATA); + return true; + case 1: + if (fCpuState == NULL) + return false; + if (!fCpuState->GetRegisterValue(reg, value)) + value.SetTo("?", VARIANT_DONT_COPY_DATA); + return true; + default: + return false; + } + } + +private: + Architecture* fArchitecture; + CpuState* fCpuState; +}; + + +// #pragma mark - RegisterView + + +RegisterView::RegisterView(Architecture* architecture) + : + BGroupView(B_VERTICAL), + fArchitecture(architecture), + fRegisterTable(NULL), + fRegisterTableModel(NULL) +{ + SetName("Registers"); +} + + +RegisterView::~RegisterView() +{ + SetCpuState(NULL); + fRegisterTable->SetTableModel(NULL); + delete fRegisterTableModel; +} + + +/*static*/ RegisterView* +RegisterView::Create(Architecture* architecture) +{ + RegisterView* self = new RegisterView(architecture); + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; +} + + +void +RegisterView::SetCpuState(CpuState* cpuState) +{ + if (cpuState == fCpuState) + return; + + if (fCpuState != NULL) + fCpuState->RemoveReference(); + + fCpuState = cpuState; + + if (fCpuState != NULL) + fCpuState->AddReference(); + + fRegisterTableModel->SetCpuState(fCpuState); +} + + +void +RegisterView::TableRowInvoked(Table* table, int32 rowIndex) +{ +} + + +void +RegisterView::_Init() +{ + fRegisterTable = new Table("register list", 0); + AddChild(fRegisterTable->ToView()); + + // columns + fRegisterTable->AddColumn(new StringTableColumn(0, "Register", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_LEFT)); + fRegisterTable->AddColumn(new RegisterValueColumn(1, "Value", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_RIGHT)); + + fRegisterTableModel = new RegisterTableModel(fArchitecture); + fRegisterTable->SetTableModel(fRegisterTableModel); + + fRegisterTable->AddTableListener(this); +} Added: haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.h 2009-06-19 17:29:39 UTC (rev 31121) +++ haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.h 2009-06-19 17:31:24 UTC (rev 31122) @@ -0,0 +1,45 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef REGISTER_VIEW_H +#define REGISTER_VIEW_H + +#include + +#include "table/Table.h" +#include "Team.h" + + +class Architecture; + + +class RegisterView : public BGroupView, private TableListener { +public: + RegisterView(Architecture* architecture); + ~RegisterView(); + + static RegisterView* Create(Architecture* architecture); + // throws + + void SetCpuState(CpuState* cpuState); + +private: + class RegisterValueColumn; + class RegisterTableModel; + +private: + // TableListener + virtual void TableRowInvoked(Table* table, int32 rowIndex); + + void _Init(); + +private: + Architecture* fArchitecture; + CpuState* fCpuState; + Table* fRegisterTable; + RegisterTableModel* fRegisterTableModel; +}; + + +#endif // REGISTER_VIEW_H Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-19 17:29:39 UTC (rev 31121) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-19 17:31:24 UTC (rev 31122) @@ -16,8 +16,10 @@ #include +#include "CpuState.h" #include "ImageListView.h" #include "MessageCodes.h" +#include "RegisterView.h" #include "TeamDebugModel.h" @@ -32,8 +34,10 @@ fActiveThread(NULL), fListener(listener), fTabView(NULL), + fLocalsTabView(NULL), fThreadListView(NULL), fImageListView(NULL), + fRegisterView(NULL), fRunButton(NULL), fStepOverButton(NULL), fStepIntoButton(NULL), @@ -95,7 +99,16 @@ _HandleThreadStateChanged(threadID); break; } -// case MSG_THREAD_CPU_STATE_CHANGED: + case MSG_THREAD_CPU_STATE_CHANGED: + { + int32 threadID; + if (message->FindInt32("thread", &threadID) != B_OK) + break; + + _HandleCpuStateChanged(threadID); + break; + } + // case MSG_THREAD_STACK_TRACE_CHANGED: default: @@ -131,18 +144,18 @@ void TeamWindow::ThreadCpuStateChanged(const Team::ThreadEvent& event) { -// BMessage message(MSG_THREAD_CPU_STATE_CHANGED); -// message.AddInt32("thread", event.GetThread()->ID()); -// PostMessage(&message); + BMessage message(MSG_THREAD_CPU_STATE_CHANGED); + message.AddInt32("thread", event.GetThread()->ID()); + PostMessage(&message); } void TeamWindow::ThreadStackTraceChanged(const Team::ThreadEvent& event) { -// BMessage message(MSG_THREAD_STACK_TRACE_CHANGED); -// message.AddInt32("thread", event.GetThread()->ID()); -// PostMessage(&message); + BMessage message(MSG_THREAD_STACK_TRACE_CHANGED); + message.AddInt32("thread", event.GetThread()->ID()); + PostMessage(&message); } @@ -162,7 +175,7 @@ .End() .AddSplit(B_HORIZONTAL, 3.0f) .Add(new BTextView("source view"), 3.0f) - .Add(new BTextView("variables view")) + .Add(fLocalsTabView = new BTabView("locals view")) .End() .End() .End(); @@ -183,6 +196,14 @@ .Add(fImageListView = ImageListView::Create()) .Add(new BTextView("source files")); + // add local variables tab + BView* tab = new BTextView("Variables"); + fLocalsTabView->AddTab(tab); + + // add registers tab + tab = fRegisterView = RegisterView::Create(fDebugModel->GetArchitecture()); + fLocalsTabView->AddTab(tab); + fThreadListView->SetTeam(fDebugModel->GetTeam()); fImageListView->SetTeam(fDebugModel->GetTeam()); @@ -210,6 +231,15 @@ AutoLocker locker(fDebugModel); _UpdateRunButtons(); + + CpuState* cpuState = fActiveThread != NULL + ? fActiveThread->GetCpuState() : NULL; + Reference reference(cpuState); + // hold a reference until the register view has one + + locker.Unlock(); + + fRegisterView->SetCpuState(cpuState); } @@ -258,6 +288,26 @@ } +void +TeamWindow::_HandleCpuStateChanged(thread_id threadID) +{ + // We're only interested in the currently selected thread + if (fActiveThread == NULL || threadID != fActiveThread->ID()) + return; + + AutoLocker locker(fDebugModel); + + CpuState* cpuState = fActiveThread != NULL + ? fActiveThread->GetCpuState() : NULL; + Reference reference(cpuState); + // hold a reference until the register view has one + + locker.Unlock(); + + fRegisterView->SetCpuState(cpuState); +} + + // #pragma mark - Listener Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-19 17:29:39 UTC (rev 31121) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-19 17:31:24 UTC (rev 31122) @@ -15,6 +15,7 @@ class BButton; class BTabView; class ImageListView; +class RegisterView; class TeamDebugModel; @@ -53,14 +54,17 @@ void _UpdateRunButtons(); void _HandleThreadStateChanged(thread_id threadID); + void _HandleCpuStateChanged(thread_id threadID); private: TeamDebugModel* fDebugModel; ::Thread* fActiveThread; Listener* fListener; BTabView* fTabView; + BTabView* fLocalsTabView; ThreadListView* fThreadListView; ImageListView* fImageListView; + RegisterView* fRegisterView; BButton* fRunButton; BButton* fStepOverButton; BButton* fStepIntoButton; From bonefish at mail.berlios.de Fri Jun 19 23:54:48 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 23:54:48 +0200 Subject: [Haiku-commits] r31123 - haiku/trunk/src/apps/debuganalyzer/gui/table Message-ID: <200906192154.n5JLsmAY020177@sheep.berlios.de> Author: bonefish Date: 2009-06-19 23:54:48 +0200 (Fri, 19 Jun 2009) New Revision: 31123 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31123&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h Log: Use a BObjectList instead of a DoublyLinkedList for the TableModelListeners. Otherwise we can't add a listener to more than one model. Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-19 17:31:24 UTC (rev 31122) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-19 21:54:48 UTC (rev 31123) @@ -66,25 +66,26 @@ } -void +bool TableModel::AddListener(TableModelListener* listener) { - fListeners.Add(listener); + return fListeners.AddItem(listener); } void TableModel::RemoveListener(TableModelListener* listener) { - fListeners.Remove(listener); + fListeners.RemoveItem(listener); } void TableModel::NotifyRowsAdded(int32 rowIndex, int32 count) { - for (ListenerList::Iterator it = fListeners.GetIterator(); - TableModelListener* listener = it.Next();) { + int32 listenerCount = fListeners.CountItems(); + for (int32 i = listenerCount - 1; i >= 0; i--) { + TableModelListener* listener = fListeners.ItemAt(i); listener->TableRowsAdded(this, rowIndex, count); } } @@ -93,8 +94,9 @@ void TableModel::NotifyRowsRemoved(int32 rowIndex, int32 count) { - for (ListenerList::Iterator it = fListeners.GetIterator(); - TableModelListener* listener = it.Next();) { + int32 listenerCount = fListeners.CountItems(); + for (int32 i = listenerCount - 1; i >= 0; i--) { + TableModelListener* listener = fListeners.ItemAt(i); listener->TableRowsRemoved(this, rowIndex, count); } } @@ -103,8 +105,9 @@ void TableModel::NotifyRowsChanged(int32 rowIndex, int32 count) { - for (ListenerList::Iterator it = fListeners.GetIterator(); - TableModelListener* listener = it.Next();) { + int32 listenerCount = fListeners.CountItems(); + for (int32 i = listenerCount - 1; i >= 0; i--) { + TableModelListener* listener = fListeners.ItemAt(i); listener->TableRowsChanged(this, rowIndex, count); } } Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-19 17:31:24 UTC (rev 31122) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-19 21:54:48 UTC (rev 31123) @@ -20,7 +20,7 @@ class TableModel; -class TableModelListener : public DoublyLinkedListLinkImpl { +class TableModelListener { public: virtual ~TableModelListener(); @@ -42,11 +42,11 @@ virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) = 0; - virtual void AddListener(TableModelListener* listener); + virtual bool AddListener(TableModelListener* listener); virtual void RemoveListener(TableModelListener* listener); protected: - typedef DoublyLinkedList ListenerList; + typedef BObjectList ListenerList; protected: void NotifyRowsAdded(int32 rowIndex, int32 count); From bonefish at mail.berlios.de Fri Jun 19 23:56:08 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 23:56:08 +0200 Subject: [Haiku-commits] r31124 - haiku/trunk/src/apps/debuganalyzer/gui/table Message-ID: <200906192156.n5JLu8Wj020336@sheep.berlios.de> Author: bonefish Date: 2009-06-19 23:56:08 +0200 (Fri, 19 Jun 2009) New Revision: 31124 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31124&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h Log: Added the sorting column related methods. Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp 2009-06-19 21:54:48 UTC (rev 31123) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.cpp 2009-06-19 21:56:08 UTC (rev 31124) @@ -103,3 +103,44 @@ { BColumnListView::DeselectAll(); } + + +void +AbstractTable::SetSortingEnabled(bool enabled) +{ + BColumnListView::SetSortingEnabled(enabled); +} + + +bool +AbstractTable::SortingEnabled() const +{ + return BColumnListView::SortingEnabled(); +} + + +void +AbstractTable::SetSortColumn(TableColumn* column, bool add, bool ascending) +{ + if (AbstractColumn* privateColumn = GetColumn(column)) + BColumnListView::SetSortColumn(privateColumn, add, ascending); +} + + +void +AbstractTable::ClearSortColumns() +{ + BColumnListView::ClearSortColumns(); +} + + +AbstractTable::AbstractColumn* +AbstractTable::GetColumn(TableColumn* column) const +{ + for (int32 i = 0; AbstractColumn* privateColumn = fColumns.ItemAt(i); i++) { + if (privateColumn->GetTableColumn() == column) + return privateColumn; + } + + return NULL; +} Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-19 21:54:48 UTC (rev 31123) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-19 21:56:08 UTC (rev 31124) @@ -37,6 +37,12 @@ void SetSelectionMode(list_view_type type); void DeselectAll(); + void SetSortingEnabled(bool enabled); + bool SortingEnabled() const; + void SetSortColumn(TableColumn* column, bool add, + bool ascending); + void ClearSortColumns(); + protected: class AbstractColumn; @@ -45,6 +51,8 @@ protected: virtual AbstractColumn* CreateColumn(TableColumn* column) = 0; + AbstractColumn* GetColumn(TableColumn* column) const; + protected: ColumnList fColumns; }; From bonefish at mail.berlios.de Fri Jun 19 23:58:48 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 19 Jun 2009 23:58:48 +0200 Subject: [Haiku-commits] r31125 - haiku/trunk/src/apps/debugger/debugger_interface Message-ID: <200906192158.n5JLwmVm020564@sheep.berlios.de> Author: bonefish Date: 2009-06-19 23:58:48 +0200 (Fri, 19 Jun 2009) New Revision: 31125 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31125&view=rev Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h Log: Added ReadMemory(). Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-19 21:56:08 UTC (rev 31124) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp 2009-06-19 21:58:48 UTC (rev 31125) @@ -434,6 +434,16 @@ } +ssize_t +DebuggerInterface::ReadMemory(target_addr_t address, void* buffer, size_t size) +{ + DebugContextGetter contextGetter(fDebugContextPool); + + return debug_read_memory(contextGetter.Context(), + (const void*)(addr_t)address, buffer, size); +} + + status_t DebuggerInterface::_CreateDebugEvent(int32 messageCode, const debug_debugger_message_data& message, bool& _ignore, Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-19 21:56:08 UTC (rev 31124) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-19 21:58:48 UTC (rev 31125) @@ -10,7 +10,9 @@ #include #include +#include "ArchitectureTypes.h" + class Architecture; class CpuState; class DebugEvent; @@ -46,6 +48,9 @@ CpuState*& _state); // returns a reference to the caller + ssize_t ReadMemory(target_addr_t address, void* buffer, + size_t size); + private: struct DebugContext; struct DebugContextPool; From bonefish at mail.berlios.de Sat Jun 20 00:13:33 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 00:13:33 +0200 Subject: [Haiku-commits] r31126 - in haiku/trunk/src/apps/debugger: . arch arch/x86 gui/team_window Message-ID: <200906192213.n5JMDXMc022469@sheep.berlios.de> Author: bonefish Date: 2009-06-20 00:13:32 +0200 (Sat, 20 Jun 2009) New Revision: 31126 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31126&view=rev Added: haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.cpp haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.h haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h Modified: haiku/trunk/src/apps/debugger/Debugger.cpp haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/Jobs.cpp haiku/trunk/src/apps/debugger/Jobs.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h haiku/trunk/src/apps/debugger/arch/Architecture.h haiku/trunk/src/apps/debugger/arch/Register.h haiku/trunk/src/apps/debugger/arch/StackFrame.h haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h Log: Some work towards getting stack traces: * Added a virtual Architecture::CreateStackTrace() and added a basic implementation in ArchitectureX86. Fleshed out StackTrace/StackFrame a bit and added StackFrameX86. This needs to be organized differently, though, so that we can get the maximum available information for each stack frame, depending on what info is available for the respective function. * Added job to get the stack trace for a thread. * Added stack trace related handling in TeamDebugger. Reorganized the thread state/CPU state/stack trace change handling a bit -- we're using a Team::Listener now, and do things asynchronously. * Added a StackTraceView to display the stack trace of the current thread. No function name available yet, otherwise working fine. Modified: haiku/trunk/src/apps/debugger/Debugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Debugger.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/Debugger.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -13,6 +13,8 @@ #include #include +#include + #include "debug_utils.h" #include "TeamDebugger.h" @@ -216,7 +218,7 @@ stopInMain = true; } - // If we've got + // If we've got if (team < 0) { printf("no team yet, getting thread info...\n"); thread_info threadInfo; @@ -245,12 +247,10 @@ fprintf(stderr, "Error: Out of memory!\n"); } - if (debugger->Init(team, thread, stopInMain) == B_OK) -{ + if (debugger->Init(team, thread, stopInMain) == B_OK + && fTeamDebuggers.AddItem(debugger)) { printf("debugger for team %ld created and initialized successfully!\n", team); - fTeamDebuggers.Add(debugger); -} - else + } else delete debugger; } @@ -261,13 +261,13 @@ } private: - typedef DoublyLinkedList TeamDebuggerList; + typedef BObjectList TeamDebuggerList; private: TeamDebugger* _TeamDebuggerForTeam(team_id teamID) const { - for (TeamDebuggerList::ConstIterator it = fTeamDebuggers.GetIterator(); - TeamDebugger* debugger = it.Next();) { + for (int32 i = 0; TeamDebugger* debugger = fTeamDebuggers.ItemAt(i); + i++) { if (debugger->TeamID() == teamID) return debugger; } Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 22:13:32 UTC (rev 31126) @@ -41,6 +41,7 @@ # arch/x86 ArchitectureX86.cpp CpuStateX86.cpp + StackFrameX86.cpp # debugger_interface DebugEvent.cpp @@ -48,6 +49,8 @@ # gui/team_window ImageListView.cpp + RegisterView.cpp + StackTraceView.cpp TeamWindow.cpp ThreadListView.cpp Modified: haiku/trunk/src/apps/debugger/Jobs.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -7,12 +7,17 @@ #include +#include "Architecture.h" #include "CpuState.h" #include "DebuggerInterface.h" +#include "StackTrace.h" #include "Team.h" #include "Thread.h" +// #pragma mark - GetCpuStateJob + + GetCpuStateJob::GetCpuStateJob(DebuggerInterface* debuggerInterface, Thread* thread) : @@ -52,3 +57,61 @@ return B_OK; } + + +// #pragma mark - GetStackTraceJob + + +GetStackTraceJob::GetStackTraceJob(DebuggerInterface* debuggerInterface, + Architecture* architecture, Thread* thread) + : + fDebuggerInterface(debuggerInterface), + fArchitecture(architecture), + fThread(thread) +{ + fThread->AddReference(); + + fCpuState = fThread->GetCpuState(); + if (fCpuState != NULL) + fCpuState->AddReference(); +} + + +GetStackTraceJob::~GetStackTraceJob() +{ + if (fCpuState != NULL) + fCpuState->RemoveReference(); + + fThread->RemoveReference(); +} + + +JobKey +GetStackTraceJob::Key() const +{ + return JobKey(fThread, JOB_TYPE_GET_CPU_STATE); +} + + +status_t +GetStackTraceJob::Do() +{ + if (fCpuState == NULL) + return B_BAD_VALUE; + + // get the stack trace + StackTrace* stackTrace; + status_t error = fArchitecture->CreateStackTrace(fThread->GetTeam(), + fCpuState, stackTrace); + if (error != B_OK) + return error; + Reference stackTraceReference(stackTrace, true); + + // set the stack trace, unless something has changed + AutoLocker locker(fThread->GetTeam()); + + if (fThread->GetCpuState() == fCpuState) + fThread->SetStackTrace(stackTrace); + + return B_OK; +} Modified: haiku/trunk/src/apps/debugger/Jobs.h =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/Jobs.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -8,13 +8,16 @@ #include "Worker.h" +class Architecture; +class CpuState; class DebuggerInterface; class Thread; // job types enum { - JOB_TYPE_GET_CPU_STATE + JOB_TYPE_GET_CPU_STATE, + JOB_TYPE_GET_STACK_TRACE }; @@ -34,4 +37,23 @@ }; +class GetStackTraceJob : public Job { +public: + GetStackTraceJob( + DebuggerInterface* debuggerInterface, + Architecture* architecture, + Thread* thread); + virtual ~GetStackTraceJob(); + + virtual JobKey Key() const; + virtual status_t Do(); + +private: + DebuggerInterface* fDebuggerInterface; + Architecture* fArchitecture; + Thread* fThread; + CpuState* fCpuState; +}; + + #endif // JOBS_H Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -19,7 +19,6 @@ #include "DebuggerInterface.h" #include "Jobs.h" #include "MessageCodes.h" -#include "Team.h" #include "TeamDebugModel.h" @@ -81,6 +80,8 @@ fTeam->SetName(teamInfo.args); // TODO: Set a better name! + fTeam->AddListener(this); + // create our worker fWorker = new(std::nothrow) Worker; if (fWorker == NULL) @@ -196,6 +197,35 @@ _HandleThreadAction(threadID, message->what); break; } + + case MSG_THREAD_STATE_CHANGED: + { + int32 threadID; + if (message->FindInt32("thread", &threadID) != B_OK) + break; + + _HandleThreadStateChanged(threadID); + break; + } + case MSG_THREAD_CPU_STATE_CHANGED: + { + int32 threadID; + if (message->FindInt32("thread", &threadID) != B_OK) + break; + + _HandleCpuStateChanged(threadID); + break; + } + case MSG_THREAD_STACK_TRACE_CHANGED: + { + int32 threadID; + if (message->FindInt32("thread", &threadID) != B_OK) + break; + + _HandleStackTraceChanged(threadID); + break; + } + default: BLooper::MessageReceived(message); break; @@ -242,6 +272,33 @@ } +void +TeamDebugger::ThreadStateChanged(const ::Team::ThreadEvent& event) +{ + BMessage message(MSG_THREAD_STATE_CHANGED); + message.AddInt32("thread", event.GetThread()->ID()); + PostMessage(&message); +} + + +void +TeamDebugger::ThreadCpuStateChanged(const ::Team::ThreadEvent& event) +{ + BMessage message(MSG_THREAD_CPU_STATE_CHANGED); + message.AddInt32("thread", event.GetThread()->ID()); + PostMessage(&message); +} + + +void +TeamDebugger::ThreadStackTraceChanged(const ::Team::ThreadEvent& event) +{ + BMessage message(MSG_THREAD_STACK_TRACE_CHANGED); + message.AddInt32("thread", event.GetThread()->ID()); + PostMessage(&message); +} + + /*static*/ status_t TeamDebugger::_DebugEventListenerEntry(void* data) { @@ -481,24 +538,8 @@ TeamDebugger::_SetThreadState(::Thread* thread, uint32 state, CpuState* cpuState) { - // update the thread state - uint32 oldState = thread->State(); thread->SetState(state); - - // cancel jobs for this thread - if (oldState == THREAD_STATE_STOPPED) - fWorker->AbortJob(JobKey(thread, JOB_TYPE_GET_CPU_STATE)); - - if (state == THREAD_STATE_STOPPED) { - if (cpuState != NULL) { - thread->SetCpuState(cpuState); - } else { - // trigger updating the CPU state - fWorker->ScheduleJob(new(std::nothrow) GetCpuStateJob( - fDebuggerInterface, thread), - this); - } - } + thread->SetCpuState(cpuState); } @@ -550,3 +591,55 @@ // TODO: Handle stepping correctly! } } + + +void +TeamDebugger::_HandleThreadStateChanged(thread_id threadID) +{ + AutoLocker< ::Team> teamLocker(fTeam); + + ::Thread* thread = fTeam->ThreadByID(threadID); + if (thread == NULL) + return; + + // cancel jobs for this thread + fWorker->AbortJob(JobKey(thread, JOB_TYPE_GET_CPU_STATE)); + fWorker->AbortJob(JobKey(thread, JOB_TYPE_GET_STACK_TRACE)); + + // If the thread is stopped and has no CPU state yet, schedule a job. + if (thread->State() == THREAD_STATE_STOPPED + && thread->GetCpuState() == NULL) { + fWorker->ScheduleJob( + new(std::nothrow) GetCpuStateJob(fDebuggerInterface, thread), + this); + } +} + + +void +TeamDebugger::_HandleCpuStateChanged(thread_id threadID) +{ + AutoLocker< ::Team> teamLocker(fTeam); + + ::Thread* thread = fTeam->ThreadByID(threadID); + if (thread == NULL) + return; + + // cancel stack trace job for this thread + fWorker->AbortJob(JobKey(thread, JOB_TYPE_GET_STACK_TRACE)); + + // If the thread has a CPU state, but no stack trace yet, schedule a job. + if (thread->GetCpuState() != NULL && thread->GetStackTrace() == NULL) { + fWorker->ScheduleJob( + new(std::nothrow) GetStackTraceJob(fDebuggerInterface, + fDebuggerInterface->GetArchitecture(), thread), + this); + } +} + + +void +TeamDebugger::_HandleStackTraceChanged(thread_id threadID) +{ +printf("TeamDebugger::_HandleStackTraceChanged()\n"); +} Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -9,20 +9,19 @@ #include #include -#include #include "DebugEvent.h" +#include "Team.h" #include "TeamWindow.h" #include "Worker.h" class DebuggerInterface; -class Team; class TeamDebugModel; -class TeamDebugger : public DoublyLinkedListLinkImpl, - private BLooper, private TeamWindow::Listener, private JobListener { +class TeamDebugger : private BLooper, private TeamWindow::Listener, + private JobListener, private Team::Listener { public: TeamDebugger(); ~TeamDebugger(); @@ -45,6 +44,14 @@ virtual void JobFailed(Job* job); virtual void JobAborted(Job* job); + // Team::Listener + virtual void ThreadStateChanged( + const ::Team::ThreadEvent& event); + virtual void ThreadCpuStateChanged( + const ::Team::ThreadEvent& event); + virtual void ThreadStackTraceChanged( + const ::Team::ThreadEvent& event); + private: static status_t _DebugEventListenerEntry(void* data); status_t _DebugEventListener(); @@ -82,6 +89,10 @@ void _HandleThreadAction(thread_id threadID, uint32 action); + void _HandleThreadStateChanged(thread_id threadID); + void _HandleCpuStateChanged(thread_id threadID); + void _HandleStackTraceChanged(thread_id threadID); + private: ::Team* fTeam; TeamDebugModel* fDebugModel; Modified: haiku/trunk/src/apps/debugger/arch/Architecture.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -13,6 +13,8 @@ class CpuState; class DebuggerInterface; class Register; +class StackTrace; +class Team; class Architecture : public Referenceable { @@ -28,6 +30,9 @@ virtual status_t CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state) = 0; + virtual status_t CreateStackTrace(Team* team, CpuState* cpuState, + StackTrace*& _stackTrace) = 0; + // team is not locked protected: DebuggerInterface* fDebuggerInterface; Modified: haiku/trunk/src/apps/debugger/arch/Register.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Register.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/Register.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -14,7 +14,7 @@ }; enum register_type { - REGISTER_TYPE_PROGRAM_COUNTER, + REGISTER_TYPE_INSTRUCTION_POINTER, REGISTER_TYPE_STACK_POINTER, REGISTER_TYPE_GENERAL_PURPOSE, REGISTER_TYPE_SPECIAL_PURPOSE, Modified: haiku/trunk/src/apps/debugger/arch/StackFrame.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackFrame.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/StackFrame.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -13,6 +13,14 @@ #include "ArchitectureTypes.h" +enum stack_frame_type { + STACK_FRAME_TYPE_TOP, // top-most frame + STACK_FRAME_TYPE_STANDARD, // non-top-most standard frame + STACK_FRAME_TYPE_SIGNAL, // signal handler frame + STACK_FRAME_TYPE_FRAMELESS // dummy frame for a frameless function +}; + + class CpuState; @@ -21,8 +29,11 @@ public: virtual ~StackFrame(); + virtual stack_frame_type Type() const = 0; + virtual CpuState* GetCpuState() const = 0; + virtual target_addr_t InstructionPointer() const = 0; virtual target_addr_t FrameAddress() const = 0; virtual target_addr_t ReturnAddress() const = 0; virtual target_addr_t PreviousFrameAddress() const = 0; Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -7,7 +7,12 @@ #include +#include + #include "CpuStateX86.h" +#include "DebuggerInterface.h" +#include "StackFrameX86.h" +#include "StackTrace.h" ArchitectureX86::ArchitectureX86(DebuggerInterface* debuggerInterface) @@ -27,7 +32,7 @@ { try { _AddIntegerRegister(X86_REGISTER_EIP, "eip", 32, - REGISTER_TYPE_PROGRAM_COUNTER); + REGISTER_TYPE_INSTRUCTION_POINTER); _AddIntegerRegister(X86_REGISTER_ESP, "esp", 32, REGISTER_TYPE_STACK_POINTER); _AddIntegerRegister(X86_REGISTER_EBP, "ebp", 32, @@ -98,6 +103,64 @@ } +status_t +ArchitectureX86::CreateStackTrace(Team* team, CpuState* _cpuState, + StackTrace*& _stackTrace) +{ + CpuStateX86* cpuState = dynamic_cast(_cpuState); + + // create the object + StackTrace* stackTrace = new(std::nothrow) StackTrace; + if (stackTrace == NULL) + return B_NO_MEMORY; + ObjectDeleter stackTraceDeleter(stackTrace); + + // create the top frame + StackFrameX86* frame = new StackFrameX86(STACK_FRAME_TYPE_TOP, cpuState); + if (frame == NULL) + return B_NO_MEMORY; + stackTrace->AddFrame(frame); + + while (true) { + uint32 framePointer = (uint32)frame->FrameAddress(); + if (framePointer == 0) + break; + + // get previous frame and return address + uint32 frameData[2]; + ssize_t bytesRead = fDebuggerInterface->ReadMemory(framePointer, + frameData, 8); + if (bytesRead != 8) + break; + + frame->SetPreviousAddresses(frameData[0], frameData[1]); + + if (frameData[0] == 0 || frameData[1] == 0) + break; + + // prepare the previous CPU state + cpuState = new(std::nothrow) CpuStateX86; + if (cpuState == NULL) + return B_NO_MEMORY; + Reference cpuStateReference(cpuState, true); + + cpuState->SetIntRegister(X86_REGISTER_EBP, frameData[0]); + cpuState->SetIntRegister(X86_REGISTER_EIP, frameData[1]); + // TODO: Actually it's the instruction before! + + // create the next frame + frame = new StackFrameX86(STACK_FRAME_TYPE_STANDARD, cpuState); + if (frame == NULL) + return B_NO_MEMORY; + stackTrace->AddFrame(frame); + } + + stackTraceDeleter.Detach(); + _stackTrace = stackTrace; + return B_OK; +} + + void ArchitectureX86::_AddRegister(int32 index, const char* name, register_format format, uint32 bitSize, register_type type) Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -23,6 +23,8 @@ virtual status_t CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state); + virtual status_t CreateStackTrace(Team* team, CpuState* cpuState, + StackTrace*& _stackTrace); private: void _AddRegister(int32 index, const char* name, Modified: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -8,6 +8,13 @@ #include "Register.h" +CpuStateX86::CpuStateX86() + : + fSetRegisters() +{ +} + + CpuStateX86::CpuStateX86(const debug_cpu_state_x86& state) : fSetRegisters() Modified: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -42,6 +42,7 @@ class CpuStateX86 : public CpuState { public: + CpuStateX86(); CpuStateX86(const debug_cpu_state_x86& state); virtual ~CpuStateX86(); Added: haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -0,0 +1,76 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "StackFrameX86.h" + +#include "CpuStateX86.h" + + +StackFrameX86::StackFrameX86(stack_frame_type type, CpuStateX86* cpuState) + : + fType(type), + fCpuState(cpuState), + fPreviousFrameAddress(0), + fReturnAddress(0) +{ + fCpuState->AddReference(); +} + + +StackFrameX86::~StackFrameX86() +{ + fCpuState->RemoveReference(); +} + + +void +StackFrameX86::SetPreviousAddresses(target_addr_t previousFrameAddress, + target_addr_t returnAddress) +{ + fPreviousFrameAddress = previousFrameAddress; + fReturnAddress = returnAddress; +} + + +stack_frame_type +StackFrameX86::Type() const +{ + return fType; +} + + +CpuState* +StackFrameX86::GetCpuState() const +{ + return fCpuState; +} + + +target_addr_t +StackFrameX86::InstructionPointer() const +{ + return fCpuState->IntRegisterValue(X86_REGISTER_EIP); +} + + +target_addr_t +StackFrameX86::FrameAddress() const +{ + return fCpuState->IntRegisterValue(X86_REGISTER_EBP); +} + + +target_addr_t +StackFrameX86::ReturnAddress() const +{ + return fReturnAddress; +} + + +target_addr_t +StackFrameX86::PreviousFrameAddress() const +{ + return fPreviousFrameAddress; +} Added: haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -0,0 +1,41 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef STACK_FRAME_X86_H +#define STACK_FRAME_X86_H + +#include "StackFrame.h" + + +class CpuStateX86; + + +class StackFrameX86 : public StackFrame { +public: + StackFrameX86(stack_frame_type type, + CpuStateX86* cpuState); + virtual ~StackFrameX86(); + + void SetPreviousAddresses( + target_addr_t previousFrameAddress, + target_addr_t returnAddress); + + virtual stack_frame_type Type() const; + + virtual CpuState* GetCpuState() const; + + virtual target_addr_t InstructionPointer() const; + virtual target_addr_t FrameAddress() const; + virtual target_addr_t ReturnAddress() const; + virtual target_addr_t PreviousFrameAddress() const; + +private: + stack_frame_type fType; + CpuStateX86* fCpuState; + target_addr_t fPreviousFrameAddress; + target_addr_t fReturnAddress; +}; + + +#endif // STACK_FRAME_X86_H Added: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-19 22:13:32 UTC (rev 31126) @@ -0,0 +1,212 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "StackTraceView.h" + +#include + +#include + +#include "table/TableColumns.h" + +#include "StackTrace.h" + + +// #pragma mark - TargetAddressValueColumn + + +class TargetAddressValueColumn : public StringTableColumn { +public: + TargetAddressValueColumn(int32 modelIndex, const char* title, float width, + float minWidth, float maxWidth, uint32 truncate = B_TRUNCATE_MIDDLE, + alignment align = B_ALIGN_RIGHT) + : + StringTableColumn(modelIndex, title, width, minWidth, maxWidth, + truncate, align) + { + } + +protected: + virtual BField* PrepareField(const Variant& value) const + { + char buffer[64]; + snprintf(buffer, sizeof(buffer), "%#llx", value.ToUInt64()); + + return StringTableColumn::PrepareField( + Variant(buffer, VARIANT_DONT_COPY_DATA)); + } + + virtual int CompareValues(const Variant& a, const Variant& b) + { + uint64 valueA = a.ToUInt64(); + uint64 valueB = b.ToUInt64(); + return valueA < valueB ? -1 : (valueA == valueB ? 0 : 1); + } +}; + + +// #pragma mark - FramesTableModel + + +class StackTraceView::FramesTableModel : public TableModel { +public: + FramesTableModel() + : + fStackTrace(NULL) + { + } + + ~FramesTableModel() + { + SetStackTrace(NULL); + } + + void SetStackTrace(StackTrace* stackTrace) + { + // unset old frames + if (fFrames.CountItems() > 0) { + NotifyRowsRemoved(0, fFrames.CountItems()); + + for (int32 i = 0; StackFrame* frame = fFrames.ItemAt(i); i++) + frame->RemoveReference(); + + fFrames.MakeEmpty(); + } + + fStackTrace = stackTrace; + + // set new frames + if (fStackTrace != NULL) { + for (StackFrameList::ConstIterator it + = fStackTrace->Frames().GetIterator(); + StackFrame* frame = it.Next();) { + if (!fFrames.AddItem(frame)) + return; + frame->AddReference(); + } + + if (fFrames.CountItems() > 0) + NotifyRowsAdded(0, fFrames.CountItems()); + } + } + + virtual int32 CountColumns() const + { + return 3; + } + + virtual int32 CountRows() const + { + return fFrames.CountItems(); + } + + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + { + StackFrame* frame = fFrames.ItemAt(rowIndex); + if (frame == NULL) + return false; + + switch (columnIndex) { + case 0: + value.SetTo(frame->FrameAddress()); + return true; + case 1: + value.SetTo(frame->InstructionPointer()); + return true; + case 2: + // TODO: function name... + return false; + default: + return false; + } + } + +private: + StackTrace* fStackTrace; + BObjectList fFrames; +}; + + +// #pragma mark - StackTraceView + + +StackTraceView::StackTraceView() + : + BGroupView(B_VERTICAL), + fFramesTable(NULL), + fFramesTableModel(NULL) +{ + SetName("Stack Trace"); +} + + +StackTraceView::~StackTraceView() +{ + SetStackTrace(NULL); + fFramesTable->SetTableModel(NULL); + delete fFramesTableModel; +} + + +/*static*/ StackTraceView* +StackTraceView::Create() +{ + StackTraceView* self = new StackTraceView(); + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; +} + + +void +StackTraceView::SetStackTrace(StackTrace* stackTrace) +{ + if (stackTrace == fStackTrace) + return; + + if (fStackTrace != NULL) + fStackTrace->RemoveReference(); + + fStackTrace = stackTrace; + + if (fStackTrace != NULL) + fStackTrace->AddReference(); + + fFramesTableModel->SetStackTrace(fStackTrace); +} + + +void +StackTraceView::TableRowInvoked(Table* table, int32 rowIndex) +{ +} + + +void +StackTraceView::_Init() +{ + fFramesTable = new Table("register list", 0); + AddChild(fFramesTable->ToView()); + fFramesTable->SetSortingEnabled(false); + + // columns + fFramesTable->AddColumn(new TargetAddressValueColumn(0, "Frame", 80, 40, + 1000, B_TRUNCATE_END, B_ALIGN_RIGHT)); + fFramesTable->AddColumn(new TargetAddressValueColumn(1, "IP", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_RIGHT)); + fFramesTable->AddColumn(new StringTableColumn(2, "Function", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_LEFT)); + + fFramesTableModel = new FramesTableModel(); + fFramesTable->SetTableModel(fFramesTableModel); + + fFramesTable->AddTableListener(this); +} Added: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h 2009-06-19 21:58:48 UTC (rev 31125) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h 2009-06-19 22:13:32 UTC (rev 31126) @@ -0,0 +1,40 @@ +/* [... truncated: 165 lines follow ...] From bonefish at mail.berlios.de Sat Jun 20 01:00:28 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 01:00:28 +0200 Subject: [Haiku-commits] r31127 - in haiku/trunk: headers/private/shared src/apps/debuganalyzer src/apps/debuganalyzer/gui/main_window src/apps/debuganalyzer/gui/table src/apps/debuganalyzer/gui/thread_window src/apps/debuganalyzer/util src/apps/debugger src/apps/debugger/arch src/apps/debugger/arch/x86 src/apps/debugger/gui/team_window src/kits/shared Message-ID: <200906192300.n5JN0SDY016088@sheep.berlios.de> Author: bonefish Date: 2009-06-20 01:00:25 +0200 (Sat, 20 Jun 2009) New Revision: 31127 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31127&view=rev Added: haiku/trunk/headers/private/shared/Variant.h haiku/trunk/src/kits/shared/Variant.cpp Removed: haiku/trunk/src/apps/debuganalyzer/util/Variant.cpp haiku/trunk/src/apps/debuganalyzer/util/Variant.h Modified: haiku/trunk/src/apps/debuganalyzer/Jamfile haiku/trunk/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp haiku/trunk/src/apps/debuganalyzer/gui/main_window/ThreadsPage.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.h haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.h haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h haiku/trunk/src/apps/debuganalyzer/gui/thread_window/WaitObjectsPage.cpp haiku/trunk/src/apps/debuganalyzer/util/Jamfile haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/arch/CpuState.h haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp haiku/trunk/src/kits/shared/Jamfile Log: Renamed Variant to BVariant and moved it to libshared.a. Copied: haiku/trunk/headers/private/shared/Variant.h (from rev 31119, haiku/trunk/src/apps/debuganalyzer/util/Variant.h) =================================================================== --- haiku/trunk/src/apps/debuganalyzer/util/Variant.h 2009-06-19 17:26:59 UTC (rev 31119) +++ haiku/trunk/headers/private/shared/Variant.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -0,0 +1,314 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _VARIANT_H +#define _VARIANT_H + + +#include +#include + + +enum { + B_VARIANT_DONT_COPY_DATA = 0x01, + B_VARIANT_OWNS_DATA = 0x02 +}; + + +class BVariant { +public: + inline BVariant(); + inline BVariant(int8 value); + inline BVariant(uint8 value); + inline BVariant(int16 value); + inline BVariant(uint16 value); + inline BVariant(int32 value); + inline BVariant(uint32 value); + inline BVariant(int64 value); + inline BVariant(uint64 value); + inline BVariant(float value); + inline BVariant(double value); + inline BVariant(const void* value); + inline BVariant(const char* value, + uint32 flags = 0); + inline BVariant(const BVariant& other); + ~BVariant(); + + inline void SetTo(const BVariant& other); + inline void SetTo(int8 value); + inline void SetTo(uint8 value); + inline void SetTo(int16 value); + inline void SetTo(uint16 value); + inline void SetTo(int32 value); + inline void SetTo(uint32 value); + inline void SetTo(int64 value); + inline void SetTo(uint64 value); + inline void SetTo(float value); + inline void SetTo(double value); + inline void SetTo(const void* value); + inline void SetTo(const char* value, + uint32 flags = 0); + void Unset(); + + inline BVariant& operator=(const BVariant& other); + + type_code Type() const { return fType; } + + bool IsNumber() const; + bool IsInteger() const; + bool IsFloat() const; + // floating point, not just float + + int8 ToInt8() const; + uint8 ToUInt8() const; + int16 ToInt16() const; + uint16 ToUInt16() const; + int32 ToInt32() const; + uint32 ToUInt32() const; + int64 ToInt64() const; + uint64 ToUInt64() const; + float ToFloat() const; + double ToDouble() const; + void* ToPointer() const; + const char* ToString() const; + +private: + void _SetTo(const BVariant& other); + void _SetTo(int8 value); + void _SetTo(uint8 value); + void _SetTo(int16 value); + void _SetTo(uint16 value); + void _SetTo(int32 value); + void _SetTo(uint32 value); + void _SetTo(int64 value); + void _SetTo(uint64 value); + void _SetTo(float value); + void _SetTo(double value); + void _SetTo(const void* value); + void _SetTo(const char* value, + uint32 flags); + + template + inline NumberType _ToNumber() const; + +private: + type_code fType; + uint32 fFlags; + union { + int8 fInt8; + uint8 fUInt8; + int16 fInt16; + uint16 fUInt16; + int32 fInt32; + uint32 fUInt32; + int64 fInt64; + uint64 fUInt64; + float fFloat; + double fDouble; + void* fPointer; + char* fString; + }; +}; + + +BVariant::BVariant() + : + fType(0), + fFlags(0) +{ +} + + +BVariant::BVariant(int8 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(uint8 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(int16 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(uint16 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(int32 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(uint32 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(int64 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(uint64 value) +{ + _SetTo(value); +} + + +BVariant::BVariant(float value) +{ + _SetTo(value); +} + + +BVariant::BVariant(double value) +{ + _SetTo(value); +} + + +BVariant::BVariant(const void* value) +{ + _SetTo(value); +} + + +BVariant::BVariant(const char* value, uint32 flags) +{ + _SetTo(value, flags); +} + + +BVariant::BVariant(const BVariant& other) +{ + _SetTo(other); +} + + +BVariant& +BVariant::operator=(const BVariant& other) +{ + Unset(); + _SetTo(other); + return *this; +} + + +void +BVariant::SetTo(const BVariant& other) +{ + Unset(); + _SetTo(other); +} + + +void +BVariant::SetTo(int8 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(uint8 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(int16 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(uint16 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(int32 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(uint32 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(int64 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(uint64 value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(float value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(double value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(const void* value) +{ + Unset(); + _SetTo(value); +} + + +void +BVariant::SetTo(const char* value, uint32 flags) +{ + Unset(); + _SetTo(value, flags); +} + + +#endif // _VARIANT_H Modified: haiku/trunk/src/apps/debuganalyzer/Jamfile =================================================================== --- haiku/trunk/src/apps/debuganalyzer/Jamfile 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/Jamfile 2009-06-19 23:00:25 UTC (rev 31127) @@ -3,7 +3,7 @@ UsePrivateHeaders debug interface kernel shared ; UsePrivateSystemHeaders ; -HAIKU_DEBUG_ANALYZER_HEADERS = +HAIKU_DEBUG_ANALYZER_HEADERS = $(SUBDIR) [ FDirName $(SUBDIR) gui ] [ FDirName $(SUBDIR) model ] @@ -24,7 +24,7 @@ DebugAnalyzer_model_loader.o DebugAnalyzer_util.o - libcolumnlistview.a libdebug.so be + libcolumnlistview.a libshared.a libdebug.so be : DebugAnalyzer.rdef ; Modified: haiku/trunk/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -33,7 +33,7 @@ return fModel->CountTeams(); } - virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value) { Model::Team* team = fModel->TeamAt(rowIndex); if (team == NULL) @@ -44,7 +44,7 @@ value.SetTo(team->ID()); return true; case 1: - value.SetTo(team->Name(), VARIANT_DONT_COPY_DATA); + value.SetTo(team->Name(), B_VARIANT_DONT_COPY_DATA); return true; case 2: value.SetTo(team->CreationTime()); Modified: haiku/trunk/src/apps/debuganalyzer/gui/main_window/ThreadsPage.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/main_window/ThreadsPage.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/main_window/ThreadsPage.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -33,7 +33,7 @@ return fModel->CountThreads(); } - virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value) { Model::Thread* thread = fModel->ThreadAt(rowIndex); if (thread == NULL) @@ -44,7 +44,7 @@ value.SetTo(thread->ID()); return true; case 1: - value.SetTo(thread->Name(), VARIANT_DONT_COPY_DATA); + value.SetTo(thread->Name(), B_VARIANT_DONT_COPY_DATA); return true; case 2: { Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -271,7 +271,7 @@ return; int32 modelIndex = fTableColumn->ModelIndex(); - Variant value; + BVariant value; if (!fModel->GetValueAt(field->RowIndex(), modelIndex, value)) return; fTableColumn->DrawValue(value, rect, targetView); @@ -293,9 +293,9 @@ return 1; int32 modelIndex = fTableColumn->ModelIndex(); - Variant value1; + BVariant value1; bool valid1 = fModel->GetValueAt(field1->RowIndex(), modelIndex, value1); - Variant value2; + BVariant value2; bool valid2 = fModel->GetValueAt(field2->RowIndex(), modelIndex, value2); if (!valid1) @@ -322,7 +322,7 @@ return Width(); int32 modelIndex = fTableColumn->ModelIndex(); - Variant value; + BVariant value; if (!fModel->GetValueAt(field->RowIndex(), modelIndex, value)) return Width(); return fTableColumn->GetPreferredWidth(value, parent); Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -9,13 +9,12 @@ #include #include +#include #include "table/AbstractTable.h" #include "table/TableColumn.h" -#include "Variant.h" - class Table; class TableModel; @@ -40,7 +39,7 @@ virtual int32 CountRows() const = 0; virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, - Variant& value) = 0; + BVariant& value) = 0; virtual bool AddListener(TableModelListener* listener); virtual void RemoveListener(TableModelListener* listener); Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -39,20 +39,20 @@ void -TableColumn::DrawValue(const Variant& value, BRect rect, BView* targetView) +TableColumn::DrawValue(const BVariant& value, BRect rect, BView* targetView) { } int -TableColumn::CompareValues(const Variant& a, const Variant& b) +TableColumn::CompareValues(const BVariant& a, const BVariant& b) { return 0; } float -TableColumn::GetPreferredWidth(const Variant& value, BView* parent) const +TableColumn::GetPreferredWidth(const BVariant& value, BView* parent) const { return Width(); } Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.h 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumn.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -8,7 +8,7 @@ #include #include -#include "Variant.h" +#include class BString; @@ -33,13 +33,13 @@ virtual void GetColumnName(BString* into) const; virtual void DrawTitle(BRect rect, BView* targetView); - virtual void DrawValue(const Variant& value, BRect rect, + virtual void DrawValue(const BVariant& value, BRect rect, BView* targetView); - virtual int CompareValues(const Variant& a, - const Variant& b); - virtual float GetPreferredWidth(const Variant& value, + virtual int CompareValues(const BVariant& a, + const BVariant& b); + virtual float GetPreferredWidth(const BVariant& value, BView* parent) const; - + private: int32 fModelIndex; float fWidth; Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -41,7 +41,7 @@ void -DelagateBasedTableColumn::DrawValue(const Variant& value, BRect rect, +DelagateBasedTableColumn::DrawValue(const BVariant& value, BRect rect, BView* targetView) { fColumnDelegate->DrawField(PrepareField(value), rect, targetView); @@ -49,7 +49,7 @@ float -DelagateBasedTableColumn::GetPreferredWidth(const Variant& value, +DelagateBasedTableColumn::GetPreferredWidth(const BVariant& value, BView* parent) const { return fColumnDelegate->GetPreferredWidth(PrepareField(value), parent); @@ -77,7 +77,7 @@ BField* -StringTableColumn::PrepareField(const Variant& value) const +StringTableColumn::PrepareField(const BVariant& value) const { fField.SetString(value.ToString()); fField.SetWidth(Width()); @@ -86,7 +86,7 @@ int -StringTableColumn::CompareValues(const Variant& a, const Variant& b) +StringTableColumn::CompareValues(const BVariant& a, const BVariant& b) { return strcasecmp(a.ToString(), b.ToString()); } @@ -106,17 +106,17 @@ BField* -Int32TableColumn::PrepareField(const Variant& value) const +Int32TableColumn::PrepareField(const BVariant& value) const { char buffer[16]; snprintf(buffer, sizeof(buffer), "%ld", value.ToInt32()); return StringTableColumn::PrepareField( - Variant(buffer, VARIANT_DONT_COPY_DATA)); + BVariant(buffer, B_VARIANT_DONT_COPY_DATA)); } int -Int32TableColumn::CompareValues(const Variant& a, const Variant& b) +Int32TableColumn::CompareValues(const BVariant& a, const BVariant& b) { return a.ToInt32() - b.ToInt32(); } @@ -136,17 +136,17 @@ BField* -Int64TableColumn::PrepareField(const Variant& value) const +Int64TableColumn::PrepareField(const BVariant& value) const { char buffer[32]; snprintf(buffer, sizeof(buffer), "%lld", value.ToInt64()); return StringTableColumn::PrepareField( - Variant(buffer, VARIANT_DONT_COPY_DATA)); + BVariant(buffer, B_VARIANT_DONT_COPY_DATA)); } int -Int64TableColumn::CompareValues(const Variant& a, const Variant& b) +Int64TableColumn::CompareValues(const BVariant& a, const BVariant& b) { int64 diff = a.ToInt64() - b.ToInt64(); if (diff == 0) @@ -170,12 +170,12 @@ BField* -BigtimeTableColumn::PrepareField(const Variant& value) const +BigtimeTableColumn::PrepareField(const BVariant& value) const { bigtime_t time = value.ToInt64(); if (time < 0) { return StringTableColumn::PrepareField( - Variant("-", VARIANT_DONT_COPY_DATA)); + BVariant("-", B_VARIANT_DONT_COPY_DATA)); } int micros = int(time % 1000000); @@ -189,19 +189,19 @@ snprintf(buffer, sizeof(buffer), "%02lld:%02d:%02d:%06d", time, minutes, seconds, micros); return StringTableColumn::PrepareField( - Variant(buffer, VARIANT_DONT_COPY_DATA)); + BVariant(buffer, B_VARIANT_DONT_COPY_DATA)); } int -BigtimeTableColumn::CompareValues(const Variant& _a, const Variant& _b) +BigtimeTableColumn::CompareValues(const BVariant& _a, const BVariant& _b) { bigtime_t a = _a.ToInt64(); bigtime_t b = _b.ToInt64(); if (a == b) return 0; - + if (a < 0) return fInvalidFirst ? -1 : 1; if (b < 0) Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.h 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TableColumns.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -23,12 +23,12 @@ virtual void DrawTitle(BRect rect, BView* targetView); virtual void GetColumnName(BString* into) const; - virtual void DrawValue(const Variant& value, BRect rect, + virtual void DrawValue(const BVariant& value, BRect rect, BView* targetView); - virtual float GetPreferredWidth(const Variant& value, + virtual float GetPreferredWidth(const BVariant& value, BView* parent) const; - virtual BField* PrepareField(const Variant& value) const = 0; + virtual BField* PrepareField(const BVariant& value) const = 0; protected: BColumn* fColumnDelegate; @@ -45,10 +45,10 @@ virtual ~StringTableColumn(); protected: - virtual BField* PrepareField(const Variant& value) const; + virtual BField* PrepareField(const BVariant& value) const; - virtual int CompareValues(const Variant& a, - const Variant& b); + virtual int CompareValues(const BVariant& a, + const BVariant& b); private: BStringColumn fColumn; @@ -65,10 +65,10 @@ alignment align = B_ALIGN_RIGHT); protected: - virtual BField* PrepareField(const Variant& value) const; + virtual BField* PrepareField(const BVariant& value) const; - virtual int CompareValues(const Variant& a, - const Variant& b); + virtual int CompareValues(const BVariant& a, + const BVariant& b); }; @@ -81,10 +81,10 @@ alignment align = B_ALIGN_RIGHT); protected: - virtual BField* PrepareField(const Variant& value) const; + virtual BField* PrepareField(const BVariant& value) const; - virtual int CompareValues(const Variant& a, - const Variant& b); + virtual int CompareValues(const BVariant& a, + const BVariant& b); }; @@ -98,10 +98,10 @@ alignment align = B_ALIGN_RIGHT); protected: - virtual BField* PrepareField(const Variant& value) const; + virtual BField* PrepareField(const BVariant& value) const; - virtual int CompareValues(const Variant& a, - const Variant& b); + virtual int CompareValues(const BVariant& a, + const BVariant& b); private: bool fInvalidFirst; Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -112,7 +112,7 @@ return; int32 modelIndex = fTableColumn->ModelIndex(); - Variant value; + BVariant value; if (!fModel->GetValueAt(field->Object(), modelIndex, value)) return; fTableColumn->DrawValue(value, rect, targetView); @@ -134,9 +134,9 @@ return 1; int32 modelIndex = fTableColumn->ModelIndex(); - Variant value1; + BVariant value1; bool valid1 = fModel->GetValueAt(field1->Object(), modelIndex, value1); - Variant value2; + BVariant value2; bool valid2 = fModel->GetValueAt(field2->Object(), modelIndex, value2); if (!valid1) @@ -163,7 +163,7 @@ return Width(); int32 modelIndex = fTableColumn->ModelIndex(); - Variant value; + BVariant value; if (!fModel->GetValueAt(field->Object(), modelIndex, value)) return Width(); return fTableColumn->GetPreferredWidth(value, parent); Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/TreeTable.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -6,13 +6,12 @@ #define TREE_TABLE_H #include +#include #include "table/AbstractTable.h" #include "table/TableColumn.h" -#include "Variant.h" - class TreeTable; @@ -27,7 +26,7 @@ virtual void* ChildAt(void* parent, int32 index) const = 0; virtual bool GetValueAt(void* object, int32 columnIndex, - Variant& value) = 0; + BVariant& value) = 0; }; Modified: haiku/trunk/src/apps/debuganalyzer/gui/thread_window/WaitObjectsPage.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/thread_window/WaitObjectsPage.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/gui/thread_window/WaitObjectsPage.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -55,7 +55,7 @@ return 6; } - virtual bool GetValueAt(void* object, int32 columnIndex, Variant& value) + virtual bool GetValueAt(void* object, int32 columnIndex, BVariant& value) { return ((Node*)object)->GetValueAt(columnIndex, value); } @@ -66,7 +66,7 @@ virtual int32 CountChildren() const = 0; virtual void* ChildAt(int32 index) const = 0; - virtual bool GetValueAt(int32 columnIndex, Variant& value) = 0; + virtual bool GetValueAt(int32 columnIndex, BVariant& value) = 0; }; struct ObjectNode : Node { @@ -88,7 +88,7 @@ return NULL; } - virtual bool GetValueAt(int32 columnIndex, Variant& value) + virtual bool GetValueAt(int32 columnIndex, BVariant& value) { return _GetWaitObjectValueAt(object, columnIndex, value); } @@ -123,7 +123,7 @@ return objectNodes.ItemAt(index); } - virtual bool GetValueAt(int32 columnIndex, Variant& value) + virtual bool GetValueAt(int32 columnIndex, BVariant& value) { if (columnIndex <= 2) { return _GetWaitObjectValueAt(group->WaitObjectAt(0), @@ -174,7 +174,7 @@ return groupNodes.ItemAt(index); } - virtual bool GetValueAt(int32 columnIndex, Variant& value) + virtual bool GetValueAt(int32 columnIndex, BVariant& value) { return false; } @@ -215,15 +215,15 @@ } static bool _GetWaitObjectValueAt(Model::ThreadWaitObject* waitObject, - int32 columnIndex, Variant& value) + int32 columnIndex, BVariant& value) { switch (columnIndex) { case 0: value.SetTo(_TypeToString(waitObject->Type()), - VARIANT_DONT_COPY_DATA); + B_VARIANT_DONT_COPY_DATA); return true; case 1: - value.SetTo(waitObject->Name(), VARIANT_DONT_COPY_DATA); + value.SetTo(waitObject->Name(), B_VARIANT_DONT_COPY_DATA); return true; case 2: { Modified: haiku/trunk/src/apps/debuganalyzer/util/Jamfile =================================================================== --- haiku/trunk/src/apps/debuganalyzer/util/Jamfile 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debuganalyzer/util/Jamfile 2009-06-19 23:00:25 UTC (rev 31127) @@ -9,5 +9,4 @@ MergeObject DebugAnalyzer_util.o : DataSource.cpp - Variant.cpp ; Deleted: haiku/trunk/src/apps/debuganalyzer/util/Variant.cpp Deleted: haiku/trunk/src/apps/debuganalyzer/util/Variant.h Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-19 23:00:25 UTC (rev 31127) @@ -16,7 +16,6 @@ SubDirHdrs [ FDirName $(HAIKU_TOP) src bin debug ] ; SubDirHdrs [ FDirName $(debugAnalyzerSources) gui ] ; -SubDirHdrs [ FDirName $(debugAnalyzerSources) util ] ; Application Debugger : Debugger.cpp @@ -54,9 +53,6 @@ TeamWindow.cpp ThreadListView.cpp - # DebugAnalyzer:util - Variant.cpp - # DWARF # attribute_classes.cpp # AttributeValue.cpp @@ -71,6 +67,7 @@ debug_utils.a libcolumnlistview.a + libshared.a $(TARGET_LIBSTDC++) be debug @@ -78,7 +75,4 @@ : Debugger.rdef ; -SEARCH on [ FGristFiles Variant.cpp ] - = [ FDirName $(debugAnalyzerSources) util ] ; - HaikuSubInclude gui running_teams_window ; Modified: haiku/trunk/src/apps/debugger/arch/CpuState.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -8,10 +8,9 @@ #include #include +#include -#include "Variant.h" - class Register; @@ -20,7 +19,7 @@ virtual ~CpuState(); virtual bool GetRegisterValue(const Register* reg, - Variant& _value) = 0; + BVariant& _value) = 0; }; Modified: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -43,7 +43,7 @@ bool -CpuStateX86::GetRegisterValue(const Register* reg, Variant& _value) +CpuStateX86::GetRegisterValue(const Register* reg, BVariant& _value) { int32 index = reg->Index(); if (!IsRegisterSet(index)) Modified: haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h 2009-06-19 23:00:25 UTC (rev 31127) @@ -47,7 +47,7 @@ virtual ~CpuStateX86(); virtual bool GetRegisterValue(const Register* reg, - Variant& _value); + BVariant& _value); bool IsRegisterSet(int32 index) const; uint32 IntRegisterValue(int32 index) const; Modified: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -97,7 +97,7 @@ return fImages.CountItems(); } - virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value) { Image* image = fImages.ItemAt(rowIndex); if (image == NULL) @@ -108,7 +108,7 @@ value.SetTo(image->ID()); return true; case 1: - value.SetTo(image->Name(), VARIANT_DONT_COPY_DATA); + value.SetTo(image->Name(), B_VARIANT_DONT_COPY_DATA); return true; default: return false; @@ -233,12 +233,12 @@ { fImagesTable = new Table("images list", 0); AddChild(fImagesTable->ToView()); - + // columns fImagesTable->AddColumn(new Int32TableColumn(0, "ID", 40, 20, 1000, B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT)); fImagesTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000, B_TRUNCATE_END, B_ALIGN_LEFT)); - + fImagesTable->AddTableListener(this); } Modified: haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp 2009-06-19 22:13:32 UTC (rev 31126) +++ haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp 2009-06-19 23:00:25 UTC (rev 31127) @@ -31,15 +31,15 @@ } protected: [... truncated: 479 lines follow ...] From phoudoin at mail.berlios.de Sat Jun 20 10:44:57 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Sat, 20 Jun 2009 10:44:57 +0200 Subject: [Haiku-commits] r31128 - haiku/trunk/build/jam Message-ID: <200906200844.n5K8iv5t001518@sheep.berlios.de> Author: phoudoin Date: 2009-06-20 10:44:54 +0200 (Sat, 20 Jun 2009) New Revision: 31128 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31128&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/OptionalPackages Log: Removed libnetwork.so aliases from Development officially supported libraries. Only libGL.so aliases, libglut.so and libGLU.so, deserves to be there. Automatic space/tab cleanup. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-19 23:00:25 UTC (rev 31127) +++ haiku/trunk/build/jam/HaikuImage 2009-06-20 08:44:54 UTC (rev 31128) @@ -251,8 +251,11 @@ } } -SYSTEM_LIBS_ALIASES - = $(SYSTEM_LIBS_LIBNETWORK_ALIASES) libnetapi.so $(SYSTEM_LIBS_LIBGL_ALIASES) ; +SYSTEM_LIBS_ALIASES = + $(SYSTEM_LIBS_LIBNETWORK_ALIASES) + libnetapi.so + $(SYSTEM_LIBS_LIBGL_ALIASES) +; # servers AddFilesToHaikuImage system servers : $(SYSTEM_SERVERS) ; @@ -517,9 +520,9 @@ # printers AddDirectoryToHaikuImage home config settings printers Preview - : home-config-settings-printers-preview.rdef ; + : home-config-settings-printers-preview.rdef ; AddDirectoryToHaikuImage home config settings printers "Save as PDF" - : home-config-settings-printers-save-as-pdf.rdef ; + : home-config-settings-printers-save-as-pdf.rdef ; # licenses CopyDirectoryToHaikuImage system data Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2009-06-19 23:00:25 UTC (rev 31127) +++ haiku/trunk/build/jam/OptionalPackages 2009-06-20 08:44:54 UTC (rev 31128) @@ -317,7 +317,7 @@ # library symlinks local lib ; - for lib in $(SYSTEM_LIBS) $(SYSTEM_LIBS_ALIASES) { + for lib in $(SYSTEM_LIBS) $(SYSTEM_LIBS_LIBGL_ALIASES) { AddSymlinkToHaikuHybridImage $(abiDirTokens) lib : /system/lib $(lib:BS) : : true ; } From phoudoin at mail.berlios.de Sat Jun 20 10:52:55 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Sat, 20 Jun 2009 10:52:55 +0200 Subject: [Haiku-commits] r31129 - in haiku/trunk/src/apps/debugger: . debugger_interface Message-ID: <200906200852.n5K8qtPc005826@sheep.berlios.de> Author: phoudoin Date: 2009-06-20 10:52:51 +0200 (Sat, 20 Jun 2009) New Revision: 31129 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31129&view=rev Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h Log: DebuggerInterface destructor wasn't virtual, raising a -Werror warning. Fixed libdebug.so link. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 08:44:54 UTC (rev 31128) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 08:52:51 UTC (rev 31129) @@ -70,7 +70,7 @@ libshared.a $(TARGET_LIBSTDC++) - be debug + be libdebug.so : Debugger.rdef ; Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-20 08:44:54 UTC (rev 31128) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-20 08:52:51 UTC (rev 31129) @@ -23,7 +23,7 @@ class DebuggerInterface { public: DebuggerInterface(team_id teamID); - ~DebuggerInterface(); + virtual ~DebuggerInterface(); status_t Init(); void Close(); From phoudoin at mail.berlios.de Sat Jun 20 10:54:49 2009 From: phoudoin at mail.berlios.de (phoudoin at mail.berlios.de) Date: Sat, 20 Jun 2009 10:54:49 +0200 Subject: [Haiku-commits] r31130 - haiku/trunk/src/bin/network/tcpdump/libpcap Message-ID: <200906200854.n5K8snCL006819@sheep.berlios.de> Author: phoudoin Date: 2009-06-20 10:54:46 +0200 (Sat, 20 Jun 2009) New Revision: 31130 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31130&view=rev Modified: haiku/trunk/src/bin/network/tcpdump/libpcap/configure Log: Fixed Haiku libpcap detection. Modified: haiku/trunk/src/bin/network/tcpdump/libpcap/configure =================================================================== --- haiku/trunk/src/bin/network/tcpdump/libpcap/configure 2009-06-20 08:52:51 UTC (rev 31129) +++ haiku/trunk/src/bin/network/tcpdump/libpcap/configure 2009-06-20 08:54:46 UTC (rev 31130) @@ -5235,7 +5235,7 @@ V_PCAP=enet elif test -c /dev/nit ; then # check again in case not readable V_PCAP=snit -elif test -r /boot/beos ; then +elif test -r /boot/system ; then V_PCAP=haiku else V_PCAP=null From stippi at mail.berlios.de Sat Jun 20 12:10:05 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 20 Jun 2009 12:10:05 +0200 Subject: [Haiku-commits] r31131 - in haiku/trunk: headers/os/app headers/private/app src/kits/app src/servers/app Message-ID: <200906201010.n5KAA5et028616@sheep.berlios.de> Author: stippi Date: 2009-06-20 12:10:01 +0200 (Sat, 20 Jun 2009) New Revision: 31131 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31131&view=rev Modified: haiku/trunk/headers/os/app/Cursor.h haiku/trunk/headers/private/app/ServerProtocol.h haiku/trunk/src/kits/app/Cursor.cpp haiku/trunk/src/servers/app/ServerApp.cpp Log: Make it possible to properly use operator= on BCursors by making sure the reference counting is maintained correctly in the app_server. While reviewing this code, I have my doubts that my previous solution for handling pending SetViewCursor() calls is always working as it is intended. Modified: haiku/trunk/headers/os/app/Cursor.h =================================================================== --- haiku/trunk/headers/os/app/Cursor.h 2009-06-20 08:54:46 UTC (rev 31130) +++ haiku/trunk/headers/os/app/Cursor.h 2009-06-20 10:10:01 UTC (rev 31131) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _CURSOR_H @@ -11,31 +11,39 @@ class BCursor : BArchivable { - public: - BCursor(const void* cursorData); - BCursor(BMessage* data); - virtual ~BCursor(); +public: + BCursor(const void* cursorData); + BCursor(const BCursor& other); + BCursor(BMessage* data); + virtual ~BCursor(); - virtual status_t Archive(BMessage* archive, bool deep = true) const; - static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* archive, + bool deep = true) const; + static BArchivable* Instantiate(BMessage* archive); - private: - virtual status_t Perform(perform_code d, void* arg); + BCursor& operator=(const BCursor& other); + bool operator==(const BCursor& other) const; + bool operator!=(const BCursor& other) const; - virtual void _ReservedCursor1(); - virtual void _ReservedCursor2(); - virtual void _ReservedCursor3(); - virtual void _ReservedCursor4(); +private: + virtual status_t Perform(perform_code d, void* arg); - private: - friend class BApplication; - friend class BView; + virtual void _ReservedCursor1(); + virtual void _ReservedCursor2(); + virtual void _ReservedCursor3(); + virtual void _ReservedCursor4(); - int32 fServerToken; - bool fNeedToFree; - mutable bool fPendingViewCursor; + void _FreeCursorData(); - uint32 _reserved[6]; +private: + friend class BApplication; + friend class BView; + + int32 fServerToken; + bool fNeedToFree; + mutable bool fPendingViewCursor; + + uint32 _reserved[6]; }; #endif // _CURSOR_H Modified: haiku/trunk/headers/private/app/ServerProtocol.h =================================================================== --- haiku/trunk/headers/private/app/ServerProtocol.h 2009-06-20 08:54:46 UTC (rev 31130) +++ haiku/trunk/headers/private/app/ServerProtocol.h 2009-06-20 10:10:01 UTC (rev 31131) @@ -68,6 +68,7 @@ AS_QUERY_CURSOR_HIDDEN, AS_CREATE_CURSOR, + AS_REFERENCE_CURSOR, AS_DELETE_CURSOR, AS_BEGIN_RECT_TRACKING, Modified: haiku/trunk/src/kits/app/Cursor.cpp =================================================================== --- haiku/trunk/src/kits/app/Cursor.cpp 2009-06-20 08:54:46 UTC (rev 31130) +++ haiku/trunk/src/kits/app/Cursor.cpp 2009-06-20 10:10:01 UTC (rev 31131) @@ -63,6 +63,16 @@ } +BCursor::BCursor(const BCursor& other) + : + fServerToken(-1), + fNeedToFree(false), + fPendingViewCursor(false) +{ + *this = other; +} + + BCursor::BCursor(BMessage *data) { // undefined on BeOS @@ -74,14 +84,7 @@ BCursor::~BCursor() { - // Notify server to deallocate server-side objects for this cursor - if (fNeedToFree) { - BPrivate::AppServerLink link; - link.StartMessage(AS_DELETE_CURSOR); - link.Attach(fServerToken); - link.Attach(fPendingViewCursor); - link.Flush(); - } + _FreeCursorData(); } @@ -101,6 +104,42 @@ } +BCursor& +BCursor::operator=(const BCursor& other) +{ + if (&other != this && other != *this) { + _FreeCursorData(); + + fServerToken = other.fServerToken; + fNeedToFree = other.fNeedToFree; + fPendingViewCursor = false; + + if (fNeedToFree) { + // Tell app_server that there is another reference for this + // cursor data! + BPrivate::AppServerLink link; + link.StartMessage(AS_REFERENCE_CURSOR); + link.Attach(fServerToken); + } + } + return *this; +} + + +bool +BCursor::operator==(const BCursor& other) const +{ + return fServerToken == other.fServerToken; +} + + +bool +BCursor::operator!=(const BCursor& other) const +{ + return fServerToken != other.fServerToken; +} + + status_t BCursor::Perform(perform_code d, void *arg) { @@ -112,3 +151,18 @@ void BCursor::_ReservedCursor2() {} void BCursor::_ReservedCursor3() {} void BCursor::_ReservedCursor4() {} + + +void +BCursor::_FreeCursorData() +{ + // Notify server to deallocate server-side objects for this cursor + if (fNeedToFree) { + BPrivate::AppServerLink link; + link.StartMessage(AS_DELETE_CURSOR); + link.Attach(fServerToken); + link.Attach(fPendingViewCursor); + link.Flush(); + } +} + Modified: haiku/trunk/src/servers/app/ServerApp.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerApp.cpp 2009-06-20 08:54:46 UTC (rev 31130) +++ haiku/trunk/src/servers/app/ServerApp.cpp 2009-06-20 10:10:01 UTC (rev 31131) @@ -939,7 +939,7 @@ if (link.Read(cursorData, sizeof(cursorData)) >= B_OK) { cursor = fDesktop->GetCursorManager().CreateCursor(fClientTeam, - cursorData); + cursorData); if (cursor == NULL) status = B_NO_MEMORY; } @@ -954,6 +954,27 @@ fLink.Flush(); break; } + case AS_REFERENCE_CURSOR: + { + STRACE(("ServerApp %s: Reference BCursor\n", Signature())); + // Attached data: + // 1) int32 token ID of the cursor to reference + int32 token; + if (link.Read(&token) != B_OK) + break; + + if (!fDesktop->GetCursorManager().Lock()) + break; + + ServerCursor* cursor + = fDesktop->GetCursorManager().FindCursor(token); + if (cursor != NULL) + cursor->Acquire(); + + fDesktop->GetCursorManager().Unlock(); + + break; + } case AS_DELETE_CURSOR: { STRACE(("ServerApp %s: Delete BCursor\n", Signature())); @@ -968,8 +989,9 @@ if (!fDesktop->GetCursorManager().Lock()) break; - ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token); - if (cursor) { + ServerCursor* cursor + = fDesktop->GetCursorManager().FindCursor(token); + if (cursor != NULL) { if (pendingViewCursor) cursor->SetPendingViewCursor(true); From joe.prostko+haiku at gmail.com Sat Jun 20 12:41:02 2009 From: joe.prostko+haiku at gmail.com (Joseph Prostko) Date: Sat, 20 Jun 2009 06:41:02 -0400 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <200905270112.n4R1Cf1p031769@sheep.berlios.de> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> Message-ID: <7e5795b0906200341s2f972ffel484098cc56af290d@mail.gmail.com> On Tue, May 26, 2009 at 9:12 PM, wrote: > Author: bonefish > Date: 2009-05-27 03:12:34 +0200 (Wed, 27 May 2009) > New Revision: 30875 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=30875&view=rev > > Modified: haiku/trunk/build/jam/OptionalPackages > =================================================================== > --- haiku/trunk/build/jam/OptionalPackages ? ? ?2009-05-27 00:45:44 UTC (rev 30874) > +++ haiku/trunk/build/jam/OptionalPackages ? ? ?2009-05-27 01:12:34 UTC (rev 30875) > @@ -208,20 +212,32 @@ > ?if [ IsOptionalHaikuImagePackageAdded DevelopmentBase ] > ? ? ? ? ? ? ? ?&& $(TARGET_ARCH) = x86 { > ? ? ? ?# gcc and binutils > - ? ? ? if $(HAIKU_GCC_VERSION[1]) = 2 { > + ? ? ? if $(HAIKU_GCC_VERSION[1]) = 2 || $(isHybridBuild) { > ? ? ? ? ? ? ? ?local baseURL = http://haiku-files.org/files/optional-packages ; > - ? ? ? ? ? ? ? InstallOptionalHaikuImagePackage gcc-2.95.3-haiku-081024 > - ? ? ? ? ? ? ? ? ? ? ? : $(baseURL)/gcc-2.95.3-haiku-081024.zip ; > - ? ? ? } else if $(HAIKU_GCC_VERSION[1]) = 4 { > - ? ? ? ? ? ? ? local baseURL = http://haiku.mlotz.ch ; > - ? ? ? ? ? ? ? InstallOptionalHaikuImagePackage gcc-4.3.3-haiku-090313 > - ? ? ? ? ? ? ? ? ? ? ? : $(baseURL)/gcc-4.3.3-haiku-090313.zip ; > + ? ? ? ? ? ? ? InstallOptionalHaikuImagePackage gcc-2.95.3-haiku-081024-1 > + ? ? ? ? ? ? ? ? ? ? ? : $(baseURL)/gcc-2.95.3-haiku-081024-1.zip ; > + ? ? ? } > > + ? ? ? if $(HAIKU_GCC_VERSION[1]) = 4 || $(isHybridBuild) { > + ? ? ? ? ? ? ? local baseURL = http://haiku-files.org/files/optional-packages ; > + ? ? ? ? ? ? ? InstallOptionalHaikuImagePackage gcc-4.3.3-haiku-090313-1 > + ? ? ? ? ? ? ? ? ? ? ? : $(baseURL)/gcc-4.3.3-haiku-090313-1.zip ; > + > ? ? ? ? ? ? ? ?# symlink cpp to g++'s headers > - ? ? ? ? ? ? ? AddSymlinkToHaikuImage develop headers > - ? ? ? ? ? ? ? ? ? ? ? : /boot/develop/tools/gnupro/include/g++ : cpp ; > + ? ? ? ? ? ? ? AddSymlinkToHaikuImage develop abi x86 gcc4 headers > + ? ? ? ? ? ? ? ? ? ? ? : ../tools/current/include/g++ : cpp ; > ? ? ? ?} > > + ? ? ? if $(HAIKU_GCC_VERSION[1]) = 4 { > + ? ? ? ? ? ? ? # symlink to libstdc++.so > + ? ? ? ? ? ? ? # TODO: This needs to be solved differently! I.e. the build system > + ? ? ? ? ? ? ? # (configure) should already produce libstdc++.so. > + ? ? ? ? ? ? ? AddSymlinkToHaikuImage system lib > + ? ? ? ? ? ? ? ? ? ? ? : /boot/develop/abi/x86/gcc4/tools/current/lib/libstdc++.so ; > + ? ? ? ? ? ? ? AddSymlinkToAlternativeGCCArchive system lib gcc4 > + ? ? ? ? ? ? ? ? ? ? ? : /boot/develop/abi/x86/gcc4/tools/current/lib/libstdc++.so ; > + ? ? ? } > + > ? ? ? ?# other commonly used tools > ? ? ? ?local baseURL = http://haiku-files.org/files/optional-packages ; > ? ? ? ?InstallOptionalHaikuImagePackage bison-2.4-gcc2-2008-11-09 In the above hunk, shouldn't the lines if $(HAIKU_GCC_VERSION[1]) = 2 || $(isHybridBuild) { and if $(HAIKU_GCC_VERSION[1]) = 4 || $(isHybridBuild) { read as if $(HAIKU_GCC_VERSION[1]) = 2 || $(isHybridBuild) = 1 { and if $(HAIKU_GCC_VERSION[1]) = 4 || $(isHybridBuild) = 1 { respectively? I tend to do hybrid and pure builds out of the same build directory, setting HAIKU_ADD_ALTERNATIVE_GCC_LIBS = ; on the profile I do not want to be hybrid. With this revision, the alternative GCC gets downloaded no matter what, since isHybridBuild is set at the beginning of the file. - joe From bonefish at mail.berlios.de Sat Jun 20 13:15:07 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 20 Jun 2009 13:15:07 +0200 Subject: [Haiku-commits] r31132 - haiku/trunk/build/jam Message-ID: <200906201115.n5KBF7pW003712@sheep.berlios.de> Author: bonefish Date: 2009-06-20 13:15:05 +0200 (Sat, 20 Jun 2009) New Revision: 31132 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31132&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Changed isHybridBuild variable from 0/1 to undefined/defined. Fixes formerly incorrect check in the DevelopmentBase package. Thanks to Joseph Prostko for the hint. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2009-06-20 10:10:01 UTC (rev 31131) +++ haiku/trunk/build/jam/OptionalPackages 2009-06-20 11:15:05 UTC (rev 31132) @@ -5,7 +5,7 @@ # Detect a hybrid GCC2/GCC4 image and disable the checks for unavailable GCC4 # packages. (It does not matter if a package was built with either compiler, # the system should have the respective other system libs.) -local isHybridBuild = 0 ; +local isHybridBuild ; if $(HAIKU_ADD_ALTERNATIVE_GCC_LIBS) && $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) { isHybridBuild = 1 ; } @@ -87,7 +87,7 @@ if [ IsOptionalHaikuImagePackageAdded Beam ] { if $(TARGET_ARCH) != x86 { Echo "No optional package Beam available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package Beam available for gcc4" ; } else { InstallOptionalHaikuImagePackage Beam @@ -117,7 +117,7 @@ if [ IsOptionalHaikuImagePackageAdded BeHappy ] { if $(TARGET_ARCH) != x86 { Echo "No optional package BeHappy available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package BeHappy available for gcc4" ; } else { InstallOptionalHaikuImagePackage BeHappy @@ -134,7 +134,7 @@ if [ IsOptionalHaikuImagePackageAdded BeOSCompatibility ] { if $(TARGET_ARCH) != x86 { Echo "No optional package BeOSCompatibility available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package BeOSCompatibility available for gcc4" ; } else { Echo "Warning: Adding BeOS compatibility symlinks. This will go away. Please fix your apps!" ; @@ -152,7 +152,7 @@ if [ IsOptionalHaikuImagePackageAdded BePDF ] { if $(TARGET_ARCH) != x86 { Echo "No optional package BePDF available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package BePDF available for gcc4" ; } else { InstallOptionalHaikuImagePackage BePDF-1.1.1b1.x86 @@ -206,7 +206,7 @@ if [ IsOptionalHaikuImagePackageAdded CLucene ] { if $(TARGET_ARCH) != x86 { Echo "No optional package CLucene available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) < 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) < 4 && ! $(isHybridBuild) { Echo "No optional package CLucene available for GCC2" ; } else { local baseURL = http://haiku-files.org/files/optional-packages ; @@ -283,7 +283,7 @@ : $(baseURL)/bison-2.4-gcc2-2008-11-09.zip ; InstallOptionalHaikuImagePackage m4-1.4.12-gcc2-2008-11-04 : $(baseURL)/m4-1.4.12-gcc2-2008-11-04.zip ; - local baseURL = http://www.haiku-ports.de/packages ; + local baseURL = http://www.haiku-ports.de/packages ; InstallOptionalHaikuImagePackage flex-2.5.35-gcc2-haiku-2009-05-26 : $(baseURL)/sys-devel/flex/flex-2.5.35-gcc2-haiku-2009-05-26.zip ; InstallOptionalHaikuImagePackage jam-gcc2-haiku-2009-05-26 @@ -399,7 +399,7 @@ if [ IsOptionalHaikuImagePackageAdded Firefox ] { if $(TARGET_ARCH) != x86 { Echo "No optional package Firefox available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { local baseURL = http://haiku-files.org/files/optional-packages ; InstallOptionalHaikuImagePackage BeZillaBrowser-2.0.0.21pre-haiku-gcc4-x86-09-03-01 : $(baseURL)/BeZillaBrowser-2.0.0.21pre-haiku-gcc4-x86-09-03-01.zip @@ -424,7 +424,7 @@ if [ IsOptionalHaikuImagePackageAdded KeymapSwitcher ] { if $(TARGET_ARCH) != x86 { Echo "No optional package KeymapSwitcher available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { local baseURL = http://downloads.sourceforge.net/dotmatrix4beos ; InstallOptionalHaikuImagePackage KeymapSwitcher-gcc4-20090531 : $(baseURL)/KeymapSwitcher-1.2.3-gcc4-2009-05-31.zip @@ -492,7 +492,7 @@ if [ IsOptionalHaikuImagePackageAdded Links ] { if $(TARGET_ARCH) != x86 { Echo "No optional package Links available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package Links available for gcc4" ; } else { InstallOptionalHaikuImagePackage Links @@ -537,7 +537,7 @@ if [ IsOptionalHaikuImagePackageAdded NetSurf ] { if $(TARGET_ARCH) != x86 { Echo "No optional package NetSurf available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package NetSurf available for gcc4" ; } else { InstallOptionalHaikuImagePackage NetSurf @@ -603,7 +603,7 @@ if [ IsOptionalHaikuImagePackageAdded P7zip ] { if $(TARGET_ARCH) != x86 { Echo "No optional package P7zip available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package P7zip available for gcc4" ; } else { local baseURL = http://www.haiku-ports.de/packages/app-arch/p7zip ; @@ -792,7 +792,7 @@ if [ IsOptionalHaikuImagePackageAdded Vim ] { if $(TARGET_ARCH) != x86 { Echo "No optional package Vim available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { local baseURL = http://haiku-ports.de/packages/app-editors/vim ; InstallOptionalHaikuImagePackage vim-7.2-gcc4-20090531 : $(baseURL)/vim-7.2-gcc4-haiku-2009-05-31.zip @@ -838,7 +838,7 @@ if [ IsOptionalHaikuImagePackageAdded VLC ] { if $(TARGET_ARCH) != x86 { Echo "No optional package VLC available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package VLC available for gcc4" ; } else { local baseURL = http://haiku-files.org/files/optional-packages ; @@ -874,7 +874,7 @@ if [ IsOptionalHaikuImagePackageAdded WonderBrush ] { if $(TARGET_ARCH) != x86 { Echo "No optional package WonderBrush available for $(TARGET_ARCH)" ; - } else if $(HAIKU_GCC_VERSION[1]) >= 4 && $(isHybridBuild) = 0 { + } else if $(HAIKU_GCC_VERSION[1]) >= 4 && ! $(isHybridBuild) { Echo "No optional package WonderBrush available for gcc4" ; } else { local baseURL = http://www.yellowbites.com/downloads ; From ingo_weinhold at gmx.de Sat Jun 20 12:51:08 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 20 Jun 2009 12:51:08 +0200 Subject: [Haiku-commits] r30875 - in haiku/trunk: . build/jam data/bin data/system/boot src/bin In-Reply-To: <7e5795b0906200341s2f972ffel484098cc56af290d@mail.gmail.com> References: <200905270112.n4R1Cf1p031769@sheep.berlios.de> <7e5795b0906200341s2f972ffel484098cc56af290d@mail.gmail.com> Message-ID: <20090620125108.382.1@knochen-vm.localdomain> On 2009-06-20 at 12:41:02 [+0200], Joseph Prostko wrote: > On Tue, May 26, 2009 at 9:12 PM, wrote: [...] > In the above hunk, shouldn't the lines > > if $(HAIKU_GCC_VERSION[1]) = 2 || $(isHybridBuild) { > > and > > if $(HAIKU_GCC_VERSION[1]) = 4 || $(isHybridBuild) { > > read as > > if $(HAIKU_GCC_VERSION[1]) = 2 || $(isHybridBuild) = 1 { > > and > > if $(HAIKU_GCC_VERSION[1]) = 4 || $(isHybridBuild) = 1 { > > respectively? Thanks. Fixed in r31132. CU, Ingo From axeld at pinc-software.de Sat Jun 20 14:10:49 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 20 Jun 2009 14:10:49 +0200 CEST Subject: [Haiku-commits] r31132 - haiku/trunk/build/jam In-Reply-To: <200906201115.n5KBF7pW003712@sheep.berlios.de> Message-ID: <11863043927-BeMail@zon> bonefish at mail.berlios.de wrote: > Log: > Changed isHybridBuild variable from 0/1 to undefined/defined. Fixes > formerly > incorrect check in the DevelopmentBase package. Thanks to Joseph > Prostko for > the hint. Just curious: why is the former check wrong? Bye, Axel. From stippi at mail.berlios.de Sat Jun 20 14:11:50 2009 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 20 Jun 2009 14:11:50 +0200 Subject: [Haiku-commits] r31133 - in haiku/trunk: headers/os/app headers/private/app src/kits/app src/kits/interface src/servers/app Message-ID: <200906201211.n5KCBoiG015166@sheep.berlios.de> Author: stippi Date: 2009-06-20 14:11:49 +0200 (Sat, 20 Jun 2009) New Revision: 31133 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31133&view=rev Modified: haiku/trunk/headers/os/app/Cursor.h haiku/trunk/headers/private/app/ServerProtocol.h haiku/trunk/headers/private/app/ServerProtocolStructs.h haiku/trunk/src/kits/app/Cursor.cpp haiku/trunk/src/kits/interface/View.cpp haiku/trunk/src/servers/app/ProfileMessageSupport.cpp haiku/trunk/src/servers/app/ServerApp.cpp haiku/trunk/src/servers/app/ServerCursor.cpp haiku/trunk/src/servers/app/ServerCursor.h haiku/trunk/src/servers/app/ServerWindow.cpp haiku/trunk/src/servers/app/View.cpp Log: * Moved the implementation of SetViewCursor from the thread of the window of the view into the application thread. This solves the race condition with asynchronous SetViewCursor and deleting the cursor immediately afterwards for real. * The ServerApp now requires a reference to the current cursor, just in case... * Added TODOs for caching the BView token, it's currently resolved for every single BView call that talks to the server... not good! Modified: haiku/trunk/headers/os/app/Cursor.h =================================================================== --- haiku/trunk/headers/os/app/Cursor.h 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/headers/os/app/Cursor.h 2009-06-20 12:11:49 UTC (rev 31133) @@ -41,8 +41,9 @@ int32 fServerToken; bool fNeedToFree; - mutable bool fPendingViewCursor; + bool _reservedWasPendingViewCursor; + // Probably bogus because of padding. uint32 _reserved[6]; }; Modified: haiku/trunk/headers/private/app/ServerProtocol.h =================================================================== --- haiku/trunk/headers/private/app/ServerProtocol.h 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/headers/private/app/ServerProtocol.h 2009-06-20 12:11:49 UTC (rev 31133) @@ -61,6 +61,7 @@ // Cursor commands AS_SET_CURSOR, + AS_SET_VIEW_CURSOR, AS_SHOW_CURSOR, AS_HIDE_CURSOR, @@ -258,7 +259,6 @@ AS_VIEW_SET_ORIGIN, AS_VIEW_GET_ORIGIN, AS_VIEW_RESIZE_MODE, - AS_VIEW_SET_CURSOR, AS_VIEW_BEGIN_RECT_TRACK, AS_VIEW_END_RECT_TRACK, AS_VIEW_DRAG_RECT, Modified: haiku/trunk/headers/private/app/ServerProtocolStructs.h =================================================================== --- haiku/trunk/headers/private/app/ServerProtocolStructs.h 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/headers/private/app/ServerProtocolStructs.h 2009-06-20 12:11:49 UTC (rev 31133) @@ -55,6 +55,7 @@ struct ViewSetViewCursorInfo { int32 cursorToken; + int32 viewToken; bool sync; }; Modified: haiku/trunk/src/kits/app/Cursor.cpp =================================================================== --- haiku/trunk/src/kits/app/Cursor.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/kits/app/Cursor.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -30,8 +30,7 @@ BCursor::BCursor(const void *cursorData) : fServerToken(-1), - fNeedToFree(false), - fPendingViewCursor(false) + fNeedToFree(false) { const uint8 *data = (const uint8 *)cursorData; @@ -66,8 +65,7 @@ BCursor::BCursor(const BCursor& other) : fServerToken(-1), - fNeedToFree(false), - fPendingViewCursor(false) + fNeedToFree(false) { *this = other; } @@ -78,7 +76,6 @@ // undefined on BeOS fServerToken = -1; fNeedToFree = false; - fPendingViewCursor = false; } @@ -112,7 +109,6 @@ fServerToken = other.fServerToken; fNeedToFree = other.fNeedToFree; - fPendingViewCursor = false; if (fNeedToFree) { // Tell app_server that there is another reference for this @@ -161,7 +157,6 @@ BPrivate::AppServerLink link; link.StartMessage(AS_DELETE_CURSOR); link.Attach(fServerToken); - link.Attach(fPendingViewCursor); link.Flush(); } } Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/kits/interface/View.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -996,26 +996,21 @@ if (cursor == NULL || fOwner == NULL) return; - _CheckLockAndSwitchCurrent(); + _CheckLock(); - fOwner->fLink->StartMessage(AS_VIEW_SET_CURSOR); ViewSetViewCursorInfo info; info.cursorToken = cursor->fServerToken; + info.viewToken = _get_object_token_(this); // TODO: Use server_token! info.sync = sync; - fOwner->fLink->Attach(info); - if (!sync) { - cursor->fPendingViewCursor = true; - // this avoids a race condition in case the cursor is - // immediately deleted after this call, as the deletion - // is handled by the application, not the window - } else { - // make sure the server has processed the - // message and "acquired" the cursor in - // the window thread before returning from - // this function + BPrivate::AppServerLink link; + link.StartMessage(AS_SET_VIEW_CURSOR); + link.Attach(info); + + if (sync) { + // Make sure the server has processed the message. int32 code; - fOwner->fLink->FlushWithReply(code); + link.FlushWithReply(code); } } @@ -3911,6 +3906,7 @@ if (owner != NULL && !fTopLevelView) { // the top level view is deleted by the app_server automatically owner->fLink->StartMessage(AS_VIEW_DELETE); + // TODO: Use server_token owner->fLink->Attach(_get_object_token_(this)); } @@ -4250,7 +4246,7 @@ if (err == B_OK) { if (newHiddenState == true) Hide(); - else + else Show(); } } @@ -4906,6 +4902,7 @@ else fOwner->fLink->StartMessage(AS_VIEW_CREATE); + // TODO: Use server_token fOwner->fLink->Attach(_get_object_token_(this)); fOwner->fLink->AttachString(Name()); fOwner->fLink->Attach(Frame()); @@ -4919,6 +4916,7 @@ if (fTopLevelView) fOwner->fLink->Attach(B_NULL_TOKEN); else + // TODO: Use server_token fOwner->fLink->Attach(_get_object_token_(fParent)); fOwner->fLink->Flush(); @@ -5127,6 +5125,7 @@ if (fOwner->fLastMouseMovedView == this) fOwner->fLastMouseMovedView = NULL; + // TODO: Use server_token if (fOwner->fLastViewToken == _get_object_token_(this)) fOwner->fLastViewToken = B_NULL_TOKEN; @@ -5344,6 +5343,7 @@ void BView::_SwitchServerCurrentView() const { + // TODO: Use server_token int32 serverToken = _get_object_token_(this); if (fOwner->fLastViewToken != serverToken) { Modified: haiku/trunk/src/servers/app/ProfileMessageSupport.cpp =================================================================== --- haiku/trunk/src/servers/app/ProfileMessageSupport.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/servers/app/ProfileMessageSupport.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -45,6 +45,7 @@ // Cursor commands case AS_SET_CURSOR: string = "AS_SET_CURSOR"; break; + case AS_SET_VIEW_CURSOR: string = "AS_SET_VIEW_CURSOR"; break; case AS_SHOW_CURSOR: string = "AS_SHOW_CURSOR"; break; case AS_HIDE_CURSOR: string = "AS_HIDE_CURSOR"; break; @@ -52,6 +53,7 @@ case AS_QUERY_CURSOR_HIDDEN: string = "AS_QUERY_CURSOR_HIDDEN"; break; case AS_CREATE_CURSOR: string = "AS_CREATE_CURSOR"; break; + case AS_REFERENCE_CURSOR: string = "AS_REFERENCE_CURSOR"; break; case AS_DELETE_CURSOR: string = "AS_DELETE_CURSOR"; break; case AS_BEGIN_RECT_TRACKING: string = "AS_BEGIN_RECT_TRACKING"; break; @@ -64,7 +66,7 @@ case AS_QUIT_WINDOW: string = "AS_QUIT_WINDOW"; break; case AS_SEND_BEHIND: string = "AS_SEND_BEHIND"; break; case AS_SET_LOOK: string = "AS_SET_LOOK"; break; - case AS_SET_FEEL: string = "AS_SET_FEEL"; break; + case AS_SET_FEEL: string = "AS_SET_FEEL"; break; case AS_SET_FLAGS: string = "AS_SET_FLAGS"; break; case AS_DISABLE_UPDATES: string = "AS_DISABLE_UPDATES"; break; case AS_ENABLE_UPDATES: string = "AS_ENABLE_UPDATES"; break; @@ -140,7 +142,7 @@ case AS_GET_ACCELERANT_INFO: string = "AS_GET_ACCELERANT_INFO"; break; case AS_GET_MONITOR_INFO: string = "AS_GET_MONITOR_INFO"; break; case AS_GET_FRAME_BUFFER_CONFIG: string = "AS_GET_FRAME_BUFFER_CONFIG"; break; - + case AS_SET_DPMS: string = "AS_SET_DPMS"; break; case AS_GET_DPMS_STATE: string = "AS_GET_DPMS_STATE"; break; case AS_GET_DPMS_CAPABILITIES: string = "AS_GET_DPMS_CAPABILITIES"; break; @@ -174,7 +176,7 @@ case AS_GET_DECORATOR_SETTINGS: string = "AS_GET_DECORATOR_SETTINGS"; break; case AS_GET_SHOW_ALL_DRAGGERS: string = "AS_GET_SHOW_ALL_DRAGGERS"; break; case AS_SET_SHOW_ALL_DRAGGERS: string = "AS_SET_SHOW_ALL_DRAGGERS"; break; - + // Subpixel antialiasing & hinting case AS_SET_SUBPIXEL_ANTIALIASING: string = "AS_SET_SUBPIXEL_ANTIALIASING"; break; case AS_GET_SUBPIXEL_ANTIALIASING: string = "AS_GET_SUBPIXEL_ANTIALIASING"; break; @@ -240,7 +242,6 @@ case AS_VIEW_SET_ORIGIN: string = "AS_VIEW_SET_ORIGIN"; break; case AS_VIEW_GET_ORIGIN: string = "AS_VIEW_GET_ORIGIN"; break; case AS_VIEW_RESIZE_MODE: string = "AS_VIEW_RESIZE_MODE"; break; - case AS_VIEW_SET_CURSOR: string = "AS_VIEW_SET_CURSOR"; break; case AS_VIEW_BEGIN_RECT_TRACK: string = "AS_VIEW_BEGIN_RECT_TRACK"; break; case AS_VIEW_END_RECT_TRACK: string = "AS_VIEW_END_RECT_TRACK"; break; case AS_VIEW_DRAG_RECT: string = "AS_VIEW_DRAG_RECT"; break; @@ -296,7 +297,7 @@ // BDirectWindow codes case AS_DIRECT_WINDOW_GET_SYNC_DATA: string = "AS_DIRECT_WINDOW_GET_SYNC_DATA"; break; case AS_DIRECT_WINDOW_SET_FULLSCREEN: string = "AS_DIRECT_WINDOW_SET_FULLSCREEN"; break; - + default: string << "unkown code: " << code; break; Modified: haiku/trunk/src/servers/app/ServerApp.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerApp.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/servers/app/ServerApp.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -300,7 +300,17 @@ void ServerApp::SetCurrentCursor(ServerCursor* cursor) { + if (fViewCursor == cursor) + return; + + if (fViewCursor) + fViewCursor->Release(); + fViewCursor = cursor; + + if (fViewCursor) + fViewCursor->Acquire(); + fDesktop->SetCursor(CurrentCursor()); } @@ -910,6 +920,63 @@ } break; } + case AS_SET_VIEW_CURSOR: + { + STRACE(("ServerApp %s: AS_SET_VIEW_CURSOR:\n", Signature())); + + ViewSetViewCursorInfo info; + if (link.Read(&info) != B_OK) + break; + + if (fDesktop->GetCursorManager().Lock()) { + ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor( + info.cursorToken); + // If we found a cursor, make sure it doesn't go away. + if (cursor != NULL) + cursor->Acquire(); + + fDesktop->GetCursorManager().Unlock(); + + if (cursor != NULL) { + // We need to acquire the write lock here, since we cannot + // afford that the window thread to which the view belongs + // is running and messing with that same view. + fDesktop->LockAllWindows(); + + // Find the corresponding view by the given token. It's ok + // if this view does not exist anymore, since it may have + // already be deleted in the window thread before this + // message got here. + View* view; + if (fViewTokens.GetToken(info.viewToken, B_HANDLER_TOKEN, + (void**)&view) == B_OK) { + // Set the cursor on the view. + view->SetCursor(cursor); + + // The cursor might need to be updated now. + Window* window = view->Window(); + if (window != NULL && window->IsFocus()) { + if (fDesktop->ViewUnderMouse(window) + == view->Token()) { + SetCurrentCursor(cursor); + } + } + } + + fDesktop->UnlockAllWindows(); + + // Release the temporary reference. + cursor->Release(); + } + } + + if (info.sync) { + // sync the client (it can now delete the cursor) + fLink.StartMessage(B_OK); + fLink.Flush(); + } + break; + } case AS_CREATE_CURSOR: { STRACE(("ServerApp %s: Create Cursor\n", Signature())); @@ -981,9 +1048,7 @@ // Attached data: // 1) int32 token ID of the cursor to delete int32 token; - bool pendingViewCursor; - link.Read(&token); - if (link.Read(&pendingViewCursor) != B_OK) + if (link.Read(&token) != B_OK) break; if (!fDesktop->GetCursorManager().Lock()) @@ -991,12 +1056,9 @@ ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token); - if (cursor != NULL) { - if (pendingViewCursor) - cursor->SetPendingViewCursor(true); + if (cursor != NULL) + cursor->Release(); - cursor->Release(); - } fDesktop->GetCursorManager().Unlock(); break; Modified: haiku/trunk/src/servers/app/ServerCursor.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerCursor.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/servers/app/ServerCursor.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -10,7 +10,7 @@ /*! Although descended from ServerBitmaps, ServerCursors are not handled by - the BitmapManager - they are allocated like any other object. Unlike BeOS + the BitmapManager - they are allocated like any other object. Unlike BeOS R5, cursors can be any size or color space, and this class accomodates and expands the R5 API. */ @@ -33,19 +33,17 @@ \param flags ServerBitmap flags. See Bitmap.h. \param hotspot Hotspot of the cursor \param bytesperline Bytes per row for the cursor. See ServerBitmap::ServerBitmap() - + */ -ServerCursor::ServerCursor(BRect r, color_space format, - int32 flags, BPoint hotspot, - int32 bytesPerRow, - screen_id screen) - : ServerBitmap(r, format, flags, bytesPerRow, screen), - fHotSpot(hotspot), - fOwningTeam(-1), - fReferenceCount(1), - fCursorData(NULL), - fManager(NULL), - fPendingViewCursor(0) +ServerCursor::ServerCursor(BRect r, color_space format, int32 flags, + BPoint hotspot, int32 bytesPerRow, screen_id screen) + : + ServerBitmap(r, format, flags, bytesPerRow, screen), + fHotSpot(hotspot), + fOwningTeam(-1), + fReferenceCount(1), + fCursorData(NULL), + fManager(NULL) { fHotSpot.ConstrainTo(Bounds()); _AllocateBuffer(); @@ -57,13 +55,13 @@ \param data Pointer to 68-byte cursor data array. See BeBook entry for BCursor for details */ ServerCursor::ServerCursor(const uint8* data) - : ServerBitmap(BRect(0, 0, 15, 15), B_RGBA32, 0), - fHotSpot(0, 0), - fOwningTeam(-1), - fReferenceCount(1), - fCursorData(NULL), - fManager(NULL), - fPendingViewCursor(0) + : + ServerBitmap(BRect(0, 0, 15, 15), B_RGBA32, 0), + fHotSpot(0, 0), + fOwningTeam(-1), + fReferenceCount(1), + fCursorData(NULL), + fManager(NULL) { // 68-byte array used in R5 for holding cursors. // This API has serious problems and should be deprecated(but supported) in R2 @@ -72,7 +70,7 @@ // to RGBA32 (little endian). Eventually, there will be support for 16 and // 8-bit depths // NOTE: review this once we have working PPC graphics cards (big endian). - if (data) { + if (data) { _AllocateBuffer(); uint8* buffer = Bits(); if (!buffer) @@ -123,17 +121,16 @@ \param data Pointer to bitmap data in memory, the padding bytes should be contained when format less than 32 bpp. */ -ServerCursor::ServerCursor(const uint8* alreadyPaddedData, - uint32 width, uint32 height, - color_space format) - : ServerBitmap(BRect(0, 0, width - 1, height - 1), format, 0), - fHotSpot(0, 0), - fOwningTeam(-1), - fReferenceCount(1), - fCursorData(NULL), - fManager(NULL), - fPendingViewCursor(0) -{ +ServerCursor::ServerCursor(const uint8* alreadyPaddedData, uint32 width, + uint32 height, color_space format) + : + ServerBitmap(BRect(0, 0, width - 1, height - 1), format, 0), + fHotSpot(0, 0), + fOwningTeam(-1), + fReferenceCount(1), + fCursorData(NULL), + fManager(NULL) +{ _AllocateBuffer(); if (Bits()) memcpy(Bits(), alreadyPaddedData, BitsLength()); @@ -145,19 +142,19 @@ \param cursor cursor to copy */ ServerCursor::ServerCursor(const ServerCursor* cursor) - : ServerBitmap(cursor), - fHotSpot(0, 0), - fOwningTeam(-1), - fReferenceCount(1), - fCursorData(NULL), - fManager(NULL), - fPendingViewCursor(0) + : + ServerBitmap(cursor), + fHotSpot(0, 0), + fOwningTeam(-1), + fReferenceCount(1), + fCursorData(NULL), + fManager(NULL) { // TODO: Hm. I don't move this into the if clause, // because it might break code elsewhere. _AllocateBuffer(); - if (cursor) { + if (cursor) { if (Bits() && cursor->Bits()) memcpy(Bits(), cursor->Bits(), BitsLength()); fHotSpot = cursor->fHotSpot; @@ -193,11 +190,6 @@ ServerCursor::Release() { if (atomic_add(&fReferenceCount, -1) == 1) { - if (fPendingViewCursor > 0) { - // There is a SetViewCursor() waiting to be carried out - return false; - } - if (fManager && !fManager->RemoveCursor(this)) return false; @@ -209,13 +201,6 @@ void -ServerCursor::SetPendingViewCursor(bool pending) -{ - atomic_add(&fPendingViewCursor, pending ? 1 : -1); -} - - -void ServerCursor::AttachedToManager(CursorManager* manager) { fManager = manager; Modified: haiku/trunk/src/servers/app/ServerCursor.h =================================================================== --- haiku/trunk/src/servers/app/ServerCursor.h 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/servers/app/ServerCursor.h 2009-06-20 12:11:49 UTC (rev 31133) @@ -52,8 +52,6 @@ bool Release(); int32 ReferenceCount() { return fReferenceCount; } - void SetPendingViewCursor(bool pending); - void AttachedToManager(CursorManager* manager); const uint8* CursorData() const @@ -67,7 +65,6 @@ vint32 fReferenceCount; uint8* fCursorData; CursorManager* fManager; - vint32 fPendingViewCursor; }; Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -1539,37 +1539,6 @@ fCurrentView->SetResizeMode(resizeMode); break; } - case AS_VIEW_SET_CURSOR: - { - DTRACE(("ServerWindow %s: Message AS_VIEW_CURSOR: View: %s\n", - Title(), fCurrentView->Name())); - - ViewSetViewCursorInfo info; - if (link.Read(&info) != B_OK) - break; - - if (!fDesktop->GetCursorManager().Lock()) - break; - - ServerCursor* cursor - = fDesktop->GetCursorManager().FindCursor(info.cursorToken); - fCurrentView->SetCursor(cursor); - - fDesktop->GetCursorManager().Unlock(); - - if (fWindow->IsFocus()) { - // The cursor might need to be updated now - if (fDesktop->ViewUnderMouse(fWindow) == fCurrentView->Token()) - fServerApp->SetCurrentCursor(cursor); - } - if (info.sync) { - // sync the client (it can now delete the cursor) - fLink.StartMessage(B_OK); - fLink.Flush(); - } - - break; - } case AS_VIEW_SET_FLAGS: { uint32 flags; Modified: haiku/trunk/src/servers/app/View.cpp =================================================================== --- haiku/trunk/src/servers/app/View.cpp 2009-06-20 11:15:05 UTC (rev 31132) +++ haiku/trunk/src/servers/app/View.cpp 2009-06-20 12:11:49 UTC (rev 31133) @@ -1291,10 +1291,8 @@ fCursor = cursor; - if (fCursor) { + if (fCursor) fCursor->Acquire(); - fCursor->SetPendingViewCursor(false); - } } From ingo_weinhold at gmx.de Sat Jun 20 14:22:49 2009 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 20 Jun 2009 14:22:49 +0200 Subject: [Haiku-commits] r31132 - haiku/trunk/build/jam In-Reply-To: <11863043927-BeMail@zon> References: <11863043927-BeMail@zon> Message-ID: <20090620142249.351.1@knochen-vm.localdomain> On 2009-06-20 at 14:10:49 [+0200], Axel D?rfler wrote: > bonefish at mail.berlios.de wrote: > > Log: > > Changed isHybridBuild variable from 0/1 to undefined/defined. Fixes > > formerly > > incorrect check in the DevelopmentBase package. Thanks to Joseph > > Prostko for > > the hint. > > Just curious: why is the former check wrong? isHybridImage was always defined to either "0" or "1", but "if $(isHybridImage)" just checks whether the variable has a value. The other "= 0" and "= 1" checks did work, of course, but I find it nicer to use the boolean-like syntax. CU, Ingo From stippi at mail.berlios.de Sat Jun 20 16:12:31 2009 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 20 Jun 2009 16:12:31 +0200 Subject: [Haiku-commits] r31134 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906201412.n5KECVPv024473@sheep.berlios.de> Author: stippi Date: 2009-06-20 16:12:30 +0200 (Sat, 20 Jun 2009) New Revision: 31134 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31134&view=rev Modified: haiku/trunk/headers/os/interface/View.h haiku/trunk/src/kits/interface/View.cpp haiku/trunk/src/kits/interface/Window.cpp Log: Cache a view's server token. Avoids getting it for every BView method that contacts the server. Modified: haiku/trunk/headers/os/interface/View.h =================================================================== --- haiku/trunk/headers/os/interface/View.h 2009-06-20 12:11:49 UTC (rev 31133) +++ haiku/trunk/headers/os/interface/View.h 2009-06-20 14:12:30 UTC (rev 31134) @@ -317,7 +317,7 @@ const BGradient& gradient); void FillPolygon(const BPoint* ptArray, int32 numPts, BRect bounds, const BGradient& gradient); - + void StrokeTriangle(BPoint pt1, BPoint pt2, BPoint pt3, BRect bounds, pattern p = B_SOLID_HIGH); void StrokeTriangle(BPoint pt1, BPoint pt2, BPoint pt3, @@ -356,7 +356,7 @@ void FillEllipse(BPoint center, float xRadius, float yRadius, const BGradient& gradient); void FillEllipse(BRect r, const BGradient& gradient); - + void StrokeArc(BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, pattern p = B_SOLID_HIGH); @@ -372,14 +372,14 @@ const BGradient& gradient); void FillArc(BRect r, float startAngle, float arcAngle, const BGradient& gradient); - + void StrokeBezier(BPoint* controlPoints, pattern p = B_SOLID_HIGH); void FillBezier(BPoint* controlPoints, pattern p = B_SOLID_HIGH); void FillBezier(BPoint* controlPoints, const BGradient& gradient); - + void StrokeShape(BShape* shape, pattern p = B_SOLID_HIGH); void FillShape(BShape* shape, pattern p = B_SOLID_HIGH); @@ -622,7 +622,7 @@ void _PrintToStream(); void _PrintTree(); - int32 server_token; + int32 fServerToken; uint32 fFlags; BPoint fParentOffset; BWindow* fOwner; Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2009-06-20 12:11:49 UTC (rev 31133) +++ haiku/trunk/src/kits/interface/View.cpp 2009-06-20 14:12:30 UTC (rev 31134) @@ -1000,7 +1000,7 @@ ViewSetViewCursorInfo info; info.cursorToken = cursor->fServerToken; - info.viewToken = _get_object_token_(this); // TODO: Use server_token! + info.viewToken = fServerToken; info.sync = sync; BPrivate::AppServerLink link; @@ -3906,8 +3906,7 @@ if (owner != NULL && !fTopLevelView) { // the top level view is deleted by the app_server automatically owner->fLink->StartMessage(AS_VIEW_DELETE); - // TODO: Use server_token - owner->fLink->Attach(_get_object_token_(this)); + owner->fLink->Attach(fServerToken); } parent->InvalidateLayout(); @@ -4646,6 +4645,7 @@ fParentOffset.Set(frame.left, frame.top); + fServerToken = _get_object_token_(this); fOwner = NULL; fParent = NULL; fNextSibling = NULL; @@ -4902,8 +4902,7 @@ else fOwner->fLink->StartMessage(AS_VIEW_CREATE); - // TODO: Use server_token - fOwner->fLink->Attach(_get_object_token_(this)); + fOwner->fLink->Attach(fServerToken); fOwner->fLink->AttachString(Name()); fOwner->fLink->Attach(Frame()); fOwner->fLink->Attach(LeftTop()); @@ -4916,8 +4915,7 @@ if (fTopLevelView) fOwner->fLink->Attach(B_NULL_TOKEN); else - // TODO: Use server_token - fOwner->fLink->Attach(_get_object_token_(fParent)); + fOwner->fLink->Attach(fParent->fServerToken); fOwner->fLink->Flush(); _CheckOwnerLockAndSwitchCurrent(); @@ -5125,8 +5123,7 @@ if (fOwner->fLastMouseMovedView == this) fOwner->fLastMouseMovedView = NULL; - // TODO: Use server_token - if (fOwner->fLastViewToken == _get_object_token_(this)) + if (fOwner->fLastViewToken == fServerToken) fOwner->fLastViewToken = B_NULL_TOKEN; _SetOwner(NULL); @@ -5343,15 +5340,12 @@ void BView::_SwitchServerCurrentView() const { - // TODO: Use server_token - int32 serverToken = _get_object_token_(this); - - if (fOwner->fLastViewToken != serverToken) { - STRACE(("contacting app_server... sending token: %ld\n", serverToken)); + if (fOwner->fLastViewToken != fServerToken) { + STRACE(("contacting app_server... sending token: %ld\n", fServerToken)); fOwner->fLink->StartMessage(AS_SET_CURRENT_VIEW); - fOwner->fLink->Attach(serverToken); + fOwner->fLink->Attach(fServerToken); - fOwner->fLastViewToken = serverToken; + fOwner->fLastViewToken = fServerToken; } else { STRACE(("quiet2\n")); } @@ -5510,7 +5504,7 @@ fNextSibling ? fNextSibling->Name() : "NULL", fPreviousSibling ? fPreviousSibling->Name() : "NULL", fOwner ? fOwner->Name() : "NULL", - _get_object_token_(this), + fServerToken, fFlags, fParentOffset.x, fParentOffset.y, fBounds.left, fBounds.top, fBounds.right, fBounds.bottom, Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2009-06-20 12:11:49 UTC (rev 31133) +++ haiku/trunk/src/kits/interface/Window.cpp 2009-06-20 14:12:30 UTC (rev 31134) @@ -2905,7 +2905,7 @@ fTopView->fTopLevelView = true; //inhibit check_lock() - fLastViewToken = _get_object_token_(fTopView); + fLastViewToken = fTopView->fServerToken; // set fTopView's owner, add it to window's eligible handler list // and also set its next handler to be this window. @@ -3089,7 +3089,7 @@ cookie.focus_token = _get_object_token_(*_target); if (fLastMouseMovedView != NULL && cookie.message->what == B_MOUSE_MOVED) - cookie.last_view_token = _get_object_token_(fLastMouseMovedView); + cookie.last_view_token = fLastMouseMovedView->fServerToken; *_usePreferred = false; } @@ -3553,8 +3553,10 @@ BWindow::_FindView(int32 token) { BHandler* handler; - if (gDefaultTokens.GetToken(token, B_HANDLER_TOKEN, (void**)&handler) != B_OK) + if (gDefaultTokens.GetToken(token, B_HANDLER_TOKEN, + (void**)&handler) != B_OK) { return NULL; + } // the view must belong to us in order to be found by this method BView* view = dynamic_cast(handler); From stippi at mail.berlios.de Sat Jun 20 17:00:13 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 20 Jun 2009 17:00:13 +0200 Subject: [Haiku-commits] r31135 - haiku/trunk/src/kits/interface Message-ID: <200906201500.n5KF0D52029924@sheep.berlios.de> Author: stippi Date: 2009-06-20 17:00:11 +0200 (Sat, 20 Jun 2009) New Revision: 31135 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31135&view=rev Modified: haiku/trunk/src/kits/interface/ScrollView.cpp Log: * Small cleanup Modified: haiku/trunk/src/kits/interface/ScrollView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ScrollView.cpp 2009-06-20 14:12:30 UTC (rev 31134) +++ haiku/trunk/src/kits/interface/ScrollView.cpp 2009-06-20 15:00:11 UTC (rev 31135) @@ -831,7 +831,7 @@ BScrollView::GetHeightForWidth(data->width, &data->min, &data->max, &data->preferred); return B_OK; -} + } case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; From stippi at mail.berlios.de Sat Jun 20 17:00:36 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 20 Jun 2009 17:00:36 +0200 Subject: [Haiku-commits] r31136 - haiku/trunk/src/kits/interface Message-ID: <200906201500.n5KF0aH9029994@sheep.berlios.de> Author: stippi Date: 2009-06-20 17:00:33 +0200 (Sat, 20 Jun 2009) New Revision: 31136 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31136&view=rev Modified: haiku/trunk/src/kits/interface/ListView.cpp Log: * Added NOTE to BListView destructor about not freeing the items. Modified: haiku/trunk/src/kits/interface/ListView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ListView.cpp 2009-06-20 15:00:11 UTC (rev 31135) +++ haiku/trunk/src/kits/interface/ListView.cpp 2009-06-20 15:00:33 UTC (rev 31136) @@ -129,6 +129,7 @@ BListView::~BListView() { + // NOTE: According to BeBook, BListView does not free the items itself. delete fTrack; SetSelectionMessage(NULL); } From stippi at mail.berlios.de Sat Jun 20 17:03:36 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 20 Jun 2009 17:03:36 +0200 Subject: [Haiku-commits] r31137 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906201503.n5KF3aBk030116@sheep.berlios.de> Author: stippi Date: 2009-06-20 17:03:33 +0200 (Sat, 20 Jun 2009) New Revision: 31137 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31137&view=rev Modified: haiku/trunk/headers/os/interface/ControlLook.h haiku/trunk/headers/os/interface/SplitView.h haiku/trunk/src/kits/interface/ControlLook.cpp haiku/trunk/src/kits/interface/SplitLayout.cpp haiku/trunk/src/kits/interface/SplitLayout.h haiku/trunk/src/kits/interface/SplitView.cpp Log: * Added BSplitView drawing code to ControlLook. * BSplitView uses ControlLook to draw itself. * Small refactoring in SplitLayout to implement IsAboveSplitter(BPoint). * BSplitView updates the view cursor when the mouse is above a splitter. * Standard splitter size is now 6 pixels, which is a bit easer to hit. Modified: haiku/trunk/headers/os/interface/ControlLook.h =================================================================== --- haiku/trunk/headers/os/interface/ControlLook.h 2009-06-20 15:00:33 UTC (rev 31136) +++ haiku/trunk/headers/os/interface/ControlLook.h 2009-06-20 15:03:33 UTC (rev 31137) @@ -208,6 +208,13 @@ const rgb_color& base, uint32 flags = 0, uint32 borders = B_ALL_BORDERS); + /*virtual*/ void DrawSplitter(BView* view, BRect& rect, + const BRect& updateRect, + const rgb_color& base, + enum orientation orientation, + uint32 flags = 0, + uint32 borders = B_ALL_BORDERS); + // various borders virtual void DrawBorder(BView* view, BRect& rect, Modified: haiku/trunk/headers/os/interface/SplitView.h =================================================================== --- haiku/trunk/headers/os/interface/SplitView.h 2009-06-20 15:00:33 UTC (rev 31136) +++ haiku/trunk/headers/os/interface/SplitView.h 2009-06-20 15:03:33 UTC (rev 31137) @@ -55,10 +55,12 @@ protected: virtual void DrawSplitter(BRect frame, + const BRect& updateRect, enum orientation orientation, bool pressed); private: static void _DrawDefaultSplitter(BView* view, BRect frame, + const BRect& updateRect, enum orientation orientation, bool pressed); private: Modified: haiku/trunk/src/kits/interface/ControlLook.cpp =================================================================== --- haiku/trunk/src/kits/interface/ControlLook.cpp 2009-06-20 15:00:33 UTC (rev 31136) +++ haiku/trunk/src/kits/interface/ControlLook.cpp 2009-06-20 15:03:33 UTC (rev 31137) @@ -239,7 +239,7 @@ if (popupIndicator) { BRect leftRect(rect); leftRect.right -= 10; - + BRect rightRect(rect); rightRect.left = rightRect.right - 9; @@ -272,7 +272,7 @@ view->SetHighColor(markColor); view->FillTriangle(triangle[0], triangle[1], triangle[2]); - + view->SetFlags(viewFlags); rect = leftRect; @@ -424,7 +424,7 @@ _DrawOuterResessedFrame(view, rect, base, 0.6); - // colors + // colors rgb_color dark1BorderColor = tint_color(base, 1.3); rgb_color dark2BorderColor = tint_color(base, 1.2); rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20); @@ -869,7 +869,7 @@ rightBarSide.top = sliderPosition; } - // fill the background for the corners, exclude the middle bar for now + // fill the background for the corners, exclude the middle bar for now BRegion region(rect); region.Exclude(rightBarSide); view->ConstrainClippingRegion(®ion); @@ -879,7 +879,7 @@ DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags, orientation); - view->PopState(); + view->PopState(); region.Set(rect); region.Exclude(leftBarSide); @@ -890,7 +890,7 @@ DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags, orientation); - view->PopState(); + view->PopState(); view->ConstrainClippingRegion(NULL); } @@ -921,7 +921,7 @@ barRect.bottom -= ceilf(barRect.Width() / 2); } - // fill the background for the corners, exclude the middle bar for now + // fill the background for the corners, exclude the middle bar for now BRegion region(rect); region.Exclude(barRect); view->ConstrainClippingRegion(®ion); @@ -968,7 +968,7 @@ _DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor, edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation); - + _DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor, edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation); @@ -976,7 +976,7 @@ _DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor, edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation); - + _DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor, edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation); @@ -1031,7 +1031,7 @@ // figure out the tints to be used float frameLightTint; float frameShadowTint; - + if (flags & B_DISABLED) { frameLightTint = 1.30; frameShadowTint = 1.35; @@ -1040,7 +1040,7 @@ frameLightTint = 1.6; frameShadowTint = 1.65; } - + frameLightColor = tint_color(base, frameLightTint); frameShadowColor = tint_color(base, frameShadowTint); } @@ -1143,7 +1143,7 @@ // figure out the tints to be used float frameLightTint; float frameShadowTint; - + if (flags & B_DISABLED) { frameLightTint = 1.30; frameShadowTint = 1.35; @@ -1152,7 +1152,7 @@ frameLightTint = 1.6; frameShadowTint = 1.65; } - + frameLightColor = tint_color(base, frameLightTint); frameShadowColor = tint_color(base, frameShadowTint); } @@ -1440,6 +1440,113 @@ } +void +BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect, + const rgb_color& base, enum orientation orientation, uint32 flags, + uint32 borders) +{ + rgb_color background; + if ((flags & (B_CLICKED | B_ACTIVATED)) != 0) + background = tint_color(base, B_DARKEN_1_TINT); + else + background = base; + + rgb_color light = tint_color(background, 0.6); + rgb_color shadow = tint_color(background, 1.21); + + // frame + if (borders != 0 && rect.Width() > 3 && rect.Height() > 3) + DrawRaisedBorder(view, rect, updateRect, background, flags, borders); + + // dots and rest of background + if (orientation == B_HORIZONTAL) { + if (rect.Width() > 2) { + // background on left/right + BRegion region(rect); + rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5); + rect.right = rect.left + 1; + region.Exclude(rect); + view->SetHighColor(background); + view->FillRegion(®ion); + } + + BPoint dot = rect.LeftTop(); + BPoint stop = rect.LeftBottom(); + int32 num = 1; + while (dot.y <= stop.y) { + rgb_color col1; + rgb_color col2; + switch (num) { + case 1: + col1 = background; + col2 = background; + break; + case 2: + col1 = shadow; + col2 = background; + break; + case 3: + col1 = background; + col2 = light; + num = 0; + break; + } + view->SetHighColor(col1); + view->StrokeLine(dot, dot, B_SOLID_HIGH); + view->SetHighColor(col2); + dot.x++; + view->StrokeLine(dot, dot, B_SOLID_HIGH); + dot.x -= 1.0; + // next pixel + num++; + dot.y++; + } + } else { + if (rect.Height() > 2) { + // background on left/right + BRegion region(rect); + rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5); + rect.bottom = rect.top + 1; + region.Exclude(rect); + view->SetHighColor(background); + view->FillRegion(®ion); + } + + BPoint dot = rect.LeftTop(); + BPoint stop = rect.RightTop(); + int32 num = 1; + while (dot.x <= stop.x) { + rgb_color col1; + rgb_color col2; + switch (num) { + case 1: + col1 = background; + col2 = background; + break; + case 2: + col1 = shadow; + col2 = background; + break; + case 3: + col1 = background; + col2 = light; + num = 0; + break; + } + view->SetHighColor(col1); + view->StrokeLine(dot, dot, B_SOLID_HIGH); + view->SetHighColor(col2); + dot.y++; + view->StrokeLine(dot, dot, B_SOLID_HIGH); + dot.y -= 1.0; + // next pixel + num++; + dot.x++; + } + } +} + + // #pragma mark - @@ -1601,7 +1708,7 @@ // truncate the label if necessary and get the width and height BString truncatedLabel(label); - + BFont font; view->GetFont(&font); @@ -1765,7 +1872,7 @@ // colors float tintLight = kEdgeBevelLightTint; float tintShadow = kEdgeBevelShadowTint; - + if (contrast == 0.0) { tintLight = B_NO_TINT; tintShadow = B_NO_TINT; @@ -1773,10 +1880,10 @@ tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast; tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast; } - + rgb_color borderBevelShadow = tint_color(base, tintShadow); rgb_color borderBevelLight = tint_color(base, tintLight); - + if (brightness < 1.0) { borderBevelShadow.red = uint8(borderBevelShadow.red * brightness); borderBevelShadow.green = uint8(borderBevelShadow.green * brightness); @@ -1785,7 +1892,7 @@ borderBevelLight.green = uint8(borderBevelLight.green * brightness); borderBevelLight.blue = uint8(borderBevelLight.blue * brightness); } - + _DrawFrame(view, rect, borderBevelShadow, borderBevelShadow, borderBevelLight, borderBevelLight, borders); } Modified: haiku/trunk/src/kits/interface/SplitLayout.cpp =================================================================== --- haiku/trunk/src/kits/interface/SplitLayout.cpp 2009-06-20 15:00:33 UTC (rev 31136) +++ haiku/trunk/src/kits/interface/SplitLayout.cpp 2009-06-20 15:03:33 UTC (rev 31137) @@ -140,7 +140,7 @@ fRightInset(0), fTopInset(0), fBottomInset(0), - fSplitterSize(3), + fSplitterSize(6), fSpacing(spacing), fSplitterItems(), @@ -153,7 +153,7 @@ fVerticalLayouter(NULL), fHorizontalLayoutInfo(NULL), fVerticalLayoutInfo(NULL), - + fHeightForWidthItems(), fHeightForWidthVerticalLayouter(NULL), fHeightForWidthHorizontalLayoutInfo(NULL), @@ -165,7 +165,7 @@ fCachedMinHeightForWidth(-1), fCachedMaxHeightForWidth(-1), fCachedPreferredHeightForWidth(-1), - + fDraggingStartPoint(), fDraggingStartValue(0), fDraggingCurrentValue(0), @@ -482,7 +482,7 @@ verticalLayouter = fHeightForWidthVerticalLayouter; } else verticalLayouter = fVerticalLayouter; - + verticalLayouter->Layout(fVerticalLayoutInfo, size.height); float xOffset = fLeftInset; @@ -551,6 +551,13 @@ return BRect(); } +// IsAboveSplitter +bool +BSplitLayout::IsAboveSplitter(const BPoint& point) const +{ + return _SplitterItemAt(point) != NULL; +} + // StartDraggingSplitter bool BSplitLayout::StartDraggingSplitter(BPoint point) @@ -568,18 +575,14 @@ return false; } - int32 splitterCount = fSplitterItems.CountItems(); - for (int32 i = 0; i < splitterCount; i++) { - SplitterItem* splitItem = _SplitterItemAt(i); - BRect frame = splitItem->Frame(); - if (frame.Contains(point)) { - fDraggingStartPoint = View()->ConvertToScreen(point); - fDraggingStartValue = _SplitterValue(i); - fDraggingCurrentValue = fDraggingStartValue; - fDraggingSplitterIndex = i; + int32 index; + if (SplitterItem* splitItem = _SplitterItemAt(point, &index)) { + fDraggingStartPoint = View()->ConvertToScreen(point); + fDraggingStartValue = _SplitterValue(index); + fDraggingCurrentValue = fDraggingStartValue; + fDraggingSplitterIndex = index; - return true; - } + return true; } return false; @@ -692,6 +695,23 @@ // _SplitterItemAt BSplitLayout::SplitterItem* +BSplitLayout::_SplitterItemAt(const BPoint& point, int32* index) const +{ + int32 splitterCount = fSplitterItems.CountItems(); + for (int32 i = 0; i < splitterCount; i++) { + SplitterItem* splitItem = _SplitterItemAt(i); + BRect frame = splitItem->Frame(); + if (frame.Contains(point)) { + if (index != NULL) + *index = i; + return splitItem; + } + } + return NULL; +} + +// _SplitterItemAt +BSplitLayout::SplitterItem* BSplitLayout::_SplitterItemAt(int32 index) const { return (SplitterItem*)fSplitterItems.ItemAt(index); @@ -778,7 +798,7 @@ bool visibilityChanged = (info->isVisible != isVisible); if (visibilityChanged) item->SetVisible(info->isVisible); - + // nothing more to do, if the item is not visible if (!info->isVisible) return; @@ -1070,7 +1090,7 @@ fHeightForWidthItems.MakeEmpty(); _InvalidateCachedHeightForWidth(); - + // filter the visible items int32 itemCount = CountItems(); for (int32 i = 0; i < itemCount; i++) { @@ -1084,7 +1104,7 @@ if (item->HasHeightForWidth()) fHeightForWidthItems.AddItem(item); } - itemCount = fVisibleItems.CountItems(); + itemCount = fVisibleItems.CountItems(); // create the layouters Layouter* itemLayouter = new SimpleLayouter(itemCount, 0); @@ -1161,7 +1181,7 @@ } horizontalLayoutInfo = fHeightForWidthHorizontalLayoutInfo; } - + // do the horizontal layout (already done when doing this for the real // layout) if (!realLayout) @@ -1223,7 +1243,7 @@ float spacing = _SplitterSpace(); if (fOrientation == B_HORIZONTAL) size.width = BLayoutUtils::AddDistances(size.width, spacing - 1); - else + else size.height = BLayoutUtils::AddDistances(size.height, spacing - 1); return size; @@ -1257,7 +1277,7 @@ float spacing = _SplitterSpace(); if (fOrientation == B_HORIZONTAL) size.width = BLayoutUtils::SubtractDistances(size.width, spacing - 1); - else + else size.height = BLayoutUtils::SubtractDistances(size.height, spacing - 1); return size; Modified: haiku/trunk/src/kits/interface/SplitLayout.h =================================================================== --- haiku/trunk/src/kits/interface/SplitLayout.h 2009-06-20 15:00:33 UTC (rev 31136) +++ haiku/trunk/src/kits/interface/SplitLayout.h 2009-06-20 15:03:33 UTC (rev 31137) @@ -80,13 +80,14 @@ // interface for BSplitView BRect SplitterItemFrame(int32 index) const; + bool IsAboveSplitter(const BPoint& point) const; bool StartDraggingSplitter(BPoint point); bool DragSplitter(BPoint point); bool StopDraggingSplitter(); int32 DraggedSplitter() const; -protected: +protected: virtual void ItemAdded(BLayoutItem* item); virtual void ItemRemoved(BLayoutItem* item); @@ -98,6 +99,8 @@ void _InvalidateLayout(bool invalidateView); void _InvalidateCachedHeightForWidth(); + SplitterItem* _SplitterItemAt(const BPoint& point, + int32* index = NULL) const; SplitterItem* _SplitterItemAt(int32 index) const; void _GetSplitterValueRange(int32 index, @@ -150,7 +153,7 @@ LayoutInfo* fHorizontalLayoutInfo; LayoutInfo* fVerticalLayoutInfo; - + BList fHeightForWidthItems; // Incorporates the children's height for width constraints for a // concrete width. Cloned lazily from fVerticalLayout when needed. @@ -165,7 +168,7 @@ float fCachedMinHeightForWidth; float fCachedMaxHeightForWidth; float fCachedPreferredHeightForWidth; - + BPoint fDraggingStartPoint; int32 fDraggingStartValue; int32 fDraggingCurrentValue; Modified: haiku/trunk/src/kits/interface/SplitView.cpp =================================================================== --- haiku/trunk/src/kits/interface/SplitView.cpp 2009-06-20 15:00:33 UTC (rev 31136) +++ haiku/trunk/src/kits/interface/SplitView.cpp 2009-06-20 15:03:33 UTC (rev 31137) @@ -5,12 +5,45 @@ #include +#include + +#include +#include + #include "SplitLayout.h" +static const unsigned char kHSplitterCursor[] = { + 16, 1, 8, 8, + 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, + 0x1a, 0x58, 0x2a, 0x54, 0x4a, 0x52, 0x8a, 0x51, + 0x8a, 0x51, 0x4a, 0x52, 0x2a, 0x54, 0x1a, 0x58, + 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, + + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, + 0x1b, 0xd8, 0x3b, 0xdc, 0x7b, 0xde, 0xfb, 0xdf, + 0xfb, 0xdf, 0x7b, 0xde, 0x3b, 0xdc, 0x1b, 0xd8, + 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 +}; + +static const unsigned char kVSplitterCursor[] = { + 16, 1, 8, 8, + 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, + 0x0f, 0xf0, 0x00, 0x00, 0xff, 0xff, 0x80, 0x01, + 0x80, 0x01, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf0, + 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, + + 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, + 0x0f, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf0, + 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80 +}; + + // constructor BSplitView::BSplitView(enum orientation orientation, float spacing) - : BView(NULL, + : + BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INVALIDATE_AFTER_LAYOUT, fSplitLayout = new BSplitLayout(orientation, spacing)) { @@ -136,7 +169,8 @@ int32 count = fSplitLayout->CountItems(); for (int32 i = 0; i < count - 1; i++) { BRect frame = fSplitLayout->SplitterItemFrame(i); - DrawSplitter(frame, Orientation(), draggedSplitterIndex == i); + DrawSplitter(frame, updateRect, Orientation(), + draggedSplitterIndex == i); } } @@ -144,7 +178,8 @@ void BSplitView::MouseDown(BPoint where) { - SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); + SetMouseEventMask(B_POINTER_EVENTS, + B_LOCK_WINDOW_FOCUS | B_SUSPEND_VIEW_FOCUS); if (fSplitLayout->StartDraggingSplitter(where)) Invalidate(); @@ -164,7 +199,17 @@ void BSplitView::MouseMoved(BPoint where, uint32 transit, const BMessage* message) { + BCursor cursor(B_CURSOR_SYSTEM_DEFAULT); + int32 splitterIndex = fSplitLayout->DraggedSplitter(); + + if (splitterIndex >= 0 || fSplitLayout->IsAboveSplitter(where)) { + if (Orientation() == B_VERTICAL) + cursor = BCursor(kVSplitterCursor); + else + cursor = BCursor(kHSplitterCursor); + } + if (splitterIndex >= 0) { BRect oldFrame = fSplitLayout->SplitterItemFrame(splitterIndex); if (fSplitLayout->DragSplitter(where)) { @@ -172,6 +217,8 @@ Invalidate(fSplitLayout->SplitterItemFrame(splitterIndex)); } } + + SetViewCursor(&cursor, true); } // SetLayout @@ -183,13 +230,18 @@ // DrawSplitter void -BSplitView::DrawSplitter(BRect frame, enum orientation orientation, - bool pressed) +BSplitView::DrawSplitter(BRect frame, const BRect& updateRect, + enum orientation orientation, bool pressed) { - rgb_color black = { 0, 0, 0, 255 }; - rgb_color white = { 255, 255, 255, 255 }; + _DrawDefaultSplitter(this, frame, updateRect, orientation, pressed); +} - SetHighColor(pressed ? white : black); - - FillRect(frame); +// _DrawDefaultSplitter +void +BSplitView::_DrawDefaultSplitter(BView* view, BRect frame, + const BRect& updateRect, enum orientation orientation, bool pressed) +{ + uint32 flags = pressed ? BControlLook::B_ACTIVATED : 0; + be_control_look->DrawSplitter(view, frame, updateRect, view->ViewColor(), + orientation, flags, 0); } From stippi at mail.berlios.de Sat Jun 20 17:26:35 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 20 Jun 2009 17:26:35 +0200 Subject: [Haiku-commits] r31138 - haiku/trunk/src/servers/app Message-ID: <200906201526.n5KFQZnb031344@sheep.berlios.de> Author: stippi Date: 2009-06-20 17:26:34 +0200 (Sat, 20 Jun 2009) New Revision: 31138 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31138&view=rev Modified: haiku/trunk/src/servers/app/ServerApp.cpp Log: Fixed regression in SetViewCursor(). It wasn't possible anymore to switch back to the system default cursor. For that cursor token, the global cursor manager returns NULL. Modified: haiku/trunk/src/servers/app/ServerApp.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerApp.cpp 2009-06-20 15:03:33 UTC (rev 31137) +++ haiku/trunk/src/servers/app/ServerApp.cpp 2009-06-20 15:26:34 UTC (rev 31138) @@ -931,43 +931,44 @@ if (fDesktop->GetCursorManager().Lock()) { ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor( info.cursorToken); - // If we found a cursor, make sure it doesn't go away. + // If we found a cursor, make sure it doesn't go away. If we + // get a NULL cursor, it probably means we are supposed to use + // the system default cursor. if (cursor != NULL) cursor->Acquire(); fDesktop->GetCursorManager().Unlock(); - if (cursor != NULL) { - // We need to acquire the write lock here, since we cannot - // afford that the window thread to which the view belongs - // is running and messing with that same view. - fDesktop->LockAllWindows(); + // We need to acquire the write lock here, since we cannot + // afford that the window thread to which the view belongs + // is running and messing with that same view. + fDesktop->LockAllWindows(); - // Find the corresponding view by the given token. It's ok - // if this view does not exist anymore, since it may have - // already be deleted in the window thread before this - // message got here. - View* view; - if (fViewTokens.GetToken(info.viewToken, B_HANDLER_TOKEN, - (void**)&view) == B_OK) { - // Set the cursor on the view. - view->SetCursor(cursor); + // Find the corresponding view by the given token. It's ok + // if this view does not exist anymore, since it may have + // already be deleted in the window thread before this + // message got here. + View* view; + if (fViewTokens.GetToken(info.viewToken, B_HANDLER_TOKEN, + (void**)&view) == B_OK) { + // Set the cursor on the view. + view->SetCursor(cursor); - // The cursor might need to be updated now. - Window* window = view->Window(); - if (window != NULL && window->IsFocus()) { - if (fDesktop->ViewUnderMouse(window) - == view->Token()) { - SetCurrentCursor(cursor); - } + // The cursor might need to be updated now. + Window* window = view->Window(); + if (window != NULL && window->IsFocus()) { + if (fDesktop->ViewUnderMouse(window) + == view->Token()) { + SetCurrentCursor(cursor); } } + } - fDesktop->UnlockAllWindows(); + fDesktop->UnlockAllWindows(); - // Release the temporary reference. + // Release the temporary reference. + if (cursor != NULL) cursor->Release(); - } } if (info.sync) { From axeld at pinc-software.de Sat Jun 20 17:29:52 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 20 Jun 2009 17:29:52 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r31134_-_in_haiku/trunk=3A_headers/os/i?= =?utf-8?q?nterface_src/kits/interface?= In-Reply-To: <200906201412.n5KECVPv024473@sheep.berlios.de> Message-ID: <23806689367-BeMail@zon> stippi at BerliOS wrote: > Log: > Cache a view's server token. Avoids getting it for every > BView method that contacts the server. Haven't you had a look at how _get_object_token_() is defined? inline int32 _get_object_token_(const BHandler* object) { return object->fToken; } You can as well revert this one, and have one uint32 more reserved; no need to store this twice. Bye, Axel. From axeld at pinc-software.de Sat Jun 20 17:32:15 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 20 Jun 2009 17:32:15 +0200 CEST Subject: [Haiku-commits] r31132 - haiku/trunk/build/jam In-Reply-To: <20090620142249.351.1@knochen-vm.localdomain> Message-ID: <23949561369-BeMail@zon> Ingo Weinhold wrote: > On 2009-06-20 at 14:10:49 [+0200], Axel D?rfler > > wrote: > > Just curious: why is the former check wrong? > isHybridImage was always defined to either "0" or "1", but "if > $(isHybridImage)" just checks whether the variable has a value. The > other > "= 0" and "= 1" checks did work, of course, but I find it nicer to > use the > boolean-like syntax. I didn't find anything wrong with the changes in that commit, that's why I asked, but it corrected the other earlier changes, not those in that commit :-) Bye, Axel. From anevilyak at mail.berlios.de Sat Jun 20 17:37:33 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sat, 20 Jun 2009 17:37:33 +0200 Subject: [Haiku-commits] r31139 - haiku/trunk/src/kits/interface Message-ID: <200906201537.n5KFbXXK031892@sheep.berlios.de> Author: anevilyak Date: 2009-06-20 17:37:33 +0200 (Sat, 20 Jun 2009) New Revision: 31139 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31139&view=rev Modified: haiku/trunk/src/kits/interface/SplitLayout.cpp Log: GCC4 build fix. Modified: haiku/trunk/src/kits/interface/SplitLayout.cpp =================================================================== --- haiku/trunk/src/kits/interface/SplitLayout.cpp 2009-06-20 15:26:34 UTC (rev 31138) +++ haiku/trunk/src/kits/interface/SplitLayout.cpp 2009-06-20 15:37:33 UTC (rev 31139) @@ -575,8 +575,8 @@ return false; } - int32 index; - if (SplitterItem* splitItem = _SplitterItemAt(point, &index)) { + int32 index = -1; + if (_SplitterItemAt(point, &index) != NULL) { fDraggingStartPoint = View()->ConvertToScreen(point); fDraggingStartValue = _SplitterValue(index); fDraggingCurrentValue = fDraggingStartValue; From superstippi at gmx.de Sat Jun 20 17:38:05 2009 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 20 Jun 2009 17:38:05 +0200 Subject: [Haiku-commits] r31134 - in haiku/trunk: headers/os/interface src/kits/interface In-Reply-To: <23806689367-BeMail@zon> References: <23806689367-BeMail@zon> Message-ID: <20090620173805.552.2@bepc.1245511607.fake> On 2009-06-20 at 17:29:52 [+0200], Axel D?rfler wrote: > stippi at BerliOS wrote: > > Log: > > Cache a view's server token. Avoids getting it for every BView method > > that contacts the server. > > Haven't you had a look at how _get_object_token_() is defined? > > inline int32 _get_object_token_(const BHandler* object) > { return object->fToken; } > > You can as well revert this one, and have one uint32 more reserved; no > need to store this twice. Ups, I thought I looked this up in the past, sorry about that. Best regards, -Stephan From stippi at mail.berlios.de Sat Jun 20 17:47:29 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sat, 20 Jun 2009 17:47:29 +0200 Subject: [Haiku-commits] r31140 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906201547.n5KFlTJ2032715@sheep.berlios.de> Author: stippi Date: 2009-06-20 17:47:28 +0200 (Sat, 20 Jun 2009) New Revision: 31140 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31140&view=rev Modified: haiku/trunk/headers/os/interface/View.h haiku/trunk/src/kits/interface/View.cpp haiku/trunk/src/kits/interface/Window.cpp Log: Reverted my change to usage of _get_object_token_(), it already means to use a cached token... doh! Thanks Axel! Modified: haiku/trunk/headers/os/interface/View.h =================================================================== --- haiku/trunk/headers/os/interface/View.h 2009-06-20 15:37:33 UTC (rev 31139) +++ haiku/trunk/headers/os/interface/View.h 2009-06-20 15:47:28 UTC (rev 31140) @@ -622,7 +622,8 @@ void _PrintToStream(); void _PrintTree(); - int32 fServerToken; + int32 _unused_int1; + uint32 fFlags; BPoint fParentOffset; BWindow* fOwner; Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2009-06-20 15:37:33 UTC (rev 31139) +++ haiku/trunk/src/kits/interface/View.cpp 2009-06-20 15:47:28 UTC (rev 31140) @@ -1000,7 +1000,7 @@ ViewSetViewCursorInfo info; info.cursorToken = cursor->fServerToken; - info.viewToken = fServerToken; + info.viewToken = _get_object_token_(this); info.sync = sync; BPrivate::AppServerLink link; @@ -3906,7 +3906,7 @@ if (owner != NULL && !fTopLevelView) { // the top level view is deleted by the app_server automatically owner->fLink->StartMessage(AS_VIEW_DELETE); - owner->fLink->Attach(fServerToken); + owner->fLink->Attach(_get_object_token_(this)); } parent->InvalidateLayout(); @@ -4302,7 +4302,7 @@ BView::GetHeightForWidth(data->width, &data->min, &data->max, &data->preferred); return B_OK; -} + } case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; @@ -4645,7 +4645,6 @@ fParentOffset.Set(frame.left, frame.top); - fServerToken = _get_object_token_(this); fOwner = NULL; fParent = NULL; fNextSibling = NULL; @@ -4902,7 +4901,7 @@ else fOwner->fLink->StartMessage(AS_VIEW_CREATE); - fOwner->fLink->Attach(fServerToken); + fOwner->fLink->Attach(_get_object_token_(this)); fOwner->fLink->AttachString(Name()); fOwner->fLink->Attach(Frame()); fOwner->fLink->Attach(LeftTop()); @@ -4915,7 +4914,7 @@ if (fTopLevelView) fOwner->fLink->Attach(B_NULL_TOKEN); else - fOwner->fLink->Attach(fParent->fServerToken); + fOwner->fLink->Attach(_get_object_token_(fParent)); fOwner->fLink->Flush(); _CheckOwnerLockAndSwitchCurrent(); @@ -5123,7 +5122,7 @@ if (fOwner->fLastMouseMovedView == this) fOwner->fLastMouseMovedView = NULL; - if (fOwner->fLastViewToken == fServerToken) + if (fOwner->fLastViewToken == _get_object_token_(this)) fOwner->fLastViewToken = B_NULL_TOKEN; _SetOwner(NULL); @@ -5340,12 +5339,14 @@ void BView::_SwitchServerCurrentView() const { - if (fOwner->fLastViewToken != fServerToken) { - STRACE(("contacting app_server... sending token: %ld\n", fServerToken)); + int32 serverToken = _get_object_token_(this); + + if (fOwner->fLastViewToken != serverToken) { + STRACE(("contacting app_server... sending token: %ld\n", serverToken)); fOwner->fLink->StartMessage(AS_SET_CURRENT_VIEW); - fOwner->fLink->Attach(fServerToken); + fOwner->fLink->Attach(serverToken); - fOwner->fLastViewToken = fServerToken; + fOwner->fLastViewToken = serverToken; } else { STRACE(("quiet2\n")); } @@ -5504,7 +5505,7 @@ fNextSibling ? fNextSibling->Name() : "NULL", fPreviousSibling ? fPreviousSibling->Name() : "NULL", fOwner ? fOwner->Name() : "NULL", - fServerToken, + _get_object_token_(this), fFlags, fParentOffset.x, fParentOffset.y, fBounds.left, fBounds.top, fBounds.right, fBounds.bottom, Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2009-06-20 15:37:33 UTC (rev 31139) +++ haiku/trunk/src/kits/interface/Window.cpp 2009-06-20 15:47:28 UTC (rev 31140) @@ -2905,7 +2905,7 @@ fTopView->fTopLevelView = true; //inhibit check_lock() - fLastViewToken = fTopView->fServerToken; + fLastViewToken = _get_object_token_(fTopView); // set fTopView's owner, add it to window's eligible handler list // and also set its next handler to be this window. @@ -3089,7 +3089,7 @@ cookie.focus_token = _get_object_token_(*_target); if (fLastMouseMovedView != NULL && cookie.message->what == B_MOUSE_MOVED) - cookie.last_view_token = fLastMouseMovedView->fServerToken; + cookie.last_view_token = _get_object_token_(fLastMouseMovedView); *_usePreferred = false; } From bonefish at mail.berlios.de Sat Jun 20 18:49:32 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 18:49:32 +0200 Subject: [Haiku-commits] r31141 - haiku/trunk/src/apps/debugger Message-ID: <200906201649.n5KGnWV0019181@sheep.berlios.de> Author: bonefish Date: 2009-06-20 18:49:31 +0200 (Sat, 20 Jun 2009) New Revision: 31141 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31141&view=rev Modified: haiku/trunk/src/apps/debugger/Worker.cpp haiku/trunk/src/apps/debugger/Worker.h Log: Added Worker::GetJob() to get a known job by key. Modified: haiku/trunk/src/apps/debugger/Worker.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Worker.cpp 2009-06-20 15:47:28 UTC (rev 31140) +++ haiku/trunk/src/apps/debugger/Worker.cpp 2009-06-20 16:49:31 UTC (rev 31141) @@ -247,6 +247,14 @@ } +Job* +Worker::GetJob(const JobKey& key) +{ + AutoLocker locker(this); + return fJobs.Lookup(key); +} + + status_t Worker::AddListener(const JobKey& key, JobListener* listener) { Modified: haiku/trunk/src/apps/debugger/Worker.h =================================================================== --- haiku/trunk/src/apps/debugger/Worker.h 2009-06-20 15:47:28 UTC (rev 31140) +++ haiku/trunk/src/apps/debugger/Worker.h 2009-06-20 16:49:31 UTC (rev 31141) @@ -146,6 +146,7 @@ JobListener* listener = NULL); // always takes over ownership void AbortJob(const JobKey& key); + Job* GetJob(const JobKey& key); status_t AddListener(const JobKey& key, JobListener* listener); From bonefish at mail.berlios.de Sat Jun 20 19:20:52 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 19:20:52 +0200 Subject: [Haiku-commits] r31142 - in haiku/trunk/src/apps/debugger: . arch arch/x86 debug_info debugger_interface gui/team_window Message-ID: <200906201720.n5KHKq1s021628@sheep.berlios.de> Author: bonefish Date: 2009-06-20 19:20:49 +0200 (Sat, 20 Jun 2009) New Revision: 31142 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31142&view=rev Added: haiku/trunk/src/apps/debugger/SymbolInfo.cpp haiku/trunk/src/apps/debugger/SymbolInfo.h haiku/trunk/src/apps/debugger/debug_info/ haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h haiku/trunk/src/apps/debugger/debug_info/DebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfoProvider.cpp haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfoProvider.h Removed: haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.cpp haiku/trunk/src/apps/debugger/arch/x86/StackFrameX86.h Modified: haiku/trunk/src/apps/debugger/Image.cpp haiku/trunk/src/apps/debugger/Image.h haiku/trunk/src/apps/debugger/ImageInfo.cpp haiku/trunk/src/apps/debugger/ImageInfo.h haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/Jobs.cpp haiku/trunk/src/apps/debugger/Jobs.h haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/arch/Architecture.cpp haiku/trunk/src/apps/debugger/arch/Architecture.h haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h haiku/trunk/src/apps/debugger/arch/CpuState.h haiku/trunk/src/apps/debugger/arch/StackFrame.cpp haiku/trunk/src/apps/debugger/arch/StackFrame.h haiku/trunk/src/apps/debugger/arch/StackTrace.cpp haiku/trunk/src/apps/debugger/arch/StackTrace.h haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.cpp haiku/trunk/src/apps/debugger/arch/x86/CpuStateX86.h haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.cpp haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp Log: * Added DebuggerInterface::GetSymbolInfos() to get the symbols for an image. * Added the beginnings of the debug info abstraction. Currently we can only load the symbols via the debugger. * Added a job to retrieve debug info for an image. Extended the GetStackTraceJob to support waiting for image debug info to be loaded. * Extended ImageInfo by text/data address and size. * Removed StackFrameX86 and made StackFrame a simple non-polymorphic class featuring all the needed data. The really architecture-dependent is in the referenced CpuState already. Added Image* and FunctionDebugInfo* attributes, referring to the image respectively debug info for the function hit by the instruction pointer. * Switched StrackTrace's StackFrame management from DoublyLinkedList to BObjectList. This makes it more comfortable to use. * Changed the code for creating stack traces: - The creation of the StackTrace object and the main loop to collect the frames are now located in the no longer virtual Architecture::CreateStackTrace(). - The decision how to create a StackFrame is based on the instruction pointer. If it hit a function for which debug info is available, the respective DebugInfo::CreateStackFrame() is used, otherwise we fall back to the new virtual Architecture::CreateStackFrame(). * Adjusted the stack trace view to also show function names (mangled ATM). Modified: haiku/trunk/src/apps/debugger/Image.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Image.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Image.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -5,17 +5,22 @@ #include "Image.h" +#include "ImageDebugInfo.h" + Image::Image(Team* team,const ImageInfo& imageInfo) : fTeam(team), - fInfo(imageInfo) + fInfo(imageInfo), + fDebugInfo(NULL) { } Image::~Image() { + if (fDebugInfo != NULL) + fDebugInfo->RemoveReference(); } @@ -24,3 +29,29 @@ { return B_OK; } + + +void +Image::SetImageDebugInfo(ImageDebugInfo* debugInfo) +{ + if (debugInfo == fDebugInfo) + return; + + if (fDebugInfo != NULL) + fDebugInfo->RemoveReference(); + + fDebugInfo = debugInfo; + + if (fDebugInfo != NULL) + fDebugInfo->AddReference(); +} + + +bool +Image::ContainsAddress(target_addr_t address) const +{ + return (address >= fInfo.TextBase() + && address < fInfo.TextBase() + fInfo.TextSize()) + || (address >= fInfo.DataBase() + && address < fInfo.DataBase() + fInfo.DataSize()); +} Modified: haiku/trunk/src/apps/debugger/Image.h =================================================================== --- haiku/trunk/src/apps/debugger/Image.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Image.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -13,6 +13,7 @@ #include "ImageInfo.h" +class ImageDebugInfo; class Team; @@ -24,14 +25,20 @@ status_t Init(); - Team* GetTeam() const { return fTeam; } - image_id ID() const { return fInfo.ImageID(); } - const char* Name() const { return fInfo.Name(); } - const ImageInfo& Info() const { return fInfo; } + Team* GetTeam() const { return fTeam; } + image_id ID() const { return fInfo.ImageID(); } + const char* Name() const { return fInfo.Name(); } + const ImageInfo& Info() const { return fInfo; } + ImageDebugInfo* GetImageDebugInfo() const { return fDebugInfo; } + void SetImageDebugInfo(ImageDebugInfo* debugInfo); + + bool ContainsAddress(target_addr_t address) const; + private: Team* fTeam; ImageInfo fInfo; + ImageDebugInfo* fDebugInfo; }; Modified: haiku/trunk/src/apps/debugger/ImageInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/ImageInfo.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/ImageInfo.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -10,7 +10,11 @@ : fTeam(-1), fImage(-1), - fName() + fName(), + fTextBase(0), + fTextSize(0), + fDataBase(0), + fDataSize(0) { } @@ -18,24 +22,40 @@ : fTeam(other.fTeam), fImage(other.fImage), - fName(other.fName) + fName(other.fName), + fTextBase(other.fTextBase), + fTextSize(other.fTextSize), + fDataBase(other.fDataBase), + fDataSize(other.fDataSize) { } -ImageInfo::ImageInfo(team_id team, image_id image, const BString& name) +ImageInfo::ImageInfo(team_id team, image_id image, const BString& name, + target_addr_t textBase, target_size_t textSize, target_addr_t dataBase, + target_size_t dataSize) : fTeam(team), fImage(image), - fName(name) + fName(name), + fTextBase(textBase), + fTextSize(textSize), + fDataBase(dataBase), + fDataSize(dataSize) { } void -ImageInfo::SetTo(team_id team, image_id image, const BString& name) +ImageInfo::SetTo(team_id team, image_id image, const BString& name, + target_addr_t textBase, target_size_t textSize, target_addr_t dataBase, + target_size_t dataSize) { fTeam = team; fImage = image; fName = name; + fTextBase = textBase; + fTextSize = textSize; + fDataBase = dataBase; + fDataSize = dataSize; } Modified: haiku/trunk/src/apps/debugger/ImageInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/ImageInfo.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/ImageInfo.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -8,25 +8,44 @@ #include #include +#include "ArchitectureTypes.h" + class ImageInfo { public: ImageInfo(); ImageInfo(const ImageInfo& other); ImageInfo(team_id team, image_id image, - const BString& name); + const BString& name, + target_addr_t textBase, + target_size_t textSize, + target_addr_t dataBase, + target_size_t dataSize); void SetTo(team_id team, image_id image, - const BString& name); + const BString& name, + target_addr_t textBase, + target_size_t textSize, + target_addr_t dataBase, + target_size_t dataSize); team_id TeamID() const { return fTeam; } image_id ImageID() const { return fImage; } const char* Name() const { return fName.String(); } + target_addr_t TextBase() const { return fTextBase; } + target_size_t TextSize() const { return fTextSize; } + target_addr_t DataBase() const { return fDataBase; } + target_size_t DataSize() const { return fDataSize; } + private: thread_id fTeam; image_id fImage; BString fName; + target_addr_t fTextBase; + target_size_t fTextSize; + target_addr_t fDataBase; + target_size_t fDataSize; }; Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 17:20:49 UTC (rev 31142) @@ -8,6 +8,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) arch ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) arch x86 ] ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) debug_info ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) debugger_interface ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ; @@ -23,6 +24,7 @@ Image.cpp ImageInfo.cpp Jobs.cpp + SymbolInfo.cpp Team.cpp TeamDebugger.cpp TeamDebugModel.cpp @@ -40,8 +42,15 @@ # arch/x86 ArchitectureX86.cpp CpuStateX86.cpp - StackFrameX86.cpp + # debug_info + BasicFunctionDebugInfo.cpp + DebuggerDebugInfo.cpp + DebugInfo.cpp + FunctionDebugInfo.cpp + ImageDebugInfo.cpp + ImageDebugInfoProvider.cpp + # debugger_interface DebugEvent.cpp DebuggerInterface.cpp Modified: haiku/trunk/src/apps/debugger/Jobs.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -5,11 +5,15 @@ #include "Jobs.h" +#include + #include #include "Architecture.h" #include "CpuState.h" #include "DebuggerInterface.h" +#include "Image.h" +#include "ImageDebugInfo.h" #include "StackTrace.h" #include "Team.h" #include "Thread.h" @@ -101,7 +105,7 @@ // get the stack trace StackTrace* stackTrace; - status_t error = fArchitecture->CreateStackTrace(fThread->GetTeam(), + status_t error = fArchitecture->CreateStackTrace(fThread->GetTeam(), this, fCpuState, stackTrace); if (error != B_OK) return error; @@ -115,3 +119,108 @@ return B_OK; } + + +status_t +GetStackTraceJob::GetImageDebugInfo(Image* image, ImageDebugInfo*& _info) +{ + AutoLocker teamLocker(fThread->GetTeam()); + + while (image->GetImageDebugInfo() == NULL) { + // The info has not yet been loaded -- check whether a job has already + // been scheduled. + AutoLocker workerLocker(GetWorker()); + JobKey key(image, JOB_TYPE_LOAD_IMAGE_DEBUG_INFO); + Job* loadImageDebugInfoJob = GetWorker()->GetJob(key); + if (loadImageDebugInfoJob == NULL) { + // no job yet -- schedule one + loadImageDebugInfoJob = new(std::nothrow) LoadImageDebugInfoJob( + fDebuggerInterface, fArchitecture, image); + if (loadImageDebugInfoJob == NULL) + return B_NO_MEMORY; + + status_t error = GetWorker()->ScheduleJob(loadImageDebugInfoJob); + if (error != B_OK) + return error; + } + + workerLocker.Unlock(); + teamLocker.Unlock(); + + // wait for the job to finish + switch (WaitFor(key)) { + case JOB_DEPENDENCY_SUCCEEDED: + case JOB_DEPENDENCY_NOT_FOUND: + // "Not found" can happen due to a race condition between + // unlocking the worker and starting to wait. + break; + case JOB_DEPENDENCY_FAILED: + case JOB_DEPENDENCY_ABORTED: + default: + return B_ERROR; + } + + teamLocker.Lock(); + } + + _info = image->GetImageDebugInfo(); + _info->AddReference(); + + return B_OK; +} + + +// #pragma mark - GetStackTraceJob + + +LoadImageDebugInfoJob::LoadImageDebugInfoJob( + DebuggerInterface* debuggerInterface, Architecture* architecture, + Image* image) + : + fDebuggerInterface(debuggerInterface), + fArchitecture(architecture), + fImage(image) +{ + fImage->AddReference(); +} + + +LoadImageDebugInfoJob::~LoadImageDebugInfoJob() +{ + fImage->RemoveReference(); +} + + +JobKey +LoadImageDebugInfoJob::Key() const +{ + return JobKey(fImage, JOB_TYPE_LOAD_IMAGE_DEBUG_INFO); +} + + +status_t +LoadImageDebugInfoJob::Do() +{ + // get an image info for the image + AutoLocker locker(fImage->GetTeam()); + ImageInfo imageInfo(fImage->Info()); + locker.Unlock(); + + // create the debug info + ImageDebugInfo* debugInfo = new(std::nothrow) ImageDebugInfo(imageInfo, + fDebuggerInterface, fArchitecture); + if (debugInfo == NULL) + return B_NO_MEMORY; + + status_t error = debugInfo->Init(); + if (error != B_OK) { + delete debugInfo; + return error; + } + + // set the info + locker.Lock(); + fImage->SetImageDebugInfo(debugInfo); + + return B_OK; +} Modified: haiku/trunk/src/apps/debugger/Jobs.h =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Jobs.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -5,19 +5,22 @@ #ifndef JOBS_H #define JOBS_H +#include "ImageDebugInfoProvider.h" #include "Worker.h" class Architecture; class CpuState; class DebuggerInterface; +class Image; class Thread; // job types enum { JOB_TYPE_GET_CPU_STATE, - JOB_TYPE_GET_STACK_TRACE + JOB_TYPE_GET_STACK_TRACE, + JOB_TYPE_LOAD_IMAGE_DEBUG_INFO }; @@ -37,18 +40,22 @@ }; -class GetStackTraceJob : public Job { +class GetStackTraceJob : public Job, private ImageDebugInfoProvider { public: GetStackTraceJob( DebuggerInterface* debuggerInterface, - Architecture* architecture, - Thread* thread); + Architecture* architecture, Thread* thread); virtual ~GetStackTraceJob(); virtual JobKey Key() const; virtual status_t Do(); private: + // ImageDebugInfoProvider + virtual status_t GetImageDebugInfo(Image* image, + ImageDebugInfo*& _info); + +private: DebuggerInterface* fDebuggerInterface; Architecture* fArchitecture; Thread* fThread; @@ -56,4 +63,22 @@ }; +class LoadImageDebugInfoJob : public Job { +public: + LoadImageDebugInfoJob( + DebuggerInterface* debuggerInterface, + Architecture* architecture, + Image* image); + virtual ~LoadImageDebugInfoJob(); + + virtual JobKey Key() const; + virtual status_t Do(); + +private: + DebuggerInterface* fDebuggerInterface; + Architecture* fArchitecture; + Image* fImage; +}; + + #endif // JOBS_H Added: haiku/trunk/src/apps/debugger/SymbolInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/SymbolInfo.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/SymbolInfo.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -0,0 +1,22 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "SymbolInfo.h" + + +SymbolInfo::SymbolInfo(target_addr_t address, target_size_t size, uint32 type, + const BString& name) + : + fAddress(address), + fSize(size), + fType(type), + fName(name) +{ +} + + +SymbolInfo::~SymbolInfo() +{ +} Added: haiku/trunk/src/apps/debugger/SymbolInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/SymbolInfo.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/SymbolInfo.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -0,0 +1,33 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef SYMBOL_INFO_H +#define SYMBOL_INFO_H + +#include + +#include "ArchitectureTypes.h" + + +class SymbolInfo { +public: + SymbolInfo(target_addr_t address, + target_size_t size, uint32 type, + const BString& name); + ~SymbolInfo(); + + target_addr_t Address() const { return fAddress; } + target_size_t Size() const { return fSize; } + uint32 Type() const { return fType; } + const char* Name() const { return fName.String(); } + +private: + target_addr_t fAddress; + target_size_t fSize; + uint32 fType; + BString fName; +}; + + +#endif // SYMBOL_INFO_H Modified: haiku/trunk/src/apps/debugger/Team.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Team.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Team.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -181,6 +181,19 @@ } +Image* +Team::ImageByAddress(target_addr_t address) const +{ + for (ImageList::ConstIterator it = fImages.GetIterator(); + Image* image = it.Next();) { + if (image->ContainsAddress(address)) + return image; + } + + return NULL; +} + + const ImageList& Team::Images() const { Modified: haiku/trunk/src/apps/debugger/Team.h =================================================================== --- haiku/trunk/src/apps/debugger/Team.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/Team.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -58,6 +58,7 @@ void RemoveImage(Image* image); bool RemoveImage(image_id imageID); Image* ImageByID(image_id imageID) const; + Image* ImageByAddress(target_addr_t address) const; const ImageList& Images() const; void AddListener(Listener* listener); Modified: haiku/trunk/src/apps/debugger/arch/Architecture.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -5,7 +5,21 @@ #include "Architecture.h" +#include +#include +#include + +#include "CpuState.h" +#include "DebugInfo.h" +#include "FunctionDebugInfo.h" +#include "Image.h" +#include "ImageDebugInfo.h" +#include "ImageDebugInfoProvider.h" +#include "StackTrace.h" +#include "Team.h" + + Architecture::Architecture(DebuggerInterface* debuggerInterface) : fDebuggerInterface(debuggerInterface) @@ -23,3 +37,78 @@ { return B_OK; } + + +status_t +Architecture::CreateStackTrace(Team* team, + ImageDebugInfoProvider* imageInfoProvider, CpuState* cpuState, + StackTrace*& _stackTrace) +{ + Reference cpuStateReference(cpuState); + + // create the object + StackTrace* stackTrace = new(std::nothrow) StackTrace; + if (stackTrace == NULL) + return B_NO_MEMORY; + ObjectDeleter stackTraceDeleter(stackTrace); + + StackFrame* frame = NULL; + + while (cpuState != NULL) { + // get the instruction pointer + target_addr_t instructionPointer = cpuState->InstructionPointer(); + if (instructionPointer == 0) + break; + + // get the image for the instruction pointer + AutoLocker teamLocker(team); + Image* image = team->ImageByAddress(instructionPointer); + Reference imageReference(image); + teamLocker.Unlock(); + + // get the image debug info + ImageDebugInfo* imageDebugInfo = NULL; + if (image != NULL) + imageInfoProvider->GetImageDebugInfo(image, imageDebugInfo); + Reference imageDebugInfoReference(imageDebugInfo, true); + + // get the function + FunctionDebugInfo* function = NULL; + if (imageDebugInfo != NULL) + function = imageDebugInfo->FindFunction(instructionPointer); + Reference functionReference(function, true); + + // create the frame using the debug info + StackFrame* previousFrame = NULL; + CpuState* previousCpuState = NULL; + if (function != NULL) { + status_t error = function->GetDebugInfo()->CreateFrame(image, + function, cpuState, previousFrame, previousCpuState); + if (error != B_OK && error != B_UNSUPPORTED) + break; + } + + // If we have no frame yet, let the architecture create it. + if (previousFrame == NULL) { + status_t error = CreateStackFrame(image, function, cpuState, + previousFrame, previousCpuState); + if (error != B_OK) + break; + } + + cpuStateReference.SetTo(previousCpuState, true); + + previousFrame->SetImage(image); + previousFrame->SetFunction(function); + + if (!stackTrace->AddFrame(previousFrame)) + return B_NO_MEMORY; + + frame = previousFrame; + cpuState = previousCpuState; + } + + stackTraceDeleter.Detach(); + _stackTrace = stackTrace; + return B_OK; +} Modified: haiku/trunk/src/apps/debugger/arch/Architecture.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -12,7 +12,11 @@ class CpuState; class DebuggerInterface; +class FunctionDebugInfo; +class Image; +class ImageDebugInfoProvider; class Register; +class StackFrame; class StackTrace; class Team; @@ -30,8 +34,19 @@ virtual status_t CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state) = 0; - virtual status_t CreateStackTrace(Team* team, CpuState* cpuState, - StackTrace*& _stackTrace) = 0; + virtual status_t CreateStackFrame(Image* image, + FunctionDebugInfo* function, + CpuState* cpuState, + StackFrame*& _previousFrame, + CpuState*& _previousCpuState) = 0; + // returns reference to previous frame + // and CPU state; returned CPU state + // can be NULL + + status_t CreateStackTrace(Team* team, + ImageDebugInfoProvider* imageInfoProvider, + CpuState* cpuState, + StackTrace*& _stackTrace); // team is not locked protected: Modified: haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -7,6 +7,7 @@ typedef uint64 target_addr_t; +typedef uint64 target_size_t; Modified: haiku/trunk/src/apps/debugger/arch/CpuState.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -10,7 +10,9 @@ #include #include +#include "ArchitectureTypes.h" + class Register; @@ -18,6 +20,7 @@ public: virtual ~CpuState(); + virtual target_addr_t InstructionPointer() const = 0; virtual bool GetRegisterValue(const Register* reg, BVariant& _value) = 0; }; Modified: haiku/trunk/src/apps/debugger/arch/StackFrame.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackFrame.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/StackFrame.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -5,7 +5,68 @@ #include "StackFrame.h" +#include "CpuState.h" +#include "FunctionDebugInfo.h" +#include "Image.h" + +StackFrame::StackFrame(stack_frame_type type, CpuState* cpuState, + target_addr_t frameAddress) + : + fType(type), + fCpuState(cpuState), + fFrameAddress(frameAddress), + fReturnAddress(0), + fImage(NULL), + fFunction(NULL) +{ + fCpuState->AddReference(); +} + + StackFrame::~StackFrame() { + SetImage(NULL); + SetFunction(NULL); + fCpuState->RemoveReference(); } + + +target_addr_t +StackFrame::InstructionPointer() const +{ + return fCpuState->InstructionPointer(); +} + + +void +StackFrame::SetReturnAddress(target_addr_t address) +{ + fReturnAddress = address; +} + + +void +StackFrame::SetImage(Image* image) +{ + if (fImage != NULL) + fImage->RemoveReference(); + + fImage = image; + + if (fImage != NULL) + fImage->AddReference(); +} + + +void +StackFrame::SetFunction(FunctionDebugInfo* function) +{ + if (fFunction != NULL) + fFunction->RemoveReference(); + + fFunction = function; + + if (fFunction != NULL) + fFunction->AddReference(); +} Modified: haiku/trunk/src/apps/debugger/arch/StackFrame.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackFrame.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/StackFrame.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -8,7 +8,6 @@ #include #include -#include #include "ArchitectureTypes.h" @@ -22,25 +21,39 @@ class CpuState; +class Image; +class FunctionDebugInfo; -class StackFrame : public Referenceable, - public DoublyLinkedListLinkImpl { +class StackFrame : public Referenceable { public: - virtual ~StackFrame(); + StackFrame(stack_frame_type type, + CpuState* cpuState, + target_addr_t frameAddress); + ~StackFrame(); - virtual stack_frame_type Type() const = 0; + stack_frame_type Type() const { return fType; } + CpuState* GetCpuState() const { return fCpuState; } + target_addr_t InstructionPointer() const; + target_addr_t FrameAddress() const { return fFrameAddress; } - virtual CpuState* GetCpuState() const = 0; + target_addr_t ReturnAddress() const { return fReturnAddress; } + void SetReturnAddress(target_addr_t address); - virtual target_addr_t InstructionPointer() const = 0; - virtual target_addr_t FrameAddress() const = 0; - virtual target_addr_t ReturnAddress() const = 0; - virtual target_addr_t PreviousFrameAddress() const = 0; -}; + Image* GetImage() const { return fImage; } + void SetImage(Image* image); + FunctionDebugInfo* Function() const { return fFunction; } + void SetFunction(FunctionDebugInfo* function); -typedef DoublyLinkedList StackFrameList; +private: + stack_frame_type fType; + CpuState* fCpuState; + target_addr_t fFrameAddress; + target_addr_t fReturnAddress; + Image* fImage; + FunctionDebugInfo* fFunction; +}; #endif // STACK_FRAME_H Modified: haiku/trunk/src/apps/debugger/arch/StackTrace.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackTrace.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/StackTrace.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -13,13 +13,31 @@ StackTrace::~StackTrace() { - while (StackFrame* frame = fStackFrames.RemoveHead()) + for (int32 i = 0; StackFrame* frame = FrameAt(i); i++) frame->RemoveReference(); } -void +bool StackTrace::AddFrame(StackFrame* frame) { - fStackFrames.Add(frame); + if (fStackFrames.AddItem(frame)) + return true; + + frame->RemoveReference(); + return false; } + + +int32 +StackTrace::CountFrames() const +{ + return fStackFrames.CountItems(); +} + + +StackFrame* +StackTrace::FrameAt(int32 index) const +{ + return fStackFrames.ItemAt(index); +} Modified: haiku/trunk/src/apps/debugger/arch/StackTrace.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/StackTrace.h 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/StackTrace.h 2009-06-20 17:20:49 UTC (rev 31142) @@ -5,6 +5,8 @@ #ifndef STACK_TRACE_H #define STACK_TRACE_H +#include + #include "StackFrame.h" @@ -13,15 +15,14 @@ StackTrace(); virtual ~StackTrace(); - void AddFrame(StackFrame* frame); - // takes over reference + bool AddFrame(StackFrame* frame); + // takes over reference (also on error) - const StackFrameList& Frames() const { return fStackFrames; } + int32 CountFrames() const; + StackFrame* FrameAt(int32 index) const; - StackFrame* TopFrame() const - { return fStackFrames.Head(); } - StackFrame* BottomFrame() const - { return fStackFrames.Tail(); } +private: + typedef BObjectList StackFrameList; private: StackFrameList fStackFrames; Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-20 16:49:31 UTC (rev 31141) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-20 17:20:49 UTC (rev 31142) @@ -11,8 +11,7 @@ #include "CpuStateX86.h" #include "DebuggerInterface.h" -#include "StackFrameX86.h" -#include "StackTrace.h" +#include "StackFrame.h" ArchitectureX86::ArchitectureX86(DebuggerInterface* debuggerInterface) @@ -104,59 +103,38 @@ status_t -ArchitectureX86::CreateStackTrace(Team* team, CpuState* _cpuState, - StackTrace*& _stackTrace) +ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function, + CpuState* _cpuState, StackFrame*& _previousFrame, + CpuState*& _previousCpuState) { CpuStateX86* cpuState = dynamic_cast(_cpuState); - // create the object - StackTrace* stackTrace = new(std::nothrow) StackTrace; - if (stackTrace == NULL) - return B_NO_MEMORY; - ObjectDeleter stackTraceDeleter(stackTrace); + uint32 framePointer = cpuState->IntRegisterValue(X86_REGISTER_EBP); [... truncated: 926 lines follow ...] From bonefish at mail.berlios.de Sat Jun 20 20:17:48 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 20:17:48 +0200 Subject: [Haiku-commits] r31143 - in haiku/trunk/src/apps/debugger: . arch model Message-ID: <200906201817.n5KIHmE4020516@sheep.berlios.de> Author: bonefish Date: 2009-06-20 20:17:48 +0200 (Sat, 20 Jun 2009) New Revision: 31143 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31143&view=rev Added: haiku/trunk/src/apps/debugger/model/ haiku/trunk/src/apps/debugger/model/Image.cpp haiku/trunk/src/apps/debugger/model/Image.h haiku/trunk/src/apps/debugger/model/ImageInfo.cpp haiku/trunk/src/apps/debugger/model/ImageInfo.h haiku/trunk/src/apps/debugger/model/StackFrame.cpp haiku/trunk/src/apps/debugger/model/StackFrame.h haiku/trunk/src/apps/debugger/model/StackTrace.cpp haiku/trunk/src/apps/debugger/model/StackTrace.h haiku/trunk/src/apps/debugger/model/SymbolInfo.cpp haiku/trunk/src/apps/debugger/model/SymbolInfo.h haiku/trunk/src/apps/debugger/model/Team.cpp haiku/trunk/src/apps/debugger/model/Team.h haiku/trunk/src/apps/debugger/model/TeamDebugModel.cpp haiku/trunk/src/apps/debugger/model/TeamDebugModel.h haiku/trunk/src/apps/debugger/model/Thread.cpp haiku/trunk/src/apps/debugger/model/Thread.h haiku/trunk/src/apps/debugger/model/ThreadInfo.cpp haiku/trunk/src/apps/debugger/model/ThreadInfo.h Removed: haiku/trunk/src/apps/debugger/Image.cpp haiku/trunk/src/apps/debugger/Image.h haiku/trunk/src/apps/debugger/ImageInfo.cpp haiku/trunk/src/apps/debugger/ImageInfo.h haiku/trunk/src/apps/debugger/SymbolInfo.cpp haiku/trunk/src/apps/debugger/SymbolInfo.h haiku/trunk/src/apps/debugger/Team.cpp haiku/trunk/src/apps/debugger/Team.h haiku/trunk/src/apps/debugger/TeamDebugModel.cpp haiku/trunk/src/apps/debugger/TeamDebugModel.h haiku/trunk/src/apps/debugger/Thread.cpp haiku/trunk/src/apps/debugger/Thread.h haiku/trunk/src/apps/debugger/ThreadInfo.cpp haiku/trunk/src/apps/debugger/ThreadInfo.h haiku/trunk/src/apps/debugger/arch/StackFrame.cpp haiku/trunk/src/apps/debugger/arch/StackFrame.h haiku/trunk/src/apps/debugger/arch/StackTrace.cpp haiku/trunk/src/apps/debugger/arch/StackTrace.h Modified: haiku/trunk/src/apps/debugger/Jamfile Log: Moved several classes into new "model" subdir. Deleted: haiku/trunk/src/apps/debugger/Image.cpp Deleted: haiku/trunk/src/apps/debugger/Image.h Deleted: haiku/trunk/src/apps/debugger/ImageInfo.cpp Deleted: haiku/trunk/src/apps/debugger/ImageInfo.h Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 17:20:49 UTC (rev 31142) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 18:17:48 UTC (rev 31143) @@ -11,6 +11,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) debug_info ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) debugger_interface ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) model ] ; local debugAnalyzerSources = [ FDirName $(HAIKU_TOP) src apps debuganalyzer ] ; @@ -21,23 +22,14 @@ Application Debugger : Debugger.cpp # ElfFile.cpp - Image.cpp - ImageInfo.cpp Jobs.cpp - SymbolInfo.cpp - Team.cpp TeamDebugger.cpp - TeamDebugModel.cpp - Thread.cpp - ThreadInfo.cpp Worker.cpp # arch Architecture.cpp CpuState.cpp Register.cpp - StackFrame.cpp - StackTrace.cpp # arch/x86 ArchitectureX86.cpp @@ -62,6 +54,17 @@ TeamWindow.cpp ThreadListView.cpp + # model + Image.cpp + ImageInfo.cpp + StackFrame.cpp + StackTrace.cpp + SymbolInfo.cpp + Team.cpp + TeamDebugModel.cpp + Thread.cpp + ThreadInfo.cpp + # DWARF # attribute_classes.cpp # AttributeValue.cpp Deleted: haiku/trunk/src/apps/debugger/SymbolInfo.cpp Deleted: haiku/trunk/src/apps/debugger/SymbolInfo.h Deleted: haiku/trunk/src/apps/debugger/Team.cpp Deleted: haiku/trunk/src/apps/debugger/Team.h Deleted: haiku/trunk/src/apps/debugger/TeamDebugModel.cpp Deleted: haiku/trunk/src/apps/debugger/TeamDebugModel.h Deleted: haiku/trunk/src/apps/debugger/Thread.cpp Deleted: haiku/trunk/src/apps/debugger/Thread.h Deleted: haiku/trunk/src/apps/debugger/ThreadInfo.cpp Deleted: haiku/trunk/src/apps/debugger/ThreadInfo.h Deleted: haiku/trunk/src/apps/debugger/arch/StackFrame.cpp Deleted: haiku/trunk/src/apps/debugger/arch/StackFrame.h Deleted: haiku/trunk/src/apps/debugger/arch/StackTrace.cpp Deleted: haiku/trunk/src/apps/debugger/arch/StackTrace.h Copied: haiku/trunk/src/apps/debugger/model/Image.cpp (from rev 31142, haiku/trunk/src/apps/debugger/Image.cpp) Copied: haiku/trunk/src/apps/debugger/model/Image.h (from rev 31142, haiku/trunk/src/apps/debugger/Image.h) Copied: haiku/trunk/src/apps/debugger/model/ImageInfo.cpp (from rev 31142, haiku/trunk/src/apps/debugger/ImageInfo.cpp) Copied: haiku/trunk/src/apps/debugger/model/ImageInfo.h (from rev 31142, haiku/trunk/src/apps/debugger/ImageInfo.h) Copied: haiku/trunk/src/apps/debugger/model/StackFrame.cpp (from rev 31142, haiku/trunk/src/apps/debugger/arch/StackFrame.cpp) Copied: haiku/trunk/src/apps/debugger/model/StackFrame.h (from rev 31142, haiku/trunk/src/apps/debugger/arch/StackFrame.h) Copied: haiku/trunk/src/apps/debugger/model/StackTrace.cpp (from rev 31142, haiku/trunk/src/apps/debugger/arch/StackTrace.cpp) Copied: haiku/trunk/src/apps/debugger/model/StackTrace.h (from rev 31142, haiku/trunk/src/apps/debugger/arch/StackTrace.h) Copied: haiku/trunk/src/apps/debugger/model/SymbolInfo.cpp (from rev 31142, haiku/trunk/src/apps/debugger/SymbolInfo.cpp) Copied: haiku/trunk/src/apps/debugger/model/SymbolInfo.h (from rev 31142, haiku/trunk/src/apps/debugger/SymbolInfo.h) Copied: haiku/trunk/src/apps/debugger/model/Team.cpp (from rev 31142, haiku/trunk/src/apps/debugger/Team.cpp) Copied: haiku/trunk/src/apps/debugger/model/Team.h (from rev 31142, haiku/trunk/src/apps/debugger/Team.h) Copied: haiku/trunk/src/apps/debugger/model/TeamDebugModel.cpp (from rev 31133, haiku/trunk/src/apps/debugger/TeamDebugModel.cpp) Copied: haiku/trunk/src/apps/debugger/model/TeamDebugModel.h (from rev 31133, haiku/trunk/src/apps/debugger/TeamDebugModel.h) Copied: haiku/trunk/src/apps/debugger/model/Thread.cpp (from rev 31133, haiku/trunk/src/apps/debugger/Thread.cpp) Copied: haiku/trunk/src/apps/debugger/model/Thread.h (from rev 31133, haiku/trunk/src/apps/debugger/Thread.h) Copied: haiku/trunk/src/apps/debugger/model/ThreadInfo.cpp (from rev 31133, haiku/trunk/src/apps/debugger/ThreadInfo.cpp) Copied: haiku/trunk/src/apps/debugger/model/ThreadInfo.h (from rev 31133, haiku/trunk/src/apps/debugger/ThreadInfo.h) From humdingerb at mail.berlios.de Sat Jun 20 20:30:10 2009 From: humdingerb at mail.berlios.de (humdingerb at mail.berlios.de) Date: Sat, 20 Jun 2009 20:30:10 +0200 Subject: [Haiku-commits] r31144 - in haiku/trunk/docs: . userguide/en userguide/en/preferences userguide/images/deskbar-images userguide/images/prefs-images Message-ID: <200906201830.n5KIUACq021157@sheep.berlios.de> Author: humdingerb Date: 2009-06-20 20:30:05 +0200 (Sat, 20 Jun 2009) New Revision: 31144 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31144&view=rev Modified: haiku/trunk/docs/Haiku-doc.css haiku/trunk/docs/userguide/en/deskbar.html haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html haiku/trunk/docs/userguide/en/preferences/prefs-keymap.html haiku/trunk/docs/userguide/en/tracker.html haiku/trunk/docs/userguide/images/deskbar-images/settings.png haiku/trunk/docs/userguide/images/prefs-images/keymap.png Log: * The topnav bar wasn't high enough. Small change in Haiku-doc.css solved that. * Corrected link in Fonts preferences. * Added Mount menu item and changed Shutdown menu item in Deskbar. Updated screenshot. * Updated Keymap documentation and screenshot (comments welcome, esp. for the keyboard commandline part at the end). Modified: haiku/trunk/docs/Haiku-doc.css =================================================================== --- haiku/trunk/docs/Haiku-doc.css 2009-06-20 18:17:48 UTC (rev 31143) +++ haiku/trunk/docs/Haiku-doc.css 2009-06-20 18:30:05 UTC (rev 31144) @@ -88,7 +88,6 @@ } div.topnav { background: #e0e0e0; - line-height: 1.0; } div.topnav p { margin-left: 40px; Modified: haiku/trunk/docs/userguide/en/deskbar.html =================================================================== --- haiku/trunk/docs/userguide/en/deskbar.html 2009-06-20 18:17:48 UTC (rev 31143) +++ haiku/trunk/docs/userguide/en/deskbar.html 2009-06-20 18:30:05 UTC (rev 31144) @@ -42,13 +42,14 @@

You can move the Deskbar to any corner or as a bar along the upper or lower border of the screen by gripping the knobbly area on the left side of the tray and drag&drop it into the new position. You can also fold it into a more compact layout by drag&dropping the knobbly area onto the Deskbar menu.

The Deskbar Menu

-

A menu opens when you click on the Deskbar's uppermost part:

-settings.png +

A menu opens when you click on the Deskbar's top:

+settings.png
  • About This System... - Shows some basic information of the system, licenses and the credits of the Haiku project.

  • Find... - Opens the Query dialog.

  • Show Replicants - Shows/hides the little Replicant widget you use to drag it around, remove or access its context menu.

  • +
  • Mount - Offers the same options as when invoked by right-clicking the Desktop (see Mounting Volumes).

  • Deskbar Settings

@@ -63,9 +64,8 @@
Configure Deskbar Menu... Opens a panel to configure the Deskbar menu (see below).
Show Application Expander Provides a small widget to show/hide all windows of a program directly under its entry in the Deskbar.
Expand New Applications Newly launched programs have their windows automatically expanded under their entry in the Deskbar.
-
  • Restart - Restarts the system.

  • -
  • Shutdown - Shuts down the system.

  • -
  • Recent Documents, Folders, Applications - List the last recently opened documents, folders and applications (see Configure Deskbar Menu... below). +

  • Shutdown - Offers options to either Restart System or Power Off.

  • +
  • Recent Documents, Folders, Applications - List of the last recently opened documents, folders and applications (see Configure Deskbar Menu... below).

  • Applications, Demos, Deskbar Applets, Preferences - List of installed applications, demos, applets and preferences (see Configure Deskbar Menu... below).

  • Modified: haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html 2009-06-20 18:17:48 UTC (rev 31143) +++ haiku/trunk/docs/userguide/en/preferences/prefs-fonts.html 2009-06-20 18:30:05 UTC (rev 31144) @@ -52,7 +52,7 @@

    Installing new fonts

    -

    You install new fonts by copying them into their respective user folder, i.e. /boot/common/fonts/ or /boot/home/config/fonts/ (see topic Filesystem layout).

    +

    You install new fonts by copying them into their respective user folder, i.e. /boot/common/fonts/ or /boot/home/config/fonts/ (see topic Filesystem layout).

    Modified: haiku/trunk/docs/userguide/en/preferences/prefs-keymap.html =================================================================== --- haiku/trunk/docs/userguide/en/preferences/prefs-keymap.html 2009-06-20 18:17:48 UTC (rev 31143) +++ haiku/trunk/docs/userguide/en/preferences/prefs-keymap.html 2009-06-20 18:30:05 UTC (rev 31144) @@ -5,7 +5,7 @@ + Modified: haiku/trunk/docs/userguide/en/tracker.html =================================================================== --- haiku/trunk/docs/userguide/en/tracker.html 2009-06-20 18:17:48 UTC (rev 31143) +++ haiku/trunk/docs/userguide/en/tracker.html 2009-06-20 18:30:05 UTC (rev 31144) @@ -40,7 +40,7 @@

    Being an application like any other (the Desktop with its icons is really just a fullscreen window in the background), Tracker appears with its windows in the Deskbar and can be quit and restarted. The easiest way to quit and restart a crashed or frozen Tracker (or a wayward Deskbar) is to call the Team Monitor.

    Mounting Volumes

    -

    In order to access a harddisk, CD, USB stick etc., you first have to mount the volume, that is, let the system know it's there. This is done with a right-click on the Desktop or an already mounted volume (like the boot disk) and choosing the volume from the Mount submenu.

    +

    In order to access a harddisk, CD, USB stick etc., you first have to mount the volume, that is, let the system know it's there. This is done with a right-click on the Desktop or an already mounted volume (like the boot disk) and choosing the volume from the Mount submenu. You find the same Mount menu in the Deskbar.

    drill-down.png

    There are also Mount Settings so you don't have to mount everything manually after every bootup.
    The above settings will automatically mount any storage device you connect/insert and also mount all disks on bootup that were mounted previously.

    Modified: haiku/trunk/docs/userguide/images/deskbar-images/settings.png =================================================================== (Binary files differ) Modified: haiku/trunk/docs/userguide/images/prefs-images/keymap.png =================================================================== (Binary files differ) From bonefish at mail.berlios.de Sat Jun 20 20:43:38 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 20:43:38 +0200 Subject: [Haiku-commits] r31145 - haiku/trunk/src/add-ons/kernel/debugger/demangle Message-ID: <200906201843.n5KIhcma021763@sheep.berlios.de> Author: bonefish Date: 2009-06-20 20:43:38 +0200 (Sat, 20 Jun 2009) New Revision: 31145 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31145&view=rev Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp Log: Added function demangle_name_gcc3() not used in the add-on. The whole demangler should better be moved to a shared location. Eventually... Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h 2009-06-20 18:30:05 UTC (rev 31144) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/demangle.h 2009-06-20 18:43:38 UTC (rev 31145) @@ -22,6 +22,10 @@ status_t get_next_argument_gcc3(uint32* _cookie, const char* symbol, char* name, size_t nameSize, int32* _type, size_t* _argumentLength); +#ifndef _KERNEL_MODE +const char* demangle_name_gcc3(const char* name, char* buffer, + size_t bufferSize); +#endif #endif // DEMANGLE_H Modified: haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp 2009-06-20 18:30:05 UTC (rev 31144) +++ haiku/trunk/src/add-ons/kernel/debugger/demangle/gcc3+.cpp 2009-06-20 18:43:38 UTC (rev 31145) @@ -3870,3 +3870,19 @@ ++*_cookie; return B_OK; } + + +#ifndef _KERNEL_MODE + +const char* +demangle_name_gcc3(const char* mangledName, char* buffer, size_t bufferSize) +{ + + Demangler demangler; + DemanglingInfo info(false); + if (demangler.Demangle(mangledName, buffer, bufferSize, info) != ERROR_OK) + return NULL; + return buffer; +} + +#endif From bonefish at mail.berlios.de Sat Jun 20 20:45:20 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 20:45:20 +0200 Subject: [Haiku-commits] r31146 - in haiku/trunk/src/apps/debugger: . debug_info demangler Message-ID: <200906201845.n5KIjKXK021908@sheep.berlios.de> Author: bonefish Date: 2009-06-20 20:45:20 +0200 (Sat, 20 Jun 2009) New Revision: 31146 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31146&view=rev Added: haiku/trunk/src/apps/debugger/demangler/ haiku/trunk/src/apps/debugger/demangler/Demangler.cpp haiku/trunk/src/apps/debugger/demangler/Demangler.h haiku/trunk/src/apps/debugger/demangler/Jamfile Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp Log: Added demangling support. Only implemented for gcc 4 yet. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 18:43:38 UTC (rev 31145) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-20 18:45:20 UTC (rev 31146) @@ -16,6 +16,7 @@ local debugAnalyzerSources = [ FDirName $(HAIKU_TOP) src apps debuganalyzer ] ; +SubDirHdrs [ FDirName $(SUBDIR) demangler ] ; SubDirHdrs [ FDirName $(HAIKU_TOP) src bin debug ] ; SubDirHdrs [ FDirName $(debugAnalyzerSources) gui ] ; @@ -75,6 +76,7 @@ # tag_names.cpp : + Debugger_demangler.o DebugAnalyzer_gui_table.o debug_utils.a @@ -87,4 +89,5 @@ : Debugger.rdef ; +HaikuSubInclude demangler ; HaikuSubInclude gui running_teams_window ; Modified: haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp 2009-06-20 18:43:38 UTC (rev 31145) +++ haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp 2009-06-20 18:45:20 UTC (rev 31146) @@ -9,6 +9,7 @@ #include "BasicFunctionDebugInfo.h" #include "DebuggerInterface.h" +#include "Demangler.h" #include "SymbolInfo.h" @@ -72,8 +73,8 @@ return NULL; return new(std::nothrow) BasicFunctionDebugInfo(this, symbolInfo->Address(), - symbolInfo->Size(), symbolInfo->Name(), symbolInfo->Name()); - // TODO: Demangle! + symbolInfo->Size(), symbolInfo->Name(), + Demangler::Demangle(symbolInfo->Name())); } Added: haiku/trunk/src/apps/debugger/demangler/Demangler.cpp =================================================================== --- haiku/trunk/src/apps/debugger/demangler/Demangler.cpp 2009-06-20 18:43:38 UTC (rev 31145) +++ haiku/trunk/src/apps/debugger/demangler/Demangler.cpp 2009-06-20 18:45:20 UTC (rev 31146) @@ -0,0 +1,25 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "Demangler.h" + +#include "demangle.h" + + +/*static*/ BString +Demangler::Demangle(const BString& mangledName) +{ + char buffer[1024]; + if (mangledName.Compare("_Z", 2) == 0) { + const char* demangled = demangle_name_gcc3(mangledName.String(), buffer, + sizeof(buffer)); + if (demangled != NULL) + return demangled; + } + + // TODO: gcc2 demangling! + + return mangledName; +} Added: haiku/trunk/src/apps/debugger/demangler/Demangler.h =================================================================== --- haiku/trunk/src/apps/debugger/demangler/Demangler.h 2009-06-20 18:43:38 UTC (rev 31145) +++ haiku/trunk/src/apps/debugger/demangler/Demangler.h 2009-06-20 18:45:20 UTC (rev 31146) @@ -0,0 +1,17 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef DEMANGLER_H +#define DEMANGLER_H + +#include + + +class Demangler { +public: + static BString Demangle(const BString& mangledName); +}; + + +#endif // DEMANGLER_H Added: haiku/trunk/src/apps/debugger/demangler/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/demangler/Jamfile 2009-06-20 18:43:38 UTC (rev 31145) +++ haiku/trunk/src/apps/debugger/demangler/Jamfile 2009-06-20 18:45:20 UTC (rev 31146) @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src apps debugger demangler ; + +CCFLAGS += -Werror ; +C++FLAGS += -Werror ; + +UsePrivateHeaders kernel ; + +SEARCH_SOURCE + += [ FDirName $(HAIKU_TOP) src add-ons kernel debugger demangle ] ; + + +MergeObject Debugger_demangler.o + : + Demangler.cpp + + gcc3+.cpp +; From bonefish at mail.berlios.de Sat Jun 20 21:26:48 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 20 Jun 2009 21:26:48 +0200 Subject: [Haiku-commits] r31147 - haiku/trunk/src/apps/debugger/gui/team_window Message-ID: <200906201926.n5KJQmxG024112@sheep.berlios.de> Author: bonefish Date: 2009-06-20 21:26:47 +0200 (Sat, 20 Jun 2009) New Revision: 31147 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31147&view=rev Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.h Log: * If a stack frame is selected show its registers instead those of the top frame. * Some cleanup in ThreadListView. * Unregister view listeners in the window destructor. Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-20 18:45:20 UTC (rev 31146) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-20 19:26:47 UTC (rev 31147) @@ -135,6 +135,11 @@ } } + StackFrame* FrameAt(int32 index) const + { + return fStackTrace != NULL ? fStackTrace->FrameAt(index) : NULL; + } + private: StackTrace* fStackTrace; }; @@ -143,11 +148,12 @@ // #pragma mark - StackTraceView -StackTraceView::StackTraceView() +StackTraceView::StackTraceView(Listener* listener) : BGroupView(B_VERTICAL), fFramesTable(NULL), - fFramesTableModel(NULL) + fFramesTableModel(NULL), + fListener(listener) { SetName("Stack Trace"); } @@ -162,9 +168,9 @@ /*static*/ StackTraceView* -StackTraceView::Create() +StackTraceView::Create(Listener* listener) { - StackTraceView* self = new StackTraceView(); + StackTraceView* self = new StackTraceView(listener); try { self->_Init(); @@ -178,6 +184,13 @@ void +StackTraceView::UnsetListener() +{ + fListener = NULL; +} + + +void StackTraceView::SetStackTrace(StackTrace* stackTrace) { if (stackTrace == fStackTrace) @@ -196,6 +209,19 @@ void +StackTraceView::TableSelectionChanged(Table* table) +{ + if (fListener == NULL) + return; + + StackFrame* frame + = fFramesTableModel->FrameAt(table->SelectionModel()->RowAt(0)); + + fListener->StackFrameSelectionChanged(frame); +} + + +void StackTraceView::TableRowInvoked(Table* table, int32 rowIndex) { } @@ -213,11 +239,20 @@ 1000, B_TRUNCATE_END, B_ALIGN_RIGHT)); fFramesTable->AddColumn(new TargetAddressValueColumn(1, "IP", 80, 40, 1000, B_TRUNCATE_END, B_ALIGN_RIGHT)); - fFramesTable->AddColumn(new StringTableColumn(2, "Function", 80, 40, 1000, + fFramesTable->AddColumn(new StringTableColumn(2, "Function", 300, 100, 1000, B_TRUNCATE_END, B_ALIGN_LEFT)); fFramesTableModel = new FramesTableModel(); fFramesTable->SetTableModel(fFramesTableModel); + fFramesTable->SetSelectionMode(B_SINGLE_SELECTION_LIST); fFramesTable->AddTableListener(this); } + + +// #pragma mark - Listener + + +StackTraceView::Listener::~Listener() +{ +} Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h 2009-06-20 18:45:20 UTC (rev 31146) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h 2009-06-20 19:26:47 UTC (rev 31147) @@ -11,14 +11,22 @@ #include "Team.h" +class StackFrame; + + class StackTraceView : public BGroupView, private TableListener { public: - StackTraceView(); + class Listener; + +public: + StackTraceView(Listener* listener); ~StackTraceView(); - static StackTraceView* Create(); + static StackTraceView* Create(Listener* listener); // throws + void UnsetListener(); + void SetStackTrace(StackTrace* stackTrace); private: @@ -26,6 +34,7 @@ private: // TableListener + virtual void TableSelectionChanged(Table* table); virtual void TableRowInvoked(Table* table, int32 rowIndex); void _Init(); @@ -34,7 +43,17 @@ StackTrace* fStackTrace; Table* fFramesTable; FramesTableModel* fFramesTableModel; + Listener* fListener; }; +class StackTraceView::Listener { +public: + virtual ~Listener(); + + virtual void StackFrameSelectionChanged( + StackFrame* frame) = 0; +}; + + #endif // STACK_TRACE_VIEW_H Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-20 18:45:20 UTC (rev 31146) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-20 19:26:47 UTC (rev 31147) @@ -34,6 +34,7 @@ B_ASYNCHRONOUS_CONTROLS), fDebugModel(debugModel), fActiveThread(NULL), + fActiveStackFrame(NULL), fListener(listener), fTabView(NULL), fLocalsTabView(NULL), @@ -58,6 +59,11 @@ TeamWindow::~TeamWindow() { + if (fThreadListView != NULL) + fThreadListView->UnsetListener(); + if (fStackTraceView != NULL) + fStackTraceView->UnsetListener(); + fDebugModel->GetTeam()->RemoveListener(this); } @@ -144,6 +150,13 @@ void +TeamWindow::StackFrameSelectionChanged(StackFrame* frame) +{ + _SetActiveStackFrame(frame); +} + + +void TeamWindow::ThreadStateChanged(const Team::ThreadEvent& event) { BMessage message(MSG_THREAD_STATE_CHANGED); @@ -197,7 +210,7 @@ fTabView->AddTab(threadGroup); BLayoutBuilder::Split<>(threadGroup) .Add(fThreadListView = ThreadListView::Create(this)) - .Add(fStackTraceView = StackTraceView::Create()); + .Add(fStackTraceView = StackTraceView::Create(this)); // add images tab BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL); @@ -243,11 +256,6 @@ AutoLocker locker(fDebugModel); _UpdateRunButtons(); - CpuState* cpuState = fActiveThread != NULL - ? fActiveThread->GetCpuState() : NULL; - Reference cpuStateReference(cpuState); - // hold a reference until the register view has one - StackTrace* stackTrace = fActiveThread != NULL ? fActiveThread->GetStackTrace() : NULL; Reference stackTraceReference(stackTrace); @@ -255,12 +263,53 @@ locker.Unlock(); - fRegisterView->SetCpuState(cpuState); fStackTraceView->SetStackTrace(stackTrace); + _UpdateCpuState(); } void +TeamWindow::_SetActiveStackFrame(StackFrame* frame) +{ + if (frame == fActiveStackFrame) + return; + + if (fActiveStackFrame != NULL) + fActiveStackFrame->RemoveReference(); + + fActiveStackFrame = frame; + + if (fActiveStackFrame != NULL) + fActiveStackFrame->AddReference(); + + _UpdateCpuState(); +} + + +void +TeamWindow::_UpdateCpuState() +{ + // get the CPU state + CpuState* cpuState = NULL; + Reference cpuStateReference; + // hold a reference until the register view has one + + if (fActiveThread != NULL) { + // Get the CPU state from the active stack frame or the thread directly. + if (fActiveStackFrame == NULL) { + AutoLocker locker(fDebugModel); + cpuState = fActiveThread->GetCpuState(); + cpuStateReference.SetTo(cpuState); + locker.Unlock(); + } else + cpuState = fActiveStackFrame->GetCpuState(); + } + + fRegisterView->SetCpuState(cpuState); +} + + +void TeamWindow::_UpdateRunButtons() { uint32 threadState = fActiveThread != NULL @@ -312,16 +361,7 @@ if (fActiveThread == NULL || threadID != fActiveThread->ID()) return; - AutoLocker locker(fDebugModel); - - CpuState* cpuState = fActiveThread != NULL - ? fActiveThread->GetCpuState() : NULL; - Reference reference(cpuState); - // hold a reference until the register view has one - - locker.Unlock(); - - fRegisterView->SetCpuState(cpuState); + _UpdateCpuState(); } Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-20 18:45:20 UTC (rev 31146) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h 2009-06-20 19:26:47 UTC (rev 31147) @@ -8,6 +8,7 @@ #include #include +#include "StackTraceView.h" #include "Team.h" #include "ThreadListView.h" @@ -16,12 +17,11 @@ class BTabView; class ImageListView; class RegisterView; -class StackTraceView; class TeamDebugModel; class TeamWindow : public BWindow, private ThreadListView::Listener, - Team::Listener { + StackTraceView::Listener, Team::Listener { public: class Listener; @@ -41,6 +41,9 @@ // ThreadListView::Listener virtual void ThreadSelectionChanged(::Thread* thread); + // StackTraceView::Listener + virtual void StackFrameSelectionChanged(StackFrame* frame); + // Team::Listener virtual void ThreadStateChanged( const Team::ThreadEvent& event); @@ -52,6 +55,8 @@ void _Init(); void _SetActiveThread(::Thread* thread); + void _SetActiveStackFrame(StackFrame* frame); + void _UpdateCpuState(); void _UpdateRunButtons(); void _HandleThreadStateChanged(thread_id threadID); @@ -61,6 +66,7 @@ private: TeamDebugModel* fDebugModel; ::Thread* fActiveThread; + StackFrame* fActiveStackFrame; Listener* fListener; BTabView* fTabView; BTabView* fLocalsTabView; Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-20 18:45:20 UTC (rev 31146) +++ haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-20 19:26:47 UTC (rev 31147) @@ -166,6 +166,13 @@ void +ThreadListView::UnsetListener() +{ + fListener = NULL; +} + + +void ThreadListView::SetTeam(Team* team) { if (team == fTeam) @@ -222,6 +229,9 @@ void ThreadListView::TableSelectionChanged(Table* table) { + if (fListener == NULL) + return; + Thread* thread = NULL; if (fThreadsTableModel != NULL) { TableSelectionModel* selectionModel = table->SelectionModel(); @@ -233,17 +243,6 @@ void -ThreadListView::TableRowInvoked(Table* table, int32 rowIndex) -{ -// if (fThreadsTableModel != NULL) { -// Thread* thread = fThreadsTableModel->ThreadAt(rowIndex); -// if (thread != NULL) -// fParent->OpenThreadWindow(thread); -// } -} - - -void ThreadListView::_Init() { fThreadsTable = new Table("threads list", 0); Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.h 2009-06-20 18:45:20 UTC (rev 31146) +++ haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.h 2009-06-20 19:26:47 UTC (rev 31147) @@ -26,6 +26,8 @@ static ThreadListView* Create(Listener* listener); // throws + void UnsetListener(); + void SetTeam(Team* team); virtual void MessageReceived(BMessage* message); @@ -40,7 +42,6 @@ // TableListener virtual void TableSelectionChanged(Table* table); - virtual void TableRowInvoked(Table* table, int32 rowIndex); void _Init(); From humdingerb at mail.berlios.de Sun Jun 21 09:11:24 2009 From: humdingerb at mail.berlios.de (humdingerb at mail.berlios.de) Date: Sun, 21 Jun 2009 09:11:24 +0200 Subject: [Haiku-commits] r31148 - in haiku/trunk/docs/userguide/en: . applications Message-ID: <200906210711.n5L7BOTv010841@sheep.berlios.de> Author: humdingerb Date: 2009-06-21 09:11:22 +0200 (Sun, 21 Jun 2009) New Revision: 31148 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31148&view=rev Modified: haiku/trunk/docs/userguide/en/applications.html haiku/trunk/docs/userguide/en/applications/apps-charactermap.html Log: * Set html MIME type for apps-charactermap.hmtl. * Added CharacterMap to applications.html contents. Property changes on: haiku/trunk/docs/userguide/en/applications/apps-charactermap.html ___________________________________________________________________ Name: svn:mime-type + text/html Modified: haiku/trunk/docs/userguide/en/applications.html =================================================================== --- haiku/trunk/docs/userguide/en/applications.html 2009-06-20 19:26:47 UTC (rev 31147) +++ haiku/trunk/docs/userguide/en/applications.html 2009-06-21 07:11:22 UTC (rev 31148) @@ -72,7 +72,7 @@ iconCDPlayer  A player for audio CDs. iconCharacterMap  - An application that shows the Unicode character map. [still missing] + An application that shows the Unicode character map. iconCodyCam  A tool to regularly upload images from a webcam to a server. iconDeskCalc  From bonefish at mail.berlios.de Sun Jun 21 12:57:12 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 21 Jun 2009 12:57:12 +0200 Subject: [Haiku-commits] r31149 - haiku/trunk/build/jam Message-ID: <200906211057.n5LAvCPo014985@sheep.berlios.de> Author: bonefish Date: 2009-06-21 12:57:01 +0200 (Sun, 21 Jun 2009) New Revision: 31149 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31149&view=rev Modified: haiku/trunk/build/jam/ImageRules Log: Added new optional parameter to AddSymlinkToHaikuHybridImage allowing to create the symlink in a subdirectory for the alternative gcc. Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2009-06-21 07:11:22 UTC (rev 31148) +++ haiku/trunk/build/jam/ImageRules 2009-06-21 10:57:01 UTC (rev 31149) @@ -1053,10 +1053,10 @@ } rule AddSymlinkToHaikuHybridImage directoryTokens : linkTarget : linkName - : useSymlinkABISubDir + : useSymlinkTargetABISubDir : useABISubDir { # AddFilesToHaikuHybridImage : : - # : + # [ : [ : ] ] # # Convenience rule calling both AddSymlinkToHaikuImage and # AddSymlinkToAlternativeGCCArchive. @@ -1064,13 +1064,21 @@ # # Can be a list of components that will be joined to path inserting # "/"s inbetween. - # + # # If non-empty, specifies that an ABI subdirectory shall be inserted # into (between the first and second component) for the # alternative GCC archive. + # + # If non-empty, specifies that an ABI subdirectory part shall be appended + # to the directory tokens for the alternative GCC archive. + local alternativeDirTokens = $(directoryTokens) ; + if $(useABISubDir) { + alternativeDirTokens += gcc$(HAIKU_GCC_VERSION[1]) ; + } + local alternativeLinkTarget = $(linkTarget) ; - if $(useSymlinkABISubDir) { + if $(useSymlinkTargetABISubDir) { alternativeLinkTarget = $(linkTarget[1]) gcc$(HAIKU_GCC_VERSION[1]) $(linkTarget[2-]) ; } @@ -1078,7 +1086,7 @@ alternativeLinkTarget = $(alternativeLinkTarget:J=/) ; AddSymlinkToHaikuImage $(directoryTokens) : $(linkTarget) : $(linkName) ; - AddSymlinkToAlternativeGCCArchive $(directoryTokens) + AddSymlinkToAlternativeGCCArchive $(alternativeDirTokens) : $(alternativeLinkTarget) : $(linkName) ; } From bonefish at mail.berlios.de Sun Jun 21 12:59:35 2009 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 21 Jun 2009 12:59:35 +0200 Subject: [Haiku-commits] r31150 - haiku/trunk/build/jam Message-ID: <200906211059.n5LAxZJ2016622@sheep.berlios.de> Author: bonefish Date: 2009-06-21 12:59:34 +0200 (Sun, 21 Jun 2009) New Revision: 31150 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31150&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * Create the symlinks for the alternative gcc in the correct subdirectory. Fixes bug #4035. * Create the libnetwork.so compatibility symlinks only for gcc 2. * Install only the shared libstdc++ to /system/lib. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2009-06-21 10:57:01 UTC (rev 31149) +++ haiku/trunk/build/jam/HaikuImage 2009-06-21 10:59:34 UTC (rev 31150) @@ -78,7 +78,7 @@ GLDirectMode GLTeapot Mandelbrot Pairs Playground Pulse Sudoku Gradients ; -SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so +SYSTEM_LIBS = libbe.so $(HAIKU_SHARED_LIBSTDC++) libmedia.so libtracker.so libtranslation.so libbnetapi.so libnetwork.so libdebug.so libbsd.so libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so @@ -233,12 +233,17 @@ SYSTEM_LIBS_LIBNETWORK_ALIASES = libsocket.so libbind.so libnet.so ; -local lib ; -for lib in $(SYSTEM_LIBS_LIBNETWORK_ALIASES) { - AddSymlinkToHaikuHybridImage system lib : libnetwork.so : $(lib) ; +if $(HAIKU_GCC_VERSION[1]) = 2 { + local lib ; + for lib in $(SYSTEM_LIBS_LIBNETWORK_ALIASES) { + AddSymlinkToHaikuHybridImage system lib : libnetwork.so : $(lib) + : : true ; + } + + AddSymlinkToHaikuHybridImage system lib : libbnetapi.so : libnetapi.so + : : true ; } -AddSymlinkToHaikuHybridImage system lib : libbnetapi.so : libnetapi.so ; # libGL.so has GLU (like BeOS) *and* GLUT API built-in SYSTEM_LIBS_LIBGL_ALIASES @@ -247,7 +252,7 @@ if $(TARGET_ARCH) = x86 { local lib ; for lib in $(SYSTEM_LIBS_LIBGL_ALIASES) { - AddSymlinkToHaikuHybridImage system lib : libGL.so : $(lib) ; + AddSymlinkToHaikuHybridImage system lib : libGL.so : $(lib) : : true ; } } From stippi at mail.berlios.de Sun Jun 21 14:05:36 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 21 Jun 2009 14:05:36 +0200 Subject: [Haiku-commits] r31151 - haiku/trunk/src/apps/debuganalyzer/gui/table Message-ID: <200906211205.n5LC5ao9007735@sheep.berlios.de> Author: stippi Date: 2009-06-21 14:05:34 +0200 (Sun, 21 Jun 2009) New Revision: 31151 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31151&view=rev Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h Log: Work around a GCC2 problem with dynamic casting a BHandler pointer to a BView in BWindow::_FindView(int32 token). This fixes the BColumnListViews in DebugAnalyzer and Debugger to draw their frames properly. Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-21 10:59:34 UTC (rev 31150) +++ haiku/trunk/src/apps/debuganalyzer/gui/table/AbstractTable.h 2009-06-21 12:05:34 UTC (rev 31151) @@ -20,7 +20,9 @@ }; -class AbstractTable : protected BColumnListView { +// NOTE: Intention is to inherit from "protected BColumnListView", but GCC2 +// has problems dynamic_casting a BHandler pointer to a BView then... +class AbstractTable : public BColumnListView { public: AbstractTable(const char* name, uint32 flags, border_style borderStyle = B_NO_BORDER, From stippi at mail.berlios.de Sun Jun 21 14:07:14 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 21 Jun 2009 14:07:14 +0200 Subject: [Haiku-commits] r31152 - in haiku/trunk/src/apps/debugger: debugger_interface gui/team_window Message-ID: <200906211207.n5LC7EdU007842@sheep.berlios.de> Author: stippi Date: 2009-06-21 14:07:11 +0200 (Sun, 21 Jun 2009) New Revision: 31152 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31152&view=rev Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp Log: * Create the BColumnListViews with fancy borders. * Add some spacing around most views in the top level layout. Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h =================================================================== --- haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-21 12:05:34 UTC (rev 31151) +++ haiku/trunk/src/apps/debugger/debugger_interface/DebuggerInterface.h 2009-06-21 12:07:11 UTC (rev 31152) @@ -24,7 +24,7 @@ class DebuggerInterface { public: DebuggerInterface(team_id teamID); - virtual ~DebuggerInterface(); + virtual ~DebuggerInterface(); status_t Init(); void Close(); Modified: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-21 12:05:34 UTC (rev 31151) +++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp 2009-06-21 12:07:11 UTC (rev 31152) @@ -231,7 +231,7 @@ void ImageListView::_Init() { - fImagesTable = new Table("images list", 0); + fImagesTable = new Table("images list", 0, B_FANCY_BORDER); AddChild(fImagesTable->ToView()); // columns Modified: haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp 2009-06-21 12:05:34 UTC (rev 31151) +++ haiku/trunk/src/apps/debugger/gui/team_window/RegisterView.cpp 2009-06-21 12:07:11 UTC (rev 31152) @@ -232,7 +232,7 @@ void RegisterView::_Init() { - fRegisterTable = new Table("register list", 0); + fRegisterTable = new Table("register list", 0, B_FANCY_BORDER); AddChild(fRegisterTable->ToView()); // columns Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-21 12:05:34 UTC (rev 31151) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-21 12:07:11 UTC (rev 31152) @@ -230,7 +230,7 @@ void StackTraceView::_Init() { - fFramesTable = new Table("register list", 0); + fFramesTable = new Table("register list", 0, B_FANCY_BORDER); AddChild(fFramesTable->ToView()); fFramesTable->SetSortingEnabled(false); Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-21 12:05:34 UTC (rev 31151) +++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp 2009-06-21 12:07:11 UTC (rev 31152) @@ -30,7 +30,7 @@ TeamWindow::TeamWindow(TeamDebugModel* debugModel, Listener* listener) : - BWindow(BRect(100, 100, 899, 699), "Team", B_DOCUMENT_WINDOW, + BWindow(BRect(100, 100, 899, 699), "Team", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS), fDebugModel(debugModel), fActiveThread(NULL), @@ -188,7 +188,10 @@ { BLayoutBuilder::Group<>(this, B_VERTICAL) .AddSplit(B_VERTICAL, 3.0f) - .Add(fTabView = new BTabView("tab view"), 0.4f) + .AddGroup(B_VERTICAL, 0.0f, 0.4f) + .Add(fTabView = new BTabView("tab view")) + .SetInsets(4.0f, 4.0f, 4.0f, 0.0f) + .End() .AddGroup(B_VERTICAL, 4.0f) .AddGroup(B_HORIZONTAL, 4.0f) .Add(fRunButton = new BButton("Run")) @@ -196,10 +199,14 @@ .Add(fStepIntoButton = new BButton("Step Into")) .Add(fStepOutButton = new BButton("Step Out")) .AddGlue() + .SetInsets(4.0f, 0.0f, 4.0f, 0.0f) .End() .AddSplit(B_HORIZONTAL, 3.0f) .Add(new BTextView("source view"), 3.0f) - .Add(fLocalsTabView = new BTabView("locals view")) + .AddGroup(B_VERTICAL) + .Add(fLocalsTabView = new BTabView("locals view")) + .SetInsets(0.0f, 0.0f, 4.0f, 4.0f) + .End() .End() .End() .End(); Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-21 12:05:34 UTC (rev 31151) +++ haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp 2009-06-21 12:07:11 UTC (rev 31152) @@ -245,7 +245,7 @@ void ThreadListView::_Init() { - fThreadsTable = new Table("threads list", 0); + fThreadsTable = new Table("threads list", 0, B_FANCY_BORDER); AddChild(fThreadsTable->ToView()); // columns From bonefish at mail.berlios.de Sun Jun 21 14:58:17 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 21 Jun 2009 14:58:17 +0200 Subject: [Haiku-commits] r31153 - in haiku/trunk: headers/libs headers/libs/udis86 headers/libs/udis86/libudis86 src/add-ons/kernel/debugger/disasm/x86 src/libs src/libs/udis86 Message-ID: <200906211258.n5LCwHdD010876@sheep.berlios.de> Author: bonefish Date: 2009-06-21 14:58:16 +0200 (Sun, 21 Jun 2009) New Revision: 31153 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31153&view=rev Added: haiku/trunk/headers/libs/udis86/ haiku/trunk/headers/libs/udis86/libudis86/ haiku/trunk/headers/libs/udis86/libudis86/decode.h haiku/trunk/headers/libs/udis86/libudis86/extern.h haiku/trunk/headers/libs/udis86/libudis86/input.h haiku/trunk/headers/libs/udis86/libudis86/itab.h haiku/trunk/headers/libs/udis86/libudis86/syn.h haiku/trunk/headers/libs/udis86/libudis86/types.h haiku/trunk/headers/libs/udis86/udis86.h haiku/trunk/src/libs/udis86/ haiku/trunk/src/libs/udis86/decode.c haiku/trunk/src/libs/udis86/input.c haiku/trunk/src/libs/udis86/itab.c haiku/trunk/src/libs/udis86/syn-att.c haiku/trunk/src/libs/udis86/syn-intel.c haiku/trunk/src/libs/udis86/syn.c haiku/trunk/src/libs/udis86/udis86.c Removed: haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/ haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/udis86.h Modified: haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/Jamfile haiku/trunk/src/libs/Jamfile Log: Moved libudis86 to headers/libs/udis86 and src/libs/udis86. Copied: haiku/trunk/headers/libs/udis86/libudis86/decode.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/decode.h) Copied: haiku/trunk/headers/libs/udis86/libudis86/extern.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/extern.h) Copied: haiku/trunk/headers/libs/udis86/libudis86/input.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/input.h) Copied: haiku/trunk/headers/libs/udis86/libudis86/itab.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/itab.h) Copied: haiku/trunk/headers/libs/udis86/libudis86/syn.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/syn.h) Copied: haiku/trunk/headers/libs/udis86/libudis86/types.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/types.h) Copied: haiku/trunk/headers/libs/udis86/udis86.h (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/udis86.h) Modified: haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/Jamfile 2009-06-21 12:07:11 UTC (rev 31152) +++ haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/Jamfile 2009-06-21 12:58:16 UTC (rev 31153) @@ -1,7 +1,8 @@ SubDir HAIKU_TOP src add-ons kernel debugger disasm $(TARGET_ARCH) ; SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ; -SubDirHdrs [ FDirName $(SUBDIR) libudis86 ] ; +UseHeaders [ LibraryHeaders udis86 ] ; +UseHeaders [ LibraryHeaders [ FDirName udis86 libudis86 ] ] ; DEFINES += __UD_STANDALONE__ ; DEFINES += assert=disasm_arch_assert ; @@ -23,5 +24,4 @@ ; SEARCH on [ FGristFiles $(libUdis86Sources) ] - = [ FDirName $(SUBDIR) libudis86 ] ; - + = [ FDirName $(HAIKU_TOP) src libs udis86 ] ; Deleted: haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/udis86.h Modified: haiku/trunk/src/libs/Jamfile =================================================================== --- haiku/trunk/src/libs/Jamfile 2009-06-21 12:07:11 UTC (rev 31152) +++ haiku/trunk/src/libs/Jamfile 2009-06-21 12:58:16 UTC (rev 31153) @@ -21,5 +21,6 @@ SubInclude HAIKU_TOP src libs print ; SubInclude HAIKU_TOP src libs stdc++ ; SubInclude HAIKU_TOP src libs termcap ; +SubInclude HAIKU_TOP src libs udis86 ; SubInclude HAIKU_TOP src libs util ; SubInclude HAIKU_TOP src libs zlib ; Copied: haiku/trunk/src/libs/udis86/decode.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/decode.c) Copied: haiku/trunk/src/libs/udis86/input.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/input.c) Copied: haiku/trunk/src/libs/udis86/itab.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/itab.c) Copied: haiku/trunk/src/libs/udis86/syn-att.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/syn-att.c) Copied: haiku/trunk/src/libs/udis86/syn-intel.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/syn-intel.c) Copied: haiku/trunk/src/libs/udis86/syn.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/syn.c) Copied: haiku/trunk/src/libs/udis86/udis86.c (from rev 31084, haiku/trunk/src/add-ons/kernel/debugger/disasm/x86/libudis86/udis86.c) From bonefish at mail.berlios.de Sun Jun 21 15:00:12 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 21 Jun 2009 15:00:12 +0200 Subject: [Haiku-commits] r31154 - haiku/trunk/src/libs/udis86 Message-ID: <200906211300.n5LD0CBh011055@sheep.berlios.de> Author: bonefish Date: 2009-06-21 15:00:12 +0200 (Sun, 21 Jun 2009) New Revision: 31154 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31154&view=rev Added: haiku/trunk/src/libs/udis86/Jamfile Log: Missed the libudis86 jamfile. Added: haiku/trunk/src/libs/udis86/Jamfile =================================================================== --- haiku/trunk/src/libs/udis86/Jamfile 2009-06-21 12:58:16 UTC (rev 31153) +++ haiku/trunk/src/libs/udis86/Jamfile 2009-06-21 13:00:12 UTC (rev 31154) @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src libs udis86 ; + +DEFINES += __UD_STANDALONE__ ; + +UseHeaders [ LibraryHeaders udis86 ] ; +UseHeaders [ LibraryHeaders [ FDirName udis86 libudis86 ] ] ; + +StaticLibrary libudis86.a : + decode.c + input.c + itab.c + syn-att.c + syn.c + syn-intel.c + udis86.c +; From stippi at mail.berlios.de Sun Jun 21 15:01:42 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 21 Jun 2009 15:01:42 +0200 Subject: [Haiku-commits] r31155 - haiku/trunk/src/kits/interface Message-ID: <200906211301.n5LD1gnu011139@sheep.berlios.de> Author: stippi Date: 2009-06-21 15:01:40 +0200 (Sun, 21 Jun 2009) New Revision: 31155 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31155&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: Small style cleanup. Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2009-06-21 13:00:12 UTC (rev 31154) +++ haiku/trunk/src/kits/interface/Window.cpp 2009-06-21 13:01:40 UTC (rev 31155) @@ -1245,9 +1245,10 @@ = (ViewUpdateInfo*)infos.ItemAtFast(i); if (BView* view = _FindView(info->token)) view->_Draw(info->updateRect); - else + else { printf("_UPDATE_ - didn't find view by token: %ld\n", info->token); + } //drawTime += system_time() - drawStart; } // NOTE: The tokens are actually hirachically sorted, From bonefish at mail.berlios.de Sun Jun 21 15:03:08 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 21 Jun 2009 15:03:08 +0200 Subject: [Haiku-commits] r31156 - haiku/trunk/src/apps/debugger/gui/team_window Message-ID: <200906211303.n5LD383k011338@sheep.berlios.de> Author: bonefish Date: 2009-06-21 15:03:08 +0200 (Sun, 21 Jun 2009) New Revision: 31156 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31156&view=rev Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h Log: * Missing initialization of fStackTrace. * Removed unnecessary TableRowInvoked(). Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-21 13:01:40 UTC (rev 31155) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.cpp 2009-06-21 13:03:08 UTC (rev 31156) @@ -151,6 +151,7 @@ StackTraceView::StackTraceView(Listener* listener) : BGroupView(B_VERTICAL), + fStackTrace(NULL), fFramesTable(NULL), fFramesTableModel(NULL), fListener(listener) @@ -222,12 +223,6 @@ void -StackTraceView::TableRowInvoked(Table* table, int32 rowIndex) -{ -} - - -void StackTraceView::_Init() { fFramesTable = new Table("register list", 0, B_FANCY_BORDER); Modified: haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h 2009-06-21 13:01:40 UTC (rev 31155) +++ haiku/trunk/src/apps/debugger/gui/team_window/StackTraceView.h 2009-06-21 13:03:08 UTC (rev 31156) @@ -35,7 +35,6 @@ private: // TableListener virtual void TableSelectionChanged(Table* table); - virtual void TableRowInvoked(Table* table, int32 rowIndex); void _Init(); From stippi at mail.berlios.de Sun Jun 21 15:04:53 2009 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Sun, 21 Jun 2009 15:04:53 +0200 Subject: [Haiku-commits] r31157 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200906211304.n5LD4r7k011458@sheep.berlios.de> Author: stippi Date: 2009-06-21 15:04:51 +0200 (Sun, 21 Jun 2009) New Revision: 31157 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31157&view=rev Modified: haiku/trunk/headers/os/interface/TabView.h haiku/trunk/src/kits/interface/ControlLook.cpp haiku/trunk/src/kits/interface/TabView.cpp Log: * Update indentation style in TabView.h * Added _MinTabeSize() to BTabView. It makes sure that the BTabView displays at least two tabs. In the future it should also add the room to display some buttons for cycling the currently displayed tabs left/right if there is more than can fit. * In BTabView::Min/Max/PreferredSize(), use _MinTabSize() to compute the respective size. * Improve Tab rendering code so there are no ugly overlaps at the right edge if the tabs falls directly on the view edge. Modified: haiku/trunk/headers/os/interface/TabView.h =================================================================== --- haiku/trunk/headers/os/interface/TabView.h 2009-06-21 13:03:08 UTC (rev 31156) +++ haiku/trunk/headers/os/interface/TabView.h 2009-06-21 13:04:51 UTC (rev 31157) @@ -1,37 +1,11 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: TabView.h -// Author: Marc Flerackers (mflerackers at androme.be) -// Description: BTab creates individual "tabs" that can be assigned -// to specific views. -// BTabView provides the framework for containing and -// managing groups of BTab objects. -//------------------------------------------------------------------------------ - +/* + * Copyright 2001-2009, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ #ifndef _TAB_VIEW_H #define _TAB_VIEW_H -#include #include @@ -42,175 +16,177 @@ }; -// BTab class ------------------------------------------------------------------ class BTab : public BArchivable { - public: - BTab(BView * tabView = NULL); - virtual ~BTab(); + BTab(BView* tabView = NULL); + virtual ~BTab(); - BTab(BMessage *archive); -static BArchivable *Instantiate(BMessage *archive); + BTab(BMessage* archive); + static BArchivable* Instantiate(BMessage* archive); -virtual status_t Archive(BMessage *archive, bool deep = true) const; -virtual status_t Perform(uint32 d, void *arg); + virtual status_t Archive(BMessage* archive, + bool deep = true) const; + virtual status_t Perform(uint32 d, void* arg); - const char *Label() const; -virtual void SetLabel(const char *label); + const char* Label() const; + virtual void SetLabel(const char* label); - bool IsSelected() const; -virtual void Select(BView *owner); -virtual void Deselect(); + bool IsSelected() const; + virtual void Select(BView* owner); + virtual void Deselect(); -virtual void SetEnabled(bool enabled); - bool IsEnabled() const; + virtual void SetEnabled(bool enabled); + bool IsEnabled() const; - void MakeFocus(bool inFocus = true); - bool IsFocus() const; + void MakeFocus(bool inFocus = true); + bool IsFocus() const; - // sets/gets the view to be displayed for this tab -virtual void SetView(BView *view); - BView *View() const; + // sets/gets the view to be displayed for this tab + virtual void SetView(BView* view); + BView* View() const; -virtual void DrawFocusMark(BView *owner, BRect frame); -virtual void DrawLabel(BView *owner, BRect frame); -virtual void DrawTab(BView *owner, BRect frame, tab_position position, - bool full = true); + virtual void DrawFocusMark(BView* owner, BRect frame); + virtual void DrawLabel(BView* owner, BRect frame); + virtual void DrawTab(BView* owner, BRect frame, + tab_position position, bool full = true); private: -virtual void _ReservedTab1(); -virtual void _ReservedTab2(); -virtual void _ReservedTab3(); -virtual void _ReservedTab4(); -virtual void _ReservedTab5(); -virtual void _ReservedTab6(); -virtual void _ReservedTab7(); -virtual void _ReservedTab8(); -virtual void _ReservedTab9(); -virtual void _ReservedTab10(); -virtual void _ReservedTab11(); -virtual void _ReservedTab12(); + virtual void _ReservedTab1(); + virtual void _ReservedTab2(); + virtual void _ReservedTab3(); + virtual void _ReservedTab4(); + virtual void _ReservedTab5(); + virtual void _ReservedTab6(); + virtual void _ReservedTab7(); + virtual void _ReservedTab8(); + virtual void _ReservedTab9(); + virtual void _ReservedTab10(); + virtual void _ReservedTab11(); + virtual void _ReservedTab12(); - BTab &operator=(const BTab &); - - bool fEnabled; - bool fSelected; - bool fFocus; - BView *fView; - uint32 _reserved[12]; + BTab& operator=(const BTab&); + + bool fEnabled; + bool fSelected; + bool fFocus; + BView* fView; + + uint32 _reserved[12]; }; -//------------------------------------------------------------------------------ -// BTabView class -------------------------------------------------------------- -class BTabView : public BView -{ +class BTabView : public BView { public: - BTabView(const char *name, - button_width width = B_WIDTH_AS_USUAL, - uint32 flags = B_FULL_UPDATE_ON_RESIZE | - B_WILL_DRAW | B_NAVIGABLE_JUMP | - B_FRAME_EVENTS | B_NAVIGABLE); - BTabView(BRect frame, const char *name, - button_width width = B_WIDTH_AS_USUAL, - uint32 resizingMode = B_FOLLOW_ALL, - uint32 flags = B_FULL_UPDATE_ON_RESIZE | - B_WILL_DRAW | B_NAVIGABLE_JUMP | - B_FRAME_EVENTS | B_NAVIGABLE); - ~BTabView(); + BTabView(const char* name, + button_width width = B_WIDTH_AS_USUAL, + uint32 flags = B_FULL_UPDATE_ON_RESIZE | + B_WILL_DRAW | B_NAVIGABLE_JUMP | + B_FRAME_EVENTS | B_NAVIGABLE); + BTabView(BRect frame, const char* name, + button_width width = B_WIDTH_AS_USUAL, + uint32 resizingMode = B_FOLLOW_ALL, + uint32 flags = B_FULL_UPDATE_ON_RESIZE | + B_WILL_DRAW | B_NAVIGABLE_JUMP | + B_FRAME_EVENTS | B_NAVIGABLE); + virtual ~BTabView(); - BTabView(BMessage *archive); -static BArchivable *Instantiate(BMessage *archive); -virtual status_t Archive(BMessage*, bool deep=true) const; -virtual status_t Perform(perform_code d, void *arg); + BTabView(BMessage* archive); + static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* into, + bool deep = true) const; + virtual status_t Perform(perform_code d, void* arg); -virtual void WindowActivated(bool active); -virtual void AttachedToWindow(); -virtual void AllAttached(); -virtual void AllDetached(); -virtual void DetachedFromWindow(); + virtual void WindowActivated(bool active); + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void AllDetached(); + virtual void DetachedFromWindow(); -virtual void MessageReceived(BMessage *message); -virtual void FrameMoved(BPoint newLocation); -virtual void FrameResized(float width,float height); -virtual void KeyDown(const char *bytes, int32 numBytes); -virtual void MouseDown(BPoint point); -virtual void MouseUp(BPoint point); -virtual void MouseMoved(BPoint point, uint32 transit, - const BMessage *message); -virtual void Pulse(); + virtual void MessageReceived(BMessage* message); + virtual void FrameMoved(BPoint newLocation); + virtual void FrameResized(float width,float height); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MouseDown(BPoint point); + virtual void MouseUp(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, + const BMessage* dragMessage); + virtual void Pulse(); -virtual void Select(int32 tab); - int32 Selection() const; + virtual void Select(int32 tab); + int32 Selection() const; -virtual void MakeFocus(bool focused = true); -virtual void SetFocusTab(int32 tab, bool focused); - int32 FocusTab() const; + virtual void MakeFocus(bool focused = true); + virtual void SetFocusTab(int32 tab, bool focused); + int32 FocusTab() const; -virtual void Draw(BRect updateRect); -virtual BRect DrawTabs(); -virtual void DrawBox(BRect selTabRect); -virtual BRect TabFrame(int32 tab_index) const; + virtual void Draw(BRect updateRect); + virtual BRect DrawTabs(); + virtual void DrawBox(BRect selectedTabRect); + virtual BRect TabFrame(int32 index) const; -virtual void SetFlags(uint32 flags); -virtual void SetResizingMode(uint32 mode); + virtual void SetFlags(uint32 flags); + virtual void SetResizingMode(uint32 mode); -virtual void ResizeToPreferred(); -virtual void GetPreferredSize(float* _width, float* _height); + virtual void ResizeToPreferred(); + virtual void GetPreferredSize(float* _width, + float* _height); -virtual BSize MinSize(); -virtual BSize MaxSize(); -virtual BSize PreferredSize(); + virtual BSize MinSize(); + virtual BSize MaxSize(); + virtual BSize PreferredSize(); -virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, - BMessage *specifier, int32 what, const char *property); -virtual status_t GetSupportedSuites(BMessage *message); + virtual BHandler* ResolveSpecifier(BMessage* message, + int32 index, BMessage* specifier, + int32 what, const char* property); + virtual status_t GetSupportedSuites(BMessage* message); -virtual void AddTab(BView *target, BTab *tab = NULL); -virtual BTab *RemoveTab(int32 tabIndex); + virtual void AddTab(BView* target, BTab* tab = NULL); + virtual BTab* RemoveTab(int32 tabIndex); -virtual BTab *TabAt ( int32 tab_index ) const; + virtual BTab* TabAt(int32 index) const; -virtual void SetTabWidth(button_width width); - button_width TabWidth() const; - -virtual void SetTabHeight(float height); - float TabHeight() const; + virtual void SetTabWidth(button_width width); + button_width TabWidth() const; - BView *ContainerView() const; + virtual void SetTabHeight(float height); + float TabHeight() const; - int32 CountTabs() const; - BView *ViewForTab(int32 tabIndex) const; + BView* ContainerView() const; + int32 CountTabs() const; + BView* ViewForTab(int32 tabIndex) const; + private: - void _InitObject(bool layouted, button_width width); + void _InitObject(bool layouted, button_width width); + BSize _TabsMinSize() const; -virtual void _ReservedTabView1(); -virtual void _ReservedTabView2(); -virtual void _ReservedTabView3(); -virtual void _ReservedTabView4(); -virtual void _ReservedTabView5(); -virtual void _ReservedTabView6(); -virtual void _ReservedTabView7(); -virtual void _ReservedTabView8(); -virtual void _ReservedTabView9(); -virtual void _ReservedTabView10(); -virtual void _ReservedTabView11(); -virtual void _ReservedTabView12(); + virtual void _ReservedTabView1(); + virtual void _ReservedTabView2(); + virtual void _ReservedTabView3(); + virtual void _ReservedTabView4(); + virtual void _ReservedTabView5(); + virtual void _ReservedTabView6(); + virtual void _ReservedTabView7(); + virtual void _ReservedTabView8(); + virtual void _ReservedTabView9(); + virtual void _ReservedTabView10(); + virtual void _ReservedTabView11(); + virtual void _ReservedTabView12(); - BTabView(const BTabView &); - BTabView &operator=(const BTabView &); - - BList *fTabList; - BView *fContainerView; - button_width fTabWidthSetting; - float fTabWidth; - float fTabHeight; - int32 fSelection; - int32 fInitialSelection; - int32 fFocus; - float fTabOffset; - uint32 _reserved[11]; + BTabView(const BTabView&); + BTabView& operator=(const BTabView&); + + BList* fTabList; + BView* fContainerView; + button_width fTabWidthSetting; + float fTabWidth; + float fTabHeight; + int32 fSelection; + int32 fInitialSelection; + int32 fFocus; + float fTabOffset; + + uint32 _reserved[11]; }; #endif // _TAB_VIEW_H Modified: haiku/trunk/src/kits/interface/ControlLook.cpp =================================================================== --- haiku/trunk/src/kits/interface/ControlLook.cpp 2009-06-21 13:03:08 UTC (rev 31156) +++ haiku/trunk/src/kits/interface/ControlLook.cpp 2009-06-21 13:04:51 UTC (rev 31157) @@ -1433,8 +1433,13 @@ frameShadowColor, borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER)); - _DrawFrame(view, rect, bevelShadowColor, bevelShadowColor, bevelLightColor, - bevelLightColor, B_LEFT_BORDER & ~borders); + if (rect.IsValid()) { + _DrawFrame(view, rect, bevelShadowColor, bevelShadowColor, + bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders); + } else { + if ((B_LEFT_BORDER & ~borders) != 0) + rect.left++; + } view->FillRect(rect, fillGradient); } Modified: haiku/trunk/src/kits/interface/TabView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TabView.cpp 2009-06-21 13:03:08 UTC (rev 31156) +++ haiku/trunk/src/kits/interface/TabView.cpp 2009-06-21 13:04:51 UTC (rev 31157) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2008, Haiku, Inc. + * Copyright 2001-2009, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: @@ -851,14 +851,17 @@ if (be_control_look != NULL) { BRect frame(Bounds()); - frame.left = left; - frame.bottom = fTabHeight; - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); - uint32 borders = BControlLook::B_TOP_BORDER - | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; - if (left == 0) - borders |= BControlLook::B_LEFT_BORDER; - be_control_look->DrawInactiveTab(this, frame, frame, base, 0, borders); + if (left < frame.right) { + frame.left = left; + frame.bottom = fTabHeight; + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + uint32 borders = BControlLook::B_TOP_BORDER + | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; + if (left == 0) + borders |= BControlLook::B_LEFT_BORDER; + be_control_look->DrawInactiveTab(this, frame, frame, base, 0, + borders); + } } if (fSelection < CountTabs()) @@ -1061,9 +1064,11 @@ BSize BTabView::MinSize() { - BSize size = fContainerView->MinSize(); - size.height += TabHeight() + 6.0f; - size.width += 6.0f; + BSize size(_TabsMinSize()); + BSize containerSize = fContainerView->MinSize(); + if (containerSize.width > size.width) + size.width = containerSize.width; + size.height += containerSize.height; return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); } @@ -1071,9 +1076,11 @@ BSize BTabView::MaxSize() { - BSize size = fContainerView->MaxSize(); - size.height += TabHeight() + 6.0f; - size.width += 6.0f; + BSize size(_TabsMinSize()); + BSize containerSize = fContainerView->MaxSize(); + if (containerSize.width > size.width) + size.width = containerSize.width; + size.height += containerSize.height; return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size); } @@ -1081,9 +1088,11 @@ BSize BTabView::PreferredSize() { - BSize size = fContainerView->PreferredSize(); - size.height += TabHeight() + 6.0f; - size.width += 6.0f; + BSize size(_TabsMinSize()); + BSize containerSize = fContainerView->PreferredSize(); + if (containerSize.width > size.width) + size.width = containerSize.width; + size.height += containerSize.height; return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size); } @@ -1291,6 +1300,28 @@ } +BSize +BTabView::_TabsMinSize() const +{ + BSize size(0.0f, TabHeight() + 6.0f); + int32 count = min_c(2, CountTabs()); + for (int32 i = 0; i < count; i++) { + BRect frame = TabFrame(i); + size.width += frame.Width(); + } + + if (count < CountTabs()) { + // TODO: Add size for yet to be implemented buttons that allow + // "scrolling" the displayed tabs left/right. + } + + return size; +} + + +// #pragma mark - FBC and forbidden + + void BTabView::_ReservedTabView1() {} void BTabView::_ReservedTabView2() {} void BTabView::_ReservedTabView3() {} @@ -1305,14 +1336,15 @@ void BTabView::_ReservedTabView12() {} -BTabView::BTabView(const BTabView &tabView) +BTabView::BTabView(const BTabView& tabView) : BView(tabView) { // this is private and not functional, but exported } -BTabView &BTabView::operator=(const BTabView &) +BTabView& +BTabView::operator=(const BTabView&) { // this is private and not functional, but exported return *this; From bonefish at mail.berlios.de Sun Jun 21 15:17:22 2009 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 21 Jun 2009 15:17:22 +0200 Subject: [Haiku-commits] r31158 - in haiku/trunk/src/apps/debugger: . arch arch/x86 arch/x86/disasm debug_info gui/team_window model Message-ID: <200906211317.n5LDHMwk014001@sheep.berlios.de> Author: bonefish Date: 2009-06-21 15:17:21 +0200 (Sun, 21 Jun 2009) New Revision: 31158 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31158&view=rev Added: haiku/trunk/src/apps/debugger/arch/TargetAddressRange.h haiku/trunk/src/apps/debugger/arch/x86/disasm/ haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.cpp haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile haiku/trunk/src/apps/debugger/gui/team_window/SourceView.cpp haiku/trunk/src/apps/debugger/gui/team_window/SourceView.h haiku/trunk/src/apps/debugger/model/SourceCode.cpp haiku/trunk/src/apps/debugger/model/SourceCode.h haiku/trunk/src/apps/debugger/model/SourceLocation.h haiku/trunk/src/apps/debugger/model/Statement.cpp haiku/trunk/src/apps/debugger/model/Statement.h Modified: haiku/trunk/src/apps/debugger/Jamfile haiku/trunk/src/apps/debugger/Jobs.cpp haiku/trunk/src/apps/debugger/Jobs.h haiku/trunk/src/apps/debugger/MessageCodes.h haiku/trunk/src/apps/debugger/TeamDebugger.cpp haiku/trunk/src/apps/debugger/TeamDebugger.h haiku/trunk/src/apps/debugger/arch/Architecture.h haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h haiku/trunk/src/apps/debugger/model/StackFrame.cpp haiku/trunk/src/apps/debugger/model/StackFrame.h Log: * Added classes to represent source code (SourceCode, Statement). * Added x86 disassembler (via libudis86). * Added Architecture::DisassembleCode() to disassemble a function to SourceCode. * Added virtual DebugInfo::LoadSourceCode() to retrieve the source code for a given function. The implementation in DebuggerDebugInfo disassembles the function. * Added source code info to StackFrame. Also added a listener mechanism to get notified on source code changes. * Added job to load the source code for a stack frame. * Added (very basic) source code view and wired everything so that when a stack frame is selected the source code (respectively disassembly) for the underlying function is retrieved and shown. Modified: haiku/trunk/src/apps/debugger/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/Jamfile 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-21 13:17:21 UTC (rev 31158) @@ -51,6 +51,7 @@ # gui/team_window ImageListView.cpp RegisterView.cpp + SourceView.cpp StackTraceView.cpp TeamWindow.cpp ThreadListView.cpp @@ -58,8 +59,10 @@ # model Image.cpp ImageInfo.cpp + SourceCode.cpp StackFrame.cpp StackTrace.cpp + Statement.cpp SymbolInfo.cpp Team.cpp TeamDebugModel.cpp @@ -77,8 +80,10 @@ : Debugger_demangler.o + Debugger_disasm_x86.o DebugAnalyzer_gui_table.o + libudis86.a debug_utils.a libcolumnlistview.a libshared.a @@ -89,5 +94,6 @@ : Debugger.rdef ; +HaikuSubInclude arch x86 disasm ; HaikuSubInclude demangler ; HaikuSubInclude gui running_teams_window ; Modified: haiku/trunk/src/apps/debugger/Jobs.cpp =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-21 13:17:21 UTC (rev 31158) @@ -12,8 +12,11 @@ #include "Architecture.h" #include "CpuState.h" #include "DebuggerInterface.h" +#include "DebugInfo.h" +#include "FunctionDebugInfo.h" #include "Image.h" #include "ImageDebugInfo.h" +#include "SourceCode.h" #include "StackTrace.h" #include "Team.h" #include "Thread.h" @@ -170,7 +173,7 @@ } -// #pragma mark - GetStackTraceJob +// #pragma mark - LoadImageDebugInfoJob LoadImageDebugInfoJob::LoadImageDebugInfoJob( @@ -224,3 +227,54 @@ return B_OK; } + + +// #pragma mark - LoadSourceCodeJob + + +LoadSourceCodeJob::LoadSourceCodeJob( + DebuggerInterface* debuggerInterface, Architecture* architecture, + Team* team, StackFrame* stackFrame) + : + fDebuggerInterface(debuggerInterface), + fArchitecture(architecture), + fTeam(team), + fStackFrame(stackFrame) +{ + fStackFrame->AddReference(); +} + + +LoadSourceCodeJob::~LoadSourceCodeJob() +{ + fStackFrame->RemoveReference(); +} + + +JobKey +LoadSourceCodeJob::Key() const +{ + return JobKey(fStackFrame, JOB_TYPE_LOAD_SOURCE_CODE); +} + + +status_t +LoadSourceCodeJob::Do() +{ + // load the source code, if we can + SourceCode* sourceCode = NULL; + status_t error = B_BAD_VALUE; + FunctionDebugInfo* function = fStackFrame->Function(); + if (function != NULL) + error = function->GetDebugInfo()->LoadSourceCode(function, sourceCode); + + // set the result + AutoLocker locker(fTeam); + if (error == B_OK) { + fStackFrame->SetSourceCode(sourceCode, STACK_SOURCE_LOADED); + sourceCode->RemoveReference(); + } else + fStackFrame->SetSourceCode(NULL, STACK_SOURCE_UNAVAILABLE); + + return error; +} Modified: haiku/trunk/src/apps/debugger/Jobs.h =================================================================== --- haiku/trunk/src/apps/debugger/Jobs.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/Jobs.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -13,6 +13,8 @@ class CpuState; class DebuggerInterface; class Image; +class StackFrame; +class Team; class Thread; @@ -20,7 +22,8 @@ enum { JOB_TYPE_GET_CPU_STATE, JOB_TYPE_GET_STACK_TRACE, - JOB_TYPE_LOAD_IMAGE_DEBUG_INFO + JOB_TYPE_LOAD_IMAGE_DEBUG_INFO, + JOB_TYPE_LOAD_SOURCE_CODE }; @@ -81,4 +84,23 @@ }; +class LoadSourceCodeJob : public Job { +public: + LoadSourceCodeJob( + DebuggerInterface* debuggerInterface, + Architecture* architecture, + Team* team, StackFrame* stackFrame); + virtual ~LoadSourceCodeJob(); + + virtual JobKey Key() const; + virtual status_t Do(); + +private: + DebuggerInterface* fDebuggerInterface; + Architecture* fArchitecture; + Team* fTeam; + StackFrame* fStackFrame; +}; + + #endif // JOBS_H Modified: haiku/trunk/src/apps/debugger/MessageCodes.h =================================================================== --- haiku/trunk/src/apps/debugger/MessageCodes.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/MessageCodes.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -7,15 +7,16 @@ enum { - MSG_THREAD_RUN = 'run_', - MSG_THREAD_STOP = 'stop', - MSG_THREAD_STEP_OVER = 'stov', - MSG_THREAD_STEP_INTO = 'stin', - MSG_THREAD_STEP_OUT = 'stou', + MSG_THREAD_RUN = 'run_', + MSG_THREAD_STOP = 'stop', + MSG_THREAD_STEP_OVER = 'stov', + MSG_THREAD_STEP_INTO = 'stin', + MSG_THREAD_STEP_OUT = 'stou', - MSG_THREAD_STATE_CHANGED = 'tsch', - MSG_THREAD_CPU_STATE_CHANGED = 'tcsc', - MSG_THREAD_STACK_TRACE_CHANGED = 'tstc' + MSG_THREAD_STATE_CHANGED = 'tsch', + MSG_THREAD_CPU_STATE_CHANGED = 'tcsc', + MSG_THREAD_STACK_TRACE_CHANGED = 'tstc', + MSG_STACK_FRAME_SOURCE_CODE_CHANGED = 'sfsc' }; Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-21 13:17:21 UTC (rev 31158) @@ -234,6 +234,30 @@ void +TeamDebugger::StackFrameSourceCodeRequested(TeamWindow* window, + StackFrame* frame) +{ + // mark loading + AutoLocker< ::Team> locker(fTeam); + if (frame->SourceCodeState() != STACK_SOURCE_NOT_LOADED) + return; + frame->SetSourceCode(NULL, STACK_SOURCE_LOADING); + locker.Unlock(); + + // schedule the job + if (fWorker->ScheduleJob( + new(std::nothrow) LoadSourceCodeJob(fDebuggerInterface, + fDebuggerInterface->GetArchitecture(), fTeam, frame), + this) != B_OK) { + // scheduling failed -- mark unavailable + locker.Lock(); + frame->SetSourceCode(NULL, STACK_SOURCE_UNAVAILABLE); + locker.Unlock(); + } +} + + +void TeamDebugger::ThreadActionRequested(TeamWindow* window, thread_id threadID, uint32 action) { @@ -269,6 +293,8 @@ TeamDebugger::JobAborted(Job* job) { printf("TeamDebugger::JobAborted(%p)\n", job); + // TODO: For a stack frame source loader thread we should reset the + // loading state! Asynchronously due to locking order. } Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h =================================================================== --- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -35,6 +35,8 @@ virtual void MessageReceived(BMessage* message); // TeamWindow::Listener + virtual void StackFrameSourceCodeRequested( + TeamWindow* window, StackFrame* frame); virtual void ThreadActionRequested(TeamWindow* window, thread_id threadID, uint32 action); virtual bool TeamWindowQuitRequested(TeamWindow* window); Modified: haiku/trunk/src/apps/debugger/arch/Architecture.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -16,6 +16,7 @@ class Image; class ImageDebugInfoProvider; class Register; +class SourceCode; class StackFrame; class StackTrace; class Team; @@ -42,6 +43,9 @@ // returns reference to previous frame // and CPU state; returned CPU state // can be NULL + virtual status_t DisassembleCode(FunctionDebugInfo* function, + const void* buffer, size_t bufferSize, + SourceCode*& _sourceCode) = 0; status_t CreateStackTrace(Team* team, ImageDebugInfoProvider* imageInfoProvider, Added: haiku/trunk/src/apps/debugger/arch/TargetAddressRange.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/TargetAddressRange.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/TargetAddressRange.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -0,0 +1,87 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef TARGET_ADDRESS_RANGE_H +#define TARGET_ADDRESS_RANGE_H + +#include "ArchitectureTypes.h" + + +class TargetAddressRange { +public: + TargetAddressRange() + : + fStart(0), + fSize(0) + { + } + + TargetAddressRange(target_addr_t start, target_size_t size) + : + fStart(start), + fSize(size) + { + } + + TargetAddressRange(const TargetAddressRange& other) + : + fStart(other.fStart), + fSize(other.fSize) + { + } + + TargetAddressRange& operator=(const TargetAddressRange& other) + { + fStart = other.fStart; + fSize = other.fSize; + return *this; + } + + bool operator==(const TargetAddressRange& other) const + { + return fStart == other.fStart && fSize == other.fSize; + } + + bool operator!=(const TargetAddressRange& other) const + { + return !(*this == other); + } + + target_addr_t Start() const + { + return fStart; + } + + target_size_t Size() const + { + return fSize; + } + + target_addr_t End() const + { + return fStart + fSize; + } + + bool Contains(target_addr_t address) const + { + return address >= Start() && address < End(); + } + + bool Contains(const TargetAddressRange& other) const + { + return Start() <= other.Start() && End() >= other.End(); + } + + bool IntersectsWith(const TargetAddressRange& other) const + { + return Contains(other.Start()) || other.Contains(Start()); + } + +private: + target_addr_t fStart; + target_size_t fSize; +}; + + +#endif // TARGET_ADDRESS_RANGE_H Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.cpp 2009-06-21 13:17:21 UTC (rev 31158) @@ -7,13 +7,20 @@ #include +#include + #include #include "CpuStateX86.h" #include "DebuggerInterface.h" +#include "FunctionDebugInfo.h" +#include "SourceCode.h" #include "StackFrame.h" +#include "Statement.h" +#include "disasm/DisassemblerX86.h" + ArchitectureX86::ArchitectureX86(DebuggerInterface* debuggerInterface) : Architecture(debuggerInterface) @@ -139,6 +146,51 @@ } +status_t +ArchitectureX86::DisassembleCode(FunctionDebugInfo* function, + const void* buffer, size_t bufferSize, SourceCode*& _sourceCode) +{ + SourceCode* source = new(std::nothrow) SourceCode; + if (source == NULL) + return B_NO_MEMORY; + Reference sourceReference(source, true); + + // init disassembler + DisassemblerX86 disassembler; + status_t error = disassembler.Init(function->Address(), buffer, bufferSize); + if (error != B_OK) + return error; + + // add a function name line + BString functionName(function->PrettyName()); + if (!source->AddLine((functionName << ':').String())) + return B_NO_MEMORY; + uint32 lineIndex = 1; + + // disassemble the instructions + BString line; + target_addr_t instructionAddress; + target_size_t instructionSize; + bool breakpointAllowed; + while (disassembler.GetNextInstruction(line, instructionAddress, + instructionSize, breakpointAllowed) == B_OK) { + Statement* statement = new(std::nothrow) ContiguousStatement( + SourceLocation(lineIndex), SourceLocation(lineIndex + 1), + TargetAddressRange(instructionAddress, instructionAddress)); + if (statement == NULL) + return B_NO_MEMORY; + + if (!source->AddStatement(statement) || !source->AddLine(line.String())) + return B_NO_MEMORY; + + lineIndex++; + } + + _sourceCode = sourceReference.Detach(); + return B_OK; +} + + void ArchitectureX86::_AddRegister(int32 index, const char* name, register_format format, uint32 bitSize, register_type type) Modified: haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/x86/ArchitectureX86.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -28,6 +28,9 @@ CpuState* cpuState, StackFrame*& _previousFrame, CpuState*& _previousCpuState); + virtual status_t DisassembleCode(FunctionDebugInfo* function, + const void* buffer, size_t bufferSize, + SourceCode*& _sourceCode); private: void _AddRegister(int32 index, const char* name, Added: haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.cpp =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.cpp 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.cpp 2009-06-21 13:17:21 UTC (rev 31158) @@ -0,0 +1,88 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Copyright 2008, Fran?ois Revol, revol at free.fr + * Distributed under the terms of the MIT License. + */ + +#include "DisassemblerX86.h" + +#include + +#include "udis86.h" + +#include + + +struct DisassemblerX86::UdisData : ud_t { +}; + + +DisassemblerX86::DisassemblerX86() + : + fAddress(0), + fCode(NULL), + fCodeSize(0), + fUdisData(NULL) +{ +} + + +DisassemblerX86::~DisassemblerX86() +{ + delete fUdisData; +} + + +status_t +DisassemblerX86::Init(target_addr_t address, const void* code, size_t codeSize) +{ + // unset old data + delete fUdisData; + fUdisData = NULL; + + // set new data + fUdisData = new(std::nothrow) UdisData; + if (fUdisData == NULL) + return B_NO_MEMORY; + + fAddress = address; + fCode = (const uint8*)code; + fCodeSize = codeSize; + + // init udis + ud_init(fUdisData); + ud_set_input_buffer(fUdisData, (unsigned char*)fCode, fCodeSize); + ud_set_mode(fUdisData, 32); + ud_set_pc(fUdisData, (uint64_t)fAddress); + ud_set_syntax(fUdisData, UD_SYN_ATT); + ud_set_vendor(fUdisData, UD_VENDOR_INTEL); + // TODO: Set the correct vendor! + + return B_OK; +} + + +status_t +DisassemblerX86::GetNextInstruction(BString& line, target_addr_t& _address, + target_size_t& _size, bool& _breakpointAllowed) +{ + unsigned int size = ud_disassemble(fUdisData); + if (size < 1) + return B_ENTRY_NOT_FOUND; + + uint32 address = (uint32)ud_insn_off(fUdisData); + + char buffer[256]; + snprintf(buffer, sizeof(buffer), "0x%08lx: %16.16s %s", address, + ud_insn_hex(fUdisData), ud_insn_asm(fUdisData)); + // TODO: Resolve symbols! + + line = buffer; + _address = address; + _size = size; + _breakpointAllowed = true; + // TODO: Implement (rep!)! + + return B_OK; +} + Added: haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -0,0 +1,37 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef DISASSEMBLER_X86_H +#define DISASSEMBLER_X86_H + +#include + +#include "ArchitectureTypes.h" + + +class DisassemblerX86 { +public: + DisassemblerX86(); + virtual ~DisassemblerX86(); + + virtual status_t Init(target_addr_t address, const void* code, + size_t codeSize); + + virtual status_t GetNextInstruction(BString& line, + target_addr_t& _address, + target_size_t& _size, + bool& _breakpointAllowed); + +private: + struct UdisData; + +private: + target_addr_t fAddress; + const uint8* fCode; + size_t fCodeSize; + UdisData* fUdisData; +}; + + +#endif // DISASSEMBLER_X86_H Added: haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile =================================================================== --- haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile 2009-06-21 13:17:21 UTC (rev 31158) @@ -0,0 +1,15 @@ +SubDir HAIKU_TOP src apps debugger arch x86 disasm ; + +CCFLAGS += -Werror ; +C++FLAGS += -Werror ; + +UseHeaders [ LibraryHeaders udis86 ] ; +UseHeaders [ LibraryHeaders [ FDirName udis86 libudis86 ] ] ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; + + +MergeObject Debugger_disasm_x86.o + : + DisassemblerX86.cpp +; Modified: haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -15,6 +15,7 @@ class DebuggerInterface; class FunctionDebugInfo; class Image; +class SourceCode; class StackFrame; @@ -33,6 +34,9 @@ // returns reference to previous frame // and CPU state; returned CPU state // can be NULL; can return B_UNSUPPORTED + virtual status_t LoadSourceCode(FunctionDebugInfo* function, + SourceCode*& _sourceCode) = 0; + // returns reference }; Modified: haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp 2009-06-21 13:17:21 UTC (rev 31158) @@ -5,8 +5,12 @@ #include "DebuggerDebugInfo.h" +#include #include +#include + +#include "Architecture.h" #include "BasicFunctionDebugInfo.h" #include "DebuggerInterface.h" #include "Demangler.h" @@ -87,6 +91,29 @@ } +status_t +DebuggerDebugInfo::LoadSourceCode(FunctionDebugInfo* function, + SourceCode*& _sourceCode) +{ + // allocate a buffer for the function code + static const target_size_t kMaxBufferSize = 64 * 1024; + target_size_t bufferSize = std::min(function->Size(), kMaxBufferSize); + void* buffer = malloc(bufferSize); + if (buffer == NULL) + return B_NO_MEMORY; + MemoryDeleter bufferDeleter(buffer); + + // read the function code + ssize_t bytesRead = fDebuggerInterface->ReadMemory(function->Address(), + buffer, bufferSize); + if (bytesRead < 0) + return bytesRead; + + return fArchitecture->DisassembleCode(function, buffer, bytesRead, + _sourceCode); +} + + SymbolInfo* DebuggerDebugInfo::_FindSymbol(target_addr_t address) { Modified: haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h =================================================================== --- haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h 2009-06-21 13:17:21 UTC (rev 31158) @@ -34,6 +34,8 @@ CpuState* cpuState, StackFrame*& _previousFrame, CpuState*& _previousCpuState); + virtual status_t LoadSourceCode(FunctionDebugInfo* function, + SourceCode*& _sourceCode); private: typedef BObjectList SymbolList; Added: haiku/trunk/src/apps/debugger/gui/team_window/SourceView.cpp =================================================================== --- haiku/trunk/src/apps/debugger/gui/team_window/SourceView.cpp 2009-06-21 13:04:51 UTC (rev 31157) +++ haiku/trunk/src/apps/debugger/gui/team_window/SourceView.cpp 2009-06-21 13:17:21 UTC (rev 31158) @@ -0,0 +1,368 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "SourceView.h" + +#include +#include + +#include + +#include +#include + +#include + +#include "SourceCode.h" +#include "StackFrame.h" +#include "TeamDebugModel.h" + + +static const int32 kLeftTextMargin = 3; + + +class SourceView::MarkerView : public BView { +public: + MarkerView(SourceView* sourceView, FontInfo* fontInfo) + : + BView("source marker view", B_WILL_DRAW), + fSourceView(sourceView), + fFontInfo(fontInfo) + { + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + } + + virtual BSize MinSize() + { + return BSize(40, 10); + } + + virtual BSize MaxSize() + { + return BSize(MinSize().width, B_SIZE_UNLIMITED); + } + + virtual BSize PreferredSize() + { + return MinSize(); + } + + virtual void Draw(BRect updateRect) + { + } + +private: + SourceView* fSourceView; + FontInfo* fFontInfo; +}; + + +class SourceView::TextView : public BView { +public: + TextView(SourceView* sourceView, FontInfo* fontInfo) + : + BView("source text view", B_WILL_DRAW), + fSourceView(sourceView), + fFontInfo(fontInfo), + fSourceCode(NULL), + fMaxLineWidth(-1) + { + SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR)); + fTextColor = ui_color(B_DOCUMENT_TEXT_COLOR); + } + + void SetSourceCode(SourceCode* sourceCode) + { + fSourceCode = sourceCode; + fMaxLineWidth = -1; + + InvalidateLayout(); + Invalidate(); + } + + virtual BSize MinSize() + { + float height = _LineCount() * fFontInfo->lineHeight; + return BSize(kLeftTextMargin + _MaxLineWidth() - 1, + std::max(height - 1, 100.0f)); + } + + virtual BSize MaxSize() + { + return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); + } + + virtual BSize PreferredSize() + { + return MinSize(); + } + + virtual void Draw(BRect updateRect) + { + if (fSourceCode == NULL) + return; + + // get the lines intersecting with the update rect + int32 lineHeight = (int32)fFontInfo->lineHeight; + int32 minLine = (int32)updateRect.top / lineHeight; + int32 maxLine = ((int32)ceilf(updateRect.bottom) + lineHeight - 1) + / lineHeight; + minLine = std::max(minLine, 0L); + maxLine = std::min(maxLine, fSourceCode->CountLines() - 1); + + // draw the affected lines + SetHighColor(fTextColor); + SetFont(&fFontInfo->font); + for (int32 i = minLine; i <= maxLine; i++) { + float y = (float)(i + 1) * fFontInfo->lineHeight + - fFontInfo->fontHeight.descent; + DrawString(fSourceCode->LineAt(i), BPoint(kLeftTextMargin, y)); + } + } + +private: + int32 _LineCount() const + { + return fSourceCode != NULL ? fSourceCode->CountLines() : 0; + } + + float _MaxLineWidth() + { + if (fMaxLineWidth >= 0) + return fMaxLineWidth; + + fMaxLineWidth = 0; + if (fSourceCode != NULL) { + for (int32 i = 0; const char* line = fSourceCode->LineAt(i); i++) { + fMaxLineWidth = std::max(fMaxLineWidth, + fFontInfo->font.StringWidth(line)); + } + } + + return fMaxLineWidth; + } + +private: + SourceView* fSourceView; + FontInfo* fFontInfo; + SourceCode* fSourceCode; + float fMaxLineWidth; + rgb_color fTextColor; +}; + + +// #pragma mark - SourceView + + +SourceView::SourceView(TeamDebugModel* debugModel, Listener* listener) + : + BView("source view", 0), + fDebugModel(debugModel), + fStackFrame(NULL), + fSourceCode(NULL), + fMarkerView(NULL), + fTextView(NULL), + fListener(listener) +{ + // init font info + fFontInfo.font = *be_fixed_font; + fFontInfo.font.GetHeight(&fFontInfo.fontHeight); + fFontInfo.lineHeight = ceilf(fFontInfo.fontHeight.ascent) + + ceilf(fFontInfo.fontHeight.descent); +} + + +SourceView::~SourceView() +{ + SetStackFrame(NULL); +} + + +/*static*/ SourceView* +SourceView::Create(TeamDebugModel* debugModel, Listener* listener) +{ + SourceView* self = new SourceView(debugModel, listener); + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; +} + + +void +SourceView::UnsetListener() +{ + fListener = NULL; +} + + +void +SourceView::SetStackFrame(StackFrame* frame) +{ +printf("SourceView::SetStackFrame(%p)\n", frame); + if (frame == fStackFrame) + return; + + if (fStackFrame != NULL) + fStackFrame->RemoveReference(); + + fStackFrame = frame; + + if (fStackFrame != NULL) + fStackFrame->AddReference(); + + UpdateSourceCode(); +} + + +void +SourceView::UpdateSourceCode() +{ + // get a reference to the source code + AutoLocker locker(fDebugModel); + + SourceCode* sourceCode = fStackFrame != NULL + ? fStackFrame->GetSourceCode() : NULL; + Reference sourceCodeReference(sourceCode); + + locker.Unlock(); + + // set the source code, if it changed + if (sourceCode == fSourceCode) + return; + + if (fSourceCode != NULL) { + fTextView->SetSourceCode(NULL); + fSourceCode->RemoveReference(); + } + + fSourceCode = sourceCodeReference.Detach(); + + fTextView->SetSourceCode(fSourceCode); + _UpdateScrollBars(); +} + + +void +SourceView::TargetedByScrollView(BScrollView* scrollView) +{ + _UpdateScrollBars(); +} + + +BSize +SourceView::MinSize() +{ +// BSize markerSize(fMarkerView->MinSize()); +// BSize textSize(fTextView->MinSize()); +// return BSize(BLayoutUtils::AddDistances(markerSize.width, textSize.width), +// std::max(markerSize.height, textSize.height)); + return BSize(10, 10); +} + + +BSize +SourceView::MaxSize() +{ +// BSize markerSize(fMarkerView->MaxSize()); +// BSize textSize(fTextView->MaxSize()); +// return BSize(BLayoutUtils::AddDistances(markerSize.width, textSize.width), +// std::min(markerSize.height, textSize.height)); + return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); +} + + +BSize +SourceView::PreferredSize() [... truncated: 882 lines follow ...] From axeld at mail.berlios.de Sun Jun 21 19:04:33 2009 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 21 Jun 2009 19:04:33 +0200 Subject: [Haiku-commits] r31159 - haiku/trunk/build/jam Message-ID: <200906211704.n5LH4XFI026838@sheep.berlios.de> Author: axeld Date: 2009-06-21 19:04:32 +0200 (Sun, 21 Jun 2009) New Revision: 31159 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31159&view=rev Modified: haiku/trunk/build/jam/BuildSetup Log: * Quick fix for the broken GCC2 build. The guilty one might want to have another look at this. Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2009-06-21 13:17:21 UTC (rev 31158) +++ haiku/trunk/build/jam/BuildSetup 2009-06-21 17:04:32 UTC (rev 31159) @@ -365,6 +365,7 @@ HAIKU_LIBSTDC++ = $(HAIKU_STATIC_LIBSTDC++) ; } else { HAIKU_LIBSTDC++ = libstdc++.r4.so ; + HAIKU_SHARED_LIBSTDC++ = $(HAIKU_LIBSTDC++) ; } # the C++ support library From anevilyak at mail.berlios.de Sun Jun 21 21:33:08 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 21 Jun 2009 21:33:08 +0200 Subject: [Haiku-commits] r31160 - haiku/trunk/src/servers/app Message-ID: <200906211933.n5LJX7VJ021133@sheep.berlios.de> Author: anevilyak Date: 2009-06-21 21:33:07 +0200 (Sun, 21 Jun 2009) New Revision: 31160 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31160&view=rev Modified: haiku/trunk/src/servers/app/Desktop.cpp Log: Fix broken check for ctrl+cmd+esc that would result in any of ctrl+esc, cmd+esc or ctrl+cmd+esc triggering safe video mode, and as a side effect, prevent menus from being opened via keyboard. Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2009-06-21 17:04:32 UTC (rev 31159) +++ haiku/trunk/src/servers/app/Desktop.cpp 2009-06-21 19:33:07 UTC (rev 31160) @@ -147,7 +147,8 @@ && message->FindInt32("key", &key) == B_OK && message->FindInt32("modifiers", &modifiers) == B_OK) { // Check for safe video mode (cmd + ctrl + escape) - if (key == 0x01 && (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY)) != 0) { + if (key == 0x01 && (modifiers & B_COMMAND_KEY) != 0 && + (modifiers & B_CONTROL_KEY) != 0) { system("screenmode --fall-back &"); return B_SKIP_MESSAGE; } From anevilyak at mail.berlios.de Sun Jun 21 21:34:16 2009 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 21 Jun 2009 21:34:16 +0200 Subject: [Haiku-commits] r31161 - haiku/trunk/src/servers/app Message-ID: <200906211934.n5LJYGfF021220@sheep.berlios.de> Author: anevilyak Date: 2009-06-21 21:34:15 +0200 (Sun, 21 Jun 2009) New Revision: 31161 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31161&view=rev Modified: haiku/trunk/src/servers/app/Desktop.cpp Log: Fix style violation. Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2009-06-21 19:33:07 UTC (rev 31160) +++ haiku/trunk/src/servers/app/Desktop.cpp 2009-06-21 19:34:15 UTC (rev 31161) @@ -147,8 +147,8 @@ && message->FindInt32("key", &key) == B_OK && message->FindInt32("modifiers", &modifiers) == B_OK) { // Check for safe video mode (cmd + ctrl + escape) - if (key == 0x01 && (modifiers & B_COMMAND_KEY) != 0 && - (modifiers & B_CONTROL_KEY) != 0) { + if (key == 0x01 && (modifiers & B_COMMAND_KEY) != 0 + && (modifiers & B_CONTROL_KEY) != 0) { system("screenmode --fall-back &"); return B_SKIP_MESSAGE; } From aljen at mail.berlios.de Sun Jun 21 22:16:47 2009 From: aljen at mail.berlios.de (aljen at mail.berlios.de) Date: Sun, 21 Jun 2009 22:16:47 +0200 Subject: [Haiku-commits] r31162 - haiku/branches/components Message-ID: <200906212016.n5LKGl3g025156@sheep.berlios.de> Author: aljen Date: 2009-06-21 22:16:33 +0200 (Sun, 21 Jun 2009) New Revision: 31162 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31162&view=rev Added: haiku/branches/components/gallium3d/ Log: Creating a Gallium3D branch Copied: haiku/branches/components/gallium3d (from rev 31161, haiku/trunk) From axeld at pinc-software.de Sun Jun 21 22:49:02 2009 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 21 Jun 2009 22:49:02 +0200 CEST Subject: [Haiku-commits] r31160 - haiku/trunk/src/servers/app In-Reply-To: <200906211933.n5LJX7VJ021133@sheep.berlios.de> Message-ID: <40891138061-BeMail@zon> anevilyak at BerliOS wrote: > Log: > Fix broken check for ctrl+cmd+esc that would result in any of ctrl+ > esc, > cmd+esc or ctrl+cmd+esc > triggering safe video mode, and as a side > effect, prevent menus from being opened via keyboard. Doh! Thanks! The Logic must have been weak with me that day ;-) Bye, Axel. From anevilyak at gmail.com Sun Jun 21 23:07:06 2009 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 21 Jun 2009 16:07:06 -0500 Subject: [Haiku-commits] r31160 - haiku/trunk/src/servers/app In-Reply-To: <40891138061-BeMail@zon> References: <200906211933.n5LJX7VJ021133@sheep.berlios.de> <40891138061-BeMail@zon> Message-ID: On Sun, Jun 21, 2009 at 3:49 PM, Axel D?rfler wrote: > > Doh! Thanks! The Logic must have been weak with me that day ;-) Happens to all of us :). I just realized my version's not strictly 100% correct either though, since it will also accept ctrl+shift+cmd+esc, but I'm doubting that's an issue. Regards, Rene From aljen at mail.berlios.de Sun Jun 21 23:21:42 2009 From: aljen at mail.berlios.de (aljen at mail.berlios.de) Date: Sun, 21 Jun 2009 23:21:42 +0200 Subject: [Haiku-commits] r31163 - in haiku/branches/components/gallium3d: headers/os/opengl/GL headers/private/opengl/GL/internal src/kits/opengl src/kits/opengl/mesa src/kits/opengl/mesa/drivers/common src/kits/opengl/mesa/gallium src/kits/opengl/mesa/gallium/auxiliary src/kits/opengl/mesa/gallium/auxiliary/cso_cache src/kits/opengl/mesa/gallium/auxiliary/draw src/kits/opengl/mesa/gallium/auxiliary/gallivm src/kits/opengl/mesa/gallium/auxiliary/indices src/kits/opengl/mesa/gallium/auxiliary/pipebuffer src/kits/opengl/mesa/gallium/auxiliary/rtasm src/kits/opengl/mesa/gallium/auxiliary/sct src/kits/opengl/mesa/gallium/auxiliary/tgsi src/kits/opengl/mesa/gallium/auxiliary/translate src/kits/opengl/mesa/gallium/auxiliary/util src/kits/opengl/mesa/gallium/include src/kits/opengl/mesa/gallium/include/pipe src/kits/opengl/mesa/gallium/include/pipe/internal src/kits/opengl/mesa/gallium/include/state_tracker src/kits/opengl/mesa/glapi src/kits/opengl/mesa/main src/kits/opengl/mesa/math src/kits/ope! ngl/mesa/ppc src/kits/opengl/mesa/shader src/kits/opengl/mesa/shader/slang src/kits/opengl/mesa/shader/slang/library src/kits/opengl/mesa/sparc src/kits/opengl/mesa/state_tracker src/kits/opengl/mesa/swrast src/kits/opengl/mesa/swrast_setup src/kits/opengl/mesa/tnl src/kits/opengl/mesa/tnl_dd src/kits/opengl/mesa/vbo src/kits/opengl/mesa/x86 src/kits/opengl/mesa/x86/rtasm src/kits/opengl/mesa/x86-64 Message-ID: <200906212121.n5LLLgmU031088@sheep.berlios.de> Author: aljen Date: 2009-06-21 23:15:24 +0200 (Sun, 21 Jun 2009) New Revision: 31163 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31163&view=rev Added: haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/cso_cache.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/cso_cache.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/cso_context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/cso_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/cso_hash.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/cso_cache/cso_hash.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_aaline.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_aapoint.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_clip.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_cull.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_flatshade.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_offset.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_pstipple.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_stipple.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_twoside.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_unfilled.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_util.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_validate.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_vbuf.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_wide_line.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pipe_wide_point.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_private.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_decompose.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_elts.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_emit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_fetch.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_fetch_emit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_post_vs.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_util.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_varray.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_varray_tmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_vcache.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_pt_vcache_tmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vbuf.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vertex.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vertex.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_aos.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_aos.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_aos_io.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_aos_machine.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_exec.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_llvm.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_ppc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_sse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/draw/draw_vs_varient.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/gallivm.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/gallivm.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/gallivm_builtins.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/gallivm_cpu.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/gallivm_p.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/instructions.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/instructions.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/instructionssoa.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/instructionssoa.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/llvm_builtins.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/loweringpass.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/loweringpass.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/soabuiltins.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/storage.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/storage.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/storagesoa.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/storagesoa.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/tgsitollvm.cpp haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/gallivm/tgsitollvm.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_indices.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_indices.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_indices_gen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_indices_gen.py haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_indices_priv.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_unfilled_gen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_unfilled_gen.py haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/indices/u_unfilled_indices.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_buffer.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_validate.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/pipebuffer/pb_validate.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_cpu.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_cpu.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_execmem.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_execmem.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_ppc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_ppc.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_ppc_spe.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_ppc_spe.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_x86sse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/rtasm/rtasm_x86sse.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/sct/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/sct/sct.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/sct/sct.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/sct/usage.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi-instruction-set.txt haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_build.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_build.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_dump.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_dump.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_dump_c.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_dump_c.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_exec.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_exec.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_info.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_info.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_iterate.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_iterate.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_parse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_parse.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_ppc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_ppc.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_sanity.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_sanity.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_scan.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_scan.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_sse2.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_sse2.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_text.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_text.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_transform.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_transform.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_util.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/tgsi/tgsi_util.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/translate.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/translate.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/translate_cache.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/translate_cache.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/translate_generic.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/translate/translate_sse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_bitmask.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_bitmask.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_blit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_blit.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_cache.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_cache.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_clear.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_cpu_detect.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_cpu_detect.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug_memory.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug_profile.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug_stack.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug_stack.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug_symbol.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_debug_symbol.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_double_list.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_draw_quad.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_draw_quad.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_gen_mipmap.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_gen_mipmap.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_handle_table.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_handle_table.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_hash.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_hash.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_hash_table.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_hash_table.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_keymap.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_keymap.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_linear.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_linear.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_math.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_math.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_memory.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_mm.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_mm.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_network.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_network.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_pack_color.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_pointer.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_prim.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_rect.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_rect.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_simple_list.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_simple_screen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_simple_screen.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_simple_shaders.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_simple_shaders.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_snprintf.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_sse.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_stream.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_stream_stdc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_stream_wd.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_string.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_surface.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_surface.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_tile.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_tile.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_time.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_time.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_timed_winsys.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_timed_winsys.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_upload_mgr.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/auxiliary/util/u_upload_mgr.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/internal/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/internal/p_winsys_screen.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_atomic.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_compiler.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_config.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_defines.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_error.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_format.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_inlines.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_refcnt.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_screen.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_shader_tokens.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_state.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/pipe/p_thread.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/state_tracker/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/gallium/include/state_tracker/drm_api.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/compiler.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/cpuinfo.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/cpuinfo.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/shared.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/shared.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texgetimage.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texgetimage.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/viewport.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/viewport.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_optimize.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_optimize.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_api.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_blend.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_clip.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_constbuf.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_constbuf.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_depth.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_framebuffer.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_pixeltransfer.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_rasterizer.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_sampler.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_scissor.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_shader.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_shader.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_stipple.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_texture.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_atom_viewport.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cache.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_accum.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_accum.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_bitmap.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_bitmap.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_blit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_blit.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_bufferobjects.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_bufferobjects.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_clear.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_clear.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_drawpixels.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_drawpixels.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_fbo.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_fbo.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_feedback.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_feedback.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_flush.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_flush.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_get.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_get.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_program.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_program.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_queryobj.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_queryobj.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_rasterpos.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_rasterpos.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_readpixels.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_readpixels.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_strings.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_strings.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_texture.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_texture.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_viewport.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_cb_viewport.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_debug.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_debug.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_draw.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_draw.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_draw_feedback.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_extensions.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_extensions.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_format.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_format.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_framebuffer.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_gen_mipmap.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_gen_mipmap.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_inlines.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_mesa_to_tgsi.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_mesa_to_tgsi.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_program.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_program.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_public.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_texture.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/state_tracker/st_texture.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_clear.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/x86_xform.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/x86_xform.h Removed: haiku/branches/components/gallium3d/src/kits/opengl/mesa/array_cache/ haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/mathmod.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_debug.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_debug.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_version_syn.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_buffers.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vtx_x86_gcc.S haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/common_x86_macros.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/x86.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/x86.h Modified: haiku/branches/components/gallium3d/headers/os/opengl/GL/gl.h haiku/branches/components/gallium3d/headers/os/opengl/GL/glext.h haiku/branches/components/gallium3d/headers/os/opengl/GL/glut.h haiku/branches/components/gallium3d/headers/private/opengl/GL/internal/glcore.h haiku/branches/components/gallium3d/src/kits/opengl/Jamfile haiku/branches/components/gallium3d/src/kits/opengl/mesa/Jamfile haiku/branches/components/gallium3d/src/kits/opengl/mesa/drivers/common/driverfuncs.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/dispatch.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glapi.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glapi_getproc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glapioffsets.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glapitable.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glapitemp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glprocs.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glthread.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/glapi/glthread.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/api_arrayelt.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/api_exec.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/api_noop.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/api_validate.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/arrayobj.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/arrayobj.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/attrib.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/bufferobj.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/bufferobj.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/buffers.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/clip.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/colormac.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/config.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/dd.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/debug.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/debug.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/depthstencil.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/dispatch.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/dlist.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/dlist.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/dlopen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/drawpix.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/enable.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/enums.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/execmem.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/extensions.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/fbobject.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/fbobject.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/feedback.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/feedback.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/ffvertex_prog.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/framebuffer.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/framebuffer.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/get.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/getstring.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/glheader.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/hint.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/histogram.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/image.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/image.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/imports.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/imports.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/light.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/light.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/macros.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/matrix.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/matrix.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/mfeatures.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/mipmap.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/mtypes.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/multisample.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/pixel.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/pixelstore.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/queryobj.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/queryobj.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/renderbuffer.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/shaders.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/state.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/state.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/stencil.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texcompress.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texcompress_fxt1.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texcompress_s3tc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texenv.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texenv.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texenvprogram.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texenvprogram.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texformat.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texformat.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texformat_tmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texgen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/teximage.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texobj.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texobj.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texparam.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texrender.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texstate.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texstore.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/texstore.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/varray.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/varray.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/version.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/main/vtxfmt.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_debug_util.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_debug_xform.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_matrix.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_matrix.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_vector.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_vector.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_xform.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/math/m_xform.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/ppc/common_ppc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/arbprogparse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/arbprogram.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/atifragshader.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/nvfragparse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/nvfragparse.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/nvprogram.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/nvvertparse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/nvvertparse.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_cache.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_cache.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_execute.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_execute.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_instruction.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_instruction.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_parameter.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_parameter.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_print.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_print.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_statevars.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_statevars.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/prog_uniform.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/program.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/program.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/programopt.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/programopt.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/shader_api.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_common_builtin.gc haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_common_builtin_gc.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_fragment_builtin.gc haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_fragment_builtin_gc.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_vertex_builtin.gc haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/library/slang_vertex_builtin_gc.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_builtin.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_codegen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_codegen.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_compile.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_emit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_emit.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_ir.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_ir.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_link.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_log.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_preprocess.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/shader/slang/slang_typeinfo.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/sparc/clip.S haiku/branches/components/gallium3d/src/kits/opengl/mesa/sparc/glapi_sparc.S haiku/branches/components/gallium3d/src/kits/opengl/mesa/sparc/norm.S haiku/branches/components/gallium3d/src/kits/opengl/mesa/sparc/sparc.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/sparc/sparc.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_accum.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_atifragshader.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_bitmap.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_blit.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_copypix.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_drawpix.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_feedback.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_fog.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_fragprog.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_imaging.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_readpix.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_span.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_span.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_texcombine.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_texfilter.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_texstore.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/s_triangle.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast/swrast.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast_setup/ss_triangle.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/swrast_setup/ss_tritmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_draw.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_rasterpos.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vb_cliptmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vb_lighttmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vb_points.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vb_program.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vb_rendertmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vb_texgen.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vertex.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vp_build.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/t_vp_build.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl/tnl.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/tnl_dd/t_dd_vb.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_attrib_tmp.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_context.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_context.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_exec.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_exec.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_exec_api.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_exec_array.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_exec_draw.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_rebase.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_save.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_save_api.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_save_draw.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_split_copy.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/vbo/vbo_split_inplace.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86-64/glapi_x86-64.S haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86-64/x86-64.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/3dnow.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/common_x86.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/common_x86_asm.h haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/gen_matypes.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/glapi_x86.S haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/rtasm/x86sse.c haiku/branches/components/gallium3d/src/kits/opengl/mesa/x86/sse.c Log: Gallium3D version of Mesa Modified: haiku/branches/components/gallium3d/headers/os/opengl/GL/gl.h =================================================================== --- haiku/branches/components/gallium3d/headers/os/opengl/GL/gl.h 2009-06-21 20:16:33 UTC (rev 31162) +++ haiku/branches/components/gallium3d/headers/os/opengl/GL/gl.h 2009-06-21 21:15:24 UTC (rev 31163) @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.4 + * Version: 7.6 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -58,7 +59,11 @@ # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern # endif /* _STATIC_MESA support */ -# define GLAPIENTRY __stdcall +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif #elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern # define GLAPIENTRY __stdcall @@ -84,8 +89,9 @@ #include #endif -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) \ - && !defined(OPENSTEP) && !defined(__CYGWIN__) || defined(__MINGW32__) +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WIN32_WCE) \ + && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) \ + && !defined(__CYGWIN__) || defined(__MINGW32__) #include #endif @@ -1734,43 +1740,8 @@ GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); - /* * OpenGL 1.3 */ @@ -1973,54 +1944,7 @@ GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); - /* * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) */ Modified: haiku/branches/components/gallium3d/headers/os/opengl/GL/glext.h =================================================================== --- haiku/branches/components/gallium3d/headers/os/opengl/GL/glext.h 2009-06-21 20:16:33 UTC (rev 31162) +++ haiku/branches/components/gallium3d/headers/os/opengl/GL/glext.h 2009-06-21 21:15:24 UTC (rev 31163) @@ -6,7 +6,7 @@ #endif /* -** Copyright (c) 2007 The Khronos Group Inc. +** Copyright (c) 2007-2009 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -28,6 +28,13 @@ ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2009-05-05 15:27:42 -0700 (Tue, 05 May 2009) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 52 + +/* Function declaration macros - to move into glplatform.h */ + #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #define WIN32_LEAN_AND_MEAN 1 #include @@ -45,18 +52,12 @@ /*************************************************************/ -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2009/03/19 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 48 - #ifndef GL_VERSION_1_2 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A #define GL_TEXTURE_BINDING_3D 0x806A #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_IMAGE_HEIGHT 0x806C @@ -83,17 +84,21 @@ #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E #endif +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + #ifndef GL_ARB_imaging #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 @@ -106,6 +111,9 @@ #define GL_BLEND_EQUATION 0x8009 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -206,12 +214,6 @@ #define GL_TEXTURE30 0x84DE #define GL_TEXTURE31 0x84DF #define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 #define GL_MULTISAMPLE 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F @@ -220,9 +222,6 @@ #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 @@ -233,10 +232,6 @@ #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_TEXTURE_COMPRESSION_HINT 0x84EF @@ -245,6 +240,22 @@ #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMBINE 0x8570 #define GL_COMBINE_RGB 0x8571 #define GL_COMBINE_ALPHA 0x8572 @@ -276,16 +287,26 @@ #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED #define GL_POINT_SIZE_MIN 0x8126 #define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 #define GL_POINT_DISTANCE_ATTENUATION 0x8129 #define GL_GENERATE_MIPMAP 0x8191 #define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 #define GL_FOG_COORDINATE_SOURCE 0x8450 #define GL_FOG_COORDINATE 0x8451 #define GL_FRAGMENT_DEPTH 0x8452 @@ -301,15 +322,8 @@ #define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D #define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD #define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_COMPARE_R_TO_TEXTURE 0x884E #endif @@ -324,15 +338,6 @@ #define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ARRAY_BUFFER_BINDING 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F #define GL_READ_ONLY 0x88B8 #define GL_WRITE_ONLY 0x88B9 @@ -350,31 +355,42 @@ #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA #endif +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A +#endif + #ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_RGB 0x8009 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 @@ -398,11 +414,8 @@ #define GL_DRAW_BUFFER14 0x8833 #define GL_DRAW_BUFFER15 0x8834 #define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 @@ -453,8 +466,14 @@ #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #endif +#ifndef GL_VERSION_2_0_DEPRECATED +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + #ifndef GL_VERSION_2_1 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED @@ -469,25 +488,29 @@ #define GL_SRGB8 0x8C41 #define GL_SRGB_ALPHA 0x8C42 #define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#endif + +#ifndef GL_VERSION_2_1_DEPRECATED +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 #define GL_SLUMINANCE 0x8C46 #define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 #define GL_COMPRESSED_SLUMINANCE 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B #endif #ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB -#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 -#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 -#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 -#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 -#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 -#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 -#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_MAX_CLIP_DISTANCES 0x0D32 #define GL_MAJOR_VERSION 0x821B #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D @@ -505,19 +528,9 @@ #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_CLAMP_READ_COLOR 0x891C #define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B #define GL_TEXTURE_1D_ARRAY 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 #define GL_TEXTURE_2D_ARRAY 0x8C1A @@ -559,7 +572,6 @@ #define GL_RED_INTEGER 0x8D94 #define GL_GREEN_INTEGER 0x8D95 #define GL_BLUE_INTEGER 0x8D96 -#define GL_ALPHA_INTEGER 0x8D97 #define GL_RGB_INTEGER 0x8D98 #define GL_RGBA_INTEGER 0x8D99 #define GL_BGR_INTEGER 0x8D9A @@ -615,8 +627,6 @@ /* reuse GL_TEXTURE_GREEN_TYPE */ /* reuse GL_TEXTURE_BLUE_TYPE */ /* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ /* reuse GL_TEXTURE_DEPTH_TYPE */ /* reuse GL_UNSIGNED_NORMALIZED */ /* reuse GL_FRAMEBUFFER_BINDING */ @@ -716,6 +726,84 @@ /* reuse GL_VERTEX_ARRAY_BINDING */ #endif +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Would reuse tokens from ARB_draw_instanced, but it has none */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + #ifndef GL_ARB_multitexture #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 @@ -1233,12 +1321,17 @@ #define GL_FRAMEBUFFER_DEFAULT 0x8218 #define GL_FRAMEBUFFER_UNDEFINED 0x8219 #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_INDEX 0x8222 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_DEPTH_STENCIL 0x84F9 #define GL_UNSIGNED_INT_24_8 0x84FA #define GL_DEPTH24_STENCIL8 0x88F0 #define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING #define GL_RENDERBUFFER_BINDING 0x8CA7 @@ -1295,6 +1388,12 @@ #define GL_MAX_SAMPLES 0x8D57 #endif +#ifndef GL_ARB_framebuffer_object_DEPRECATED +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + #ifndef GL_ARB_framebuffer_sRGB #define GL_FRAMEBUFFER_SRGB 0x8DB9 #endif @@ -1327,6 +1426,7 @@ #endif #ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE #endif #ifndef GL_ARB_map_buffer_range @@ -1382,6 +1482,54 @@ #define GL_VERTEX_ARRAY_BINDING 0x85B5 #endif +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + #ifndef GL_EXT_abgr #define GL_ABGR_EXT 0x8000 #endif @@ -3367,7 +3515,7 @@ #endif #ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 #define GL_BLEND_EQUATION_ALPHA_EXT 0x883D #endif @@ -3904,7 +4052,7 @@ #include #ifndef GL_VERSION_2_0 /* GL type for program/shader text */ -typedef char GLchar; /* native character */ +typedef char GLchar; #endif #ifndef GL_VERSION_1_5 @@ -3920,12 +4068,12 @@ #endif #ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +typedef unsigned int GLhandleARB; #endif -/* GL types for "half" precision (s10e5) float data in host memory */ +/* GL type for "half" precision (s10e5) float data in host memory */ #ifndef GL_ARB_half_float_pixel typedef unsigned short GLhalfARB; #endif @@ -3967,7 +4115,8 @@ typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else -#include /* Fallback option */ +/* Fallback if nothing above works */ +#include #endif #endif @@ -3982,6 +4131,21 @@ GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); GLAPI void APIENTRY glBlendEquation (GLenum); GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_VERSION_1_2_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); @@ -4014,13 +4178,7 @@ GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); GLAPI void APIENTRY glResetHistogram (GLenum); GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); @@ -4053,15 +4211,35 @@ typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif #ifndef GL_VERSION_1_3 #define GL_VERSION_1_3 1 #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_VERSION_1_3_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glClientActiveTexture (GLenum); GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); @@ -4099,16 +4277,7 @@ GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); @@ -4146,31 +4315,36 @@ typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); #endif #ifndef GL_VERSION_1_4 #define GL_VERSION_1_4 1 #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); GLAPI void APIENTRY glPointParameteri (GLenum, GLint); GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_VERSION_1_4_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); @@ -4205,18 +4379,11 @@ GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); GLAPI void APIENTRY glWindowPos3sv (const GLshort *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); @@ -4528,26 +4695,6 @@ GLAPI void APIENTRY glClampColor (GLenum, GLenum); GLAPI void APIENTRY glBeginConditionalRender (GLuint, GLenum); GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint); -GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *); GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *); GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *); GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *); @@ -4587,26 +4734,6 @@ typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); @@ -4632,6 +4759,69 @@ typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); #endif +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_VERSION_3_0_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint); +GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 [... truncated: 160240 lines follow ...] From aljen at mail.berlios.de Sun Jun 21 23:30:36 2009 From: aljen at mail.berlios.de (aljen at mail.berlios.de) Date: Sun, 21 Jun 2009 23:30:36 +0200 Subject: [Haiku-commits] r31164 - in haiku/branches/components/gallium3d: build/jam src/add-ons/opengl src/add-ons/opengl/softpipe src/add-ons/opengl/trace Message-ID: <200906212130.n5LLUa25031684@sheep.berlios.de> Author: aljen Date: 2009-06-21 23:29:57 +0200 (Sun, 21 Jun 2009) New Revision: 31164 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31164&view=rev Added: haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/ haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/Jamfile haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/SoftPipeRenderer.cpp haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/SoftPipeRenderer.h haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/haiku_softpipe_winsys.c haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/haiku_softpipe_winsys.h haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/hsp_bitmap_wrapper.cpp haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/hsp_bitmap_wrapper.h haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/hsp_context.c haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/hsp_context.h haiku/branches/components/gallium3d/src/add-ons/opengl/softpipe/hsp_device.c haiku/branch