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

Commit

Permalink
[SAMS]: Added support to connect to a Tizen device.
Browse files Browse the repository at this point in the history
 Allow use of sdb instead of adb
  • Loading branch information
Thales Sabino committed Dec 6, 2018
1 parent 6112af2 commit 82a67ae
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#define LPGPU2_APPLICATION_DEFS_H

#define LPGPU2_CODEXL_APPLICATION_VERSION_MAJOR 3
#define LPGPU2_CODEXL_APPLICATION_VERSION_MINOR 9
#define LPGPU2_CODEXL_APPLICATION_VERSION_PATCH 4
#define LPGPU2_CODEXL_APPLICATION_VERSION_MINOR 10
#define LPGPU2_CODEXL_APPLICATION_VERSION_PATCH 0
#define LPGPU2_CODEXL_APPLICATION_VERSION_SUFFIX ""

#endif // LPGPU2_APPLICATION_DEFS_H
20 changes: 20 additions & 0 deletions CodeXL/AMDTApplicationFramework/src/afNewProjectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ void afNewProjectDialog::ShowDialog(afDialogMode mode, const gtString& selectedT
// Initialize the current project settings:
initDialogCurrentProjectSettings();

// TIZEN FIX start the status monitor thread when the dialog is displayed
if (m_projectSettings.isAndroidDeviceTarget())
NotifyExtensionsOfHostTypeChange(lpgpu2::HostType::LPGPU2);

if (mode == AF_DIALOG_NEW_PROJECT)
{
// Restore default values:
Expand Down Expand Up @@ -791,6 +795,10 @@ void afNewProjectDialog::OnOkButton()
else if (isAndroidRemoteSession)
{
m_projectSettings.setAndroidRemoteDebugging();

// TIZEN FIX disable the status monitor thread on exit
// Otherwise CPU time is wasted during profiling
NotifyExtensionsOfHostTypeChange(lpgpu2::HostType::Local);
}
#endif
//--AT:LPGPU2
Expand Down Expand Up @@ -883,6 +891,18 @@ void afNewProjectDialog::OnCancelButton()
// Restore each of the extensions settings:
afProjectManager::instance().restoreCurrentExtensionSettings();

// Check if this is a remote session.

#if LPGPU2_ANDROID_REMOTE_PROTOCOL_COMPILE_IN == 1
bool isAndroidRemoteSession = m_pAndroidDeviceRadioButton->isChecked();
if (isAndroidRemoteSession)
{
// TIZEN FIX disable the status monitor thread on exit
// Otherwise CPU time is wasted during profiling
NotifyExtensionsOfHostTypeChange(lpgpu2::HostType::Local);
}
#endif

// Cancel the dialog and exit:
reject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2458,9 +2458,11 @@ status LPGPU2DatabaseAccessor::UpdateShaderTraceFromMainShaderPacket(const Shade
stmtGuard.Bind("@apiId", static_cast<gtUInt32>(vShaderTrace.m_apiId));

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

stmtGuard.Exec();

Expand Down
4 changes: 2 additions & 2 deletions CodeXL/Components/GpuProfiling/Backend/Common/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,13 @@ bool FileUtils::MergeTmpTraceFiles(SP_outStream& sout,

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

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

if (files.size() == 0)
{
{
Log(logWARNING, "No temp files found under %s. Nothing will be merged.\n", strTmpFilesDirPath.asUTF8CharArray());
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
#define PP_STR_iGPUDisabledMsg "iGPU is Disabled. Some of the counters will be disabled."
#define PP_STR_dbMigrateFailureMsg "Unable to migrate the older version of CodeXL profile database."
#define PP_STR_ProjectSettingsPathsInvalid AF_STR_newProjectExeDoesNotExistOrInvalid
#define PP_STR_ADBStartErrorMessage L"Failed to start ADB connection"
#define PP_STR_RAgentStartErrorMessage L"Failed to start RAgent"
#define PP_STR_RAgentStopErrorMessage L"Failed to stop RAgent"

// Strings for metrics calculations:
#define PP_STR_LongestCounterName PP_STR_Counter_AvgFreq_Core0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
// STL:
#include <chrono>

#if AMDT_BUILD_TARGET == AMDT_LINUX_OS
#include <unistd.h>
#endif

/// @brief Interval between ADB system queries.
static constexpr auto gs_ADBMonitorTimerInterval = std::chrono::milliseconds{ 2000 };

Expand Down Expand Up @@ -113,6 +117,21 @@ void LPGPU2ppADBCommandExecutor::OnStartMonitoring()
m_adbObserverTimerId = startTimer(gs_ADBMonitorTimerInterval.count());
}

///@brief TIZEN FIX do not monitor during capture as this leads to high CPU utilization
void LPGPU2ppADBCommandExecutor::PauseMonitoring()
{
if (m_adbObserverTimerId != -1)
{
killTimer(m_adbObserverTimerId);
}
}

///@brief TIZEN FIX resume device status monitoring after capture has finished
void LPGPU2ppADBCommandExecutor::ResumeMonitoring()
{
m_adbObserverTimerId = startTimer(gs_ADBMonitorTimerInterval.count());
}

/// @brief Handles request to start ADB as a server.
/// @warning If ADB is already running this method does nothing.
void LPGPU2ppADBCommandExecutor::OnStartADB()
Expand Down Expand Up @@ -150,7 +169,19 @@ void LPGPU2ppADBCommandExecutor::OnStartRAgent()
if (m_bIsADBRunning && m_bIsRAgentInstalled && !m_bIsRAgentRunning)
{
gtString output;
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)
gtString command;

if (!m_bIsTizenTarget)
{
command = 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";
}
else
{
command = L"shell \"nohup /opt/usr/lpgpu2-remote-agent/start_ragent.sh > /tmp/lpgpu2-remote-agent.log\"";
}

if (ExecADBCommand(command, output) == lpgpu2::PPFnStatus::success)
{
const auto bIsRAgentRunning = GetRAgentRunningStatus();
SetRAgentRunning(bIsRAgentRunning);
Expand All @@ -165,7 +196,15 @@ void LPGPU2ppADBCommandExecutor::OnStopRAgent()
if (m_bIsADBRunning && m_bIsRAgentInstalled && m_bIsRAgentRunning)
{
gtString output;
ExecADBCommand(L"shell am force-stop agent.remote.lpgpu2.lpgpu2ragent", output);
if (!m_bIsTizenTarget)
{
ExecADBCommand(L"shell am force-stop agent.remote.lpgpu2.lpgpu2ragent", output);
}
else
{
ExecADBCommand(L"shell /opt/usr/lpgpu2-remote-agent/stop_ragent.sh", output);
}

const auto bIsRAgentRunning = GetRAgentRunningStatus();
SetRAgentRunning(bIsRAgentRunning);
}
Expand Down Expand Up @@ -278,6 +317,26 @@ bool LPGPU2ppADBCommandExecutor::GetADBRunningStatus() const
#if AMDT_BUILD_TARGET == AMDT_WINDOWS_OS
return osIsProcessAlive(L"adb.exe");
#elif AMDT_BUILD_TARGET == AMDT_LINUX_OS
// Tizen - use the specified debug bridge if set
if (!m_ADBPath.isEmpty())
{
gtString adbFilename;
m_ADBPath.getFileNameAndExtension(adbFilename);

// Resolve a symbolic link if necessary
const char* pPathAsChars = m_ADBPath.asString().asASCIICharArray();
gtString adbFilepath = m_ADBPath.asString();
char buf[512] = {};
int count = readlink(pPathAsChars, buf, sizeof(buf));
if (count > 0)
{
gtString name;
adbFilename.fromASCIIString(buf);
}

return osIsProcessAlive(adbFilename);
}

return osIsProcessAlive(L"adb");
#else
#error Unsupported OS
Expand All @@ -292,9 +351,19 @@ bool LPGPU2ppADBCommandExecutor::GetRAgentInstallationStatus() const
auto bReturn = false;

gtString output;
if (ExecADBCommand(L"shell pm list packages | grep package:agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
if (!m_bIsTizenTarget)
{
bReturn = output.trim().compareNoCase(L"package:agent.remote.lpgpu2.lpgpu2ragent") == 0;
if (ExecADBCommand(L"shell pm list packages | grep package:agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
{
bReturn = output.trim().compareNoCase(L"package:agent.remote.lpgpu2.lpgpu2ragent") == 0;
}
}
else
{
if (ExecADBCommand(L"shell rpm -qa | grep lpgpu2-remote-agent-0.0.1-01.armv7l", output) == lpgpu2::PPFnStatus::success)
{
bReturn = output.trim().compareNoCase(L"lpgpu2-remote-agent-0.0.1-01.armv7l") == 0;
}
}

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

gtString output;
if (ExecADBCommand(L"shell ps | grep agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
if (!m_bIsTizenTarget)
{
if (ExecADBCommand(L"shell ps | grep agent.remote.lpgpu2.lpgpu2ragent", output) == lpgpu2::PPFnStatus::success)
{
bReturn = !output.isEmpty();
}
}
else
{
bReturn = !output.isEmpty();
if (ExecADBCommand(L"shell ps -ef | grep lpgpu2-remote-agent", output) == lpgpu2::PPFnStatus::success)
{
bReturn = !output.isEmpty();
}
}

return bReturn;
Expand Down Expand Up @@ -361,6 +440,15 @@ gtVector<gtString> LPGPU2ppADBCommandExecutor::GetAttachedDevices() const
deviceModelCmd += L" shell getprop ro.product.model";
if (ExecADBCommand(deviceModelCmd, output, bNoDevice) == lpgpu2::PPFnStatus::success)
{
// Fallback to Tizen
if (output.find(L"command not found"))
{
deviceModelCmd = L"-s ";
deviceModelCmd += deviceName;
deviceModelCmd += L" shell cat /etc/info.ini | grep Model";
ExecADBCommand(deviceModelCmd, output, bNoDevice);
}

deviceName += L" (";
deviceName += output.trim();
deviceName += L")";
Expand Down Expand Up @@ -404,6 +492,15 @@ void LPGPU2ppADBCommandExecutor::ValidateADBPath()
if (line.find(searchText) != -1)
{
line.getSubString(searchText.length() + 1, line.length(), m_ADBVersion);
m_bIsTizenTarget = false;
}

// Tizen support
searchText = L"Smart Development Bridge version";
if (line.find(searchText) != -1)
{
line.getSubString(searchText.length() + 1, line.length(), m_ADBVersion);
m_bIsTizenTarget = true;
}

searchText = L"Revision";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public slots:
void SetRAgentInstalledStatus(bool vbIsInstalled);
void SetRAgentRunning(bool vbIsRunning);
void SetADBDevices(gtVector<gtString> &&vNewDevices);
void PauseMonitoring();
void ResumeMonitoring();

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

bool m_bIsADBPathValid = false;
bool m_bIsTizenTarget = false;
osFilePath m_ADBPath;
gtString m_ADBVersion;
gtString m_ADBRevision;
Expand All @@ -116,4 +119,4 @@ public slots:
};
// clang-format on

#endif // LPGPU2_PP_ADB_COMMAND_EXECUTOR_H_INCLUDE
#endif // LPGPU2_PP_ADB_COMMAND_EXECUTOR_H_INCLUDE
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,19 @@ PPFnStatus LPGPU2ppFeedbackEngineDialog::OnLoadScript()
// Store the option widget so we can delete it later
m_feedbackOptionsList.append(pOptionWidget);

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

// Connect the select all checkbox event to enable the option widgets.
connect(m_pSelectAllCheckBox, &QCheckBox::stateChanged, pOptionWidget, &LPGPU2ppFeedbackEngineOptionWidget::SetOptionEnabled);
connect(pOptionWidget, &LPGPU2ppFeedbackEngineOptionWidget::OptionsEnabledChanged, this, &LPGPU2ppFeedbackEngineDialog::OnOptionEnabledChanged);
}

// Finally add the option widget to the group box layout
pCategoryGroupBoxLayout->addWidget(pOptionWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ void ppAppController::onProfileStarted(const gtString& profileTypeStr, const spI
if (now - startLoopTime > LPGPU2ppADBCommands::MaxStartAdbWaitTime)
{
bIsAndroidOk = false;
OS_OUTPUT_DEBUG_LOG(PP_STR_ADBStartErrorMessage, OS_DEBUG_LOG_ERROR);
break;
}
}
Expand All @@ -523,6 +524,7 @@ void ppAppController::onProfileStarted(const gtString& profileTypeStr, const spI
if (now - startLoopTime > LPGPU2ppADBCommands::MaxStopRAgentWaitTime)
{
bIsAndroidOk = false;
OS_OUTPUT_DEBUG_LOG(PP_STR_RAgentStopErrorMessage, OS_DEBUG_LOG_ERROR);
break;
}
}
Expand All @@ -542,6 +544,7 @@ void ppAppController::onProfileStarted(const gtString& profileTypeStr, const spI
if (now - startLoopTime > LPGPU2ppADBCommands::MaxStartRAgentWaitTime)
{
bIsAndroidOk = false;
OS_OUTPUT_DEBUG_LOG(PP_STR_RAgentStartErrorMessage, OS_DEBUG_LOG_ERROR);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,31 @@ CollectionDefs CollectionDefs::Builder::Build()
pCollection->LinkEndChild(pCaptureShaders);


// TIZEN FIX set override even when m_commands is empty
#define FORCE_DEFAULT_OVERRIDE 1
#if FORCE_DEFAULT_OVERRIDE // new code

// Command Names
TiXmlElement* pCommandNames = new TiXmlElement("CommandNames");
if (m_commandsDefaultOverride != none)
{
pCommandNames->SetAttribute("DefaultOverride",
ToString(m_commandsDefaultOverride));
}
#endif

// Commands
if (m_commands.size() > 0)
{
#if !FORCE_DEFAULT_OVERRIDE // original code
// Command Names
TiXmlElement* pCommandNames = new TiXmlElement("CommandNames");
if (m_commandsDefaultOverride != none)
{
pCommandNames->SetAttribute("DefaultOverride",
ToString(m_commandsDefaultOverride));
}

#endif
for (const auto &item : m_commands)
{
const auto &cmnd = item.second;
Expand All @@ -583,9 +597,15 @@ CollectionDefs CollectionDefs::Builder::Build()
pCommandNames->LinkEndChild(pCommand);
}

#if !FORCE_DEFAULT_OVERRIDE // original code
pCollection->LinkEndChild(pCommandNames);
#endif
}

#if FORCE_DEFAULT_OVERRIDE // new code
pCollection->LinkEndChild(pCommandNames);
#endif

// Config (NumberedBufferSize)
TiXmlElement* pNumberedBufferSize = new TiXmlElement("Config");
pNumberedBufferSize->SetAttribute("Name", "NumberedBufferSize");
Expand Down Expand Up @@ -760,10 +780,11 @@ CollectionDefs::Builder::SetCommandName(gtUInt32 apiId,

if (apiInfo != apisLUT.end())
{
// TIZEN FIX set cmdName before first use
cmdName.assign(originalCommandName.asASCIICharArray());
auto cmdInfoPtr = apiInfo->second.cmdNamesLUT.find(cmdName);
if (cmdInfoPtr != apiInfo->second.cmdNamesLUT.end())
{
cmdName.assign(originalCommandName.asASCIICharArray());
gtUInt32 commandId = (gtUInt32)cmdInfoPtr->second;

m_commands.insert(std::pair<gtUInt32, APICommand>(commandId, APICommand{ commandId, originalCommandName,
Expand Down
Loading

0 comments on commit 82a67ae

Please sign in to comment.