2 * Copyright 2012-2014, Rene Gollent, rene@gollent.com.
3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
9 #include <AutoLocker.h>
12 #include "ImageDebugInfo.h"
13 #include "TeamDebugInfo.h"
17 // #pragma mark - LoadImageDebugInfoJob
20 LoadImageDebugInfoJob::LoadImageDebugInfoJob(Image
* image
)
22 fKey(image
, JOB_TYPE_LOAD_IMAGE_DEBUG_INFO
),
26 fImage
->AcquireReference();
28 SetDescription("Loading debugging information for %s",
29 fImage
->Name().String());
33 LoadImageDebugInfoJob::~LoadImageDebugInfoJob()
35 fImage
->ReleaseReference();
40 LoadImageDebugInfoJob::Key() const
47 LoadImageDebugInfoJob::Do()
49 // get an image info for the image
50 AutoLocker
<Team
> locker(fImage
->GetTeam());
51 ImageInfo
imageInfo(fImage
->Info());
54 // create the debug info
55 ImageDebugInfo
* debugInfo
;
56 status_t error
= fImage
->GetTeam()->DebugInfo()->LoadImageDebugInfo(
57 imageInfo
, fImage
->ImageFile(), fState
, debugInfo
);
62 if (fState
.UserInputRequired()) {
63 return WaitForUserInput();
64 } else if (error
== B_OK
) {
65 error
= fImage
->SetImageDebugInfo(debugInfo
, IMAGE_DEBUG_INFO_LOADED
);
66 debugInfo
->ReleaseReference();
68 fImage
->SetImageDebugInfo(NULL
, IMAGE_DEBUG_INFO_UNAVAILABLE
);
75 LoadImageDebugInfoJob::ScheduleIfNecessary(Worker
* worker
, Image
* image
,
76 JobListener
* listener
, ImageDebugInfo
** _imageDebugInfo
)
78 AutoLocker
<Team
> teamLocker(image
->GetTeam());
80 // If already loaded, we're done.
81 if (image
->GetImageDebugInfo() != NULL
) {
82 if (_imageDebugInfo
!= NULL
) {
83 *_imageDebugInfo
= image
->GetImageDebugInfo();
84 (*_imageDebugInfo
)->AcquireReference();
89 // If already loading, the caller has to wait, if desired.
90 if (image
->ImageDebugInfoState() == IMAGE_DEBUG_INFO_LOADING
) {
91 if (_imageDebugInfo
!= NULL
)
92 *_imageDebugInfo
= NULL
;
96 // If an earlier load attempt failed, bail out.
97 if (image
->ImageDebugInfoState() != IMAGE_DEBUG_INFO_NOT_LOADED
)
101 LoadImageDebugInfoJob
* job
= new(std::nothrow
) LoadImageDebugInfoJob(
106 status_t error
= worker
->ScheduleJob(job
, listener
);
108 image
->SetImageDebugInfo(NULL
, IMAGE_DEBUG_INFO_UNAVAILABLE
);
112 image
->SetImageDebugInfo(NULL
, IMAGE_DEBUG_INFO_LOADING
);
114 if (_imageDebugInfo
!= NULL
)
115 *_imageDebugInfo
= NULL
;