Merge branch 'master' into sam460ex

This commit is contained in:
François Revol 2012-11-23 14:18:16 +01:00
commit c447257769
41 changed files with 737 additions and 462 deletions

View File

@ -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 ;

View File

@ -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...........

View File

@ -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).

View File

@ -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)

View File

@ -14,4 +14,4 @@
//#define ATOMIC64_FUNCS_ARE_SYSCALLS
#endif /* _KERNEL_ARCH_M68K_CONFIG_H */
#endif /* _KERNEL_ARCH_ARM_CONFIG_H */

View File

@ -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
;

View File

@ -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 <KernelExport.h>
#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;
}

View File

@ -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 <KernelExport.h>
#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;
}

View File

@ -0,0 +1,2 @@
SubDir HAIKU_TOP src add-ons kernel cpu arm ;

View File

@ -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)

View File

@ -7,15 +7,16 @@
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <drivers/device_manager.h>
#include <drivers/KernelExport.h>
#include <drivers/Drivers.h>
#include <kernel/OS.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
//#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

View File

@ -14,8 +14,6 @@
#include <sstream>
#include <string>
#include <syslog.h>
#include <Application.h>
#include <Directory.h>
#include <File.h>
@ -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

View File

@ -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},

View File

@ -192,6 +192,7 @@ Application Debugger :
CliCommand.cpp
CliContext.cpp
CliContinueCommand.cpp
CliDebugReportCommand.cpp
CliStackTraceCommand.cpp
CliStopCommand.cpp
CliThreadCommand.cpp

View File

@ -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);
@ -96,7 +96,8 @@ DebugReportGenerator::_GenerateReportHeader(BString& _output)
AutoLocker<Team> 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,16 +109,23 @@ DebugReportGenerator::_DumpLoadedImages(BString& _output)
{
AutoLocker<Team> locker(fTeam);
_output << "\nLoaded Images:\n";
BString data;
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: %#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,
dataBase + info.DataSize());
_output << data;
} catch (...) {
@ -134,15 +142,17 @@ DebugReportGenerator::_DumpRunningThreads(BString& _output)
{
AutoLocker<Team> 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 +178,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\t%#08" B_PRIx64 "\t%#08" B_PRIx64 "\t%s\n",
frame->FrameAddress(), frame->InstructionPointer(),
UiUtils::FunctionNameForFrame(frame, functionName,
sizeof(functionName)));
@ -179,16 +191,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;
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2012, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#include "CliDebugReportCommand.h"
#include <Entry.h>
#include <FindDirectory.h>
#include <Path.h>
#include <String.h>
#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);
}

View File

@ -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

View File

@ -11,9 +11,9 @@
#include <AutoLocker.h>
#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);
}
}

View File

@ -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;
}

View File

