From 184553775feb6de9bbc75de699a044d4f984627a Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 18 Nov 2012 14:25:13 -0600 Subject: [PATCH 01/32] Haiku3D: Add GLU header. Sorry for missing that one. --- src/apps/haiku3d/Jamfile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apps/haiku3d/Jamfile b/src/apps/haiku3d/Jamfile index 44914c003a..c4588f6cf4 100644 --- a/src/apps/haiku3d/Jamfile +++ b/src/apps/haiku3d/Jamfile @@ -1,4 +1,5 @@ SubDir HAIKU_TOP src apps haiku3d ; +SubDirSysHdrs $(HAIKU_GLU_HEADERS) ; SubDirSysHdrs $(HAIKU_MESA_HEADERS) ; SEARCH_SOURCE += [ FDirName $(SUBDIR) mesh ] ; From ba68dfba8744215f9f625310d4f262ec99a6c56a Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Sun, 18 Nov 2012 21:16:37 +0000 Subject: [PATCH 02/32] Fixed 64-bit pointer truncation in FreeBSD driver compat layer, fixes #9187. --- src/libs/compat/freebsd_network/compat/sys/param.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/compat/freebsd_network/compat/sys/param.h b/src/libs/compat/freebsd_network/compat/sys/param.h index ca29011cc7..51e09e4a6d 100644 --- a/src/libs/compat/freebsd_network/compat/sys/param.h +++ b/src/libs/compat/freebsd_network/compat/sys/param.h @@ -46,8 +46,8 @@ #define MJUM9BYTES (9 * 1024) #define MJUM16BYTES (16 * 1024) -#define ALIGN_BYTES (sizeof(int) - 1) -#define ALIGN(x) ((((unsigned)x) + ALIGN_BYTES) & ~ALIGN_BYTES) +#define ALIGN_BYTES (sizeof(unsigned long) - 1) +#define ALIGN(x) ((((unsigned long)x) + ALIGN_BYTES) & ~ALIGN_BYTES) /* Macros for counting and rounding. */ #ifndef howmany From b0f9ebaca53fb5ff079d1330f4dccfce6687e4a5 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Sun, 18 Nov 2012 22:51:54 +0000 Subject: [PATCH 03/32] Don't compile in x86emu debug code for builds with DEBUG set. --- headers/libs/x86emu/x86emu/x86emui.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/headers/libs/x86emu/x86emu/x86emui.h b/headers/libs/x86emu/x86emu/x86emui.h index f11dc102ff..53f9fe4803 100644 --- a/headers/libs/x86emu/x86emu/x86emui.h +++ b/headers/libs/x86emu/x86emu/x86emui.h @@ -41,6 +41,11 @@ #ifndef __X86EMU_X86EMUI_H #define __X86EMU_X86EMUI_H +// Haiku workaround - don't want to compile all of the debugging code even +// when doing a debug build, it's unnecessary unless you're trying to debug +// x86emu itself. +#undef DEBUG + /* If we are compiling in C++ mode, we can compile some functions as * inline to increase performance (however the code size increases quite * dramatically in this case). From 75384e609293eebaaf9c60dc5c2690bc6e95d74a Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Mon, 19 Nov 2012 17:36:14 +0100 Subject: [PATCH 04/32] Enable PCI memory access and interrupt --- .../kernel/drivers/audio/hda/hda_controller.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp b/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp index 2f281c3909..cdebc554dc 100644 --- a/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp +++ b/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp @@ -869,11 +869,20 @@ hda_hw_init(hda_controller* controller) controller->pci_info.device, controller->pci_info.function, PCI_command, 2); if (!(cmd & PCI_command_master)) { - (gPci->write_pci_config)(controller->pci_info.bus, - controller->pci_info.device, controller->pci_info.function, - PCI_command, 2, cmd | PCI_command_master); dprintf("hda: enabling PCI bus mastering\n"); + cmd |= PCI_command_master; } + if (!(cmd & PCI_command_memory)) { + dprintf("hda: enabling PCI memory access\n"); + cmd |= PCI_command_memory; + } + if ((cmd & PCI_command_int_disable)) { + dprintf("hda: enabling PCI interrupts\n"); + cmd &= ~PCI_command_int_disable; + } + (gPci->write_pci_config)(controller->pci_info.bus, + controller->pci_info.device, controller->pci_info.function, + PCI_command, 2, cmd); if (get_module(B_PCI_X86_MODULE_NAME, (module_info**)&sPCIx86Module) != B_OK) From 93b5e5614cab5777788dff6f6ecd7cbe00892fe0 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 20 Nov 2012 19:33:05 +0100 Subject: [PATCH 05/32] Adjust Locale Kit to no longer use syslog --- src/kits/locale/Catalog.cpp | 2 - src/kits/locale/DefaultCatalog.cpp | 99 ++++--------------------- src/kits/locale/InitLocaleKit.cpp | 21 +----- src/kits/locale/LocaleRoster.cpp | 11 +-- src/kits/locale/MutableLocaleRoster.cpp | 29 +------- 5 files changed, 20 insertions(+), 142 deletions(-) diff --git a/src/kits/locale/Catalog.cpp b/src/kits/locale/Catalog.cpp index f2ec81a889..25c2104755 100644 --- a/src/kits/locale/Catalog.cpp +++ b/src/kits/locale/Catalog.cpp @@ -6,8 +6,6 @@ #include -#include - #include #include #include diff --git a/src/kits/locale/DefaultCatalog.cpp b/src/kits/locale/DefaultCatalog.cpp index 43a39d06b2..b56368f1e6 100644 --- a/src/kits/locale/DefaultCatalog.cpp +++ b/src/kits/locale/DefaultCatalog.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -118,9 +117,6 @@ DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *langua } fInitCheck = status; - log_team(LOG_DEBUG, - "trying to load default-catalog(sig=%s, lang=%s) results in %s", - fSignature.String(), language, strerror(fInitCheck)); } @@ -134,9 +130,6 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef) HashMapCatalog("", "", 0) { fInitCheck = ReadFromResource(*appOrAddOnRef); - log_team(LOG_DEBUG, - "trying to load embedded catalog from resources results in %s", - strerror(fInitCheck)); } @@ -167,8 +160,6 @@ DefaultCatalog::SetSignature(const entry_ref &catalogOwner) BAppFileInfo objectInfo(&objectFile); char objectSignature[B_MIME_TYPE_LENGTH]; if (objectInfo.GetSignature(objectSignature) != B_OK) { - log_team(LOG_ERR, "File %s has no mimesignature, so it can't use" - " localization.", catalogOwner.name); fSignature = ""; return; } @@ -183,8 +174,6 @@ DefaultCatalog::SetSignature(const entry_ref &catalogOwner) else stripSignature ++; - log_team(LOG_DEBUG, "Image %s requested catalog with mimetype %s", - catalogOwner.name, stripSignature); fSignature = stripSignature; } @@ -204,40 +193,25 @@ DefaultCatalog::ReadFromFile(const char *path) BFile catalogFile; status_t res = catalogFile.SetTo(path, B_READ_ONLY); - if (res != B_OK) { - log_team(LOG_DEBUG, "LocaleKit DefaultCatalog: no catalog at %s", path); + if (res != B_OK) return B_ENTRY_NOT_FOUND; - } fPath = path; - log_team(LOG_DEBUG, "LocaleKit DefaultCatalog: found catalog at %s", path); off_t sz = 0; res = catalogFile.GetSize(&sz); if (res != B_OK) { - log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't get size for " - "catalog-file %s", path); return res; } auto_ptr buf(new(std::nothrow) char [sz]); - if (buf.get() == NULL) { - log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't allocate array " - "of %d chars", sz); + if (buf.get() == NULL) return B_NO_MEMORY; - } res = catalogFile.Read(buf.get(), sz); - if (res < B_OK) { - log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't read from " - "catalog-file %s", path); + if (res < B_OK) return res; - } - if (res < sz) { - log_team(LOG_ERR, - "LocaleKit DefaultCatalog: only got %lu instead of %Lu bytes from " - "catalog-file %s", res, sz, path); + if (res < sz) return res; - } BMemoryIO memIO(buf.get(), sz); res = Unflatten(&memIO); @@ -260,43 +234,24 @@ DefaultCatalog::ReadFromAttribute(const entry_ref &appOrAddOnRef) { BNode node; status_t res = node.SetTo(&appOrAddOnRef); - if (res != B_OK) { - log_team(LOG_ERR, - "couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)", - appOrAddOnRef.device, appOrAddOnRef.directory, - appOrAddOnRef.name); + if (res != B_OK) return B_ENTRY_NOT_FOUND; - } - - log_team(LOG_DEBUG, - "looking for embedded catalog-attribute in app/add-on" - "(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef.device, - appOrAddOnRef.directory, appOrAddOnRef.name); attr_info attrInfo; res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo); - if (res != B_OK) { - log_team(LOG_DEBUG, "no embedded catalog found"); + if (res != B_OK) return B_NAME_NOT_FOUND; - } - if (attrInfo.type != B_MESSAGE_TYPE) { - log_team(LOG_ERR, "attribute %s has incorrect type and is ignored!", - BLocaleRoster::kEmbeddedCatAttr); + if (attrInfo.type != B_MESSAGE_TYPE) return B_BAD_TYPE; - } size_t size = attrInfo.size; auto_ptr buf(new(std::nothrow) char [size]); - if (buf.get() == NULL) { - log_team(LOG_ERR, "couldn't allocate array of %d chars", size); + if (buf.get() == NULL) return B_NO_MEMORY; - } res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0, buf.get(), size); - if (res < (ssize_t)size) { - log_team(LOG_ERR, "unable to read embedded catalog from attribute"); + if (res < (ssize_t)size) return res < B_OK ? res : B_BAD_DATA; - } BMemoryIO memIO(buf.get(), size); res = Unflatten(&memIO); @@ -310,35 +265,20 @@ DefaultCatalog::ReadFromResource(const entry_ref &appOrAddOnRef) { BFile file; status_t res = file.SetTo(&appOrAddOnRef, B_READ_ONLY); - if (res != B_OK) { - log_team(LOG_ERR, - "couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)", - appOrAddOnRef.device, appOrAddOnRef.directory, - appOrAddOnRef.name); + if (res != B_OK) return B_ENTRY_NOT_FOUND; - } - - log_team(LOG_DEBUG, - "looking for embedded catalog-resource in app/add-on" - "(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef.device, - appOrAddOnRef.directory, appOrAddOnRef.name); BResources rsrc; res = rsrc.SetTo(&file); - if (res != B_OK) { - log_team(LOG_DEBUG, "file has no resources"); + if (res != B_OK) return res; - } int mangledLanguage = CatKey::HashFun(fLanguageName.String(), 0); size_t sz; - const void *buf = rsrc.LoadResource('CADA', - mangledLanguage, &sz); - if (!buf) { - log_team(LOG_DEBUG, "file has no catalog-resource"); + const void *buf = rsrc.LoadResource('CADA', mangledLanguage, &sz); + if (!buf) return B_NAME_NOT_FOUND; - } BMemoryIO memIO(buf, sz); res = Unflatten(&memIO); @@ -540,11 +480,6 @@ DefaultCatalog::Unflatten(BDataIO *dataIO) // not accept this catalog: if (foundFingerprint != 0 && fFingerprint != 0 && foundFingerprint != fFingerprint) { - log_team(LOG_INFO, "default-catalog(sig=%s, lang=%s) " - "has mismatching fingerprint (%ld instead of the requested %ld), " - "so this catalog is skipped.", - fSignature.String(), fLanguageName.String(), foundFingerprint, - fFingerprint); res = B_MISMATCHED_VALUES; } else fFingerprint = foundFingerprint; @@ -580,14 +515,8 @@ DefaultCatalog::Unflatten(BDataIO *dataIO) } } uint32 checkFP = ComputeFingerprint(); - if (fFingerprint != checkFP) { - log_team(LOG_WARNING, "default-catalog(sig=%s, lang=%s) " - "has wrong fingerprint after load (%ld instead of the %ld). " - "The catalog data may be corrupted, so this catalog is skipped.", - fSignature.String(), fLanguageName.String(), checkFP, - fFingerprint); + if (fFingerprint != checkFP) return B_BAD_DATA; - } } return res; } diff --git a/src/kits/locale/InitLocaleKit.cpp b/src/kits/locale/InitLocaleKit.cpp index 96f281a8f7..274b8920d4 100644 --- a/src/kits/locale/InitLocaleKit.cpp +++ b/src/kits/locale/InitLocaleKit.cpp @@ -3,8 +3,6 @@ * The required mimetypes and attribute-indices are created here. */ -#include - #include #include #include @@ -35,19 +33,8 @@ static void EnsureIndexExists(const char *attrName) if (volRoster.GetBootVolume(&bootVol) != B_OK) return; struct index_info idxInfo; - if (fs_stat_index(bootVol.Device(), attrName, &idxInfo) != 0) { - status_t res = fs_create_index(bootVol.Device(), attrName, - B_STRING_TYPE, 0); - if (res == 0) { - log_team(LOG_INFO, - "successfully created the required index for attribute %s", - attrName); - } else { - log_team(LOG_ERR, - "failed to create the required index for attribute %s (%s)", - attrName, strerror(res)); - } - } + if (fs_stat_index(bootVol.Device(), attrName, &idxInfo) != 0) + fs_create_index(bootVol.Device(), attrName, B_STRING_TYPE, 0); } @@ -122,10 +109,6 @@ SetupCatalogBasics() if (res == B_OK) res = mt.Install(); } - if (res != B_OK) { - log_team(LOG_ERR, "Could not install mimetype %s (%s)", - DefaultCatalog::kCatMimeType, strerror(res)); - } } diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp index d13b61496d..c4238b9108 100644 --- a/src/kits/locale/LocaleRoster.cpp +++ b/src/kits/locale/LocaleRoster.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -521,11 +520,8 @@ BLocaleRoster::GetLocalizedFileName(BString& localizedFileName, // The signature is missing application/ signature.Prepend("application/"); status = roster.FindApp(signature, &catalogRef); - if (status != B_OK) { - log_team(LOG_ERR, "Could not find the entry_ref for signature %s" - " to load a catalog.", signature.String()); + if (status != B_OK) return status; - } BCatalog catalog(catalogRef); const char* temp = catalog.GetString(string, context); @@ -562,11 +558,8 @@ BLocaleRoster::_GetCatalog(BCatalog* catalog, vint32* catalogInitStatus) } } - if (!found) { - log_team(LOG_DEBUG, "Catalog %x doesn't belong to any image!", - catalog); + if (!found) return catalog; - } // load the catalog for this mimetype and return it to the app entry_ref ref; diff --git a/src/kits/locale/MutableLocaleRoster.cpp b/src/kits/locale/MutableLocaleRoster.cpp index 3d51c99723..2b4d606136 100644 --- a/src/kits/locale/MutableLocaleRoster.cpp +++ b/src/kits/locale/MutableLocaleRoster.cpp @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -91,13 +90,8 @@ CatalogAddOnInfo::MakeSureItsLoaded() B_SYMBOL_TYPE_TEXT, (void**)&fCreateFunc); get_image_symbol(fAddOnImage, "get_available_languages", B_SYMBOL_TYPE_TEXT, (void**)&fLanguagesFunc); - log_team(LOG_DEBUG, "catalog-add-on %s has been loaded", - fName.String()); - } else { - log_team(LOG_DEBUG, "could not load catalog-add-on %s (%s)", - fName.String(), strerror(fAddOnImage)); + } else return false; - } } else if (fIsEmbedded) { // The built-in catalog still has to provide this function fLanguagesFunc = default_catalog_get_available_languages; @@ -115,8 +109,6 @@ CatalogAddOnInfo::UnloadIfPossible() fInstantiateFunc = NULL; fCreateFunc = NULL; fLanguagesFunc = NULL; -// log_team(LOG_DEBUG, "catalog-add-on %s has been unloaded", -// fName.String()); } } @@ -176,7 +168,6 @@ RosterData::~RosterData() BAutolock lock(fLock); _CleanupCatalogAddOns(); - closelog(); } @@ -320,11 +311,6 @@ RosterData::SetFilesystemTranslationPreferred(bool preferred) status_t RosterData::_Initialize() { - openlog_team("liblocale.so", LOG_PID, LOG_USER); -#ifndef DEBUG - setlogmask_team(LOG_UPTO(LOG_WARNING)); -#endif - status_t result = _InitializeCatalogAddOns(); if (result != B_OK) return result; @@ -429,16 +415,8 @@ RosterData::_InitializeCatalogAddOns() 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 { - log_team(LOG_ERR, - "couldn't load add-on %s, error: %s\n", - fullAddOnPath.String(), strerror(image)); } } @@ -793,11 +771,8 @@ MutableLocaleRoster::LoadSystemCatalog(BCatalog* catalog) const } } - if (!found) { - log_team(LOG_DEBUG, "Unable to find libbe-image!"); - + if (!found) return B_ERROR; - } // load the catalog for libbe into the given catalog entry_ref ref; From 9761f00b1b520e6fb3c60d8d408559a637ffe1a4 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 20 Nov 2012 21:51:27 +0000 Subject: [PATCH 06/32] Fix build of set_haiku_revision.cpp with gcc2 (on haiku) * move template method implementations out of class body, as otherwise gcc2 bails with internal compiler error - thanks to Christof Lutteroth for reporting --- src/tools/set_haiku_revision.cpp | 266 ++++++++++++++++--------------- 1 file changed, 137 insertions(+), 129 deletions(-) diff --git a/src/tools/set_haiku_revision.cpp b/src/tools/set_haiku_revision.cpp index acaa697204..88c4704e04 100644 --- a/src/tools/set_haiku_revision.cpp +++ b/src/tools/set_haiku_revision.cpp @@ -450,137 +450,10 @@ public: private: template - void _ParseELFHeader() - { - // read ELF header - EhdrType fileHeader; - Read(0, &fileHeader, sizeof(EhdrType), "Failed to read ELF header."); - - // check data encoding (endianess) - switch (fileHeader.e_ident[EI_DATA]) { - case ELFDATA2LSB: - fHostEndianess = (htonl(1) != 1); - break; - case ELFDATA2MSB: - fHostEndianess = (htonl(1) == 1); - break; - default: - case ELFDATANONE: - throw Exception(EIO, "Unsupported ELF data encoding."); - break; - } - - // get the header values - fELFHeaderSize = GetValue(fileHeader.e_ehsize); - fSectionHeaderTableOffset = GetValue(fileHeader.e_shoff); - fSectionHeaderSize = GetValue(fileHeader.e_shentsize); - fSectionHeaderCount = GetValue(fileHeader.e_shnum); - bool hasSectionHeaderTable = (fSectionHeaderTableOffset != 0); - - // check the sanity of the header values - // ELF header size - if (fELFHeaderSize < sizeof(EhdrType)) { - throw Exception(EIO, - "Invalid ELF header: invalid ELF header size: %lu.", - fELFHeaderSize); - } - - // section header table offset and entry count/size - if (hasSectionHeaderTable) { - if (fSectionHeaderTableOffset < (off_t)fELFHeaderSize - || fSectionHeaderTableOffset > fFileSize) { - throw Exception(EIO, "Invalid ELF header: invalid section " - "header table offset: %llu.", - fSectionHeaderTableOffset); - } - size_t sectionHeaderTableSize - = fSectionHeaderSize * fSectionHeaderCount; - if (fSectionHeaderSize < (off_t)sizeof(ShdrType) - || fSectionHeaderTableOffset + (off_t)sectionHeaderTableSize - > fFileSize) { - throw Exception(EIO, "Invalid ELF header: section header " - "table exceeds file: %llu.", - fSectionHeaderTableOffset - + sectionHeaderTableSize); - } - - - // load section header string section - uint16_t sectionHeaderStringSectionIndex - = GetValue(fileHeader.e_shstrndx); - if (sectionHeaderStringSectionIndex != SHN_UNDEF) { - if (sectionHeaderStringSectionIndex >= fSectionHeaderCount) { - throw Exception(EIO, "Invalid ELF header: invalid section " - "header string section index: %u.", - sectionHeaderStringSectionIndex); - } - - // get the section info - SectionInfo info; - if (_ReadSectionHeader(sectionHeaderStringSectionIndex, - info)) { - fSectionHeaderStrings = new char[info.size + 1]; - Read(info.offset, fSectionHeaderStrings, info.size, - "Failed to read section header string section."); - fSectionHeaderStringsLength = info.size; - // null-terminate to be on the safe side - fSectionHeaderStrings[info.size] = '\0'; - } - } - } - } + void _ParseELFHeader(); template - bool _ReadSectionHeader(int index, SectionInfo& info) - { - off_t shOffset = fSectionHeaderTableOffset - + index * fSectionHeaderSize; - ShdrType sectionHeader; - Read(shOffset, §ionHeader, sizeof(ShdrType), - "Failed to read ELF section header."); - - // get the header values - uint32_t type = GetValue(sectionHeader.sh_type); - off_t offset = GetValue(sectionHeader.sh_offset); - size_t size = GetValue(sectionHeader.sh_size); - uint32_t nameIndex = GetValue(sectionHeader.sh_name); - - // check the values - // SHT_NULL marks the header unused, - if (type == SHT_NULL) - return false; - - // SHT_NOBITS sections take no space in the file - if (type != SHT_NOBITS) { - if (offset < (off_t)fELFHeaderSize || offset > fFileSize) { - throw Exception(EIO, "Invalid ELF section header: " - "invalid section offset: %llu.", offset); - } - off_t sectionEnd = offset + size; - if (sectionEnd > fFileSize) { - throw Exception(EIO, "Invalid ELF section header: " - "section exceeds file: %llu.", sectionEnd); - } - } - - // get name, if we have a string section - if (fSectionHeaderStrings) { - if (nameIndex >= (uint32_t)fSectionHeaderStringsLength) { - throw Exception(EIO, "Invalid ELF section header: " - "invalid name index: %lu.", nameIndex); - } - info.name = fSectionHeaderStrings + nameIndex; - } else { - info.name = ""; - } - - info.type = type; - info.offset = offset; - info.size = size; - - - return true; - } + bool _ReadSectionHeader(int index, SectionInfo& info); // _SwapUInt16 static inline uint16_t _SwapUInt16(uint16_t value) @@ -658,6 +531,141 @@ uint64_t ELFObject::GetValue(uint64_t& value) } +template +void ELFObject::_ParseELFHeader() +{ + // read ELF header + EhdrType fileHeader; + Read(0, &fileHeader, sizeof(EhdrType), "Failed to read ELF header."); + + // check data encoding (endianess) + switch (fileHeader.e_ident[EI_DATA]) { + case ELFDATA2LSB: + fHostEndianess = (htonl(1) != 1); + break; + case ELFDATA2MSB: + fHostEndianess = (htonl(1) == 1); + break; + default: + case ELFDATANONE: + throw Exception(EIO, "Unsupported ELF data encoding."); + break; + } + + // get the header values + fELFHeaderSize = GetValue(fileHeader.e_ehsize); + fSectionHeaderTableOffset = GetValue(fileHeader.e_shoff); + fSectionHeaderSize = GetValue(fileHeader.e_shentsize); + fSectionHeaderCount = GetValue(fileHeader.e_shnum); + bool hasSectionHeaderTable = (fSectionHeaderTableOffset != 0); + + // check the sanity of the header values + // ELF header size + if (fELFHeaderSize < sizeof(EhdrType)) { + throw Exception(EIO, + "Invalid ELF header: invalid ELF header size: %lu.", + fELFHeaderSize); + } + + // section header table offset and entry count/size + if (hasSectionHeaderTable) { + if (fSectionHeaderTableOffset < (off_t)fELFHeaderSize + || fSectionHeaderTableOffset > fFileSize) { + throw Exception(EIO, "Invalid ELF header: invalid section " + "header table offset: %llu.", + fSectionHeaderTableOffset); + } + size_t sectionHeaderTableSize + = fSectionHeaderSize * fSectionHeaderCount; + if (fSectionHeaderSize < (off_t)sizeof(ShdrType) + || fSectionHeaderTableOffset + (off_t)sectionHeaderTableSize + > fFileSize) { + throw Exception(EIO, "Invalid ELF header: section header " + "table exceeds file: %llu.", + fSectionHeaderTableOffset + + sectionHeaderTableSize); + } + + + // load section header string section + uint16_t sectionHeaderStringSectionIndex + = GetValue(fileHeader.e_shstrndx); + if (sectionHeaderStringSectionIndex != SHN_UNDEF) { + if (sectionHeaderStringSectionIndex >= fSectionHeaderCount) { + throw Exception(EIO, "Invalid ELF header: invalid section " + "header string section index: %u.", + sectionHeaderStringSectionIndex); + } + + // get the section info + SectionInfo info; + if (_ReadSectionHeader(sectionHeaderStringSectionIndex, + info)) { + fSectionHeaderStrings = new char[info.size + 1]; + Read(info.offset, fSectionHeaderStrings, info.size, + "Failed to read section header string section."); + fSectionHeaderStringsLength = info.size; + // null-terminate to be on the safe side + fSectionHeaderStrings[info.size] = '\0'; + } + } + } +} + + +template +bool ELFObject::_ReadSectionHeader(int index, SectionInfo& info) +{ + off_t shOffset = fSectionHeaderTableOffset + + index * fSectionHeaderSize; + ShdrType sectionHeader; + Read(shOffset, §ionHeader, sizeof(ShdrType), + "Failed to read ELF section header."); + + // get the header values + uint32_t type = GetValue(sectionHeader.sh_type); + off_t offset = GetValue(sectionHeader.sh_offset); + size_t size = GetValue(sectionHeader.sh_size); + uint32_t nameIndex = GetValue(sectionHeader.sh_name); + + // check the values + // SHT_NULL marks the header unused, + if (type == SHT_NULL) + return false; + + // SHT_NOBITS sections take no space in the file + if (type != SHT_NOBITS) { + if (offset < (off_t)fELFHeaderSize || offset > fFileSize) { + throw Exception(EIO, "Invalid ELF section header: " + "invalid section offset: %llu.", offset); + } + off_t sectionEnd = offset + size; + if (sectionEnd > fFileSize) { + throw Exception(EIO, "Invalid ELF section header: " + "section exceeds file: %llu.", sectionEnd); + } + } + + // get name, if we have a string section + if (fSectionHeaderStrings) { + if (nameIndex >= (uint32_t)fSectionHeaderStringsLength) { + throw Exception(EIO, "Invalid ELF section header: " + "invalid name index: %lu.", nameIndex); + } + info.name = fSectionHeaderStrings + nameIndex; + } else { + info.name = ""; + } + + info.type = type; + info.offset = offset; + info.size = size; + + + return true; +} + + // main int main(int argc, const char* const* argv) From 0c13e65e472b1c53460d791bd57009e58f1d32ec Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Wed, 21 Nov 2012 00:14:51 +0100 Subject: [PATCH 07/32] Drop syslog output from Locale Kit add-ons, too --- .../locale/catalogs/plaintext/Catalog.cpp | 64 +++---------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp index 8c924258a0..f05d7bb2bf 100644 --- a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp +++ b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp @@ -14,8 +14,6 @@ #include #include -#include - #include #include #include @@ -125,9 +123,6 @@ PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language, } fInitCheck = status; - log_team(LOG_DEBUG, - "trying to load default-catalog(sig=%s, lang=%s) results in %s", - signature, language, strerror(fInitCheck)); } @@ -161,10 +156,8 @@ PlainTextCatalog::ReadFromFile(const char *path) path = fPath.String(); catalogFile.open(path, std::fstream::in); - if (!catalogFile.is_open()) { - log_team(LOG_DEBUG, "couldn't open catalog at %s", path); + if (!catalogFile.is_open()) return B_ENTRY_NOT_FOUND; - } // Now read all the data from the file @@ -177,50 +170,35 @@ PlainTextCatalog::ReadFromFile(const char *path) ss >> arcver; if (ss.fail()) { // can't convert to int - log_team(LOG_DEBUG, - "Unable to extract archive version ( string: %s ) from %s", - currentItem.c_str(), path); return B_ERROR; } if (arcver != kCatArchiveVersion) { // wrong version - log_team(LOG_DEBUG, - "Wrong archive version ! Got %d instead of %d from %s", arcver, - kCatArchiveVersion, path); return B_ERROR; } - } else { - log_team(LOG_DEBUG, "Unable to read from catalog %s", path); + } else return B_ERROR; - } if (std::getline(catalogFile, currentItem, '\t').good()) { // Get the language fLanguageName = currentItem.c_str() ; - } else { - log_team(LOG_DEBUG, "Unable to get language from %s", path); + } else return B_ERROR; - } if (std::getline(catalogFile, currentItem, '\t').good()) { // Get the signature fSignature = currentItem.c_str() ; - } else { - log_team(LOG_DEBUG, "Unable to get signature from %s", path); + } else return B_ERROR; - } if (std::getline(catalogFile, currentItem).good()) { // Get the fingerprint std::istringstream ss(currentItem); uint32 foundFingerprint; ss >> foundFingerprint; - if (ss.fail()) { - log_team(LOG_DEBUG, "Unable to get fingerprint (%s) from %s", - currentItem.c_str(), path); + if (ss.fail()) return B_ERROR; - } if (fFingerprint == 0) fFingerprint = foundFingerprint; @@ -228,14 +206,11 @@ PlainTextCatalog::ReadFromFile(const char *path) if (fFingerprint != foundFingerprint) { return B_MISMATCHED_VALUES; } - } else { - log_team(LOG_DEBUG, "Unable to get fingerprint from %s", path); + } else return B_ERROR; - } // We managed to open the file, so we remember it's the one we are using fPath = path; - log_team(LOG_DEBUG, "found plaintext catalog at %s", path); std::string originalString; std::string context; @@ -245,24 +220,14 @@ PlainTextCatalog::ReadFromFile(const char *path) while (std::getline(catalogFile, originalString,'\t').good()) { // Each line is : "original string \t context \t comment \t translation" - if (!std::getline(catalogFile, context,'\t').good()) { - log_team(LOG_DEBUG, "Unable to get context for string %s from %s", - originalString.c_str(), path); + if (!std::getline(catalogFile, context,'\t').good()) return B_ERROR; - } - if (!std::getline(catalogFile, comment,'\t').good()) { - log_team(LOG_DEBUG, "Unable to get comment for string %s from %s", - originalString.c_str(), path); + if (!std::getline(catalogFile, comment,'\t').good()) return B_ERROR; - } - if (!std::getline(catalogFile, translated).good()) { - log_team(LOG_DEBUG, - "Unable to get translated text for string %s from %s", - originalString.c_str(), path); + if (!std::getline(catalogFile, translated).good()) return B_ERROR; - } // We could do that : // SetString(key, translated.c_str()); @@ -270,22 +235,13 @@ PlainTextCatalog::ReadFromFile(const char *path) // happen, you know. (and CatKey::== will fail) SetString(originalString.c_str(), translated.c_str(), context.c_str(), comment.c_str()); - log_team(LOG_DEBUG, "Added string %s from file %s", - originalString.c_str(), path); } catalogFile.close(); uint32 checkFP = ComputeFingerprint(); - if (fFingerprint != checkFP) { - log_team(LOG_DEBUG, "plaintext-catalog(sig=%s, lang=%s) " - "has wrong fingerprint after load (%lu instead of %lu). " - "The catalog data may be corrupted, so this catalog is " - "skipped.\n", - fSignature.String(), fLanguageName.String(), checkFP, - fFingerprint); + if (fFingerprint != checkFP) return B_BAD_DATA; - } // some information living in member variables needs to be copied // to attributes. Although these attributes should have been written From 066688dcac74062a8d05834a9eed4ad2187ab9ce Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Tue, 20 Nov 2012 21:18:08 +0100 Subject: [PATCH 08/32] ARM/haiku_loader: Style fixes As suggested by Axel, thanks! --- src/system/boot/arch/arm/arch_cpu.cpp | 29 ++++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/system/boot/arch/arm/arch_cpu.cpp b/src/system/boot/arch/arm/arch_cpu.cpp index 2decd55ab3..5868da03c2 100644 --- a/src/system/boot/arch/arm/arch_cpu.cpp +++ b/src/system/boot/arch/arm/arch_cpu.cpp @@ -26,29 +26,31 @@ # define TRACE(x) ; #endif -/*! check_cpu_features - * - * Please note the fact that ARM7 and ARMv7 are two different things ;) - * ARMx is a specific ARM CPU core instance, while ARMvX refers to the - * ARM architecture specification version.... - * - * Most of the architecture versions we're detecting here we will probably - * never run on, just included for completeness sake... ARMv5 and up are - * the likely ones for us to support (as they all have some kind of MMU). - */ - +/*! Detect ARM core version and features. + Please note the fact that ARM7 and ARMv7 are two different things ;) + ARMx is a specific ARM CPU core instance, while ARMvX refers to the + ARM architecture specification version.... + + Most of the architecture versions we're detecting here we will probably + never run on, just included for completeness sake... ARMv5 and up are + the likely ones for us to support (as they all have some kind of MMU). +*/ static status_t check_cpu_features() { uint32 result = 0; - int arch, variant = 0, part = 0, revision = 0, implementor = 0; + int arch; + int variant = 0; + int part = 0; + int revision = 0; + int implementor = 0; asm volatile("MRC p15, 0, %[c1out], c0, c0, 0":[c1out] "=r" (result)); implementor = (result >> 24) & 0xff; if (!(result & (1 << 19))) { - switch((result >> 12) & 0xf) { + switch ((result >> 12) & 0xf) { case 0: /* early ARMv3 or even older */ arch = ARCH_ARM_PRE_ARM7; break; @@ -84,7 +86,6 @@ check_cpu_features() return B_OK; } -// #pragma mark - extern "C" void arch_spin(bigtime_t microseconds) From 64e4a8207f542cdd3f0a8f02378c514fd0323ab6 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Tue, 20 Nov 2012 21:27:54 +0100 Subject: [PATCH 09/32] norflash: Style fixes As pointed out by Axel, thanks! --- .../kernel/drivers/disk/norflash/norflash.cpp | 83 +++++++------------ 1 file changed, 30 insertions(+), 53 deletions(-) diff --git a/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp b/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp index cfd8c1fff9..37b9186c1e 100644 --- a/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp +++ b/src/add-ons/kernel/drivers/disk/norflash/norflash.cpp @@ -7,15 +7,16 @@ */ +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include -#include //#define TRACE_NORFLASH #ifdef TRACE_NORFLASH @@ -24,11 +25,14 @@ #define TRACE(x...) #endif + #define NORFLASH_DEVICE_MODULE_NAME "drivers/disk/norflash/device_v1" #define NORFLASH_DRIVER_MODULE_NAME "drivers/disk/norflash/driver_v1" + #define NORFLASH_ADDR 0x00000000 + struct nor_driver_info { device_node *node; size_t blocksize; @@ -38,42 +42,15 @@ struct nor_driver_info { void *mapped; }; -static device_manager_info* sDeviceManager; -static const char *sTabTab = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; -#define DS "%.*s" -#define DA depth - 1, sTabTab - -static void -dump_hex(const char *data, int32 len, int depth = 1) -{ - char str[128]; - char astr[32]; - char *p; - int l; - int i; - - for (i = 0; i < len; ) { - p = str; - l = sizeof(str); - for (; i < len && (p == str || (i % 16 != 0)); i++) { - snprintf(p, l - 1, "%02x ", data[i]); - l -= strlen(p); - p += strlen(p); - astr[i % 16] = isprint(data[i]) ? data[i] : '.'; - astr[i % 16] = isprint(data[i]) ? data[i] : '.'; - astr[(i % 16) + 1] = '\0'; - } - dprintf(DS" %-48.48s %s\n", DA, str, astr); - } -} +static device_manager_info *sDeviceManager; static status_t -nor_init_device(void* _info, void** _cookie) +nor_init_device(void *_info, void **_cookie) { TRACE("init_device\n"); - nor_driver_info* info = (nor_driver_info*)_info; + nor_driver_info *info = (nor_driver_info*)_info; info->mapped = NULL; info->blocksize = 128 * 1024; @@ -89,10 +66,10 @@ nor_init_device(void* _info, void** _cookie) static void -nor_uninit_device(void* _cookie) +nor_uninit_device(void *_cookie) { TRACE("uninit_device\n"); - nor_driver_info* info = (nor_driver_info*)_cookie; + nor_driver_info *info = (nor_driver_info*)_cookie; if (info) delete_area(info->id); } @@ -100,7 +77,7 @@ nor_uninit_device(void* _cookie) static status_t nor_open(void *deviceCookie, const char *path, int openMode, - void **_cookie) + void **_cookie) { TRACE("open(%s)\n", path); *_cookie = deviceCookie; @@ -127,11 +104,11 @@ nor_free(void *_cookie) static status_t nor_ioctl(void *cookie, uint32 op, void *buffer, size_t length) { - nor_driver_info* info = (nor_driver_info*)cookie; + nor_driver_info *info = (nor_driver_info*)cookie; TRACE("ioctl(%ld,%lu)\n", op, length); - switch(op) { - case B_GET_GEOMETRY: + switch (op) { + case B_GET_GEOMETRY: { device_geometry *deviceGeometry = (device_geometry*)buffer; deviceGeometry->removable = false; @@ -146,9 +123,10 @@ nor_ioctl(void *cookie, uint32 op, void *buffer, size_t length) return B_OK; } break; - case B_GET_DEVICE_NAME: - strlcpy((char*)buffer, "NORFlash", length); - break; + + case B_GET_DEVICE_NAME: + strlcpy((char*)buffer, "NORFlash", length); + break; } return B_ERROR; @@ -158,7 +136,7 @@ nor_ioctl(void *cookie, uint32 op, void *buffer, size_t length) static status_t nor_read(void *_cookie, off_t position, void *data, size_t *numbytes) { - nor_driver_info* info = (nor_driver_info*)_cookie; + nor_driver_info *info = (nor_driver_info*)_cookie; TRACE("read(%Ld,%lu)\n", position, *numbytes); if (position + *numbytes > info->totalsize) @@ -166,10 +144,6 @@ nor_read(void *_cookie, off_t position, void *data, size_t *numbytes) memcpy(data, info->mapped + position, *numbytes); -#ifdef TRACE_NORFLASH - dump_hex((const char*)(info->mapped + position), *numbytes, 1); -#endif - return B_OK; } @@ -210,7 +184,7 @@ nor_init_driver(device_node *node, void **cookie) { TRACE("init_driver\n"); - nor_driver_info* info = (nor_driver_info*)malloc(sizeof(nor_driver_info)); + nor_driver_info *info = (nor_driver_info*)malloc(sizeof(nor_driver_info)); if (info == NULL) return B_NO_MEMORY; @@ -227,16 +201,16 @@ static void nor_uninit_driver(void *_cookie) { TRACE("uninit_driver\n"); - nor_driver_info* info = (nor_driver_info*)_cookie; + nor_driver_info *info = (nor_driver_info*)_cookie; free(info); } static status_t -nor_register_child_devices(void* _cookie) +nor_register_child_devices(void *_cookie) { TRACE("register_child_devices\n"); - nor_driver_info* info = (nor_driver_info*)_cookie; + nor_driver_info *info = (nor_driver_info*)_cookie; status_t status; status = sDeviceManager->publish_device(info->node, "disk/nor/0/raw", @@ -245,6 +219,7 @@ nor_register_child_devices(void* _cookie) return status; } + struct device_module_info sNORFlashDiskDevice = { { NORFLASH_DEVICE_MODULE_NAME, @@ -286,12 +261,14 @@ struct driver_module_info sNORFlashDiskDriver = { NULL, // removed }; + module_dependency module_dependencies[] = { { B_DEVICE_MANAGER_MODULE_NAME, (module_info**)&sDeviceManager }, { } }; -module_info* modules[] = { + +module_info *modules[] = { (module_info*)&sNORFlashDiskDriver, (module_info*)&sNORFlashDiskDevice, NULL From 7a66f064428420d4c8cf1aea3646bc729bc3c054 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 15:27:19 +0100 Subject: [PATCH 10/32] ARM/libroot: add (l)rintf functions --- src/system/libroot/posix/glibc/arch/arm/Jamfile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/system/libroot/posix/glibc/arch/arm/Jamfile b/src/system/libroot/posix/glibc/arch/arm/Jamfile index 5299ee5cd3..f95f6198f4 100644 --- a/src/system/libroot/posix/glibc/arch/arm/Jamfile +++ b/src/system/libroot/posix/glibc/arch/arm/Jamfile @@ -62,6 +62,7 @@ local genericSources = s_copysign.c s_tanh.c s_lround.c s_lroundf.c s_round.c s_roundf.c + s_rintf.c s_lrintf.c ; MergeObject posix_gnu_arch_$(TARGET_ARCH)_generic.o : From 379aaaab11a8b616f34628464a60dca78fb3e257 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 15:28:01 +0100 Subject: [PATCH 11/32] ARM/libroot: small workaround for crash The whole system_time support will have to be revisited anyhow, since the only base we have for timing is SoC specific, not ARM core specific :( --- src/system/libroot/os/arch/arm/system_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/libroot/os/arch/arm/system_time.c b/src/system/libroot/os/arch/arm/system_time.c index 6514ae92e4..bef6175a18 100644 --- a/src/system/libroot/os/arch/arm/system_time.c +++ b/src/system/libroot/os/arch/arm/system_time.c @@ -35,6 +35,6 @@ system_time(void) { uint64 timeBase = __arm_get_time_base(); - uint32 cv = *sConversionFactor; + uint32 cv = sConversionFactor ? *sConversionFactor : 0; return (timeBase >> 32) * cv + (((timeBase & 0xffffffff) * cv) >> 32); } From 0495c9313a10f57f0018ef752b56e59d32fecda5 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 23:53:24 +0100 Subject: [PATCH 12/32] ARM/libroot: last missing bits-n-pieces to get a full image built --- src/system/libroot/posix/glibc/arch/arm/Jamfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/system/libroot/posix/glibc/arch/arm/Jamfile b/src/system/libroot/posix/glibc/arch/arm/Jamfile index f95f6198f4..034ad45bf8 100644 --- a/src/system/libroot/posix/glibc/arch/arm/Jamfile +++ b/src/system/libroot/posix/glibc/arch/arm/Jamfile @@ -37,6 +37,7 @@ local genericSources = s_floor.c s_floorf.c s_ceil.c s_ceilf.c s_modf.c + w_powf.c e_powf.c w_pow.c e_pow.c slowpow.c w_exp.c e_exp.c slowexp.c s_frexp.c s_expm1.c @@ -47,7 +48,7 @@ local genericSources = halfulp.c mpa.c mplog.c mpexp.c s_sin.c - s_atan.c + s_atan.c s_atanf.c s_tan.c e_asin.c w_asin.c e_log10.c w_log10.c @@ -57,12 +58,19 @@ local genericSources = e_log.c w_log.c e_cosh.c w_cosh.c e_sinh.c w_sinh.c + s_cosf.c k_cosf.c + s_sinf.c k_sinf.c s_ldexp.c s_ldexpf.c s_scalbnf.c s_scalbn.c s_copysign.c - s_tanh.c + s_tanh.c s_tanf.c k_tanf.c s_lround.c s_lroundf.c s_round.c s_roundf.c - s_rintf.c s_lrintf.c + s_rint.c s_rintf.c s_lrintf.c + e_fmodf.c w_fmodf.c + e_atan2f.c w_atan2f.c + e_rem_pio2f.c k_rem_pio2f.c + + memrchr.c ; MergeObject posix_gnu_arch_$(TARGET_ARCH)_generic.o : From 8b33059d8c7bb0778908377ccfd82608d24bf124 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 23:54:13 +0100 Subject: [PATCH 13/32] ARM/libroot: fixup string functions --- src/system/libroot/posix/string/arch/arm/Jamfile | 2 +- src/system/libroot/posix/string/arch/arm/arch_string.S | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/system/libroot/posix/string/arch/arm/Jamfile b/src/system/libroot/posix/string/arch/arm/Jamfile index 6d67684cff..7146ba3e65 100644 --- a/src/system/libroot/posix/string/arch/arm/Jamfile +++ b/src/system/libroot/posix/string/arch/arm/Jamfile @@ -5,6 +5,6 @@ UsePrivateSystemHeaders ; SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; MergeObject posix_string_arch_$(TARGET_ARCH).o : - memcpy.c + arch_string.S memset.c ; diff --git a/src/system/libroot/posix/string/arch/arm/arch_string.S b/src/system/libroot/posix/string/arch/arm/arch_string.S index 88e1bfa4af..5826ce9dea 100644 --- a/src/system/libroot/posix/string/arch/arm/arch_string.S +++ b/src/system/libroot/posix/string/arch/arm/arch_string.S @@ -5,7 +5,6 @@ #include -//#warning M68K: optimize memcpy #if 1 /* that should be enough for now */ From c59d7b390fd3baebab90265f7f9edc50389ffe29 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 23:56:05 +0100 Subject: [PATCH 14/32] ARM: add optional packages --- build/jam/OptionalBuildFeatures | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/build/jam/OptionalBuildFeatures b/build/jam/OptionalBuildFeatures index f83c2e76a9..4a13618df9 100644 --- a/build/jam/OptionalBuildFeatures +++ b/build/jam/OptionalBuildFeatures @@ -69,7 +69,7 @@ if $(HAIKU_BUILD_FEATURE_SSL) { HAIKU_ICU_GCC_2_PACKAGE = icu-4.8.1.1-r1a4-x86-gcc2-2012-08-29.zip ; HAIKU_ICU_GCC_4_PACKAGE = icu-4.8.1.1-r1a4-x86-gcc4-2012-08-29.zip ; HAIKU_ICU_PPC_PACKAGE = icu-4.8.1-ppc-2011-08-20.zip ; -HAIKU_ICU_ARM_PACKAGE = icu-4.8.1.1-arm-2012-11-16.zip ; +HAIKU_ICU_ARM_PACKAGE = icu-4.8.1.1-arm-2012-11-21.zip ; HAIKU_ICU_X86_64_PACKAGE = icu-4.8.1.1-x86_64-2012-07-30.zip ; if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = arm || $(TARGET_ARCH) = x86_64 { @@ -79,7 +79,7 @@ if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = arm || $(TAR HAIKU_ICU_DEVEL_PACKAGE = icu-devel-4.8.1-ppc-2011-12-19.zip ; } else if $(TARGET_ARCH) = arm { icu_package = $(HAIKU_ICU_ARM_PACKAGE) ; - HAIKU_ICU_DEVEL_PACKAGE = icu-devel-4.8.1.1-arm-2012-11-16.zip ; + HAIKU_ICU_DEVEL_PACKAGE = icu-devel-4.8.1.1-arm-2012-11-21.zip ; } else if $(TARGET_ARCH) = x86_64 { icu_package = $(HAIKU_ICU_X86_64_PACKAGE) ; HAIKU_ICU_DEVEL_PACKAGE = icu-devel-4.8.1.1-x86_64-2012-07-30.zip ; @@ -408,8 +408,10 @@ if $(TARGET_ARCH) = x86 { # Freetype local freetypeBaseURL = $(baseURL)/lib ; -if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { - if $(TARGET_ARCH) = ppc { +if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 || $(TARGET_ARCH) = arm { + if $(TARGET_ARCH) = arm { + HAIKU_FREETYPE_FILE = freetype-2.4.9-arm-2012-11-21.zip ; + } else if $(TARGET_ARCH) = ppc { HAIKU_FREETYPE_FILE = freetype-2.4.9-ppc-gcc4-2012-06-26.zip ; } else if $(TARGET_ARCH) = x86_64 { HAIKU_FREETYPE_FILE = freetype-2.4.9-x86_64-2012-08-04.zip ; @@ -538,8 +540,10 @@ if $(HAIKU_BUILD_FEATURE_WEBKIT) { # libpng local libpngBaseURL = $(baseURL)/lib ; -if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { - if $(TARGET_ARCH) = ppc { +if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 || $(TARGET_ARCH) = arm { + if $(TARGET_ARCH) = arm { + HAIKU_LIBPNG_FILE = libpng-1.5.12-arm-2012-11-21.zip ; + } else if $(TARGET_ARCH) = ppc { HAIKU_LIBPNG_FILE = libpng-1.5.12-ppc-gcc4-2012-08-27.zip ; } else if $(TARGET_ARCH) = x86_64 { HAIKU_LIBPNG_FILE = libpng-1.5.12-x86_64-2012-11-18.zip ; @@ -580,8 +584,10 @@ if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { # jpeg local jpegBaseURL = $(baseURL)/lib ; -if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { - if $(TARGET_ARCH) = ppc { +if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 || $(TARGET_ARCH) = arm { + if $(TARGET_ARCH) = arm { + HAIKU_JPEG_FILE = jpeg-8d-arm-2012-11-21.zip ; + } else if $(TARGET_ARCH) = ppc { HAIKU_JPEG_FILE = jpeg-8d-ppc-gcc4-2012-08-27.zip ; } else if $(TARGET_ARCH) = x86_64 { HAIKU_JPEG_FILE = jpeg-8d-x86_64-2012-11-18.zip ; @@ -622,8 +628,10 @@ if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { # zlib local zlibBaseURL = $(baseURL)/lib ; -if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 { - if $(TARGET_ARCH) = ppc { +if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = x86_64 || $(TARGET_ARCH) = arm { + if $(TARGET_ARCH) = arm { + HAIKU_ZLIB_FILE = zlib-1.2.7-arm-2012-11-21.zip ; + } else if $(TARGET_ARCH) = ppc { HAIKU_ZLIB_FILE = zlib-1.2.7-ppc-gcc4-2012-10-30.zip ; } else if $(TARGET_ARCH) = x86_64 { HAIKU_ZLIB_FILE = zlib-1.2.7-x86_64-2012-11-18.zip ; From 39b546702c2cbfa7ff253f543a5dbc12fd98bbc5 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 23:56:56 +0100 Subject: [PATCH 15/32] ARM: fixup header comment --- headers/private/system/arch/arm/arch_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headers/private/system/arch/arm/arch_config.h b/headers/private/system/arch/arm/arch_config.h index a4f3ca740a..409f58dfc0 100644 --- a/headers/private/system/arch/arm/arch_config.h +++ b/headers/private/system/arch/arm/arch_config.h @@ -14,4 +14,4 @@ //#define ATOMIC64_FUNCS_ARE_SYSCALLS -#endif /* _KERNEL_ARCH_M68K_CONFIG_H */ +#endif /* _KERNEL_ARCH_ARM_CONFIG_H */ From e25f9cbb24d84936f0e89abbe7c0687f7f11316d Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 23:57:52 +0100 Subject: [PATCH 16/32] ARM: add ISA support code --- .../kernel/bus_managers/isa/arch/arm/Jamfile | 12 +++ .../isa/arch/arm/isa_controller.c | 84 +++++++++++++++++++ .../bus_managers/isa/arch/arm/isa_dma.c | 25 ++++++ 3 files changed, 121 insertions(+) create mode 100644 src/add-ons/kernel/bus_managers/isa/arch/arm/Jamfile create mode 100644 src/add-ons/kernel/bus_managers/isa/arch/arm/isa_controller.c create mode 100644 src/add-ons/kernel/bus_managers/isa/arch/arm/isa_dma.c diff --git a/src/add-ons/kernel/bus_managers/isa/arch/arm/Jamfile b/src/add-ons/kernel/bus_managers/isa/arch/arm/Jamfile new file mode 100644 index 0000000000..12a6b4a5d1 --- /dev/null +++ b/src/add-ons/kernel/bus_managers/isa/arch/arm/Jamfile @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src add-ons kernel bus_managers isa arch arm ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; + +UsePrivateHeaders kernel [ FDirName kernel arch arm ] ; +UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; + +KernelStaticLibrary isa_arch_bus_manager : + isa_dma.c + isa_controller.c + ; + diff --git a/src/add-ons/kernel/bus_managers/isa/arch/arm/isa_controller.c b/src/add-ons/kernel/bus_managers/isa/arch/arm/isa_controller.c new file mode 100644 index 0000000000..6efd553c7c --- /dev/null +++ b/src/add-ons/kernel/bus_managers/isa/arch/arm/isa_controller.c @@ -0,0 +1,84 @@ +/* + * Copyright 2007 Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * arch-specific config manager + * + * Authors (in chronological order): + * François Revol (revol@free.fr) + */ + +#include +#include "ISA.h" +#include "arch_cpu.h" +#include "isa_arch.h" + +//#define TRACE_ISA +#ifdef TRACE_ISA +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +uint8 +arch_isa_read_io_8(int mapped_io_addr) +{ + uint8 value = in8(mapped_io_addr); + + TRACE(("isa_read8(%x->%x)\n", mapped_io_addr, value)); + + return value; +} + + +void +arch_isa_write_io_8(int mapped_io_addr, uint8 value) +{ + TRACE(("isa_write8(%x->%x)\n", value, mapped_io_addr)); + + out8(value, mapped_io_addr); +} + + +uint16 +arch_isa_read_io_16(int mapped_io_addr) +{ + return in16(mapped_io_addr); +} + + +void +arch_isa_write_io_16(int mapped_io_addr, uint16 value) +{ + out16(value, mapped_io_addr); +} + + +uint32 +arch_isa_read_io_32(int mapped_io_addr) +{ + return in32(mapped_io_addr); +} + + +void +arch_isa_write_io_32(int mapped_io_addr, uint32 value) +{ + out32(value, mapped_io_addr); +} + + +void * +arch_isa_ram_address(const void *physical_address_in_system_memory) +{ + // this is what the BeOS kernel does + return (void *)physical_address_in_system_memory; +} + + +status_t +arch_isa_init(void) +{ + return B_OK; +} diff --git a/src/add-ons/kernel/bus_managers/isa/arch/arm/isa_dma.c b/src/add-ons/kernel/bus_managers/isa/arch/arm/isa_dma.c new file mode 100644 index 0000000000..50bc63af6c --- /dev/null +++ b/src/add-ons/kernel/bus_managers/isa/arch/arm/isa_dma.c @@ -0,0 +1,25 @@ +/* + * Copyright 2007 Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * arch-specific config manager + * + * Authors (in chronological order): + * François Revol (revol@free.fr) + */ + +#include +#include "ISA.h" +#include "arch_cpu.h" +#include "isa_arch.h" + + +status_t +arch_start_isa_dma(long channel, void *buf, long transfer_count, + uchar mode, uchar e_mode) +{ + // ToDo: implement this?! + return B_NOT_ALLOWED; +} + + From 8f6bf9abf63cca0e6de1c3062e222e5eecfa1313 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Wed, 21 Nov 2012 23:58:34 +0100 Subject: [PATCH 17/32] ARM: create CPU addon Jamfile --- src/add-ons/kernel/cpu/arm/Jamfile | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/add-ons/kernel/cpu/arm/Jamfile diff --git a/src/add-ons/kernel/cpu/arm/Jamfile b/src/add-ons/kernel/cpu/arm/Jamfile new file mode 100644 index 0000000000..22527f7a1b --- /dev/null +++ b/src/add-ons/kernel/cpu/arm/Jamfile @@ -0,0 +1,2 @@ +SubDir HAIKU_TOP src add-ons kernel cpu arm ; + From 6656d950c41db92e80beadcba718fa277c0817a7 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 21 Nov 2012 23:40:20 -0500 Subject: [PATCH 18/32] Fix extraneous semicolon. --- src/apps/debugger/controllers/DebugReportGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index 30dd8d84c3..1173978158 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -71,7 +71,7 @@ DebugReportGenerator::GenerateReport(const entry_ref& outputPath) BString output; result = _GenerateReportHeader(output); - if (result != B_OK); + if (result != B_OK) return result; result = _DumpLoadedImages(output); From f20eea8ca91a5c2b1c69e5f2fbabad8f2d8be42b Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 00:05:30 -0500 Subject: [PATCH 19/32] Fix various parameter errors and improve output formatting. --- .../controllers/DebugReportGenerator.cpp | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index 1173978158..8322326e73 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -96,7 +96,8 @@ DebugReportGenerator::_GenerateReportHeader(BString& _output) AutoLocker locker(fTeam); BString data; - data.SetToFormat("Debug information for team %s (%" B_PRId32 "):\n\n"); + data.SetToFormat("Debug information for team %s (%" B_PRId32 "):\n", + fTeam->Name(), fTeam->ID()); _output << data; return B_OK; @@ -108,6 +109,7 @@ DebugReportGenerator::_DumpLoadedImages(BString& _output) { AutoLocker locker(fTeam); + _output << "\nLoaded Images:\n"; BString data; for (ImageList::ConstIterator it = fTeam->Images().GetIterator(); Image* image = it.Next();) { @@ -134,15 +136,17 @@ DebugReportGenerator::_DumpRunningThreads(BString& _output) { AutoLocker locker(fTeam); + _output << "\nActive Threads:\n"; BString data; status_t result = B_OK; for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator(); Thread* thread = it.Next();) { try { - data.SetToFormat("\t%s %s, id: %" B_PRId32", state: %" B_PRId32 - "\n", thread->Name(), thread->IsMainThread() - ? "(main)" : "", UiUtils::ThreadStateToString( - thread->State(), thread->StoppedReason())); + data.SetToFormat("\t%s %s, id: %" B_PRId32", state: %s\n", + thread->Name(), thread->IsMainThread() + ? "(main)" : "", thread->ID(), + UiUtils::ThreadStateToString(thread->State(), + thread->StoppedReason())); _output << data; @@ -168,10 +172,12 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BString& _output, Thread* thread) if (trace == NULL) return B_OK; + _output << "\t\tFrame\t\tIP\t\t\tFunction Name\n"; + _output << "\t\t-----------------------------------------------\n"; BString data; for (int32 i = 0; StackFrame* frame = trace->FrameAt(i); i++) { char functionName[512]; - data.SetToFormat("0x%" B_PRIx64 "\t0x%" B_PRIx64 "\t%s\n", + data.SetToFormat("\t\t0x%08" B_PRIx64 "\t0x%08" B_PRIx64 "\t%s\n", frame->FrameAddress(), frame->InstructionPointer(), UiUtils::FunctionNameForFrame(frame, functionName, sizeof(functionName))); @@ -179,16 +185,17 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BString& _output, Thread* thread) _output << data; } - _output << "\nRegisters:\n\n"; + _output << "\n\t\tRegisters:\n"; CpuState* state = thread->GetCpuState(); BVariant value; + const Register* reg = NULL; for (int32 i = 0; i < fArchitecture->CountRegisters(); i++) { - const Register* reg = fArchitecture->Registers() + i; + reg = fArchitecture->Registers() + i; state->GetRegisterValue(reg, value); char buffer[64]; - data.SetToFormat("%s\t%0x%s\n", reg->Name(), + data.SetToFormat("\t\t\t%5s:\t%s\n", reg->Name(), UiUtils::VariantToString(value, buffer, sizeof(buffer))); _output << data; } From 37ddff87ec1e472d4ec6ca9863d41a01f5347037 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 00:21:18 -0500 Subject: [PATCH 20/32] Add option to save a debug information report. - The Tools menu now contains an option to save a debug report for the currently debugged team. For now this report contains the following: A list of all loaded images, their base address and their size. A list of all threads active in their team, and their state. * For each thread that is in a debug or exception state, a stack trace, and a register dump at the top frame will also be emitted. Feedback on report format + included details welcome. For now, when the option is requested, the report is saved to the desktop with an auto-generated name based on the target team and the current date/time. --- .../gui/team_window/TeamWindow.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 9042ff3e16..3560d07fd9 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include #include @@ -215,6 +217,32 @@ void TeamWindow::MessageReceived(BMessage* message) { switch (message->what) { + case MSG_GENERATE_DEBUG_REPORT: + { + try { + BPath path; + BPath teamPath(fTeam->Name()); + find_directory(B_DESKTOP_DIRECTORY, &path); + BDateTime currentTime; + currentTime.SetTime_t(time(NULL)); + BString filename; + filename.SetToFormat("%s-%" B_PRId32 "-debug-%02" + B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02" + B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 ".report", + teamPath.Leaf(), fTeam->ID(), currentTime.Date().Day(), + currentTime.Date().Month(), currentTime.Date().Year(), + currentTime.Time().Hour(), currentTime.Time().Minute(), + currentTime.Time().Second()); + path.Append(filename); + entry_ref ref; + status_t result = get_ref_for_path(path.Path(), &ref); + if (result == B_OK) + fListener->DebugReportRequested(&ref); + } catch (...) { + // TODO: notify user + } + break; + } case MSG_SHOW_INSPECTOR_WINDOW: { if (fInspectorWindow) { @@ -799,6 +827,10 @@ TeamWindow::_Init() item->SetTarget(this); menu = new BMenu("Tools"); fMenuBar->AddItem(menu); + item = new BMenuItem("Save Debug Report", + new BMessage(MSG_GENERATE_DEBUG_REPORT)); + menu->AddItem(item); + item->SetTarget(this); item = new BMenuItem("Inspect Memory", new BMessage(MSG_SHOW_INSPECTOR_WINDOW), 'I'); menu->AddItem(item); From 3d09339dddca2a6ab1959dba7c0c127b572297f8 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 10:56:26 -0500 Subject: [PATCH 21/32] Added convenience formatting function for image types. --- .../debugger/user_interface/util/UiUtils.cpp | 25 +++++++++++++++++++ .../debugger/user_interface/util/UiUtils.h | 6 +++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp b/src/apps/debugger/user_interface/util/UiUtils.cpp index 4c955c40af..539e069926 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.cpp +++ b/src/apps/debugger/user_interface/util/UiUtils.cpp @@ -109,3 +109,28 @@ UiUtils::FunctionNameForFrame(StackFrame* frame, char* buffer, return buffer; } + + +/*static*/ const char* +UiUtils::ImageTypeToString(image_type type, char* buffer, size_t bufferSize) +{ + switch (type) { + case B_APP_IMAGE: + snprintf(buffer, bufferSize, "Application"); + break; + case B_LIBRARY_IMAGE: + snprintf(buffer, bufferSize, "Library"); + break; + case B_ADD_ON_IMAGE: + snprintf(buffer, bufferSize, "Add-on"); + break; + case B_SYSTEM_IMAGE: + snprintf(buffer, bufferSize, "System"); + break; + default: + snprintf(buffer, bufferSize, "Unknown"); + break; + } + + return buffer; +} diff --git a/src/apps/debugger/user_interface/util/UiUtils.h b/src/apps/debugger/user_interface/util/UiUtils.h index 8ac0743816..4415754e35 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.h +++ b/src/apps/debugger/user_interface/util/UiUtils.h @@ -7,11 +7,11 @@ #include - -class StackFrame; +#include class BVariant; +class StackFrame; class UiUtils { @@ -23,6 +23,8 @@ public: char* buffer, size_t bufferSize); static const char* FunctionNameForFrame(StackFrame* frame, char* buffer, size_t bufferSize); + static const char* ImageTypeToString(image_type type, + char* buffer, size_t bufferSize); }; From 19ea0235be12d9cc271e29832a8a00abe56a89fe Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 10:57:11 -0500 Subject: [PATCH 22/32] Formatting tweaks to loaded image output. --- .../controllers/DebugReportGenerator.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index 8322326e73..ab29467b6f 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -114,12 +114,18 @@ DebugReportGenerator::_DumpLoadedImages(BString& _output) for (ImageList::ConstIterator it = fTeam->Images().GetIterator(); Image* image = it.Next();) { const ImageInfo& info = image->Info(); + char buffer[32]; try { - data.SetToFormat("\t%s, id: %" B_PRId32", type: %" B_PRId32 ", " - "Text: 0x%" B_PRIx64 ", %" B_PRIu64 " bytes, Data: 0x%" - B_PRIx64 ", %" B_PRIu64 " bytes\n", info.Name().String(), - info.ImageID(), info.Type(), info.TextBase(), info.TextSize(), - info.DataBase(), info.DataSize()); + target_addr_t textBase = info.TextBase(); + target_addr_t dataBase = info.DataBase(); + + data.SetToFormat("\t%s (%" B_PRId32 ", %s) " + "Text: 0x%08" B_PRIx64 " - 0x%08" B_PRIx64 ", Data: 0x%08" + B_PRIx64 " - 0x%08" B_PRIx64 "\n", info.Name().String(), + info.ImageID(), UiUtils::ImageTypeToString(info.Type(), + buffer, sizeof(buffer)), textBase, + textBase + info.TextSize(), dataBase, + dataBase + info.DataSize()); _output << data; } catch (...) { From 2bf866783ca42ba86a7acde1445d3d2a8f9b1dd6 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 11:44:20 -0500 Subject: [PATCH 23/32] Cleanups. --- .../controllers/DebugReportGenerator.cpp | 6 ++--- .../cli/CliStackTraceCommand.cpp | 25 ++++--------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index ab29467b6f..254f0b8de2 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -120,8 +120,8 @@ DebugReportGenerator::_DumpLoadedImages(BString& _output) target_addr_t dataBase = info.DataBase(); data.SetToFormat("\t%s (%" B_PRId32 ", %s) " - "Text: 0x%08" B_PRIx64 " - 0x%08" B_PRIx64 ", Data: 0x%08" - B_PRIx64 " - 0x%08" B_PRIx64 "\n", info.Name().String(), + "Text: %#08" B_PRIx64 " - %#08" B_PRIx64 ", Data: %#08" + B_PRIx64 " - %#08" B_PRIx64 "\n", info.Name().String(), info.ImageID(), UiUtils::ImageTypeToString(info.Type(), buffer, sizeof(buffer)), textBase, textBase + info.TextSize(), dataBase, @@ -183,7 +183,7 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BString& _output, Thread* thread) BString data; for (int32 i = 0; StackFrame* frame = trace->FrameAt(i); i++) { char functionName[512]; - data.SetToFormat("\t\t0x%08" B_PRIx64 "\t0x%08" B_PRIx64 "\t%s\n", + data.SetToFormat("\t\t%#08" B_PRIx64 "\t%#08" B_PRIx64 "\t%s\n", frame->FrameAddress(), frame->InstructionPointer(), UiUtils::FunctionNameForFrame(frame, functionName, sizeof(functionName))); diff --git a/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp b/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp index 5b5b2e168e..9e7f0330a6 100644 --- a/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp +++ b/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp @@ -11,9 +11,9 @@ #include #include "CliContext.h" -#include "FunctionInstance.h" #include "StackTrace.h" #include "Team.h" +#include "UiUtils.h" CliStackTraceCommand::CliStackTraceCommand() @@ -63,24 +63,9 @@ CliStackTraceCommand::Execute(int argc, const char* const* argv, printf("%3" B_PRId32 " %#" B_PRIx64 " %#" B_PRIx64, i, (uint64)frame->FrameAddress(), (uint64)frame->InstructionPointer()); - Image* image = frame->GetImage(); - FunctionInstance* function = frame->Function(); - if (image == NULL && function == NULL) { - printf(" ???\n"); - continue; - } - - BString name; - target_addr_t baseAddress; - if (function != NULL) { - name = function->PrettyName(); - baseAddress = function->Address(); - } else { - name = image->Name(); - baseAddress = image->Info().TextBase(); - } - - printf(" %s + %#" B_PRIx64 "\n", name.String(), - uint64(frame->InstructionPointer() - baseAddress)); + char functionName[512]; + UiUtils::FunctionNameForFrame(frame, functionName, + sizeof(functionName)); + printf(" %s\n", functionName); } } From ba71ae755234e05c8a3b8563a680ad487e75aa45 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 12:07:47 -0500 Subject: [PATCH 24/32] Prompt user for location to save report to. --- .../gui/team_window/TeamWindow.cpp | 50 ++++++++++++------- .../gui/team_window/TeamWindow.h | 2 +- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 3560d07fd9..1c50a88ef0 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -56,6 +56,7 @@ enum { enum { + MSG_CHOOSE_DEBUG_REPORT_LOCATION = 'ccrl', MSG_LOCATE_SOURCE_IF_NEEDED = 'lsin' }; @@ -113,7 +114,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener) fStepIntoButton(NULL), fStepOutButton(NULL), fInspectorWindow(NULL), - fSourceLocatePanel(NULL) + fFilePanel(NULL) { fTeam->Lock(); BString name = fTeam->Name(); @@ -145,7 +146,7 @@ TeamWindow::~TeamWindow() _SetActiveImage(NULL); _SetActiveThread(NULL); - delete fSourceLocatePanel; + delete fFilePanel; } @@ -217,12 +218,10 @@ void TeamWindow::MessageReceived(BMessage* message) { switch (message->what) { - case MSG_GENERATE_DEBUG_REPORT: + case MSG_CHOOSE_DEBUG_REPORT_LOCATION: { try { - BPath path; BPath teamPath(fTeam->Name()); - find_directory(B_DESKTOP_DIRECTORY, &path); BDateTime currentTime; currentTime.SetTime_t(time(NULL)); BString filename; @@ -233,13 +232,30 @@ TeamWindow::MessageReceived(BMessage* message) currentTime.Date().Month(), currentTime.Date().Year(), currentTime.Time().Hour(), currentTime.Time().Minute(), currentTime.Time().Second()); - path.Append(filename); - entry_ref ref; - status_t result = get_ref_for_path(path.Path(), &ref); - if (result == B_OK) - fListener->DebugReportRequested(&ref); + BMessenger msgr(this); + fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr, + NULL, 0, false, new BMessage(MSG_GENERATE_DEBUG_REPORT)); + fFilePanel->SetSaveText(filename.String()); + fFilePanel->Show(); } catch (...) { - // TODO: notify user + delete fFilePanel; + fFilePanel = NULL; + } + break; + } + case MSG_GENERATE_DEBUG_REPORT: + { + delete fFilePanel; + fFilePanel = NULL; + + BPath path; + entry_ref ref; + if (message->FindRef("directory", &ref) == B_OK + && message->HasString("name")) { + path.SetTo(&ref); + path.Append(message->FindString("name")); + if (get_ref_for_path(path.Path(), &ref) == B_OK) + fListener->DebugReportRequested(&ref); } break; } @@ -312,14 +328,14 @@ TeamWindow::MessageReceived(BMessage* message) ->SourceFile() != NULL && fActiveSourceCode != NULL && fActiveSourceCode->GetSourceFile() == NULL) { try { - if (fSourceLocatePanel == NULL) { - fSourceLocatePanel = new BFilePanel(B_OPEN_PANEL, + if (fFilePanel == NULL) { + fFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this)); } - fSourceLocatePanel->Show(); + fFilePanel->Show(); } catch (...) { - delete fSourceLocatePanel; - fSourceLocatePanel = NULL; + delete fFilePanel; + fFilePanel = NULL; } } break; @@ -828,7 +844,7 @@ TeamWindow::_Init() menu = new BMenu("Tools"); fMenuBar->AddItem(menu); item = new BMenuItem("Save Debug Report", - new BMessage(MSG_GENERATE_DEBUG_REPORT)); + new BMessage(MSG_CHOOSE_DEBUG_REPORT_LOCATION)); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Inspect Memory", diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h index d371a5b694..5821b2c734 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h @@ -193,7 +193,7 @@ private: BSplitView* fThreadSplitView; InspectorWindow* fInspectorWindow; GuiTeamUiSettings fUiSettings; - BFilePanel* fSourceLocatePanel; + BFilePanel* fFilePanel; }; From b190a54c4046dd230f5ae19ad4fa86cf3d1dc4fc Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Thu, 22 Nov 2012 14:20:57 +0100 Subject: [PATCH 25/32] activitymonitor: remove B_MAX_CPU_COUNT reference It has no use, since we don't know its value and the list of colors might be longer (for example, for ARM currently B_MAX_CPU_COUNT is only 1). The modula operator later on makes sure we keep within the bounds of the kColors array anyway. --- src/apps/activitymonitor/DataSource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/activitymonitor/DataSource.cpp b/src/apps/activitymonitor/DataSource.cpp index 644bf69988..43ea62d233 100644 --- a/src/apps/activitymonitor/DataSource.cpp +++ b/src/apps/activitymonitor/DataSource.cpp @@ -949,7 +949,7 @@ CPUUsageDataSource::_SetCPU(int32 cpu) fLabel << " " << B_TRANSLATE("usage"); - const rgb_color kColors[B_MAX_CPU_COUNT] = { + const rgb_color kColors[] = { // TODO: find some better defaults... {200, 0, 200}, {0, 200, 200}, From 2beda3bb5be8191b672688bed7ddcadd2b17dc41 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Thu, 22 Nov 2012 15:44:20 +0100 Subject: [PATCH 26/32] ARM/runtime_loader: add stub to make it compile --- src/system/ldscripts/arm/runtime_loader.ld | 68 +++++++++++++++++++ src/system/runtime_loader/arch/arm/Jamfile | 16 +++++ .../runtime_loader/arch/arm/arch_relocate.cpp | 32 +++++++++ 3 files changed, 116 insertions(+) create mode 100644 src/system/ldscripts/arm/runtime_loader.ld create mode 100644 src/system/runtime_loader/arch/arm/Jamfile create mode 100644 src/system/runtime_loader/arch/arm/arch_relocate.cpp diff --git a/src/system/ldscripts/arm/runtime_loader.ld b/src/system/ldscripts/arm/runtime_loader.ld new file mode 100644 index 0000000000..dfe708c3f0 --- /dev/null +++ b/src/system/ldscripts/arm/runtime_loader.ld @@ -0,0 +1,68 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +ENTRY(runtime_loader) +SEARCH_DIR("libgcc"); +SECTIONS +{ + . = 0x00100000 + SIZEOF_HEADERS; + + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } =0x9090 + .plt : { *(.plt) } + + /* text/read-only data */ + .text : { *(.text .gnu.linkonce.t.*) } + + .rodata : { *(.rodata) } + + /* exception unwinding - should really not be needed! XXX: find the correct place. */ + __exidx_start = .; + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + __exidx_end = .; + + /* writable data */ + . = ALIGN(0x1000) + (. & (0x1000 - 1)); + __data_start = .; + PROVIDE(_data_start = .); + .data : { *(.data .gnu.linkonce.d.*) } + + __ctor_list = .; + PROVIDE (_ctor_list = .); + .ctors : { *(.ctors) } + PROVIDE (__ctor_end = .); + + + /* uninitialized data (in same segment as writable data) */ + PROVIDE (__bss_start = .); + .bss : { *(.bss) } + + . = ALIGN(0x1000); + PROVIDE (_end = .); + + /* Strip unnecessary stuff */ + /DISCARD/ : { *(.comment .note .eh_frame .dtors) } +} diff --git a/src/system/runtime_loader/arch/arm/Jamfile b/src/system/runtime_loader/arch/arm/Jamfile new file mode 100644 index 0000000000..23bb1bd8d6 --- /dev/null +++ b/src/system/runtime_loader/arch/arm/Jamfile @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src system runtime_loader arch arm ; + +UsePrivateHeaders runtime_loader ; +UsePrivateSystemHeaders ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ; + +StaticLibrary libruntime_loader_$(TARGET_ARCH).a : + arch_relocate.cpp + : + atomic.o + thread.o + + arch_string.o + memset.o +; diff --git a/src/system/runtime_loader/arch/arm/arch_relocate.cpp b/src/system/runtime_loader/arch/arm/arch_relocate.cpp new file mode 100644 index 0000000000..2e849b039e --- /dev/null +++ b/src/system/runtime_loader/arch/arm/arch_relocate.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2012, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + +#include +#include +#include + +#include "runtime_loader_private.h" + +#include + +//#define TRACE_RLD +#ifdef TRACE_RLD +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + +void *__dso_handle; + +status_t +arch_relocate_image(image_t *rootImage, image_t *image, + SymbolLookupCache* cache) +{ + debugger("arch_relocate_image: Not Yet Implemented!"); + return B_OK; +} From 79a34d6fc6969dea0ed5a2805dfd589ba7b7ea31 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Thu, 22 Nov 2012 15:45:38 +0100 Subject: [PATCH 27/32] ARM/debug: add ARM stubs --- .../debug/arch/arm/arch_debug_support.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/kits/debug/arch/arm/arch_debug_support.cpp diff --git a/src/kits/debug/arch/arm/arch_debug_support.cpp b/src/kits/debug/arch/arm/arch_debug_support.cpp new file mode 100644 index 0000000000..ee287bb6e4 --- /dev/null +++ b/src/kits/debug/arch/arm/arch_debug_support.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2012, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ithamar R. Adema + */ + + +#include + +#include "arch_debug_support.h" + +status_t +arch_debug_get_instruction_pointer(debug_context *context, thread_id thread, + void **ip, void **stackFrameAddress) +{ + return B_ERROR; +} + + +status_t +arch_debug_get_stack_frame(debug_context *context, void *stackFrameAddress, + debug_stack_frame_info *stackFrameInfo) +{ + return B_ERROR; +} From 99d027cd0238c1d86da86d7c3f4200509ccc61a6 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Thu, 22 Nov 2012 15:46:41 +0100 Subject: [PATCH 28/32] ARM/ltrace: add stubs --- src/bin/debug/ltrace/arch/arm/Jamfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/bin/debug/ltrace/arch/arm/Jamfile diff --git a/src/bin/debug/ltrace/arch/arm/Jamfile b/src/bin/debug/ltrace/arch/arm/Jamfile new file mode 100644 index 0000000000..e70e54c73f --- /dev/null +++ b/src/bin/debug/ltrace/arch/arm/Jamfile @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src bin debug ltrace arch arm ; + +# TODO: Implement! From 0f16abe379ce45cd0ecfec28cd2862499304db60 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Thu, 22 Nov 2012 21:30:54 +0100 Subject: [PATCH 29/32] Update todo notes --- docs/develop/ports/arm/todo.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/develop/ports/arm/todo.txt b/docs/develop/ports/arm/todo.txt index 17cc54bf21..e49b6c8aa5 100644 --- a/docs/develop/ports/arm/todo.txt +++ b/docs/develop/ports/arm/todo.txt @@ -16,6 +16,8 @@ * Research stack unwinding to implement backtrace support for KDL & friends. +* B_MAX_CPU_COUNT should be fixed to be a more sensible future-proof value then 1 + * Add KDL hangman to the boot floppy image for more enjoyment during porting.... * Userland........... From 53a59cd99a876a158c480989e9787757ef7a28ed Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Thu, 22 Nov 2012 22:58:24 +0100 Subject: [PATCH 30/32] Fix minor typo --- headers/private/graphics/nvidia/DriverInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headers/private/graphics/nvidia/DriverInterface.h b/headers/private/graphics/nvidia/DriverInterface.h index c50bf205ab..a6360af3e4 100644 --- a/headers/private/graphics/nvidia/DriverInterface.h +++ b/headers/private/graphics/nvidia/DriverInterface.h @@ -56,7 +56,7 @@ typedef struct { #define DUALHEAD_BITS (3<<6) #define DUALHEAD_CAPABLE (1<<8) #define TV_BITS (3<<9) -#define TV_MON (0<<9 +#define TV_MON (0<<9) #define TV_PAL (1<<9) #define TV_NTSC (2<<9) #define TV_CAPABLE (1<<11) From 53342f94c969443d6877b2b0bbfe35f4d7fb2d23 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 23:41:11 -0500 Subject: [PATCH 31/32] Factor out report name generation as a utility function. --- .../gui/team_window/TeamWindow.cpp | 17 ++++---------- .../debugger/user_interface/util/UiUtils.cpp | 22 +++++++++++++++++++ .../debugger/user_interface/util/UiUtils.h | 4 ++++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 1c50a88ef0..869d9ff523 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -44,6 +43,7 @@ #include "StackTraceView.h" #include "Tracing.h" #include "TypeComponentPath.h" +#include "UiUtils.h" #include "UserInterface.h" #include "Variable.h" #include "WatchPromptWindow.h" @@ -221,21 +221,12 @@ TeamWindow::MessageReceived(BMessage* message) case MSG_CHOOSE_DEBUG_REPORT_LOCATION: { try { - BPath teamPath(fTeam->Name()); - BDateTime currentTime; - currentTime.SetTime_t(time(NULL)); - BString filename; - filename.SetToFormat("%s-%" B_PRId32 "-debug-%02" - B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02" - B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 ".report", - teamPath.Leaf(), fTeam->ID(), currentTime.Date().Day(), - currentTime.Date().Month(), currentTime.Date().Year(), - currentTime.Time().Hour(), currentTime.Time().Minute(), - currentTime.Time().Second()); + char filename[B_FILE_NAME_LENGTH]; + UiUtils::ReportNameForTeam(fTeam, filename, sizeof(filename)); BMessenger msgr(this); fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr, NULL, 0, false, new BMessage(MSG_GENERATE_DEBUG_REPORT)); - fFilePanel->SetSaveText(filename.String()); + fFilePanel->SetSaveText(filename); fFilePanel->Show(); } catch (...) { delete fFilePanel; diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp b/src/apps/debugger/user_interface/util/UiUtils.cpp index 539e069926..72aa28120c 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.cpp +++ b/src/apps/debugger/user_interface/util/UiUtils.cpp @@ -1,5 +1,6 @@ /* * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2012, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -8,11 +9,14 @@ #include +#include +#include #include #include "FunctionInstance.h" #include "Image.h" #include "StackFrame.h" +#include "Team.h" #include "Thread.h" @@ -134,3 +138,21 @@ UiUtils::ImageTypeToString(image_type type, char* buffer, size_t bufferSize) return buffer; } + + +/*static*/ const char* +UiUtils::ReportNameForTeam(::Team* team, char* buffer, size_t bufferSize) +{ + BPath teamPath(team->Name()); + BDateTime currentTime; + currentTime.SetTime_t(time(NULL)); + snprintf(buffer, bufferSize, "%s-%" B_PRId32 "-debug-%02" B_PRId32 "-%02" + B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02" + B_PRId32 ".report", teamPath.Leaf(), team->ID(), + currentTime.Date().Day(), currentTime.Date().Month(), + currentTime.Date().Year(), currentTime.Time().Hour(), + currentTime.Time().Minute(), currentTime.Time().Second()); + + return buffer; + +} diff --git a/src/apps/debugger/user_interface/util/UiUtils.h b/src/apps/debugger/user_interface/util/UiUtils.h index 4415754e35..81ed46df90 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.h +++ b/src/apps/debugger/user_interface/util/UiUtils.h @@ -12,6 +12,7 @@ class BVariant; class StackFrame; +class Team; class UiUtils { @@ -25,6 +26,9 @@ public: char* buffer, size_t bufferSize); static const char* ImageTypeToString(image_type type, char* buffer, size_t bufferSize); + + static const char* ReportNameForTeam(::Team* team, + char* buffer, size_t bufferSize); }; From bb7d146c64d025442c6798caf2d13114dfd18deb Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 23:41:34 -0500 Subject: [PATCH 32/32] Add CLI command for saving debug reports. --- src/apps/debugger/Jamfile | 1 + .../cli/CliDebugReportCommand.cpp | 39 +++++++++++++++++++ .../cli/CliDebugReportCommand.h | 20 ++++++++++ .../cli/CommandLineUserInterface.cpp | 7 +++- 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp create mode 100644 src/apps/debugger/user_interface/cli/CliDebugReportCommand.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index a1a1ddbe13..4eb12819dd 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -192,6 +192,7 @@ Application Debugger : CliCommand.cpp CliContext.cpp CliContinueCommand.cpp + CliDebugReportCommand.cpp CliStackTraceCommand.cpp CliStopCommand.cpp CliThreadCommand.cpp diff --git a/src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp new file mode 100644 index 0000000000..213b5f774d --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2012, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + + +#include "CliDebugReportCommand.h" + +#include +#include +#include +#include + +#include "CliContext.h" +#include "UiUtils.h" +#include "UserInterface.h" + + +CliDebugReportCommand::CliDebugReportCommand() + : + CliCommand("save debug report", + "%s\n" + "Saves a debug information report for the current team.") +{ +} + + +void +CliDebugReportCommand::Execute(int argc, const char* const* argv, CliContext& context) +{ + char buffer[B_FILE_NAME_LENGTH]; + UiUtils::ReportNameForTeam(context.GetTeam(), buffer, sizeof(buffer)); + BPath path; + find_directory(B_DESKTOP_DIRECTORY, &path); + path.Append(buffer); + entry_ref ref; + if (get_ref_for_path(path.Path(), &ref) == B_OK) + context.GetUserInterfaceListener()->DebugReportRequested(&ref); +} diff --git a/src/apps/debugger/user_interface/cli/CliDebugReportCommand.h b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.h new file mode 100644 index 0000000000..ffe423c213 --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.h @@ -0,0 +1,20 @@ +/* + * Copyright 2012, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef CLI_DEBUG_REPORT_COMMAND_H +#define CLI_DEBUG_REPORT_COMMAND_H + + +#include "CliCommand.h" + + +class CliDebugReportCommand : public CliCommand { +public: + CliDebugReportCommand(); + virtual void Execute(int argc, const char* const* argv, + CliContext& context); +}; + + +#endif // CLI_DEBUG_REPORT_COMMAND_H diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 1871c45b51..bbd0f86366 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2012, Rene Gollent, rene@gollent.com. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -17,6 +17,7 @@ #include "CliContext.h" #include "CliContinueCommand.h" +#include "CliDebugReportCommand.h" #include "CliQuitCommand.h" #include "CliStackTraceCommand.h" #include "CliStopCommand.h" @@ -284,7 +285,9 @@ CommandLineUserInterface::_RegisterCommands() _RegisterCommand("sc", stackTraceCommandReference2.Detach()) && _RegisterCommand("stop", new(std::nothrow) CliStopCommand) && _RegisterCommand("thread", new(std::nothrow) CliThreadCommand) && - _RegisterCommand("threads", new(std::nothrow) CliThreadsCommand)) { + _RegisterCommand("threads", new(std::nothrow) CliThreadsCommand) && + _RegisterCommand("save-report", + new(std::nothrow) CliDebugReportCommand)) { return B_OK; }