⛏️ index : haiku.git

author Augustin Cavalier <waddlesplash@gmail.com> 2024-08-21 15:36:44.0 -04:00:00
committer waddlesplash <waddlesplash@gmail.com> 2024-08-21 19:37:50.0 +00:00:00
commit
bf34eab8768384f8a8743e73fd3975e312b35d05 [patch]
tree
f646f3423d264cd3d4e5abec0bcb70d663ada321
parent
c99033f8a88104a5042da3957a481abee486f9e8
download
bf34eab8768384f8a8743e73fd3975e312b35d05.tar.gz

Debugger: Don't query the package kit in non-interactive mode.

We always skip loading debug information in this case, so
querying the package kit is just a waste of time. And it could
result in hangs or crashes if the package kit is in an invalid
state (e.g. if we are debugging package_daemon.)
(cherry picked from commit 69f1c57f0cc40fd0d32e61dc01507b234e498df8)

Change-Id: I9ce322bce111a458e830ace2286274bae126a861
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8067
Reviewed-by: waddlesplash <waddlesplash@gmail.com>

Diff

 src/kits/debugger/debug_info/loading_state_handlers/DwarfLoadingStateHandler.cpp | 48 +++++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/kits/debugger/debug_info/loading_state_handlers/DwarfLoadingStateHandler.cpp b/src/kits/debugger/debug_info/loading_state_handlers/DwarfLoadingStateHandler.cpp
index 8722193..3f4c764 100644
--- a/src/kits/debugger/debug_info/loading_state_handlers/DwarfLoadingStateHandler.cpp
+++ b/src/kits/debugger/debug_info/loading_state_handlers/DwarfLoadingStateHandler.cpp
@@ -68,6 +68,11 @@

	DwarfFileLoadingState& fileState = dwarfState->GetFileState();

	if (!interface->IsInteractive()) {
		fileState.state = DWARF_FILE_LOADING_STATE_USER_INPUT_PROVIDED;
		return;
	}

	BString requiredPackage;
	try {
		// Package Kit may throw exceptions.
@@ -83,29 +88,26 @@
	for (;;) {
		int32 choice;
		BString message;
		if (interface->IsInteractive()) {
			if (requiredPackage.IsEmpty()) {
				message.SetToFormat("The debug information file '%s' for "
					"image '%s' is missing. Would you like to locate the file "
					"manually?", fileState.externalInfoFileName.String(),
					fileState.dwarfFile->Name());
				choice = interface->SynchronouslyAskUser("Debug info missing",
					message.String(), "Locate", "Skip", NULL);
				if (choice == 0)
					choice = USER_CHOICE_LOCATE_FILE;
				else if (choice == 1)
					choice = USER_CHOICE_SKIP;
			} else {
				message.SetToFormat("The debug information file '%s' for "
					"image '%s' is missing, but can be found in the package "
					"'%s'. Would you like to install it, or locate the file "
					"manually?", fileState.externalInfoFileName.String(),
					fileState.dwarfFile->Name(), requiredPackage.String());
				choice = interface->SynchronouslyAskUser("Debug info missing",
					message.String(), "Install", "Locate", "Skip");
			}
		} else
			choice = USER_CHOICE_SKIP;
		if (requiredPackage.IsEmpty()) {
			message.SetToFormat("The debug information file '%s' for "
				"image '%s' is missing. Would you like to locate the file "
				"manually?", fileState.externalInfoFileName.String(),
				fileState.dwarfFile->Name());
			choice = interface->SynchronouslyAskUser("Debug info missing",
				message.String(), "Locate", "Skip", NULL);
			if (choice == 0)
				choice = USER_CHOICE_LOCATE_FILE;
			else if (choice == 1)
				choice = USER_CHOICE_SKIP;
		} else {
			message.SetToFormat("The debug information file '%s' for "
				"image '%s' is missing, but can be found in the package "
				"'%s'. Would you like to install it, or locate the file "
				"manually?", fileState.externalInfoFileName.String(),
				fileState.dwarfFile->Name(), requiredPackage.String());
			choice = interface->SynchronouslyAskUser("Debug info missing",
				message.String(), "Install", "Locate", "Skip");
		}

		if (choice == USER_CHOICE_INSTALL_PACKAGE) {
			// TODO: integrate the package installation functionality directly.