[3/3] winedbg: Add the ability to save the backtrace to a file
André Hentschel
nerv at dawncrow.de
Mon Oct 24 13:00:06 CDT 2011
---
programs/winedbg/crashdlg.c | 47 +++++++++++++++++++++++++++++++++++++++++++
programs/winedbg/resource.h | 6 +++++
programs/winedbg/winedbg.rc | 11 ++++++++++
3 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/programs/winedbg/crashdlg.c b/programs/winedbg/crashdlg.c
index ed0c312..e4f4582 100644
--- a/programs/winedbg/crashdlg.c
+++ b/programs/winedbg/crashdlg.c
@@ -184,6 +184,38 @@ static void output_backtrace(HWND hDlg, enum output_targets target)
HeapFree(GetProcessHeap(), 0, pTemp);
}
+static void save_to_file(HWND hDlg)
+{
+ OPENFILENAMEW ofn;
+ static const WCHAR txt_files[] = { '*', '.', 't', 'x', 't', 0 };
+ static const WCHAR all_files[] = { '*', '.', '*', 0 };
+ static WCHAR file[MAX_PATH] = {'b', 'a', 'c', 'k', 't', 'r', 'a', 'c', 'e', '.', 't', 'x', 't', 0};
+ static WCHAR filter[MAXIMUM_FILENAME_LENGTH];
+ LPWSTR p = filter;
+
+ LoadStringW(hInstance, IDS_TEXT_FILES, p, sizeof(filter)/sizeof(WCHAR));
+ p += lstrlenW(p) + 1;
+ lstrcpyW(p, txt_files);
+ p += lstrlenW(p) + 1;
+ LoadStringW(hInstance, IDS_ALL_FILES, p, sizeof(filter)/sizeof(WCHAR));
+ p += lstrlenW(p) + 1;
+ lstrcpyW(p, all_files);
+ p += lstrlenW(p) + 1;
+ *p = '\0';
+
+ ZeroMemory(&ofn, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+ ofn.hInstance = hInstance;
+ ofn.hwndOwner = hDlg;
+ ofn.lpstrFile = file;
+ ofn.lpstrFilter = filter;
+ ofn.nMaxFile = MAX_PATH;
+
+ if (!GetSaveFileNameW(&ofn)) return;
+ CopyFileW( filename, file, FALSE );
+}
+
static LRESULT WINAPI slave_WndProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam)
{
@@ -203,6 +235,20 @@ static LRESULT WINAPI slave_WndProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
+ case WM_COMMAND:
+ switch (wParam)
+ {
+ case ID_SAVEREPORT:
+ save_to_file(hwnd);
+ break;
+ case ID_EXITREPORT:
+ DestroyWindow(hwnd);
+ break;
+ default:
+ break;
+ }
+ break;
+
case WM_SIZE:
SetWindowPos(hEdit, NULL, 0, 0, LOWORD(lParam), HIWORD(lParam),
SWP_NOOWNERZORDER | SWP_NOZORDER);
@@ -236,6 +282,7 @@ static INT_PTR WINAPI DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
class.lpfnWndProc = slave_WndProc;
class.hInstance = hInstance;
class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ class.lpszMenuName = MAKEINTRESOURCEW(MAIN_MENU);
class.lpszClassName = className;
if (!RegisterClassExW(&class)) return FALSE;
diff --git a/programs/winedbg/resource.h b/programs/winedbg/resource.h
index 6563a53..07a3ae3 100644
--- a/programs/winedbg/resource.h
+++ b/programs/winedbg/resource.h
@@ -28,8 +28,14 @@
#define IDC_STATIC_TXT2 102
#define IDC_CRASHLOG 103
+#define MAIN_MENU 100
+
#define ID_SHOWDETAILS 200
+#define ID_SAVEREPORT 201
+#define ID_EXITREPORT 202
#define IDS_AUTO_CAPTION 16
#define IDS_INVALID_PARAMS 17
#define IDS_UNIDENTIFIED 18
+#define IDS_ALL_FILES 19
+#define IDS_TEXT_FILES 20
diff --git a/programs/winedbg/winedbg.rc b/programs/winedbg/winedbg.rc
index 9bcdab5..1d587d3 100644
--- a/programs/winedbg/winedbg.rc
+++ b/programs/winedbg/winedbg.rc
@@ -22,9 +22,20 @@
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+MAIN_MENU MENU
+{
+ POPUP "&Report" {
+ MENUITEM "Save &as...", ID_SAVEREPORT
+ MENUITEM "E&xit", ID_EXITREPORT
+ }
+}
+
STRINGTABLE
BEGIN
IDS_AUTO_CAPTION "Wine program crash"
IDS_INVALID_PARAMS "Internal errors - invalid parameters received"
IDS_UNIDENTIFIED "(unidentified)"
+
+ IDS_TEXT_FILES "Text files (*.txt)"
+ IDS_ALL_FILES "All files (*.*)"
END
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list