@ -11,6 +11,7 @@
#include <Button.h>
#include <FilePanel.h>
#include <FindDirectory.h>
#include <LayoutBuilder.h>
#include <Menu.h>
#include <MenuBar.h>
@ -42,6 +43,7 @@
#include "StackTraceView.h"
#include "Tracing.h"
#include "TypeComponentPath.h"
#include "UiUtils.h"
#include "UserInterface.h"
#include "Variable.h"
#include "WatchPromptWindow.h"
@ -54,6 +56,7 @@ enum {
enum {
MSG_CHOOSE_DEBUG_REPORT_LOCATION = 'ccrl',
MSG_LOCATE_SOURCE_IF_NEEDED = 'lsin'
};
@ -111,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();
@ -143,7 +146,7 @@ TeamWindow::~TeamWindow()
_SetActiveImage(NULL);
_SetActiveThread(NULL);
delete fSourceLocatePanel;
delete fFilePanel;
}
@ -215,6 +218,38 @@ void
TeamWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_CHOOSE_DEBUG_REPORT_LOCATION:
{
try {
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);
fFilePanel->Show();
} catch (...) {
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;
}
case MSG_SHOW_INSPECTOR_WINDOW:
{
if (fInspectorWindow) {
@ -284,14 +319,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;
@ -799,6 +834,10 @@ TeamWindow::_Init()
item->SetTarget(this);
menu = new BMenu("Tools");
fMenuBar->AddItem(menu);
item = new BMenuItem("Save Debug Report",
new BMessage(MSG_CHOOSE_DEBUG_REPORT_LOCATION));
menu->AddItem(item);
item->SetTarget(this);
item = new BMenuItem("Inspect Memory",
new BMessage(MSG_SHOW_INSPECTOR_WINDOW), 'I');
menu->AddItem(item);

View File

@ -193,7 +193,7 @@ private:
BSplitView* fThreadSplitView;
InspectorWindow* fInspectorWindow;
GuiTeamUiSettings fUiSettings;
BFilePanel* fSourceLocatePanel;
BFilePanel* fFilePanel;
};

View File

@ -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 <stdio.h>
#include <DateTime.h>
#include <Path.h>
#include <Variant.h>
#include "FunctionInstance.h"
#include "Image.h"
#include "StackFrame.h"
#include "Team.h"
#include "Thread.h"
@ -109,3 +113,46 @@ 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;
}
/*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;
}

View File

@ -7,11 +7,12 @@
#include <size_t.h>
class StackFrame;
#include <image.h>
class BVariant;
class StackFrame;
class Team;
class UiUtils {
@ -23,6 +24,11 @@ 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);
static const char* ReportNameForTeam(::Team* team,
char* buffer, size_t bufferSize);
};

View File

@ -1,4 +1,5 @@
SubDir HAIKU_TOP src apps haiku3d ;
SubDirSysHdrs $(HAIKU_GLU_HEADERS) ;
SubDirSysHdrs $(HAIKU_MESA_HEADERS) ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) mesh ] ;

View File

@ -0,0 +1,3 @@
SubDir HAIKU_TOP src bin debug ltrace arch arm ;
# TODO: Implement!

View File

@ -0,0 +1,27 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ithamar R. Adema <ithamar@upgrade-android.com>
*/
#include <debug_support.h>
#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;
}

View File

@ -6,8 +6,6 @@
#include <Catalog.h>
#include <syslog.h>
#include <Application.h>
#include <Autolock.h>
#include <CatalogData.h>

View File

@ -10,7 +10,6 @@
#include <memory>
#include <new>
#include <syslog.h>
#include <AppFileInfo.h>
#include <Application.h>
@ -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<char> 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<char> 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;
}

View File

@ -3,8 +3,6 @@
* The required mimetypes and attribute-indices are created here.
*/
#include <syslog.h>
#include <fs_attr.h>
#include <fs_index.h>
#include <Volume.h>
@ -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));
}
}

View File

@ -14,7 +14,6 @@
#include <set>
#include <assert.h>
#include <syslog.h>
#include <Autolock.h>
#include <Bitmap.h>
@ -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;

View File

@ -13,7 +13,6 @@
#include <set>
#include <pthread.h>
#include <syslog.h>
#include <AppFileInfo.h>
#include <Application.h>
@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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) }
}

View File

@ -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);
}

View File

@ -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,11 +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_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 :

View File

@ -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
;

View File

@ -5,7 +5,6 @@
#include <asm_defs.h>
//#warning M68K: optimize memcpy
#if 1
/* that should be enough for now */

View File

@ -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
:
<src!system!libroot!os!arch!$(TARGET_ARCH)>atomic.o
<src!system!libroot!os!arch!$(TARGET_ARCH)>thread.o
<src!system!libroot!posix!string!arch!$(TARGET_ARCH)>arch_string.o
<src!system!libroot!posix!string!arch!$(TARGET_ARCH)>memset.o
;

View File

@ -0,0 +1,32 @@
/*
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ithamar R. Adema <ithamar@upgrade-android.com>
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "runtime_loader_private.h"
#include <runtime_loader.h>
//#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;
}

View File

@ -450,137 +450,10 @@ public:
private:
template<typename EhdrType, typename ShdrType>
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<ShdrType>(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<typename ShdrType>
bool _ReadSectionHeader(int index, SectionInfo& info)
{
off_t shOffset = fSectionHeaderTableOffset
+ index * fSectionHeaderSize;
ShdrType sectionHeader;
Read(shOffset, &sectionHeader, 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<typename EhdrType, typename ShdrType>
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<ShdrType>(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<typename ShdrType>
bool ELFObject::_ReadSectionHeader(int index, SectionInfo& info)
{
off_t shOffset = fSectionHeaderTableOffset
+ index * fSectionHeaderSize;
ShdrType sectionHeader;
Read(shOffset, &sectionHeader, 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)