mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 00:19:35 +00:00
f617a91abb
- Bug 1167633 - Remove SpiderMonkey specific JS syntax from App Manager / WebIDE. r=pbrosset (882d61d26) - missing parts of Bug 932179 - Part 1: Expose security information in the WebConsoleActor. r=past (202d33c93) - Bug 1106470 - Drop SSLv3 support from devtools. r=vporof (4d6f99643) - Bug 955933 - Allow copying the network response string. r=vporof (0f1a79fe1) - Follow-up nit to bug 1147648 (alphabetize prefs). r=kats (e251ec2e5) - Bug 1155252 * -WError fix (2d4c016d2) - Disable layers acceleration on Windows if the last startup crashed during driver initialization. (bug 1168935, r=mattwoodrow) (cb4769ace) - Add telemetry for reporting graphics driver startup states. (bug 1168935 part 2, r=vdjeric,mattwoodrow) (a7a605d93) - Bug 1150715 - Implement "Copy Request/Response Headers" context menu items. r=jsantell (0eabd68f7) - part of Bug 1102219 - Part 4: Replace with in chrome code. r=till (dab16f660) - Bug 1150717 - Implement "Copy URL Parameters" context menu item. r=bgrins (f20e86e8f) - Bug 1158046 - Add access keys to all context menu items in the Network panel. r=bgrins r=jsantell (71fd1e050) - Remove static vars from DriverInitCrashDetection. (bug 1183910 part 1, r=mattwoodrow) (29ea344ce) - Bug 1151541, part 3 - Fix leading tabs in xpcom/. r=froydnj (eb1fa5c14) - Bug 1151541, part 1 - Add MPL2 to StaticMutex.h and stub_test.cpp. r=froydnj (bf00b19ee) - Bug 1140760 - Move TestXPIDLString.cpp to gtest and enable it; r=froydnj (7bea14ce1) - Bug 1140762 - Move TestThreads.cpp to gtest and enable it; r=froydnj (93a007768) - Bug 1151541, part 2 - Fix mode lines in xpcom/. r=froydnj (0ac8fd176) - Bug 1159751: Ensure WARP can never be used for Windows 7. r=milan (ad4a84b10) - Bug 1178426. Add GfxInfo to ServicesList.h. r=nfroyd (8e09c6349) - Bug 1158144 - Fix "Copy URL Parameters" line separation on Windows. r=vporof (d7359d740) - Bug 1158144 - Implement "Copy POST Data" context menu item. r=vporof (adddce05a) - Bug 1127423 - Don't scroll horizontally when selecting an element in markup view;r=jryans (3256aa5eb) - Bug 1159938 - Remove dead nodeChanged() function;r=pbrosset (213880754) - Bug 1153022 - Add trimOutput option to inplace editor;r=pbrosset (52228252a) - Bug 1120111 - Adds key listeners to highlighter pick mode to traverse DOM and submit/cancel selection; r=pbrosset (40f6e8e33) - Bug 1120111 - Tests for the highlighter pick mode key listeners; r=pbrosset (6c9ff1c95) - Bug 988278 - Fixes ESCape keypress mess in the inspector to make sure the split console opens; r=miker (d915ca7ae) - Bug 1153635 - Focus first focusable element in MarkupContainer when line is clicked; r=bgrins (f7b231d4c) - Bug 1158781 - Make sure attributes gets focused when clicked in the inspector. r=bgrins (d6e1521f3) - Bug 966787 - 1 - Code cleanup in breadcrumbs.js; r=bgrins For a better consistency with the rest of the DevTools codebase. (867a768c6) - fix imports again (180eb1ac7) - Bug 966787 - 2 - Skip inspector breadcrumb updates when the output doesn't change; r=bgrins (5bddce972) - Bug 892935 - Auto-expand elements with only text in the markup view;r=pbrosset,r=bgrins (6dddecd01)
291 lines
7.6 KiB
C++
291 lines
7.6 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/Mutex.h"
|
|
#include "mozilla/Scoped.h"
|
|
#include "mozilla/UniquePtr.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include "PoisonIOInterposer.h"
|
|
|
|
#ifdef MOZ_REPLACE_MALLOC
|
|
#include "replace_malloc_bridge.h"
|
|
#endif
|
|
|
|
// Auxiliary method to convert file descriptors to ids
|
|
#if defined(XP_WIN32)
|
|
#include <io.h>
|
|
inline intptr_t
|
|
FileDescriptorToHandle(int aFd)
|
|
{
|
|
return _get_osfhandle(aFd);
|
|
}
|
|
#else
|
|
inline intptr_t
|
|
FileDescriptorToHandle(int aFd)
|
|
{
|
|
return aFd;
|
|
}
|
|
#endif /* if not XP_WIN32 */
|
|
|
|
using namespace mozilla;
|
|
|
|
namespace {
|
|
struct DebugFilesAutoLockTraits
|
|
{
|
|
typedef PRLock* type;
|
|
const static type empty() { return nullptr; }
|
|
const static void release(type aL) { PR_Unlock(aL); }
|
|
};
|
|
|
|
class DebugFilesAutoLock : public Scoped<DebugFilesAutoLockTraits>
|
|
{
|
|
static PRLock* Lock;
|
|
public:
|
|
static void Clear();
|
|
static PRLock* getDebugFileIDsLock()
|
|
{
|
|
// On windows this static is not thread safe, but we know that the first
|
|
// call is from
|
|
// * An early registration of a debug FD or
|
|
// * The call to InitWritePoisoning.
|
|
// Since the early debug FDs are logs created early in the main thread
|
|
// and no writes are trapped before InitWritePoisoning, we are safe.
|
|
if (!Lock) {
|
|
Lock = PR_NewLock();
|
|
}
|
|
|
|
// We have to use something lower level than a mutex. If we don't, we
|
|
// can get recursive in here when called from logging a call to free.
|
|
return Lock;
|
|
}
|
|
|
|
DebugFilesAutoLock()
|
|
: Scoped<DebugFilesAutoLockTraits>(getDebugFileIDsLock())
|
|
{
|
|
PR_Lock(get());
|
|
}
|
|
};
|
|
|
|
PRLock* DebugFilesAutoLock::Lock;
|
|
void
|
|
DebugFilesAutoLock::Clear()
|
|
{
|
|
MOZ_ASSERT(Lock != nullptr);
|
|
Lock = nullptr;
|
|
}
|
|
|
|
// The ChunkedList<T> class implements, at the high level, a non-iterable
|
|
// list of instances of T. Its goal is to be somehow minimalist for the
|
|
// use case of storing the debug files handles here, with the property of
|
|
// not requiring a lock to look up whether it contains a specific value.
|
|
// It is also chunked in blocks of chunk_size bytes so that its
|
|
// initialization doesn't require a memory allocation, while keeping the
|
|
// possibility to increase its size as necessary. Note that chunks are
|
|
// never deallocated (except in the destructor).
|
|
// All operations are essentially O(N) but N is not expected to be large
|
|
// enough to matter.
|
|
template <typename T, size_t chunk_size=64>
|
|
class ChunkedList {
|
|
struct ListChunk {
|
|
static const size_t kLength = \
|
|
(chunk_size - sizeof(ListChunk*)) / sizeof(mozilla::Atomic<T>);
|
|
|
|
mozilla::Atomic<T> mElements[kLength];
|
|
mozilla::UniquePtr<ListChunk> mNext;
|
|
|
|
ListChunk() : mNext(nullptr) {}
|
|
};
|
|
|
|
ListChunk mList;
|
|
mozilla::Atomic<size_t> mLength;
|
|
|
|
public:
|
|
ChunkedList() : mLength(0) {}
|
|
|
|
~ChunkedList() {
|
|
// There can be writes happening after this destructor runs, so keep
|
|
// the list contents and don't reset mLength. But if there are more
|
|
// elements left than the first chunk can hold, then all hell breaks
|
|
// loose for any write that would happen after that because any extra
|
|
// chunk would be deallocated, so just crash in that case.
|
|
MOZ_RELEASE_ASSERT(mLength <= ListChunk::kLength);
|
|
}
|
|
|
|
// Add an element at the end of the last chunk of the list. Create a new
|
|
// chunk if there is not enough room.
|
|
// This is not thread-safe with another thread calling Add or Remove.
|
|
void Add(T aValue)
|
|
{
|
|
ListChunk *list = &mList;
|
|
size_t position = mLength;
|
|
for (; position >= ListChunk::kLength; position -= ListChunk::kLength) {
|
|
if (!list->mNext) {
|
|
list->mNext.reset(new ListChunk());
|
|
}
|
|
list = list->mNext.get();
|
|
}
|
|
// Use an order of operations that ensures any racing Contains call
|
|
// can't be hurt.
|
|
list->mElements[position] = aValue;
|
|
mLength++;
|
|
}
|
|
|
|
// Remove an element from the list by replacing it with the last element
|
|
// of the list, and then shrinking the list.
|
|
// This is not thread-safe with another thread calling Add or Remove.
|
|
void Remove(T aValue)
|
|
{
|
|
if (!mLength) {
|
|
return;
|
|
}
|
|
ListChunk *list = &mList;
|
|
size_t last = mLength - 1;
|
|
do {
|
|
size_t position = 0;
|
|
// Look for an element matching the given value.
|
|
for (; position < ListChunk::kLength; position++) {
|
|
if (aValue == list->mElements[position]) {
|
|
ListChunk *last_list = list;
|
|
// Look for the last element in the list, starting from where we are
|
|
// instead of starting over.
|
|
for (; last >= ListChunk::kLength; last -= ListChunk::kLength) {
|
|
last_list = last_list->mNext.get();
|
|
}
|
|
// Use an order of operations that ensures any racing Contains call
|
|
// can't be hurt.
|
|
T value = last_list->mElements[last];
|
|
list->mElements[position] = value;
|
|
mLength--;
|
|
return;
|
|
}
|
|
}
|
|
last -= ListChunk::kLength;
|
|
list = list->mNext.get();
|
|
} while (list);
|
|
}
|
|
|
|
// Returns whether the list contains the given value. It is meant to be safe
|
|
// to use without locking, with the tradeoff of being not entirely accurate
|
|
// if another thread adds or removes an element while this function runs.
|
|
bool Contains(T aValue)
|
|
{
|
|
ListChunk *list = &mList;
|
|
// Fix the range of the lookup to whatever the list length is when the
|
|
// function is called.
|
|
size_t length = mLength;
|
|
do {
|
|
size_t list_length = ListChunk::kLength;
|
|
list_length = std::min(list_length, length);
|
|
for (size_t position = 0; position < list_length; position++) {
|
|
if (aValue == list->mElements[position]) {
|
|
return true;
|
|
}
|
|
}
|
|
length -= ListChunk::kLength;
|
|
list = list->mNext.get();
|
|
} while (list);
|
|
|
|
return false;
|
|
}
|
|
};
|
|
|
|
typedef ChunkedList<intptr_t> FdList;
|
|
|
|
// Return a list used to hold the IDs of the current debug files. On unix
|
|
// an ID is a file descriptor. On Windows it is a file HANDLE.
|
|
FdList&
|
|
getDebugFileIDs()
|
|
{
|
|
static FdList DebugFileIDs;
|
|
return DebugFileIDs;
|
|
}
|
|
|
|
|
|
} // namespace
|
|
|
|
namespace mozilla {
|
|
|
|
// Auxiliary Method to test if a file descriptor is registered to be ignored
|
|
// by the poisoning IO interposer
|
|
bool
|
|
IsDebugFile(intptr_t aFileID)
|
|
{
|
|
return getDebugFileIDs().Contains(aFileID);
|
|
}
|
|
|
|
} // namespace mozilla
|
|
|
|
extern "C" {
|
|
|
|
void
|
|
MozillaRegisterDebugHandle(intptr_t aHandle)
|
|
{
|
|
DebugFilesAutoLock lockedScope;
|
|
FdList& DebugFileIDs = getDebugFileIDs();
|
|
MOZ_ASSERT(!DebugFileIDs.Contains(aHandle));
|
|
DebugFileIDs.Add(aHandle);
|
|
}
|
|
|
|
void
|
|
MozillaRegisterDebugFD(int aFd)
|
|
{
|
|
MozillaRegisterDebugHandle(FileDescriptorToHandle(aFd));
|
|
}
|
|
|
|
void
|
|
MozillaRegisterDebugFILE(FILE* aFile)
|
|
{
|
|
int fd = fileno(aFile);
|
|
if (fd == 1 || fd == 2) {
|
|
return;
|
|
}
|
|
MozillaRegisterDebugFD(fd);
|
|
}
|
|
|
|
void
|
|
MozillaUnRegisterDebugHandle(intptr_t aHandle)
|
|
{
|
|
DebugFilesAutoLock lockedScope;
|
|
FdList& DebugFileIDs = getDebugFileIDs();
|
|
MOZ_ASSERT(DebugFileIDs.Contains(aHandle));
|
|
DebugFileIDs.Remove(aHandle);
|
|
}
|
|
|
|
void
|
|
MozillaUnRegisterDebugFD(int aFd)
|
|
{
|
|
MozillaUnRegisterDebugHandle(FileDescriptorToHandle(aFd));
|
|
}
|
|
|
|
void
|
|
MozillaUnRegisterDebugFILE(FILE* aFile)
|
|
{
|
|
int fd = fileno(aFile);
|
|
if (fd == 1 || fd == 2) {
|
|
return;
|
|
}
|
|
fflush(aFile);
|
|
MozillaUnRegisterDebugFD(fd);
|
|
}
|
|
|
|
} // extern "C"
|
|
|
|
#ifdef MOZ_REPLACE_MALLOC
|
|
void
|
|
DebugFdRegistry::RegisterHandle(intptr_t aHandle)
|
|
{
|
|
MozillaRegisterDebugHandle(aHandle);
|
|
}
|
|
|
|
void
|
|
DebugFdRegistry::UnRegisterHandle(intptr_t aHandle)
|
|
{
|
|
MozillaUnRegisterDebugHandle(aHandle);
|
|
}
|
|
#endif
|