private void ReloadProjectSymbols()
        {
            vacVisualMapView.Symbols.Clear();
            _symbolParser.ClearSymbols();

            if (cmbProjectList.SelectedItem == null)
            {
                return;
            }

            String projectName = (String)cmbProjectList.SelectedItem.ToString();

            if (String.IsNullOrEmpty(projectName))
            {
                return;
            }

            Project project = null;

            try
            {
                project = _DTE.Solution.Item(projectName);
            }
            catch { }

            if (project == null)
            {
                return;
            }

            IProjectHandle projectNode = project.Object as IProjectHandle;

            if (projectNode == null)
            {
                return;
            }

            string elfPath = null;

            string previousDirectory = Directory.GetCurrentDirectory();

            try
            {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(project.FullName));
                elfPath = Path.GetFullPath(Path.Combine(projectNode.GetProperty("OutputDirectory"), projectNode.GetProperty("OutputFilename") + ".elf"));
            }
            finally
            {
                Directory.SetCurrentDirectory(previousDirectory);
            }

            string toolchainNMPath = GetContentLocation("GNU-NM");

            if (File.Exists(elfPath) && File.Exists(toolchainNMPath))
            {
                DispatcherOperation dispatcher = Dispatcher.BeginInvoke(
                    new Action(
                        () => _symbolParser.ReloadSymbols(elfPath, toolchainNMPath)
                        )
                    );

                dispatcher.Completed += (s, e) =>
                {
                    vacVisualMapView.Symbols.AddRange(_symbolParser.SymbolSizes);
                    vacVisualMapView.InvalidateVisual();
                };

                if (dispatcher.Status == DispatcherOperationStatus.Completed)
                {
                    vacVisualMapView.Symbols.AddRange(_symbolParser.SymbolSizes);
                    vacVisualMapView.InvalidateVisual();
                }
            }
        }
Example #2
0
        private void ReloadProjectSymbols()
        {
            mSymbolParser.ClearSymbols();

            ShowError("No project is currently selected.", "Select a project from the toolbar to display symbols.");

            if (projectList.SelectedItem == null)
            {
                return;
            }

            Project project = projectList.SelectedItem as Project;

            if (project == null)
            {
                return;
            }

            IProjectHandle projectNode = project.Object as IProjectHandle;

            if (projectNode == null)
            {
                ShowError("An internal error has occurred.", "Project could not be loaded.");
                return;
            }

            string elfPath = null;

            string previousDirectory = Directory.GetCurrentDirectory();

            try
            {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(project.FullName));
                elfPath = Path.GetFullPath(Path.Combine(projectNode.GetProperty("OutputDirectory"), projectNode.GetProperty("OutputFilename") + ".elf"));
            }
            finally
            {
                Directory.SetCurrentDirectory(previousDirectory);
            }

            string toolchainNMPath = GetContentLocation("GNU-NM");

            if (!File.Exists(elfPath))
            {
                ShowError("Could not find project ELF file.", "Verify that the ELF file output specified in your project options exists.");
            }
            else if (!File.Exists(toolchainNMPath))
            {
                ShowError("An internal error has occurred.", "GNU NM binary cound not be found.");
            }
            else
            {
                ShowError("No symbols have been loaded.", "Ensure you are compiling in Debug mode, and have debug symbols enabled in your toolchain options.");

                DispatcherOperation dispatcher = Dispatcher.BeginInvoke(
                    new Action(
                        () => mSymbolParser.ReloadSymbols(elfPath, toolchainNMPath, DataSizeViewerPackage.Options.VerifyLocations)
                        )
                    );

                dispatcher.Completed += (s, e) =>
                {
                    if (symbolSize.Items.Count != 0)
                    {
                        ShowSymbolTable();
                    }
                };

                if (dispatcher.Status == DispatcherOperationStatus.Completed)
                {
                    if (symbolSize.Items.Count != 0)
                    {
                        ShowSymbolTable();
                    }
                }
            }
        }