Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 82a67ae

Browse files
author
Thales Sabino
committed
[SAMS]: Added support to connect to a Tizen device.
Allow use of sdb instead of adb
1 parent 6112af2 commit 82a67ae

File tree

13 files changed

+182
-20
lines changed

13 files changed

+182
-20
lines changed

Diff for: CodeXL/AMDTApplicationFramework/Include/LPGPU2ApplicationDefs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#define LPGPU2_APPLICATION_DEFS_H
1212

1313
#define LPGPU2_CODEXL_APPLICATION_VERSION_MAJOR 3
14-
#define LPGPU2_CODEXL_APPLICATION_VERSION_MINOR 9
15-
#define LPGPU2_CODEXL_APPLICATION_VERSION_PATCH 4
14+
#define LPGPU2_CODEXL_APPLICATION_VERSION_MINOR 10
15+
#define LPGPU2_CODEXL_APPLICATION_VERSION_PATCH 0
1616
#define LPGPU2_CODEXL_APPLICATION_VERSION_SUFFIX ""
1717

1818
#endif // LPGPU2_APPLICATION_DEFS_H

Diff for: CodeXL/AMDTApplicationFramework/src/afNewProjectDialog.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ void afNewProjectDialog::ShowDialog(afDialogMode mode, const gtString& selectedT
162162
// Initialize the current project settings:
163163
initDialogCurrentProjectSettings();
164164

165+
// TIZEN FIX start the status monitor thread when the dialog is displayed
166+
if (m_projectSettings.isAndroidDeviceTarget())
167+
NotifyExtensionsOfHostTypeChange(lpgpu2::HostType::LPGPU2);
168+
165169
if (mode == AF_DIALOG_NEW_PROJECT)
166170
{
167171
// Restore default values:
@@ -791,6 +795,10 @@ void afNewProjectDialog::OnOkButton()
791795
else if (isAndroidRemoteSession)
792796
{
793797
m_projectSettings.setAndroidRemoteDebugging();
798+
799+
// TIZEN FIX disable the status monitor thread on exit
800+
// Otherwise CPU time is wasted during profiling
801+
NotifyExtensionsOfHostTypeChange(lpgpu2::HostType::Local);
794802
}
795803
#endif
796804
//--AT:LPGPU2
@@ -883,6 +891,18 @@ void afNewProjectDialog::OnCancelButton()
883891
// Restore each of the extensions settings:
884892
afProjectManager::instance().restoreCurrentExtensionSettings();
885893

894+
// Check if this is a remote session.
895+
896+
#if LPGPU2_ANDROID_REMOTE_PROTOCOL_COMPILE_IN == 1
897+
bool isAndroidRemoteSession = m_pAndroidDeviceRadioButton->isChecked();
898+
if (isAndroidRemoteSession)
899+
{
900+
// TIZEN FIX disable the status monitor thread on exit
901+
// Otherwise CPU time is wasted during profiling
902+
NotifyExtensionsOfHostTypeChange(lpgpu2::HostType::Local);
903+
}
904+
#endif
905+
886906
// Cancel the dialog and exit:
887907
reject();
888908
}

Diff for: CodeXL/Components/DatabaseLayer/LPGPU2Database/LPGPU2Database/LPGPU2_db_DatabaseAccessor.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2458,9 +2458,11 @@ status LPGPU2DatabaseAccessor::UpdateShaderTraceFromMainShaderPacket(const Shade
24582458
stmtGuard.Bind("@apiId", static_cast<gtUInt32>(vShaderTrace.m_apiId));
24592459

24602460
stmtGuard.Bind("@srcCode", vShaderTrace.m_srcCode);
2461+
#if 0 // TIZEN FIX - The following are not included in the statement m_pUpdateShaderTraceSourceStmt (UPDATE_SHADERTRACE_SOURCE_SQL)
24612462
stmtGuard.Bind("@cpuTime", vShaderTrace.m_cpuTime);
24622463
stmtGuard.Bind("@frameNum", vShaderTrace.m_frameNum);
24632464
stmtGuard.Bind("@drawNum", vShaderTrace.m_drawNum);
2465+
#endif
24642466

24652467
stmtGuard.Exec();
24662468

Diff for: CodeXL/Components/GpuProfiling/Backend/Common/FileUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1081,13 +1081,13 @@ bool FileUtils::MergeTmpTraceFiles(SP_outStream& sout,
10811081

10821082
// ++LPGPU2: Thales: This fixes the parsing of the trace files when merging them.
10831083
gtString finalPrefix = strFilePrefix;
1084-
finalPrefix.append(L"*");
1084+
finalPrefix.append(L"*");
10851085
// --LPGPU2: Thales: This fixes the parsing of the trace files when merging them.
10861086

10871087
bool ret = tempFileDirectory.getContainedFilePaths(finalPrefix, osDirectory::SORT_BY_NAME_ASCENDING, files);
10881088

10891089
if (files.size() == 0)
1090-
{
1090+
{
10911091
Log(logWARNING, "No temp files found under %s. Nothing will be merged.\n", strTmpFilesDirPath.asUTF8CharArray());
10921092
return false;
10931093
}

Diff for: CodeXL/Components/PowerProfiling/AMDTPowerProfiling/Include/ppStringConstants.h

+3
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@
322322
#define PP_STR_iGPUDisabledMsg "iGPU is Disabled. Some of the counters will be disabled."
323323
#define PP_STR_dbMigrateFailureMsg "Unable to migrate the older version of CodeXL profile database."
324324
#define PP_STR_ProjectSettingsPathsInvalid AF_STR_newProjectExeDoesNotExistOrInvalid
325+
#define PP_STR_ADBStartErrorMessage L"Failed to start ADB connection"
326+
#define PP_STR_RAgentStartErrorMessage L"Failed to start RAgent"
327+
#define PP_STR_RAgentStopErrorMessage L"Failed to stop RAgent"
325328

326329
// Strings for metrics calculations:
327330
#define PP_STR_LongestCounterName PP_STR_Counter_AvgFreq_Core0

Diff for: CodeXL/Components/PowerProfiling/AMDTPowerProfiling/src/LPGPU2ppADBCommandsExecutor.cpp

+103-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// STL:
2222
#include <chrono>
2323

24+
#if AMDT_BUILD_TARGET == AMDT_LINUX_OS
25+
#include <unistd.h>
26+
#endif
27+
2428
/// @brief Interval between ADB system queries.
2529
static constexpr auto gs_ADBMonitorTimerInterval = std::chrono::milliseconds{ 2000 };
2630

@@ -113,6 +117,21 @@ void LPGPU2ppADBCommandExecutor::OnStartMonitoring()
113117
m_adbObserverTimerId = startTimer(gs_ADBMonitorTimerInterval.count());
114118
}
115119

120+
///@brief TIZEN FIX do not monitor during capture as this leads to high CPU utilization
121+
void LPGPU2ppADBCommandExecutor::PauseMonitoring()
122+
{
123+
if (m_adbObserverTimerId != -1)
124+
{
125+
killTimer(m_adbObserverTimerId);
126+
}
127+
}
128+
129+
///@brief TIZEN FIX resume device status monitoring after capture has finished
130+
void LPGPU2ppADBCommandExecutor::ResumeMonitoring()
131+
{
132+
m_adbObserverTimerId = startTimer(gs_ADBMonitorTimerInterval.count());
133+
}
134+
116135
/// @brief Handles request to start ADB as a server.
117136
/// @warning If ADB is already running this method does nothing.
118137
void LPGPU2ppADBCommandExecutor::OnStartADB()
@@ -150,7 +169,19 @@ void LPGPU2ppADBCommandExecutor::OnStartRAgent()
150169
if (m_bIsADBRunning && m_bIsRAgentInstalled && !m_bIsRAgentRunning)
151170
{
152171
gtString output;
153-
if (ExecADBCommand(L"shell am start -W -n agent.remote.lpgpu2.lpgpu2ragent/agent.remote.lpgpu2.lpgpu2ragent.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER", output) == lpgpu2::PPFnStatus::success)
172+
gtString command;
173+
174+
if (!m_bIsTizenTarget)
175+
{
176+
command = L"shell am start -W -n agent.remote.lpgpu2.lpgpu2ragent/agent.remote.lpgpu2.lpgpu2ragent.MainActivity"
177+
" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER";
178+
}
179+
else
180+
{
181+
command = L"shell \"nohup /opt/usr/lpgpu2-remote-agent/start_ragent.sh > /tmp/lpgpu2-remote-agent.log\"";
182+
}
183+
184+
if (ExecADBCommand(command, output) == lpgpu2::PPFnStatus::success)
154185
{
155186
const auto bIsRAgentRunning = GetRAgentRunningStatus();
156187
SetRAgentRunning(bIsRAgentRunning);
@@ -165,7 +196,15 @@ void LPGPU2ppADBCommandExecutor::OnStopRAgent()
165196
if (m_bIsADBRunning && m_bIsRAgentInstalled && m_bIsRAgentRunning)
166197
{
167198
gtString output;
168-
ExecADBCommand(L"shell am force-stop agent.remote.lpgpu2.lpgpu2ragent", output);
199+
if (!m_bIsTizenTarget)
200+
{
201+
ExecADBCommand(L"shell am force-stop agent.remote.lpgpu2.lpgpu2ragent", output);
202+
}
203+
else
204+
{
205+
ExecADBCommand(L"shell /opt/usr/lpgpu2-remote-agent/stop_ragent.sh", output);
206+
}
207+
169208
const auto bIsRAgentRunning = GetRAgentRunningStatus();
170209
SetRAgentRunning(bIsRAgentRunning);
171210
}
@@ -278,6 +317,26 @@ bool LPGPU2ppADBCommandExecutor::GetADBRunningStatus() const
278317
#if AMDT_BUILD_TARGET == AMDT_WINDOWS_OS
279318
return osIsProcessAlive(L"adb.exe");
280319
#elif AMDT_BUILD_TARGET == AMDT_LINUX_OS
320+
// Tizen - use the specified debug bridge if set
321+
if (!m_ADBPath.isEmpty())
322+
{
323+
gtString adbFilename;
324+
m_ADBPath.getFileNameAndExtension(adbFilename);
325+
326+
// Resolve a symbolic link if necessary
327+
const char* pPathAsChars = m_ADBPath.asString().asASCIICharArray();
328+
gtString adbFilepath = m_ADBPath.asString();
329+
char buf[512] = {};
330+
int count = readlink(pPathAsChars, buf, sizeof(buf));
331+
if (count > 0)
332+
{
333+
gtString name;
334+
adbFilename.fromASCIIString(buf);
335+
}
336+
337+
return osIsProcessAlive(adbFilename);
338+
}
339+
281340
return osIsProcessAlive(L"adb");
282341
#else
283342
#error Unsupported OS
@@ -292,9 +351,19 @@ bool LPGPU2ppADBCommandExecutor::GetRAgentInstallationStatus() const
292351
auto bReturn = false;
293352

294353
gtString output;
295-
if (ExecADBCommand(L"shell pm list packages | grep package:agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
354+
if (!m_bIsTizenTarget)
296355
{
297-
bReturn = output.trim().compareNoCase(L"package:agent.remote.lpgpu2.lpgpu2ragent") == 0;
356+
if (ExecADBCommand(L"shell pm list packages | grep package:agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
357+
{
358+
bReturn = output.trim().compareNoCase(L"package:agent.remote.lpgpu2.lpgpu2ragent") == 0;
359+
}
360+
}
361+
else
362+
{
363+
if (ExecADBCommand(L"shell rpm -qa | grep lpgpu2-remote-agent-0.0.1-01.armv7l", output) == lpgpu2::PPFnStatus::success)
364+
{
365+
bReturn = output.trim().compareNoCase(L"lpgpu2-remote-agent-0.0.1-01.armv7l") == 0;
366+
}
298367
}
299368

300369
return bReturn;
@@ -308,9 +377,19 @@ bool LPGPU2ppADBCommandExecutor::GetRAgentRunningStatus() const
308377
auto bReturn = false;
309378

310379
gtString output;
311-
if (ExecADBCommand(L"shell ps | grep agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
380+
if (!m_bIsTizenTarget)
381+
{
382+
if (ExecADBCommand(L"shell ps | grep agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
383+
{
384+
bReturn = !output.isEmpty();
385+
}
386+
}
387+
else
312388
{
313-
bReturn = !output.isEmpty();
389+
if (ExecADBCommand(L"shell ps -ef | grep lpgpu2-remote-agent", output) == lpgpu2::PPFnStatus::success)
390+
{
391+
bReturn = !output.isEmpty();
392+
}
314393
}
315394

316395
return bReturn;
@@ -361,6 +440,15 @@ gtVector<gtString> LPGPU2ppADBCommandExecutor::GetAttachedDevices() const
361440
deviceModelCmd += L" shell getprop ro.product.model";
362441
if (ExecADBCommand(deviceModelCmd, output, bNoDevice) == lpgpu2::PPFnStatus::success)
363442
{
443+
// Fallback to Tizen
444+
if (output.find(L"command not found"))
445+
{
446+
deviceModelCmd = L"-s ";
447+
deviceModelCmd += deviceName;
448+
deviceModelCmd += L" shell cat /etc/info.ini | grep Model";
449+
ExecADBCommand(deviceModelCmd, output, bNoDevice);
450+
}
451+
364452
deviceName += L" (";
365453
deviceName += output.trim();
366454
deviceName += L")";
@@ -404,6 +492,15 @@ void LPGPU2ppADBCommandExecutor::ValidateADBPath()
404492
if (line.find(searchText) != -1)
405493
{
406494
line.getSubString(searchText.length() + 1, line.length(), m_ADBVersion);
495+
m_bIsTizenTarget = false;
496+
}
497+
498+
// Tizen support
499+
searchText = L"Smart Development Bridge version";
500+
if (line.find(searchText) != -1)
501+
{
502+
line.getSubString(searchText.length() + 1, line.length(), m_ADBVersion);
503+
m_bIsTizenTarget = true;
407504
}
408505

409506
searchText = L"Revision";

Diff for: CodeXL/Components/PowerProfiling/AMDTPowerProfiling/src/LPGPU2ppADBCommandsExecutor.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public slots:
9898
void SetRAgentInstalledStatus(bool vbIsInstalled);
9999
void SetRAgentRunning(bool vbIsRunning);
100100
void SetADBDevices(gtVector<gtString> &&vNewDevices);
101+
void PauseMonitoring();
102+
void ResumeMonitoring();
101103

102104
// Attributes:
103105
private:
@@ -108,6 +110,7 @@ public slots:
108110
int m_adbObserverTimerId = -1; //!< The timer id used by this object to monitor the ADB status.
109111

110112
bool m_bIsADBPathValid = false;
113+
bool m_bIsTizenTarget = false;
111114
osFilePath m_ADBPath;
112115
gtString m_ADBVersion;
113116
gtString m_ADBRevision;
@@ -116,4 +119,4 @@ public slots:
116119
};
117120
// clang-format on
118121

119-
#endif // LPGPU2_PP_ADB_COMMAND_EXECUTOR_H_INCLUDE
122+
#endif // LPGPU2_PP_ADB_COMMAND_EXECUTOR_H_INCLUDE

Diff for: CodeXL/Components/PowerProfiling/AMDTPowerProfiling/src/LPGPU2ppFeedbackEngineDialog.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,19 @@ PPFnStatus LPGPU2ppFeedbackEngineDialog::OnLoadScript()
553553
// Store the option widget so we can delete it later
554554
m_feedbackOptionsList.append(pOptionWidget);
555555

556-
// Connect the select all checkbox event to enable the option widgets.
557-
connect(m_pSelectAllCheckBox, &QCheckBox::stateChanged, pOptionWidget, &LPGPU2ppFeedbackEngineOptionWidget::SetOptionEnabled);
558-
connect(pOptionWidget, &LPGPU2ppFeedbackEngineOptionWidget::OptionsEnabledChanged, this, &LPGPU2ppFeedbackEngineDialog::OnOptionEnabledChanged);
556+
// TIZEN FIX Disable call_sequence_analysis feedback
557+
if (acGTStringToQString(feedbackOption.scriptFunction).compare("call_sequence_analysis") == 0)
558+
{
559+
// Don't support this as it breaks the system by using memory
560+
pOptionWidget->setEnabled(false);
561+
}
562+
else
563+
{
564+
565+
// Connect the select all checkbox event to enable the option widgets.
566+
connect(m_pSelectAllCheckBox, &QCheckBox::stateChanged, pOptionWidget, &LPGPU2ppFeedbackEngineOptionWidget::SetOptionEnabled);
567+
connect(pOptionWidget, &LPGPU2ppFeedbackEngineOptionWidget::OptionsEnabledChanged, this, &LPGPU2ppFeedbackEngineDialog::OnOptionEnabledChanged);
568+
}
559569

560570
// Finally add the option widget to the group box layout
561571
pCategoryGroupBoxLayout->addWidget(pOptionWidget);

Diff for: CodeXL/Components/PowerProfiling/AMDTPowerProfiling/src/ppAppController.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ void ppAppController::onProfileStarted(const gtString& profileTypeStr, const spI
501501
if (now - startLoopTime > LPGPU2ppADBCommands::MaxStartAdbWaitTime)
502502
{
503503
bIsAndroidOk = false;
504+
OS_OUTPUT_DEBUG_LOG(PP_STR_ADBStartErrorMessage, OS_DEBUG_LOG_ERROR);
504505
break;
505506
}
506507
}
@@ -523,6 +524,7 @@ void ppAppController::onProfileStarted(const gtString& profileTypeStr, const spI
523524
if (now - startLoopTime > LPGPU2ppADBCommands::MaxStopRAgentWaitTime)
524525
{
525526
bIsAndroidOk = false;
527+
OS_OUTPUT_DEBUG_LOG(PP_STR_RAgentStopErrorMessage, OS_DEBUG_LOG_ERROR);
526528
break;
527529
}
528530
}
@@ -542,6 +544,7 @@ void ppAppController::onProfileStarted(const gtString& profileTypeStr, const spI
542544
if (now - startLoopTime > LPGPU2ppADBCommands::MaxStartRAgentWaitTime)
543545
{
544546
bIsAndroidOk = false;
547+
OS_OUTPUT_DEBUG_LOG(PP_STR_RAgentStartErrorMessage, OS_DEBUG_LOG_ERROR);
545548
break;
546549
}
547550
}

Diff for: CodeXL/Components/PowerProfiling/AMDTPowerProfiling/src/ppLPGPU2CollectionDefs.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -560,17 +560,31 @@ CollectionDefs CollectionDefs::Builder::Build()
560560
pCollection->LinkEndChild(pCaptureShaders);
561561

562562

563+
// TIZEN FIX set override even when m_commands is empty
564+
#define FORCE_DEFAULT_OVERRIDE 1
565+
#if FORCE_DEFAULT_OVERRIDE // new code
566+
567+
// Command Names
568+
TiXmlElement* pCommandNames = new TiXmlElement("CommandNames");
569+
if (m_commandsDefaultOverride != none)
570+
{
571+
pCommandNames->SetAttribute("DefaultOverride",
572+
ToString(m_commandsDefaultOverride));
573+
}
574+
#endif
575+
563576
// Commands
564577
if (m_commands.size() > 0)
565578
{
579+
#if !FORCE_DEFAULT_OVERRIDE // original code
566580
// Command Names
567581
TiXmlElement* pCommandNames = new TiXmlElement("CommandNames");
568582
if (m_commandsDefaultOverride != none)
569583
{
570584
pCommandNames->SetAttribute("DefaultOverride",
571585
ToString(m_commandsDefaultOverride));
572586
}
573-
587+
#endif
574588
for (const auto &item : m_commands)
575589
{
576590
const auto &cmnd = item.second;
@@ -583,9 +597,15 @@ CollectionDefs CollectionDefs::Builder::Build()
583597
pCommandNames->LinkEndChild(pCommand);
584598
}
585599

600+
#if !FORCE_DEFAULT_OVERRIDE // original code
586601
pCollection->LinkEndChild(pCommandNames);
602+
#endif
587603
}
588604

605+
#if FORCE_DEFAULT_OVERRIDE // new code
606+
pCollection->LinkEndChild(pCommandNames);
607+
#endif
608+
589609
// Config (NumberedBufferSize)
590610
TiXmlElement* pNumberedBufferSize = new TiXmlElement("Config");
591611
pNumberedBufferSize->SetAttribute("Name", "NumberedBufferSize");
@@ -760,10 +780,11 @@ CollectionDefs::Builder::SetCommandName(gtUInt32 apiId,
760780

761781
if (apiInfo != apisLUT.end())
762782
{
783+
// TIZEN FIX set cmdName before first use
784+
cmdName.assign(originalCommandName.asASCIICharArray());
763785
auto cmdInfoPtr = apiInfo->second.cmdNamesLUT.find(cmdName);
764786
if (cmdInfoPtr != apiInfo->second.cmdNamesLUT.end())
765787
{
766-
cmdName.assign(originalCommandName.asASCIICharArray());
767788
gtUInt32 commandId = (gtUInt32)cmdInfoPtr->second;
768789

769790
m_commands.insert(std::pair<gtUInt32, APICommand>(commandId, APICommand{ commandId, originalCommandName,

0 commit comments

Comments
 (0)