diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 907865cbe3..2ddf9c8843 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -30,6 +30,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface gui team_window ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface gui teams_window ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface gui util ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface gui value ] ; +SEARCH_SOURCE += [ FDirName $(SUBDIR) user_interface util ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) util ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) value ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) value type_handlers ] ; @@ -221,6 +222,9 @@ Application Debugger : TableCellValueRenderer.cpp TableCellValueRendererUtils.cpp + # user_interface/util + UiUtils.cpp + # util ArchivingUtils.cpp BitBuffer.cpp diff --git a/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp b/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp index 4799286ffa..7ef001c405 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp @@ -18,6 +18,7 @@ #include "GUISettingsUtils.h" #include "table/TableColumns.h" +#include "UiUtils.h" enum { @@ -114,35 +115,10 @@ public: return true; case 1: { - switch (thread->State()) { - case THREAD_STATE_RUNNING: - value.SetTo("Running", B_VARIANT_DONT_COPY_DATA); - return true; - case THREAD_STATE_STOPPED: - break; - case THREAD_STATE_UNKNOWN: - default: - value.SetTo("?", B_VARIANT_DONT_COPY_DATA); - return true; - } - - // thread is stopped -- get the reason - switch (thread->StoppedReason()) { - case THREAD_STOPPED_DEBUGGER_CALL: - value.SetTo("Call", B_VARIANT_DONT_COPY_DATA); - return true; - case THREAD_STOPPED_EXCEPTION: - value.SetTo("Exception", B_VARIANT_DONT_COPY_DATA); - return true; - case THREAD_STOPPED_BREAKPOINT: - case THREAD_STOPPED_WATCHPOINT: - case THREAD_STOPPED_SINGLE_STEP: - case THREAD_STOPPED_DEBUGGED: - case THREAD_STOPPED_UNKNOWN: - default: - value.SetTo("Debugged", B_VARIANT_DONT_COPY_DATA); - return true; - } + const char* string = UiUtils::ThreadStateToString( + thread->State(), thread->StoppedReason()); + value.SetTo(string, B_VARIANT_DONT_COPY_DATA); + return true; } case 2: value.SetTo(thread->Name(), B_VARIANT_DONT_COPY_DATA); diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp b/src/apps/debugger/user_interface/util/UiUtils.cpp new file mode 100644 index 0000000000..e92d4bdb4f --- /dev/null +++ b/src/apps/debugger/user_interface/util/UiUtils.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "UiUtils.h" + + +/*static*/ const char* +UiUtils::ThreadStateToString(int state, int stoppedReason) +{ + switch (state) { + case THREAD_STATE_RUNNING: + return "Running"; + case THREAD_STATE_STOPPED: + break; + case THREAD_STATE_UNKNOWN: + default: + return "?"; + } + + // thread is stopped -- get the reason + switch (stoppedReason) { + case THREAD_STOPPED_DEBUGGER_CALL: + return "Call"; + case THREAD_STOPPED_EXCEPTION: + return "Exception"; + case THREAD_STOPPED_BREAKPOINT: + case THREAD_STOPPED_WATCHPOINT: + case THREAD_STOPPED_SINGLE_STEP: + case THREAD_STOPPED_DEBUGGED: + case THREAD_STOPPED_UNKNOWN: + default: + return "Debugged"; + } +} diff --git a/src/apps/debugger/user_interface/util/UiUtils.h b/src/apps/debugger/user_interface/util/UiUtils.h new file mode 100644 index 0000000000..a7f74b4d54 --- /dev/null +++ b/src/apps/debugger/user_interface/util/UiUtils.h @@ -0,0 +1,19 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef UI_UTILS_H +#define UI_UTILS_H + + +#include "Thread.h" + + +class UiUtils { +public: + static const char* ThreadStateToString(int state, + int stoppedReason); +}; + + +#endif // UI_UTILS_H