Skip to content

Commit

Permalink
Remove --debug-on-start and --debug-children.
Browse files Browse the repository at this point in the history
debug_on_start_win.cc also had some code to support --wait-for-debugger, but I
don't think it's important to preserve it.  This would only have any effect in
modules which included debug_on_start.h, which was basically just test code; and
it also wouldn't have any effect when the component build is enabled, which I
suspect is true for most developers trying to run tests.  I didn't remove any of
the other pieces of --wait-for-debugger elsewhere.

BUG=359822
TEST=none
R=darin@chromium.org

Review URL: https://codereview.chromium.org/227723008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264671 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
pkasting@chromium.org committed Apr 17, 2014
1 parent a7cf736 commit 8a65f28
Show file tree
Hide file tree
Showing 16 changed files with 8 additions and 341 deletions.
2 changes: 0 additions & 2 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ component("base") {
"debug/alias.h",
"debug/crash_logging.cc",
"debug/crash_logging.h",
"debug/debug_on_start_win.cc",
"debug/debug_on_start_win.h",
"debug/debugger.cc",
"debug/debugger.h",
"debug/debugger_posix.cc",
Expand Down
2 changes: 0 additions & 2 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@
'debug/alias.h',
'debug/crash_logging.cc',
'debug/crash_logging.h',
'debug/debug_on_start_win.cc',
'debug/debug_on_start_win.h',
'debug/debugger.cc',
'debug/debugger.h',
'debug/debugger_posix.cc',
Expand Down
6 changes: 0 additions & 6 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@

namespace switches {

// If the program includes base/debug/debug_on_start_win.h, the process will
// (on Windows only) start the JIT system-registered debugger on itself and
// will wait for 60 seconds for the debugger to attach to itself. Then a break
// point will be hit.
const char kDebugOnStart[] = "debug-on-start";

// Disables the crash reporting.
const char kDisableBreakpad[] = "disable-breakpad";

Expand Down
1 change: 0 additions & 1 deletion base/base_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace switches {

extern const char kDebugOnStart[];
extern const char kDisableBreakpad[];
extern const char kEnableCrashReporter[];
extern const char kFullMemoryCrashReport[];
Expand Down
74 changes: 0 additions & 74 deletions base/debug/debug_on_start_win.cc

This file was deleted.

83 changes: 0 additions & 83 deletions base/debug/debug_on_start_win.h

This file was deleted.

4 changes: 0 additions & 4 deletions base/debug/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
namespace base {
namespace debug {

// Starts the registered system-wide JIT debugger to attach it to specified
// process.
BASE_EXPORT bool SpawnDebuggerOnProcess(unsigned process_id);

// Waits wait_seconds seconds for a debugger to attach to the current process.
// When silent is false, an exception is thrown when a debugger is detected.
BASE_EXPORT bool WaitForDebugger(int wait_seconds, bool silent);
Expand Down
18 changes: 0 additions & 18 deletions base/debug/debugger_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <sys/types.h>
#include <unistd.h>

#include <string>
#include <vector>

#if defined(__GLIBCXX__)
Expand All @@ -41,7 +40,6 @@
#include "base/posix/eintr_wrapper.h"
#include "base/safe_strerror_posix.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"

#if defined(USE_SYMBOLIZE)
#include "base/third_party/symbolize/symbolize.h"
Expand All @@ -54,22 +52,6 @@
namespace base {
namespace debug {

bool SpawnDebuggerOnProcess(unsigned process_id) {
#if OS_ANDROID || OS_NACL
NOTIMPLEMENTED();
return false;
#else
const std::string debug_cmd =
StringPrintf("xterm -e 'gdb --pid=%u' &", process_id);
LOG(WARNING) << "Starting debugger on pid " << process_id
<< " with command `" << debug_cmd << "`";
int ret = system(debug_cmd.c_str());
if (ret == -1)
return false;
return true;
#endif
}

#if defined(OS_MACOSX) || defined(OS_BSD)

// Based on Apple's recommended method as described in
Expand Down
89 changes: 1 addition & 88 deletions base/debug/debugger_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,99 +4,12 @@

#include "base/debug/debugger.h"

#include <stdlib.h>
#include <windows.h>
#include <dbghelp.h>

#include "base/basictypes.h"
#include "base/logging.h"

namespace base {
namespace debug {

namespace {

// Minimalist key reader.
// Note: Does not use the CRT.
bool RegReadString(HKEY root, const wchar_t* subkey,
const wchar_t* value_name, wchar_t* buffer, int* len) {
HKEY key = NULL;
DWORD res = RegOpenKeyEx(root, subkey, 0, KEY_READ, &key);
if (ERROR_SUCCESS != res || key == NULL)
return false;

DWORD type = 0;
DWORD buffer_size = *len * sizeof(wchar_t);
// We don't support REG_EXPAND_SZ.
res = RegQueryValueEx(key, value_name, NULL, &type,
reinterpret_cast<BYTE*>(buffer), &buffer_size);
if (ERROR_SUCCESS == res && buffer_size != 0 && type == REG_SZ) {
// Make sure the buffer is NULL terminated.
buffer[*len - 1] = 0;
*len = lstrlen(buffer);
RegCloseKey(key);
return true;
}
RegCloseKey(key);
return false;
}

// Replaces each "%ld" in input per a value. Not efficient but it works.
// Note: Does not use the CRT.
bool StringReplace(const wchar_t* input, int value, wchar_t* output,
int output_len) {
memset(output, 0, output_len*sizeof(wchar_t));
int input_len = lstrlen(input);

for (int i = 0; i < input_len; ++i) {
int current_output_len = lstrlen(output);

if (input[i] == L'%' && input[i + 1] == L'l' && input[i + 2] == L'd') {
// Make sure we have enough place left.
if ((current_output_len + 12) >= output_len)
return false;

// Cheap _itow().
wsprintf(output+current_output_len, L"%d", value);
i += 2;
} else {
if (current_output_len >= output_len)
return false;
output[current_output_len] = input[i];
}
}
return true;
}

} // namespace

// Note: Does not use the CRT.
bool SpawnDebuggerOnProcess(unsigned process_id) {
wchar_t reg_value[1026];
int len = arraysize(reg_value);
if (RegReadString(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug",
L"Debugger", reg_value, &len)) {
wchar_t command_line[1026];
if (StringReplace(reg_value, process_id, command_line,
arraysize(command_line))) {
// We don't mind if the debugger is present because it will simply fail
// to attach to this process.
STARTUPINFO startup_info = {0};
startup_info.cb = sizeof(startup_info);
PROCESS_INFORMATION process_info = {0};

if (CreateProcess(NULL, command_line, NULL, NULL, FALSE, 0, NULL, NULL,
&startup_info, &process_info)) {
CloseHandle(process_info.hThread);
WaitForInputIdle(process_info.hProcess, 10000);
CloseHandle(process_info.hProcess);
return true;
}
}
}
return false;
}

bool BeingDebugged() {
return ::IsDebuggerPresent() != 0;
}
Expand Down
1 change: 0 additions & 1 deletion base/test/test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/debug_on_start_win.h"
#include "base/debug/debugger.h"
#include "base/debug/stack_trace.h"
#include "base/file_util.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ipc/ipc_listener.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_multiprocess_test.h"
#include "ipc/ipc_switches.h"
#include "testing/multiprocess_func_list.h"

#define IPC_MESSAGE_IMPL
Expand Down Expand Up @@ -56,10 +55,7 @@ bool LaunchNSSDecrypterChildProcess(const base::FilePath& nss_path,
fds_to_map.push_back(std::pair<int,int>(ipcfd.get(),
kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));

bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDebugChildren);
options.fds_to_remap = &fds_to_map;
options.wait = debug_on_start;
return base::LaunchProcess(cl.argv(), options, handle);
}

Expand Down
12 changes: 0 additions & 12 deletions content/browser/worker_host/worker_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,6 @@ bool debugging_child = false;
debugging_child = true;
}
}

if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren)) {
// Look to pass-on the kDebugOnStart flag.
std::string value = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kDebugChildren);
if (value.empty() || value == switches::kWorkerProcess) {
// launches a new xterm, and runs the worker process in gdb, reading
// optional commands from gdb_chrome file in the working directory.
cmd_line->PrependWrapper("xterm -e gdb -x gdb_chrome --args");
debugging_child = true;
}
}
#endif

process_->Launch(
Expand Down
Loading

0 comments on commit 8a65f28

Please sign in to comment.