1. Copyrights changed to EPL
2. Feature updates mentioned in release notes.
Binary file srcanamdw/appdep/bin/appdep.exe has changed
Binary file srcanamdw/appdep/bin/cfilt.exe has changed
Binary file srcanamdw/appdep/doc/S60_AppDep_Users_Guide.doc has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/group/Makefile Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,117 @@
+#
+# Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: Makefile
+#
+#
+
+BOOSTHOME = E:/boost_1_33_1
+
+CPP = g++
+CC = gcc
+RES =
+OBJ = ../obj/appdep.o ../obj/appdep_analysis.o ../obj/appdep_cache.o ../obj/appdep_getters.o ../obj/appdep_otherfunc.o ../obj/appdep_sisfiles.o ../obj/appdep_statdeps.o ../obj/appdep_utils.o ../obj/static_mutex.o ../obj/w32_regex_traits.o ../obj/icu.o ../obj/wc_regex_traits.o ../obj/usinstances.o ../obj/cpp_regex_traits.o ../obj/regex_traits_defaults.o ../obj/wide_posix_api.o ../obj/posix_api.o ../obj/fileiter.o ../obj/cregex.o ../obj/c_regex_traits.o ../obj/winstances.o ../obj/regex_raw_buffer.o ../obj/regex_debug.o ../obj/regex.o ../obj/instances.o $(RES)
+LINKOBJ = ../obj/appdep.o ../obj/appdep_analysis.o ../obj/appdep_cache.o ../obj/appdep_getters.o ../obj/appdep_otherfunc.o ../obj/appdep_sisfiles.o ../obj/appdep_statdeps.o ../obj/appdep_utils.o ../obj/static_mutex.o ../obj/w32_regex_traits.o ../obj/icu.o ../obj/wc_regex_traits.o ../obj/usinstances.o ../obj/cpp_regex_traits.o ../obj/regex_traits_defaults.o ../obj/wide_posix_api.o ../obj/posix_api.o ../obj/fileiter.o ../obj/cregex.o ../obj/c_regex_traits.o ../obj/winstances.o ../obj/regex_raw_buffer.o ../obj/regex_debug.o ../obj/regex.o ../obj/instances.o $(RES)
+LIBS =
+INCS = -I../inc -I$(BOOSTHOME)
+CXXINCS = -I../inc -I$(BOOSTHOME)
+BIN = ../bin/appdep
+CXXFLAGS = $(CXXINCS) -pedantic -Wall -Wextra -Wno-long-long
+CFLAGS = $(INCS) -std=c99 -pedantic -Wall -Wextra -Wno-long-long
+RM = rm -f
+
+.PHONY: all all-before all-after clean clean-custom
+
+all: all-before ../bin/appdep all-after
+
+
+clean: clean-custom
+ ${RM} $(OBJ) $(BIN)
+
+$(BIN): $(OBJ)
+ $(CPP) $(LINKOBJ) -o "../bin/appdep" $(LIBS)
+
+../obj/appdep.o: ../src/appdep.cpp
+ $(CPP) -c ../src/appdep.cpp -o ../obj/appdep.o $(CXXFLAGS)
+
+../obj/appdep_analysis.o: ../src/appdep_analysis.cpp
+ $(CPP) -c ../src/appdep_analysis.cpp -o ../obj/appdep_analysis.o $(CXXFLAGS)
+
+../obj/appdep_cache.o: ../src/appdep_cache.cpp
+ $(CPP) -c ../src/appdep_cache.cpp -o ../obj/appdep_cache.o $(CXXFLAGS)
+
+../obj/appdep_getters.o: ../src/appdep_getters.cpp
+ $(CPP) -c ../src/appdep_getters.cpp -o ../obj/appdep_getters.o $(CXXFLAGS)
+
+../obj/appdep_otherfunc.o: ../src/appdep_otherfunc.cpp
+ $(CPP) -c ../src/appdep_otherfunc.cpp -o ../obj/appdep_otherfunc.o $(CXXFLAGS)
+
+../obj/appdep_sisfiles.o: ../src/appdep_sisfiles.cpp
+ $(CPP) -c ../src/appdep_sisfiles.cpp -o ../obj/appdep_sisfiles.o $(CXXFLAGS)
+
+../obj/appdep_statdeps.o: ../src/appdep_statdeps.cpp
+ $(CPP) -c ../src/appdep_statdeps.cpp -o ../obj/appdep_statdeps.o $(CXXFLAGS)
+
+../obj/appdep_utils.o: ../src/appdep_utils.cpp
+ $(CPP) -c ../src/appdep_utils.cpp -o ../obj/appdep_utils.o $(CXXFLAGS)
+
+../obj/static_mutex.o: $(BOOSTHOME)/libs/regex/src/static_mutex.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/static_mutex.cpp -o ../obj/static_mutex.o $(CXXFLAGS)
+
+../obj/w32_regex_traits.o: $(BOOSTHOME)/libs/regex/src/w32_regex_traits.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/w32_regex_traits.cpp -o ../obj/w32_regex_traits.o $(CXXFLAGS)
+
+../obj/icu.o: $(BOOSTHOME)/libs/regex/src/icu.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/icu.cpp -o ../obj/icu.o $(CXXFLAGS)
+
+../obj/wc_regex_traits.o: $(BOOSTHOME)/libs/regex/src/wc_regex_traits.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/wc_regex_traits.cpp -o ../obj/wc_regex_traits.o $(CXXFLAGS)
+
+../obj/usinstances.o: $(BOOSTHOME)/libs/regex/src/usinstances.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/usinstances.cpp -o ../obj/usinstances.o $(CXXFLAGS)
+
+../obj/cpp_regex_traits.o: $(BOOSTHOME)/libs/regex/src/cpp_regex_traits.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/cpp_regex_traits.cpp -o ../obj/cpp_regex_traits.o $(CXXFLAGS)
+
+../obj/regex_traits_defaults.o: $(BOOSTHOME)/libs/regex/src/regex_traits_defaults.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex_traits_defaults.cpp -o ../obj/regex_traits_defaults.o $(CXXFLAGS)
+
+../obj/wide_posix_api.o: $(BOOSTHOME)/libs/regex/src/wide_posix_api.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/wide_posix_api.cpp -o ../obj/wide_posix_api.o $(CXXFLAGS)
+
+../obj/posix_api.o: $(BOOSTHOME)/libs/regex/src/posix_api.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/posix_api.cpp -o ../obj/posix_api.o $(CXXFLAGS)
+
+../obj/fileiter.o: $(BOOSTHOME)/libs/regex/src/fileiter.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/fileiter.cpp -o ../obj/fileiter.o $(CXXFLAGS)
+
+../obj/cregex.o: $(BOOSTHOME)/libs/regex/src/cregex.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/cregex.cpp -o ../obj/cregex.o $(CXXFLAGS)
+
+../obj/c_regex_traits.o: $(BOOSTHOME)/libs/regex/src/c_regex_traits.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/c_regex_traits.cpp -o ../obj/c_regex_traits.o $(CXXFLAGS)
+
+../obj/winstances.o: $(BOOSTHOME)/libs/regex/src/winstances.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/winstances.cpp -o ../obj/winstances.o $(CXXFLAGS)
+
+../obj/regex_raw_buffer.o: $(BOOSTHOME)/libs/regex/src/regex_raw_buffer.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex_raw_buffer.cpp -o ../obj/regex_raw_buffer.o $(CXXFLAGS)
+
+../obj/regex_debug.o: $(BOOSTHOME)/libs/regex/src/regex_debug.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex_debug.cpp -o ../obj/regex_debug.o $(CXXFLAGS)
+
+../obj/regex.o: $(BOOSTHOME)/libs/regex/src/regex.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex.cpp -o ../obj/regex.o $(CXXFLAGS)
+
+../obj/instances.o: $(BOOSTHOME)/libs/regex/src/instances.cpp
+ $(CPP) -c $(BOOSTHOME)/libs/regex/src/instances.cpp -o ../obj/instances.o $(CXXFLAGS)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/group/ReleaseNote.txt Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,90 @@
+========================================================================
+RELEASE NOTE FOR APPDEP, 2.2
+========================================================================
+
+Product Description:
+====================
+AppDep is a command line tool that can be used to resolve static
+dependency information of a component within a Symbian OS build (either
+platform or custom). The tool generates a cache file by reading the data
+from all binaries and import libraries within a release, by using an
+external compiler tool set. The use of a cache file is a fast way to make
+a dependency review, such as what dependencies a binary has, and functions
+and ordinals used in a binary, and to generate dependency lists to a
+component or a function. The tool can also be used to view the properties
+of a binary.
+
+Features:
+=========
+- Generates a cache file appdep-cache-symbol-tables.txt which contain
+ symbol tables of all import libraries within a release
+- Generates a cache file appdep-cache-dependencies.txt which contain
+ dependency information of all binaries within a release
+- Reading data from AppDep generated cache files or from platform
+ generated StaticDependencies.txt
+- Include SIS files under analysis
+- Support for defining multiple target types
+- Support for reading binaries from a release or a debug build
+- Support for reading .lib files or .dso files
+- Display properties of a file
+- Print all static dependencies of a component
+- Print all components that depends on a component
+- Print all functions used by a component
+- Print all components that are using a function
+
+Fixed issues:
+=============
+- Added support for components that include "-" character in the middle of the component name i.e. now
+ also imported function lines of format '27 imports from libdbus-utils{000a0000}[20010154].dll' are parsed
+ correctly from dump created by elftran.exe.
+- Fixed issue 'command '-showfunctions' may report functions with same ordinal twice' which was due to duplicate
+ import function instances found from cache file. Now the possible duplicate import function instances are detected
+ during cache creation and only one import function instance is stored.
+
+Enhancements:
+=============
+- Appdep now scans *.agt and *.fxt files as binaries
+- Changed tool to use elftran.exe instead petran.exe for GCCE and RVCT toolchains (petran.exe is still used for GCC).
+
+New Features:
+=============
+
+System Requirements:
+====================
+Basic Requirements:
+- Windows 2000
+- External RVCT or GCCE tool chain installed when Symbian OS 9.x is
+ being used
+- Symbian OS development environment installed including all related
+ import libraries (.lib or .dso)
+
+Compatibility Issues:
+=====================
+N/A
+
+Known Issues:
+=============
+
+RVCT toolset slowness
+---------------------
+- If your installed RVCT toolset does not have a fixed license, it will
+ get a license for each import library every time. This may cause the
+ cache generation become very slow. If this is causing problems, try
+ --uselibs parameter or use GCCE tool chain instead.
+
+C++filt location when RVCT toolchain is used
+--------------------------------------------
+- When you RVCT toolchain, you must also specify a location to C++filt
+ tool since RVCT toolchain does not provide that. It is recommended to
+ use the cfilt.exe provided with AppDep installed since it has been
+ tested to work correctly. C++filt.exe provided by the platform cannot
+ be used since it is not compatible.
+
+Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
+All rights reserved.
+
+This component and the accompanying materials are made available
+under the terms of "Eclipse Public License v1.0"
+which accompanies this distribution, and is available
+at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/inc/appdep.hpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,335 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Header file of Appdep
+*
+*/
+
+
+#ifndef __APPDEP_HPP__
+#define __APPDEP_HPP__
+
+
+#if (defined(_MSC_VER) && (_MSC_VER < 1400))
+ #error "ERROR: Minimum supported version of Visual C++ is 8.0 (2005)."
+#endif
+
+#ifdef _MSC_VER
+ #pragma message("IMPORTANT: You can use Visual C++ to aid development, but please compile the releasable executable with MinGW/MSYS !!!")
+ #pragma warning(disable:4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
+ #pragma warning(disable:4996) // 'function': was declared deprecated
+ #define _CRT_SECURE_NO_DEPRECATE
+ #ifndef WIN32
+ #error "ERROR: Only Win32 target supported!"
+ #endif
+#endif
+
+
+#include <algorithm>
+#include <string>
+#include <cctype>
+#include <fstream>
+#include <iostream>
+#include <vector>
+#include <sstream>
+#include <time.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <boost/regex.hpp>
+
+#ifdef _MSC_VER
+ #include <direct.h>
+ #define S_ISDIR(m) ((m) & S_IFDIR)
+#else
+ #include <dirent.h>
+#endif
+
+using namespace std;
+
+#define APPDEP_VERSION "2.2"
+#define APPDEP_DATE "27th Nov 2009"
+#define APPDEP_COPYRIGHT_YEARS "2001-2009"
+#define CACHE_ST_FILENAME "appdep-cache_symbol_tables.txt"
+#define CACHE_DEP_FILENAME "appdep-cache_dependencies.txt"
+#define CACHE_ST_HEADER "appdep symbol tables cache version: 101"
+#define CACHE_DEP_HEADER "appdep dependencies cache version: 101"
+#define CACHE_FOOTER "#end"
+#define CACHE_COMMENT_CHAR '#'
+#define CACHE_SEP "|"
+#define TEMP_FILENAME "appdep-temp.txt"
+#define SIS_TEMP_DIR "sistemp"
+#define UNKNOWN "unknown"
+#define NOT_VALID "not valid"
+
+#ifdef WIN32
+ #define DIR_SEPARATOR "\\"
+ #define DIR_SEPARATOR2 '\\'
+ #define DEFAULT_CACHE_DIR "epoc32\\tools\\s60rndtools\\appdep\\cache\\"
+ #define DUMPSIS_LOCATION "epoc32\\tools\\dumpsis.exe"
+ #define PETRAN_LOCATION "epoc32\\tools\\petran.exe" // used for GCC toolchain
+ #define ELFTRAN_LOCATION "epoc32\\tools\\elftran.exe" // used for other toolchains
+ #define EPOC32_RELEASE "epoc32\\release\\"
+ #define GCC_NM_EXE "nm.exe"
+ #define GCCE_NM_EXE "arm-none-symbianelf-nm.exe"
+ #define GCCE_READELF_EXE "arm-none-symbianelf-readelf.exe"
+ #define GCCE_CFILT_EXE "arm-none-symbianelf-c++filt.exe"
+ #define RVCT_ARMAR_EXE "armar.exe"
+ #define RVCT_FROMELF_EXE "fromelf.exe"
+ #define CERR_TO_NULL "2>NUL"
+ #define DIR_COMMAND "dir /b"
+ #define DEL_ALL_COMMAND "del /F /S /Q"
+#else
+ #define DIR_SEPARATOR "/"
+ #define DIR_SEPARATOR2 '/'
+ #define DEFAULT_CACHE_DIR "epoc32/tools/s60rndtools/appdep/cache/"
+ #define DUMPSIS_LOCATION "epoc32/tools/dumpsis"
+ #define PETRAN_LOCATION "epoc32/tools/petran" // used for GCC toolchain
+ #define ELFTRAN_LOCATION "epoc32/tools/elftran" // used for other toolchains
+ #define EPOC32_RELEASE "epoc32/release/"
+ #define GCC_NM_EXE "nm"
+ #define GCCE_NM_EXE "arm-none-symbianelf-nm"
+ #define GCCE_READELF_EXE "arm-none-symbianelf-readelf"
+ #define GCCE_CFILT_EXE "arm-none-symbianelf-c++filt"
+ #define RVCT_ARMAR_EXE "armar"
+ #define RVCT_FROMELF_EXE "fromelf"
+ #define CERR_TO_NULL "2>/dev/null"
+ #define DIR_COMMAND "ls --format=single-column"
+ #define DEL_ALL_COMMAND "rm -f -R"
+ #define _mkdir(X) mkdir(X, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
+ #define _rmdir rmdir
+ #define _unlink unlink
+ #define _popen popen
+ #define _pclose pclose
+#endif
+
+enum ExitStates
+{
+ EXIT_NORMAL = 0,
+ EXIT_INVALID_ARGUMENT,
+ EXIT_NO_TARGETS,
+ EXIT_WRONG_USAGE,
+ EXIT_CANNOT_CREATE_OUTPUT_FILE,
+ EXIT_TOOLCHAIN_NOT_FOUND,
+ EXIT_TARGETDIR_NOT_FOUND,
+ EXIT_CFILT_NOT_FOUND,
+ EXIT_PETRAN_NOT_FOUND,
+ EXIT_TOOLCHAIN_NOT_FOUND_FROM_PATH,
+ EXIT_PATH_VARIABLE_NOT_FOUND,
+ EXIT_ONLY_SUPPORTED_IN_WIN32,
+ EXIT_CANNOT_WRITE_TO_TEMP_FILE,
+ EXIT_ORDINAL_LIST_CORRUPTED,
+ EXIT_COMPONENT_NOT_FOUND,
+ EXIT_INVALID_ORDINAL,
+ EXIT_CANNOT_WRITE_TO_CACHE_FILE,
+ EXIT_CANNOT_OPEN_STATIC_DEPENDENCIES_TXT,
+ EXIT_OPENED_STATIC_DEPENDENCIES_TXT_NOT_SUPPORTED,
+ EXIT_DUMPSIS_NOT_FOUND,
+ EXIT_SIS_FILE_NOT_FOUND,
+ EXIT_SIS_FILE_NOT_SUPPORTED,
+ EXIT_NOT_SIS_FILE,
+ EXIT_SIS_FILE_CANNOT_OPEN_FOR_READING,
+ EXIT_TEMP_SIS_FILE_CANNOT_OPEN_FOR_WRITING,
+ EXIT_NO_PKG_FILE_FOUND,
+ EXIT_PKG_FILE_CANNOT_OPEN_FOR_READING,
+ EXIT_PKG_FORMAT_NOT_SUPPORTED
+};
+
+struct ordinal
+{
+ unsigned int funcpos;
+ string funcname;
+
+ ordinal(unsigned int fp, string fn)
+ {
+ funcpos = fp;
+ funcname = fn;
+ }
+};
+
+struct import
+{
+ unsigned int funcpos;
+ string funcname;
+ bool is_vtable;
+ unsigned int vtable_offset;
+};
+
+struct dependency
+{
+ string filename;
+ vector<import> imports;
+};
+
+struct binary_info
+{
+ string directory;
+ string filename;
+ string binary_format;
+ unsigned long file_size;
+ string uid1;
+ string uid2;
+ string uid3;
+ string secureid;
+ string vendorid;
+ unsigned long capabilities;
+ unsigned long min_heap_size;
+ unsigned long max_heap_size;
+ unsigned long stack_size;
+ time_t mod_time;
+ vector<dependency> dependencies;
+};
+
+struct import_library_info
+{
+ string directory;
+ string filename;
+ time_t mod_time;
+ vector<string> symbol_table;
+};
+
+struct target
+{
+ string name;
+ string release_dir;
+ string release_lib_dir;
+ string release_bin_dir;
+ string cache_dir;
+ string st_cache_path;
+ string dep_cache_path;
+ bool cache_files_valid;
+ vector<string> lib_files;
+ vector<string> bin_files;
+ vector<import_library_info> import_libraries;
+ vector<binary_info> binaries;
+};
+
+
+// global variables
+extern bool _cl_use_gcc;
+extern bool _cl_use_gcce;
+extern bool _cl_use_rvct;
+extern bool _cl_generate_clean_cache;
+extern bool _cl_update_cache;
+extern bool _cl_use_libs;
+extern bool _cl_show_ordinals;
+extern bool _cl_use_udeb;
+extern bool _cl_print_debug;
+extern bool _some_cache_needs_update;
+
+extern string _cl_toolsdir;
+extern string _cl_cachedir;
+extern string _cl_releasedir;
+extern string _cl_targets;
+extern string _cl_cfiltloc;
+extern string _cl_outputfile;
+extern string _cl_configfile;
+extern string _cl_sisfiles;
+extern string _cl_usestaticdepstxt;
+extern string _cl_properties;
+extern string _cl_staticdeps;
+extern string _cl_dependson;
+extern string _cl_showfunctions;
+extern string _cl_usesfunction;
+
+extern string _gcc_nm_location;
+extern string _gcce_nm_location;
+extern string _gcce_readelf_location;
+extern string _gcce_cfilt_location;
+extern string _rvct_armar_location;
+extern string _rvct_fromelf_location;
+extern string _rvct_cfilt_location;
+extern string _petran_location;
+extern string _dumpsis_location;
+extern string _tempfile_location;
+extern string _target_mode;
+
+extern vector<target> _targets;
+extern vector<binary_info> _all_binary_infos;
+extern vector<import_library_info> _all_import_library_infos;
+extern vector<import_library_info> _changed_import_libraries;
+extern vector<string> _sisfiles;
+
+extern unsigned int _current_progress;
+extern unsigned int _current_progress_percentage;
+extern unsigned int _max_progress;
+
+extern ofstream _outputf;
+
+
+// from appdep_otherfunc.cpp
+void ParseCommandLineParameters(int argc, char* argv[]);
+void ShowCommandLineOptionsAndExit();
+void DoInitialChecksAndPreparations();
+void ParseTargets();
+void DoCacheGenerationChecksAndPreparations();
+void GetToolsPathFromEnvironmentVariable();
+void FindImportLibrariesAndBinariesFromReleases();
+void GetFileNamesFromDirectory(const string& directory, const string& filter, vector<string>& resultset);
+void SetAndCheckPetranPath();
+
+// from appdep_utils.cpp
+void PrintOutputLn(const string& s);
+void MakeSureTrailingDirectoryMarkerExists(string& path);
+bool FileExists(const string& path);
+bool DirectoryExists(const string& path);
+bool RemoveFile(const string& path);
+bool RemoveDirectoryWithAllFiles(const string& path);
+string LowerCase(const string& s);
+string Int2Str(int value);
+int Str2Int(const string& s);
+void MkDirAll(const string& path);
+string& TrimRight(string& s);
+string& TrimLeft(string& s);
+string& TrimAll(string& s);
+int StringICmp(const string& s1, const string& s2);
+int StringICmpFileNamesWithoutExtension(const string& s1, const string& s2);
+void InsertQuotesToFilePath(string& s);
+bool ExecuteCommand(const string& command, vector<string>& resultset);
+bool TimestampsMatches(const time_t& orginal_time, const time_t& new_time);
+void ShowProgressInfo(unsigned int& current_progress_percentage, unsigned int& current_progress, unsigned int& max_progress, bool print_initial_value);
+
+// from appdep_getters.cpp
+void GetImportTableWithPetran(const string& petran_location, binary_info& b_info);
+bool ImportFunctionsHasSameOrdinal(import imp1, import imp2);
+void GetSymbolTableWithNM(const string& nm_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table);
+void GetSymbolTableWithReadelf(const string& readelf_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table);
+void GetSymbolTableWithArmar(const string& armar_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table);
+void GetSymbolTableWithFromelf(const string& fromelf_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table);
+void ConvertOrdinalListIntoSymbolTable(const vector<ordinal>& ordinals, vector<string>& symbol_table, const string& lib_path);
+void DemangleOrdinalsInSymbolTable(const string& cfilt_location, vector<string>& symbol_table);
+bool OrdinalCompare(const ordinal& left, const ordinal& right);
+
+// from appdep_cache.cpp
+void ReadDataFromSymbolTablesCache(target& a_target);
+void ReadDataFromDependenciesCache(target& a_target);
+void GetDataFromImportTables(target& a_target);
+void GetDataFromBinaries(target& a_target);
+void WriteDataToSymbolTableCacheFile(const target& a_target);
+void WriteDataToDependenciesCacheFile(const target& a_target);
+
+// from appdep_statdeps.cpp
+void GetDataFromStaticDependenciesTxt();
+
+// from appdep_sisfiles.cpp
+void DoInitialChecksAndPreparationsForSisFiles();
+void AnalyseSisFiles();
+
+// from appdep_analysis.cpp
+void DisplayProperties(const string& binary_name);
+void DisplayStaticDependencies(const string& binary_name);
+void DisplayDependents(const string& binary_name);
+void DisplayFunctions(const string& binary_name);
+void DisplayUsesFunction(const string& function_name);
+
+
+#endif // __APPDEP_HPP__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,278 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Main entry of Appdep
+*
+*/
+
+
+#include "appdep.hpp"
+
+// init globals
+bool _cl_use_gcc = false;
+bool _cl_use_gcce = false;
+bool _cl_use_rvct = false;
+bool _cl_generate_clean_cache = false;
+bool _cl_update_cache = false;
+bool _cl_use_libs = false;
+bool _cl_show_ordinals = false;
+bool _cl_use_udeb = false;
+bool _cl_print_debug = false;
+bool _some_cache_needs_update = false;
+
+string _cl_toolsdir = "";
+string _cl_cachedir = "";
+string _cl_releasedir = "";
+string _cl_targets = "";
+string _cl_cfiltloc = "";
+string _cl_outputfile = "";
+string _cl_configfile = "";
+string _cl_sisfiles = "";
+string _cl_usestaticdepstxt = "";
+string _cl_properties = "";
+string _cl_staticdeps = "";
+string _cl_dependson = "";
+string _cl_showfunctions = "";
+string _cl_usesfunction = "";
+
+string _gcc_nm_location = "";
+string _gcce_nm_location = "";
+string _gcce_readelf_location = "";
+string _gcce_cfilt_location = "";
+string _rvct_armar_location = "";
+string _rvct_fromelf_location = "";
+string _rvct_cfilt_location = "";
+string _petran_location = "";
+string _dumpsis_location = "";
+string _tempfile_location = "";
+string _target_mode = "";
+
+vector<target> _targets;
+vector<binary_info> _all_binary_infos;
+vector<import_library_info> _all_import_library_infos;
+vector<import_library_info> _changed_import_libraries;
+vector<string> _sisfiles;
+
+unsigned int _current_progress = 0;
+unsigned int _current_progress_percentage = 0;
+unsigned int _max_progress = 0;
+
+ofstream _outputf;
+
+int _CRT_glob = 0; // globbing not supported
+
+// ----------------------------------------------------------------------------------------------------------
+
+int main(int argc, char* argv[])
+{
+ // parse command line arguments
+ ParseCommandLineParameters(argc, argv);
+
+ // read from StaticDependencies.txt if in use
+ if (!_cl_usestaticdepstxt.empty())
+ {
+ GetDataFromStaticDependenciesTxt();
+ }
+
+ // otherwise do normal cache operations
+ else
+ {
+ // first do some checks
+ DoInitialChecksAndPreparations();
+ ParseTargets();
+
+ // checks for sis files if in use
+ if (!_cl_sisfiles.empty())
+ DoInitialChecksAndPreparationsForSisFiles();
+
+ // try to read data from caches
+ if (!_cl_generate_clean_cache)
+ {
+ for (unsigned int i=0; i<_targets.size(); i++) // loop each target
+ {
+ if (_targets.at(i).cache_files_valid)
+ {
+ ReadDataFromSymbolTablesCache(_targets.at(i));
+
+ if (_targets.at(i).cache_files_valid)
+ ReadDataFromDependenciesCache(_targets.at(i));
+ else
+ _some_cache_needs_update = true;
+ }
+ else
+ {
+ _some_cache_needs_update = true;
+ }
+ }
+ }
+ }
+
+ // check if cache needs generation or update
+ if (_cl_generate_clean_cache || _cl_update_cache || _some_cache_needs_update)
+ {
+ // before starting generating cache, we need more checks that user given params are correct
+ DoCacheGenerationChecksAndPreparations();
+
+
+ if (_cl_generate_clean_cache)
+ cerr << "Generating cache files at " << _cl_cachedir << " ";
+ else
+ cerr << "Updating cache files at " << _cl_cachedir << " ";
+
+
+ // get lists of files from the directories
+ FindImportLibrariesAndBinariesFromReleases();
+
+
+ // init progress values
+ if (_max_progress == 0)
+ _max_progress = 1;
+
+ if (_cl_print_debug)
+ cerr << endl;
+ else
+ ShowProgressInfo(_current_progress_percentage, _current_progress, _max_progress, true);
+
+
+ // get import libaries of each target and then write that data to the caches
+ for (unsigned int i=0; i<_targets.size(); i++) // loop each target
+ {
+ GetDataFromImportTables(_targets.at(i));
+
+ // write data only if current file is not valid
+ if (!_targets.at(i).cache_files_valid)
+ {
+ WriteDataToSymbolTableCacheFile(_targets.at(i));
+ }
+
+ // append all data to common vector
+ for (unsigned int j=0; j<_targets.at(i).import_libraries.size(); j++) // loop all binaries in one target
+ {
+ _all_import_library_infos.push_back(_targets.at(i).import_libraries.at(j));
+ }
+
+ // clear the original vector to save RAM since it is not needed anymore
+ _targets.at(i).import_libraries.clear();
+ }
+
+ // get dependency data and write it to the cache files
+ for (unsigned int i=0; i<_targets.size(); i++) // loop each target
+ {
+ GetDataFromBinaries(_targets.at(i));
+
+ if (!_targets.at(i).cache_files_valid) // only write cache if it needs updating
+ {
+ WriteDataToDependenciesCacheFile(_targets.at(i));
+ }
+
+ }
+
+ cerr << endl;
+ }
+
+ // if sis files in use and not done any previous operations, some things must be done
+ else if (!_cl_sisfiles.empty())
+ {
+ // check Petran can be found
+ SetAndCheckPetranPath();
+
+ for (unsigned int i=0; i<_targets.size(); i++) // loop each target
+ {
+ // append all data to common vector
+ for (unsigned int j=0; j<_targets.at(i).import_libraries.size(); j++) // loop all import libraries in one target
+ {
+ // get a binary info data
+ _all_import_library_infos.push_back(_targets.at(i).import_libraries.at(j));
+ }
+
+ // clear the original vector to save RAM since it is not needed anymore
+ _targets.at(i).import_libraries.clear();
+ }
+ }
+
+
+ // include sis files to analysis if in use
+ if (!_cl_sisfiles.empty())
+ AnalyseSisFiles();
+
+
+ // do the analysis
+ if (_cl_properties.empty() && _cl_staticdeps.empty() && _cl_dependson.empty() && _cl_showfunctions.empty() && _cl_usesfunction.empty())
+ {
+ cerr << "Nothing to do." << endl;
+ }
+ else
+ {
+ // copy binary_info vectors to a single one
+ if (_cl_usestaticdepstxt.empty())
+ {
+ for (unsigned int i=0; i<_targets.size(); i++) // loop all targets
+ {
+ for (unsigned int j=0; j<_targets.at(i).binaries.size(); j++) // loop all binaries in one target
+ {
+ // get a binary info data
+ _all_binary_infos.push_back(_targets.at(i).binaries.at(j));
+ }
+
+ // clear the original vector to save RAM
+ _targets.at(i).binaries.clear();
+ }
+ }
+
+ if (!_cl_properties.empty())
+ {
+ // show properties of the binary file
+ DisplayProperties(_cl_properties);
+ }
+
+ if (!_cl_staticdeps.empty())
+ {
+ // determine all static dependencies of selected component
+ DisplayStaticDependencies(_cl_staticdeps);
+ }
+
+ if (!_cl_dependson.empty())
+ {
+ // list all components that depends on selected component
+ DisplayDependents(_cl_dependson);
+ }
+
+ if (!_cl_showfunctions.empty())
+ {
+ // determine all functions that are included / supported in selected component
+ DisplayFunctions(_cl_showfunctions);
+ }
+
+ if (!_cl_usesfunction.empty())
+ {
+ // list all components that are using selected function
+ DisplayUsesFunction(_cl_usesfunction);
+ }
+ }
+
+
+ // close output file
+ if (_outputf.is_open())
+ {
+ _outputf.close();
+ }
+
+ // delete the temporary file
+ if (!_tempfile_location.empty())
+ RemoveFile(_tempfile_location);
+
+ return EXIT_NORMAL;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_analysis.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Functionality of analysis
+*
+*/
+
+
+#include "appdep.hpp"
+
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DisplayProperties(const string& binary_name)
+{
+ bool match_found = false;
+
+ for (unsigned int i=0; i<_all_binary_infos.size(); i++)
+ {
+ if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0)
+ {
+ binary_info b_info = _all_binary_infos.at(i);
+
+ PrintOutputLn("Directory: " + b_info.directory);
+ PrintOutputLn("Filename: " + b_info.filename);
+ PrintOutputLn("Binary format: " + b_info.binary_format);
+ PrintOutputLn("UID1: " + b_info.uid1);
+ PrintOutputLn("UID2: " + b_info.uid2);
+ PrintOutputLn("UID3: " + b_info.uid3);
+
+ if (b_info.secureid.length() > 2 && b_info.secureid.at(0)=='0' && b_info.secureid.at(1)=='x')
+ {
+ PrintOutputLn("Secure ID: " + b_info.secureid);
+ PrintOutputLn("Vendor ID: " + b_info.vendorid);
+
+ vector<string> symbian_caps;
+ symbian_caps.push_back("TCB");
+ symbian_caps.push_back("CommDD");
+ symbian_caps.push_back("PowerMgmt");
+ symbian_caps.push_back("MultimediaDD");
+ symbian_caps.push_back("ReadDeviceData");
+ symbian_caps.push_back("WriteDeviceData");
+ symbian_caps.push_back("DRM");
+ symbian_caps.push_back("TrustedUI");
+ symbian_caps.push_back("ProtServ");
+ symbian_caps.push_back("DiskAdmin");
+ symbian_caps.push_back("NetworkControl");
+ symbian_caps.push_back("AllFiles");
+ symbian_caps.push_back("SwEvent");
+ symbian_caps.push_back("NetworkServices");
+ symbian_caps.push_back("LocalServices");
+ symbian_caps.push_back("ReadUserData");
+ symbian_caps.push_back("WriteUserData");
+ symbian_caps.push_back("Location");
+ symbian_caps.push_back("SurroundingsDD");
+ symbian_caps.push_back("UserEnvironment");
+
+ PrintOutputLn("Capabilities:");
+ for (unsigned int x=0; x<symbian_caps.size(); x++)
+ {
+ if (b_info.capabilities&(1<<(x&31)))
+ PrintOutputLn(" " + symbian_caps.at(x));
+ }
+ }
+ PrintOutputLn("Min Heap Size: " + Int2Str(b_info.min_heap_size));
+ PrintOutputLn("Max Heap Size: " + Int2Str(b_info.max_heap_size));
+ PrintOutputLn("Stack Size: " + Int2Str(b_info.stack_size));
+ PrintOutputLn("Dll ref table count: " + Int2Str(b_info.dependencies.size()));
+
+ match_found = true;
+ break;
+ }
+ }
+
+ if (!match_found)
+ {
+ cerr << "Properties: " << binary_name << " not found from the release" << endl;
+ exit(EXIT_COMPONENT_NOT_FOUND);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DisplayStaticDependencies(const string& binary_name)
+{
+ bool match_found = false;
+
+ for (unsigned int i=0; i<_all_binary_infos.size(); i++)
+ {
+ if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0)
+ {
+ PrintOutputLn(binary_name + " - static dependencies:");
+
+ vector<dependency> deps = _all_binary_infos.at(i).dependencies;
+
+ for (unsigned int j=0; j<deps.size(); j++)
+ {
+ PrintOutputLn(deps.at(j).filename);
+ }
+
+ match_found = true;
+ break;
+ }
+ }
+
+ if (!match_found)
+ {
+ cerr << "Static deps: " << binary_name << " not found from the release" << endl;
+ exit(EXIT_COMPONENT_NOT_FOUND);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DisplayDependents(const string& binary_name)
+{
+ PrintOutputLn(binary_name + " - components that depends on:");
+
+ for (unsigned int i=0; i<_all_binary_infos.size(); i++)
+ {
+ string component_name = _all_binary_infos.at(i).filename;
+
+ vector<dependency> deps = _all_binary_infos.at(i).dependencies;
+
+ for (unsigned int j=0; j<deps.size(); j++)
+ {
+ if (StringICmp(deps.at(j).filename.c_str(), binary_name.c_str()) == 0)
+ {
+ PrintOutputLn(component_name);
+ break;
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DisplayFunctions(const string& binary_name)
+{
+ bool match_found = false;
+
+ for (unsigned int i=0; i<_all_binary_infos.size(); i++)
+ {
+ if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0)
+ {
+ PrintOutputLn(binary_name + " - included functions:");
+
+ vector<dependency> deps = _all_binary_infos.at(i).dependencies;
+
+ for (unsigned int j=0; j<deps.size(); j++)
+ {
+ vector<import> imps = deps.at(j).imports;
+
+ for (unsigned int k=0; k<imps.size(); k++)
+ {
+ if (_cl_show_ordinals)
+ {
+ if (imps.at(k).is_vtable)
+ PrintOutputLn(imps.at(k).funcname + " [virtual table offset by " + Int2Str(imps.at(k).vtable_offset) + "]" + " [" + deps.at(j).filename + "@" + Int2Str(imps.at(k).funcpos) + "]");
+ else
+ PrintOutputLn(imps.at(k).funcname + " [" + deps.at(j).filename + "@" + Int2Str(imps.at(k).funcpos) + "]");
+ }
+ else
+ {
+ if (imps.at(k).is_vtable)
+ PrintOutputLn(imps.at(k).funcname + " [virtual table offset by " + Int2Str(imps.at(k).vtable_offset) + "]");
+ else
+ PrintOutputLn(imps.at(k).funcname);
+ }
+ }
+ }
+
+ match_found = true;
+ break;
+ }
+ }
+
+ if (!match_found)
+ {
+ cerr << "Show functions: " << binary_name << " not found from the release" << endl;
+ exit(EXIT_COMPONENT_NOT_FOUND);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DisplayUsesFunction(const string& function_name)
+{
+ // check if it's full function name or dll name with ordinal
+ string::size_type marker_pos = function_name.find_last_of('@');
+
+ if (marker_pos == string::npos)
+ {
+ // it is a normal function name
+
+ PrintOutputLn(function_name + " - is used by:");
+
+ for (unsigned int i=0; i<_all_binary_infos.size(); i++)
+ {
+ string component_name = _all_binary_infos.at(i).filename;
+
+ vector<dependency> deps = _all_binary_infos.at(i).dependencies;
+
+ for (unsigned int j=0; j<deps.size(); j++)
+ {
+ vector<import> imps = deps.at(j).imports;
+
+ for (unsigned int k=0; k<imps.size(); k++)
+ {
+ if (StringICmp(imps.at(k).funcname.c_str(), function_name.c_str()) == 0)
+ {
+ if (_cl_show_ordinals)
+ PrintOutputLn(component_name + " [" + deps.at(j).filename + "@" + Int2Str(imps.at(k).funcpos) + "]");
+ else
+ PrintOutputLn(component_name);
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ else
+ {
+ // get dll name and ordinal number
+ string dll_name = function_name.substr(0, marker_pos);
+ unsigned int ordinal_number = Str2Int( function_name.substr(marker_pos+1, function_name.length()-marker_pos-1) );
+
+ if (ordinal_number == 0 || ordinal_number > 27500)
+ {
+ cerr << "Uses function: Given ordinal number is invalid: " << ordinal_number << endl;
+ exit(EXIT_INVALID_ORDINAL);
+ }
+
+ PrintOutputLn(function_name + " - is used by:");
+
+ for (unsigned int i=0; i<_all_binary_infos.size(); i++)
+ {
+ string component_name = _all_binary_infos.at(i).filename;
+
+ vector<dependency> deps = _all_binary_infos.at(i).dependencies;
+
+ for (unsigned int j=0; j<deps.size(); j++)
+ {
+ string dependency_name = deps.at(j).filename;
+
+ if (StringICmp(deps.at(j).filename.c_str(), dll_name.c_str()) == 0)
+ {
+ vector<import> imps = deps.at(j).imports;
+
+ for (unsigned int k=0; k<imps.size(); k++)
+ {
+ if (imps.at(k).funcpos == ordinal_number)
+ {
+ PrintOutputLn(component_name);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_cache.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,557 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Cache handling routines
+*
+*/
+
+
+#include "appdep.hpp"
+
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ReadDataFromSymbolTablesCache(target& a_target)
+{
+ string line;
+
+ ifstream symtabcachef(a_target.st_cache_path.c_str());
+ if (!symtabcachef.is_open())
+ {
+ cerr << "Warning: Regenerating corrupted cache of target " << a_target.name << endl;
+ a_target.cache_files_valid = false;
+ _some_cache_needs_update = true;
+ return;
+ }
+
+ getline(symtabcachef, line);
+ if (line != CACHE_ST_HEADER)
+ {
+ cerr << "Warning: Regenerating corrupted cache of target " << a_target.name << endl;
+ a_target.cache_files_valid = false;
+ _some_cache_needs_update = true;
+ }
+ else
+ {
+ // loop through all lines in the file
+ while(!symtabcachef.eof())
+ {
+ getline(symtabcachef, line);
+
+ if (line.length() > 0 && line[0] != CACHE_COMMENT_CHAR)
+ {
+ // first entry is the directory|filename|modification_time|symbol_table_size , eg
+ // x:\epoc32\release\armv5\urel\|avkon.dll|1160666488|178
+ string::size_type delim1 = line.find(CACHE_SEP, 0);
+ string::size_type delim2 = line.find(CACHE_SEP, delim1+1);
+ string::size_type delim3 = line.find(CACHE_SEP, delim2+1);
+
+ import_library_info lib_info;
+ lib_info.directory = line.substr(0, delim1);
+ lib_info.filename = line.substr(delim1+1, delim2-delim1-1);
+ lib_info.mod_time = Str2Int( line.substr(delim2+1, delim3-delim2-1) );
+ unsigned int symbol_table_size = Str2Int( line.substr(delim3+1, line.length()-delim3-1) );
+
+ // get symbol table
+ vector<string> symbol_table;
+ for (unsigned int j=0; j<symbol_table_size; j++)
+ {
+ getline(symtabcachef, line);
+ symbol_table.push_back( line );
+ }
+
+ lib_info.symbol_table = symbol_table;
+
+ // append binary info to the vectory
+ a_target.import_libraries.push_back( lib_info );
+ }
+ }
+
+ // check that the last line of the file contains the footer of the cache
+ if (line != CACHE_FOOTER)
+ {
+ cerr << "Warning: Regenerating corrupted cache of target " << a_target.name << endl;
+ a_target.import_libraries.clear();
+ a_target.cache_files_valid = false;
+ _some_cache_needs_update = true;
+ }
+ }
+
+ symtabcachef.close();
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ReadDataFromDependenciesCache(target& a_target)
+{
+ string line;
+
+ // read data from the dependencies cache file
+ ifstream depcachef(a_target.dep_cache_path.c_str());
+ if (!depcachef.is_open())
+ {
+ cerr << "Warning: Regenerating corrupted cache of target " << a_target.name << endl;
+ a_target.cache_files_valid = false;
+ _some_cache_needs_update = true;
+ return;
+ }
+
+ getline(depcachef, line);
+ if (line != CACHE_DEP_HEADER)
+ {
+ cerr << "Warning: Regenerating corrupted cache of target " << a_target.name << endl;
+ a_target.cache_files_valid = false;
+ _some_cache_needs_update = true;
+ }
+ else
+ {
+ // loop through all lines in the file
+ while(!depcachef.eof())
+ {
+ getline(depcachef, line);
+
+ if (line.length() > 0 && line[0] != CACHE_COMMENT_CHAR)
+ {
+ // first entry is the directory|filename|binary_format|uid1|uid2|uid3|secureid|vendorid|capabilities|min_heap_size|max_heap_size|stack_size|modification_time|number_of_dependencies , eg
+ // x:\epoc32\release\armv5\urel\|about.exe|EPOC Exe for ARMV4 CPU|0x1000007a|0x100039ce|0x10005a22|0x10005a22|0x101fb657|782384|4096|1048576|8192|1160666488|11
+ string::size_type delim1 = line.find(CACHE_SEP, 0);
+ string::size_type delim2 = line.find(CACHE_SEP, delim1+1);
+ string::size_type delim3 = line.find(CACHE_SEP, delim2+1);
+ string::size_type delim4 = line.find(CACHE_SEP, delim3+1);
+ string::size_type delim5 = line.find(CACHE_SEP, delim4+1);
+ string::size_type delim6 = line.find(CACHE_SEP, delim5+1);
+ string::size_type delim7 = line.find(CACHE_SEP, delim6+1);
+ string::size_type delim8 = line.find(CACHE_SEP, delim7+1);
+ string::size_type delim9 = line.find(CACHE_SEP, delim8+1);
+ string::size_type delim10 = line.find(CACHE_SEP, delim9+1);
+ string::size_type delim11 = line.find(CACHE_SEP, delim10+1);
+ string::size_type delim12 = line.find(CACHE_SEP, delim11+1);
+ string::size_type delim13 = line.find(CACHE_SEP, delim12+1);
+
+ binary_info b_info;
+ b_info.directory = line.substr(0, delim1);
+ b_info.filename = line.substr(delim1+1, delim2-delim1-1);
+ b_info.binary_format = line.substr(delim2+1, delim3-delim2-1);
+ b_info.uid1 = line.substr(delim3+1, delim4-delim3-1);
+ b_info.uid2 = line.substr(delim4+1, delim5-delim4-1);
+ b_info.uid3 = line.substr(delim5+1, delim6-delim5-1);
+ b_info.secureid = line.substr(delim6+1, delim7-delim6-1);
+ b_info.vendorid = line.substr(delim7+1, delim8-delim7-1);
+ b_info.capabilities = Str2Int( line.substr(delim8+1, delim9-delim8-1) );
+ b_info.min_heap_size = Str2Int( line.substr(delim9+1, delim10-delim9-1) );
+ b_info.max_heap_size = Str2Int( line.substr(delim10+1, delim11-delim10-1) );
+ b_info.stack_size = Str2Int( line.substr(delim11+1, delim12-delim11-1) );
+ b_info.mod_time = Str2Int( line.substr(delim12+1, delim13-delim12-1) );
+ unsigned int number_of_deps = Str2Int( line.substr(delim13+1, line.length()-delim13-1) );
+
+ vector<dependency> deps;
+ for (unsigned int j=0; j<number_of_deps; j++)
+ {
+ getline(depcachef, line);
+
+ // second type entry is filename|number_of_imports , eg
+ // APPARC.DLL|6
+ string::size_type delim1 = line.find(CACHE_SEP, 0);
+
+ dependency dep;
+ dep.filename = line.substr(0, delim1);
+ unsigned int number_of_imports = Str2Int( line.substr(delim1+1, line.length()-delim1-1) );
+
+ vector<import> imps;
+ for (unsigned int k=0; k<number_of_imports; k++)
+ {
+ getline(depcachef, line);
+
+ // third type on entry is funcpos|funcname|is_vtable|vtable_offset, eg
+ // 121|CApaDocument::Capability() const|0|0
+ string::size_type delim1 = line.find(CACHE_SEP, 0);
+ string::size_type delim2 = line.find(CACHE_SEP, delim1+1);
+ string::size_type delim3 = line.find(CACHE_SEP, delim2+1);
+
+ import imp;
+ imp.funcpos = Str2Int( line.substr(0, delim1) );
+ imp.funcname = line.substr(delim1+1, delim2-delim1-1);
+ imp.is_vtable = Str2Int( line.substr(delim2+1, delim3-delim2-1) );
+ imp.vtable_offset = Str2Int( line.substr(delim3+1, line.length()-delim3-1) );
+
+ // append to the import info vector
+ imps.push_back( imp );
+ }
+
+ // now we have import info too
+ dep.imports = imps;
+
+ // append to the deps info vector
+ deps.push_back( dep );
+
+ }
+ // now we have the dep info too
+ b_info.dependencies = deps;
+
+ // apppend binary info to the vector
+ a_target.binaries.push_back( b_info );
+ }
+ }
+
+ // check that the last line of the file contains the footer of the cache
+ if (line != CACHE_FOOTER)
+ {
+ cerr << "Warning: Regenerating corrupted cache of target " << a_target.name << endl;
+ a_target.binaries.clear();
+ a_target.cache_files_valid = false;
+ _some_cache_needs_update = true;
+ }
+ }
+ depcachef.close();
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetDataFromImportTables(target& a_target)
+{
+ // read data from import libraries if needed
+ for (unsigned int i=0; i<a_target.lib_files.size(); i++)
+ {
+ bool is_new_file = true;
+
+ vector<string> symbol_table;
+
+ if (_cl_print_debug)
+ cerr << "Processing " << a_target.release_lib_dir << a_target.lib_files.at(i) << "...";
+
+ // if not generating a clean cache, check if this file was already in the cache
+ if (!_cl_generate_clean_cache)
+ {
+ // first try to find existing file
+ bool update_file = false;
+ int position = 0;
+
+ for (unsigned int j=0; j<a_target.import_libraries.size(); j++)
+ {
+ // check if names match
+ if (StringICmpFileNamesWithoutExtension(a_target.lib_files.at(i), a_target.import_libraries.at(j).filename) == 0)
+ {
+ // the file was already found from the cache
+ is_new_file = false;
+
+ // compare modification times
+ struct stat stat_p;
+ stat((a_target.release_lib_dir + a_target.lib_files.at(i)).c_str(), &stat_p); // get new stats
+
+ if (!TimestampsMatches(a_target.import_libraries.at(j).mod_time, stat_p.st_mtime))
+ {
+ // time stamps are different so needs to update the file
+ update_file = true;
+ position = j;
+ }
+
+ // there can't be anymore same names, so break the loop anyway
+ break;
+ }
+ }
+
+ // get the new data
+ if (update_file)
+ {
+ a_target.cache_files_valid = false; // cache files on disk must be rewritten
+
+ import_library_info& lib_info = a_target.import_libraries.at(position);
+ lib_info.directory = a_target.release_lib_dir;
+
+ if (_cl_use_gcc)
+ {
+ GetSymbolTableWithNM(_gcc_nm_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ else if (_cl_use_gcce)
+ {
+ if (_cl_use_libs)
+ {
+ GetSymbolTableWithNM(_gcce_nm_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ else
+ {
+ GetSymbolTableWithReadelf(_gcce_readelf_location, _gcce_cfilt_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ }
+ else if (_cl_use_rvct)
+ {
+ if (_cl_use_libs)
+ {
+ GetSymbolTableWithArmar(_rvct_armar_location, _rvct_cfilt_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ else
+ {
+ GetSymbolTableWithFromelf(_rvct_fromelf_location, _rvct_cfilt_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ }
+
+ lib_info.symbol_table = symbol_table;
+
+ // get statistics of the file and set the modification time
+ struct stat stat_p;
+ stat((a_target.release_lib_dir + a_target.lib_files.at(i)).c_str(), &stat_p);
+ lib_info.mod_time = stat_p.st_mtime;
+
+ // record changed import libraries
+ _changed_import_libraries.push_back( lib_info );
+ }
+ }
+
+ // this is a new file, get info and append it to the vector
+ if (is_new_file)
+ {
+ a_target.cache_files_valid = false; // cache files on disk must be rewritten
+
+ // get the symbol tables of the library
+ if (_cl_use_gcc)
+ {
+ GetSymbolTableWithNM(_gcc_nm_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ else if (_cl_use_gcce)
+ {
+ if (_cl_use_libs)
+ {
+ GetSymbolTableWithNM(_gcce_nm_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ else
+ {
+ GetSymbolTableWithReadelf(_gcce_readelf_location, _gcce_cfilt_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ }
+ else if (_cl_use_rvct)
+ {
+ if (_cl_use_libs)
+ {
+ GetSymbolTableWithArmar(_rvct_armar_location, _rvct_cfilt_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ else
+ {
+ GetSymbolTableWithFromelf(_rvct_fromelf_location, _rvct_cfilt_location, a_target.release_lib_dir, a_target.lib_files.at(i), symbol_table);
+ }
+ }
+
+ // get statistics of the file
+ struct stat stat_p;
+ stat((a_target.release_lib_dir + a_target.lib_files.at(i)).c_str(), &stat_p);
+
+ // create a new entry to list of all import libraries
+ import_library_info lib_info;
+ lib_info.directory = a_target.release_lib_dir;
+ lib_info.filename = a_target.lib_files.at(i);
+ lib_info.mod_time = stat_p.st_mtime;
+ lib_info.symbol_table = symbol_table;
+
+ a_target.import_libraries.push_back( lib_info );
+ }
+ if (_cl_print_debug)
+ cerr << "OK" << endl;
+ else
+ ShowProgressInfo(_current_progress_percentage, _current_progress, _max_progress, false);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetDataFromBinaries(target& a_target)
+{
+ // read data from binaries
+ for (unsigned int i=0; i<a_target.bin_files.size(); i++)
+ {
+ bool is_new_file = true;
+
+ if (_cl_print_debug)
+ cerr << "Processing " << a_target.release_bin_dir << a_target.bin_files.at(i) << "...";
+
+ // if not generating a clean cache, check if this file was already in the cache
+ if (!_cl_generate_clean_cache)
+ {
+ // first try to find existing file
+ bool update_file = false;
+ int position = 0;
+
+ for (unsigned int j=0; j<a_target.binaries.size(); j++)
+ {
+ // check if names match
+ if (StringICmp(a_target.bin_files.at(i).c_str(), a_target.binaries.at(j).filename.c_str()) == 0)
+ {
+ is_new_file = false;
+
+ // compare modification times
+ struct stat stat_p;
+ stat((a_target.release_bin_dir + a_target.bin_files.at(i)).c_str(), &stat_p); // get new stats
+
+ if (!TimestampsMatches(a_target.binaries.at(j).mod_time, stat_p.st_mtime))
+ {
+ // time stamps are different so needs to update the file
+ update_file = true;
+ position = j;
+ break;
+ }
+
+ // the entry also needs to be updated if any import library which this binary has dependency on has changed
+ for (unsigned int k=0; k<_changed_import_libraries.size(); k++)
+ {
+ for (unsigned int p=0; p<a_target.binaries.at(j).dependencies.size(); p++)
+ {
+ // check for file name match
+ if (StringICmpFileNamesWithoutExtension(a_target.binaries.at(j).dependencies.at(p).filename, _changed_import_libraries.at(k).filename) == 0)
+ {
+ update_file = true;
+ position = j;
+ break;
+ }
+ }
+
+ // no need to loop anymore if the file needs update
+ if (update_file)
+ break;
+ }
+
+ // there can't be anymore same names, so break the loop anyway
+ break;
+ }
+ }
+
+ // get the new data
+ if (update_file)
+ {
+ a_target.cache_files_valid = false; // cache files on disk must be rewritten
+
+ binary_info& b_info = a_target.binaries.at(position);
+ b_info.directory = a_target.release_bin_dir;
+
+ GetImportTableWithPetran(_petran_location, b_info);
+
+ // get statistics of the file and set the modification time
+ struct stat stat_p;
+ stat((a_target.release_bin_dir + a_target.bin_files.at(i)).c_str(), &stat_p);
+ b_info.mod_time = stat_p.st_mtime;
+ }
+ }
+
+ // this is a new file, get info and append it to the vector
+ if (is_new_file)
+ {
+ a_target.cache_files_valid = false; // cache files on disk must be rewritten
+
+ binary_info b_info;
+ b_info.directory = a_target.release_bin_dir;
+ b_info.filename = a_target.bin_files.at(i);
+
+ GetImportTableWithPetran(_petran_location, b_info);
+
+ // get statistics of the file and set the modification time
+ struct stat stat_p;
+ stat((a_target.release_bin_dir + a_target.bin_files.at(i)).c_str(), &stat_p);
+ b_info.mod_time = stat_p.st_mtime;
+
+ // create a new entry to list of all binary files
+ a_target.binaries.push_back( b_info );
+ }
+
+ if (_cl_print_debug)
+ cerr << "OK" << endl;
+ else
+ ShowProgressInfo(_current_progress_percentage, _current_progress, _max_progress, false);
+ }
+
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void WriteDataToSymbolTableCacheFile(const target& a_target)
+{
+ // open the cache file for writing
+ ofstream symtabcachef(a_target.st_cache_path.c_str(), ios::trunc);
+ if (!symtabcachef.is_open())
+ {
+ symtabcachef.close();
+ cerr << endl << "ERROR: Cannot open " << a_target.st_cache_path << " for writing!" << endl;
+ cerr << "Please check that the directory exists and there are no write permission problems" << endl;
+ exit(EXIT_CANNOT_WRITE_TO_CACHE_FILE);
+ }
+
+ // write data to the cache file
+ symtabcachef << CACHE_ST_HEADER << endl;
+
+ for (unsigned int i=0; i<a_target.import_libraries.size(); i++)
+ {
+ vector<string> symbol_table = a_target.import_libraries.at(i).symbol_table;
+
+ symtabcachef << a_target.import_libraries.at(i).directory << CACHE_SEP << a_target.import_libraries.at(i).filename << CACHE_SEP
+ << a_target.import_libraries.at(i).mod_time << CACHE_SEP << symbol_table.size() << endl;
+
+ for (unsigned int j=0; j<symbol_table.size(); j++)
+ {
+ symtabcachef << symbol_table.at(j) << endl;
+ }
+ }
+
+ // write footer, note that there is no eol char
+ symtabcachef << CACHE_FOOTER;
+
+ symtabcachef.close();
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void WriteDataToDependenciesCacheFile(const target& a_target)
+{
+ // open the cache file for writing
+ ofstream depcachef(a_target.dep_cache_path.c_str(), ios::trunc);
+ if (!depcachef.is_open())
+ {
+ depcachef.close();
+ cerr << endl << "ERROR: Cannot open " << a_target.dep_cache_path << " for writing!" << endl;
+ cerr << "Please check that the directory exists and there are no write permission problems" << endl;
+ exit(EXIT_CANNOT_WRITE_TO_CACHE_FILE);
+ }
+
+ // write data to the cache file
+ depcachef << CACHE_DEP_HEADER << endl;
+
+ for (unsigned int i=0; i<a_target.binaries.size(); i++)
+ {
+ vector<dependency> deps = a_target.binaries.at(i).dependencies;
+
+ depcachef << a_target.binaries.at(i).directory << CACHE_SEP << a_target.binaries.at(i).filename << CACHE_SEP
+ << a_target.binaries.at(i).binary_format << CACHE_SEP << a_target.binaries.at(i).uid1 << CACHE_SEP
+ << a_target.binaries.at(i).uid2 << CACHE_SEP << a_target.binaries.at(i).uid3 << CACHE_SEP
+ << a_target.binaries.at(i).secureid << CACHE_SEP << a_target.binaries.at(i).vendorid << CACHE_SEP
+ << a_target.binaries.at(i).capabilities << CACHE_SEP << a_target.binaries.at(i).min_heap_size << CACHE_SEP
+ << a_target.binaries.at(i).max_heap_size << CACHE_SEP << a_target.binaries.at(i).stack_size << CACHE_SEP
+ << a_target.binaries.at(i).mod_time << CACHE_SEP << deps.size() << endl;
+
+ for (unsigned int j=0; j<deps.size(); j++)
+ {
+ vector<import> imps = deps.at(j).imports;
+
+ depcachef << deps.at(j).filename << CACHE_SEP << imps.size() << endl;
+
+ for (unsigned int k=0; k<imps.size(); k++)
+ {
+ depcachef << imps.at(k).funcpos << CACHE_SEP << imps.at(k).funcname << CACHE_SEP << imps.at(k).is_vtable
+ << CACHE_SEP << imps.at(k).vtable_offset << endl;
+ }
+ }
+ }
+
+ // write footer, note that there is no eol char
+ depcachef << CACHE_FOOTER;
+
+ depcachef.close();
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_getters.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,631 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Utility functions for getting data via 3rd party tools
+*
+*/
+
+
+#include "appdep.hpp"
+
+// ----------------------------------------------------------------------------------------------------------
+// Note that in C/C++ code \ has been replaced with \\ and " with \".
+// ----------------------------------------------------------------------------------------------------------
+
+void GetImportTableWithPetran(const string& petran_location, binary_info& b_info)
+{
+ vector<dependency> deps;
+ vector<string> tempVector;
+
+ // init defaults
+ b_info.binary_format = UNKNOWN;
+ b_info.uid1 = UNKNOWN;
+ b_info.uid2 = UNKNOWN;
+ b_info.uid3 = UNKNOWN;
+ b_info.secureid = NOT_VALID;
+ b_info.vendorid = NOT_VALID;
+ b_info.capabilities = 0;
+ b_info.min_heap_size = 0;
+ b_info.max_heap_size = 0;
+ b_info.stack_size = 0;
+
+ // execute petran
+ string cmd;
+
+ if (_cl_use_gcce || _cl_use_rvct)
+ cmd = petran_location + " -dump hi \"" + b_info.directory + b_info.filename + "\" " + CERR_TO_NULL;
+ else
+ cmd = petran_location + " \"" + b_info.directory + b_info.filename + "\" " + CERR_TO_NULL;
+
+ //cerr << cmd << endl;
+ ExecuteCommand(cmd, tempVector);
+
+ // get binary format, assuming it's the first line which begings with EPOC
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^(EPOC.+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ TrimAll(ms1);
+ b_info.binary_format = ms1;
+ break;
+ }
+ }
+
+ // get uids
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Uids:\\s+(\\S+)\\s+(\\S+)\\s+(\\S+).+");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ string ms2(matches[2].first, matches[2].second);
+ string ms3(matches[3].first, matches[3].second);
+ b_info.uid1 = "0x"+ms1;
+ b_info.uid2 = "0x"+ms2;
+ b_info.uid3 = "0x"+ms3;
+ break;
+ }
+ }
+
+ // get secure id
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Secure\\sID:\\s+(\\S+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ b_info.secureid = "0x"+ms1;
+ break;
+ }
+ }
+
+ // get vendor id
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Vendor\\sID:\\s+(\\S+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ b_info.vendorid = "0x"+ms1;
+ break;
+ }
+ }
+
+ // get capabilities
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Capabilities:\\s+\\S+\\s+(\\S+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ b_info.capabilities = Str2Int("0x"+ms1);
+ break;
+ }
+ }
+
+ // get min heap size
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Min\\sHeap\\sSize:\\s+(\\S+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ b_info.min_heap_size = Str2Int("0x"+ms1);
+ break;
+ }
+ }
+
+ // get max heap size
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Max\\sHeap\\sSize:\\s+(\\S+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ b_info.max_heap_size = Str2Int("0x"+ms1);
+ break;
+ }
+ }
+
+ // get stack size
+ for (unsigned int j=0; j<tempVector.size() && j<100; j++)
+ {
+ boost::regex re("^Stack\\sSize:\\s+(\\S+)");
+ boost::cmatch matches;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches, re))
+ {
+ string ms1(matches[1].first, matches[1].second);
+ b_info.stack_size = Str2Int("0x"+ms1);
+ break;
+ }
+ }
+
+ // finally get the dependency information
+ for (unsigned int j=0; j<tempVector.size(); j++)
+ {
+ // first find where the import table begins, example:
+ // Offset of import address table (relative to code section): 00005660
+ if (tempVector.at(j).find("Offset of import", 0) != string::npos)
+ {
+ // continue looping
+ while (j<tempVector.size()-1)
+ {
+ j++;
+
+ // now find denpendency entry, examples:
+ // 68 imports from euser{000a0000}[100039e5].dll
+ // 1 imports from COMMONENGINE[100058fe].DLL
+ // 3 imports from drtrvct2_2{000a0000}.dll
+ // 27 imports from libdbus-utils{000a0000}[20010154].dll
+ boost::regex re1("^(\\d+)\\simports\\sfrom\\s([\\w\\-]+)\\S*(\\.\\w+).*");
+ boost::cmatch matches1;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1))
+ {
+ // match found
+ string ms1(matches1[1].first, matches1[1].second); // number in the beginning
+ string ms2(matches1[2].first, matches1[2].second); // first part of filename
+ string ms3(matches1[3].first, matches1[3].second); // extension of filename
+
+ unsigned int number_of_imports = Str2Int(ms1);
+ vector<import> imps; // imports
+ string filename = ms2+ms3;
+
+ // get position of the filename in import libaries
+ int lib_pos = -1;
+ for (unsigned int x=0; x<_all_import_library_infos.size(); x++)
+ {
+ if (StringICmpFileNamesWithoutExtension(_all_import_library_infos.at(x).filename, filename) == 0)
+ {
+ lib_pos = x;
+ break;
+ }
+ }
+
+
+ // read ordinal numbers
+ for (unsigned int k=0; k<number_of_imports; k++)
+ {
+ j++;
+
+ import imp;
+ imp.is_vtable = false;
+ imp.vtable_offset = 0;
+
+ string ordinal_data = tempVector.at(j);
+ TrimAll(ordinal_data);
+
+ // check if it's virtual data
+ string::size_type pos = ordinal_data.find(" offset by", 0);
+
+ if (pos == string::npos)
+ {
+ // regular entry, just get the ordinal number
+ imp.funcpos = Str2Int(ordinal_data);
+ imp.is_vtable = false;
+ imp.vtable_offset = 0;
+ }
+ else
+ {
+ // this is a virtual table entry
+ imp.funcpos = Str2Int(ordinal_data.substr(0, pos));
+ imp.is_vtable = true;
+ imp.vtable_offset = Str2Int(ordinal_data.substr(pos+11, ordinal_data.length()-pos-1));
+ }
+
+ // get the function name
+ if (lib_pos >= 0)
+ {
+ if (imp.funcpos-1 < _all_import_library_infos.at(lib_pos).symbol_table.size())
+ imp.funcname = _all_import_library_infos.at(lib_pos).symbol_table.at(imp.funcpos-1);
+ else
+ imp.funcname = "BC break: This ordinal position is not in the import library!";
+ }
+ else
+ {
+ imp.funcname = "Import library not found!";
+ }
+
+ // Checking for possible duplicate imported function ordinals.
+ import compare[] = { imp };
+ vector<import>::iterator it = find_first_of(imps.begin(), imps.end(), compare, compare+1, ImportFunctionsHasSameOrdinal);
+ if(it == imps.end())
+ {
+ // No duplicate detected. Appending ordinal data to the array.
+ imps.push_back(imp);
+ }
+
+ }
+
+ // append to the vector
+
+ dependency dep;
+ dep.filename = filename;
+ dep.imports = imps;
+
+ deps.push_back( dep );
+
+ }
+ }
+
+ break; //for (int j=0; j<tempVector.size(); j++)
+ }
+
+ } // for (int j=0; j<tempVector.size(); j++)
+
+ // store the dependencies array
+ b_info.dependencies = deps;
+
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool ImportFunctionsHasSameOrdinal(import imp1, import imp2)
+{
+ return (imp1.funcpos == imp2.funcpos);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetSymbolTableWithNM(const string& nm_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table)
+{
+ symbol_table.clear();
+ vector<string> tempVector;
+ vector<ordinal> ordinals;
+
+ // execute nm
+ string cmd = nm_location + " --demangle \"" + lib_directory + lib_name + "\"";
+ ExecuteCommand(cmd, tempVector);
+
+
+ // parse the results of the command
+ for (unsigned int j=0; j<tempVector.size(); j++)
+ {
+ // first check if we have found the beginning of a block
+
+ boost::cmatch matches1;
+ boost::cmatch matches2;
+ boost::cmatch matches3;
+
+ bool match1 = false;
+ bool match2 = false;
+ bool match3 = false;
+
+ // Symbian OS 6.1 LIB file, example: ds00001.o:
+ boost::regex re1("^ds(\\d+)\\.o\\:");
+ match1 = boost::regex_match(tempVector.at(j).c_str(), matches1, re1);
+
+ if (!match1)
+ {
+ // Symbian OS 7.x-8.x LIB file, example: C:/DOCUME~1/mattlait/LOCALS~1/Temp/1/d1000s_00001.o:
+ boost::regex re2("^\\S*s_(\\d+)\\.o\\:");
+ match2 = boost::regex_match(tempVector.at(j).c_str(), matches2, re2);
+
+ if (!match2)
+ {
+ // Symbian OS 9.x LIB file, example: AGENTDIALOG{000a0000}-14.o:
+ boost::regex re3("^\\S*\\{000a0000\\}-(\\d+)\\.o\\:");
+ match3 = boost::regex_match(tempVector.at(j).c_str(), matches3, re3);
+ }
+ }
+
+ if (match1 || match2 || match3)
+ {
+ // now get the ordinal number
+ string ordNum;
+
+ if (match1)
+ {
+ string ms(matches1[1].first, matches1[1].second);
+ ordNum = ms;
+ }
+ else if (match2)
+ {
+ string ms(matches2[1].first, matches2[1].second);
+ ordNum = ms;
+ }
+ else if (match3)
+ {
+ string ms(matches3[1].first, matches3[1].second);
+ ordNum = ms;
+ }
+
+ // now start looking for the line with the export name
+ // eg: 00000000 T CUserActivityManager::RunL(void)
+ while (j<tempVector.size()-1)
+ {
+ j++;
+
+ boost::regex re4("^\\d+\\sT\\s(.*)$");
+ boost::cmatch matches4;
+
+ if (boost::regex_match(tempVector.at(j).c_str(), matches4, re4))
+ {
+ // now we have a full entry
+ string ms(matches4[1].first, matches4[1].second);
+
+ // append to the ordinal list
+ ordinals.push_back(ordinal(Str2Int(ordNum), ms));
+
+ break;
+ }
+ }
+ } // (match1 || match2)
+ } // for (int j=0; j<tempVector.size(); j++)
+
+ // convert the ordinal list into a symbol table
+ ConvertOrdinalListIntoSymbolTable(ordinals, symbol_table, lib_directory+lib_name);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetSymbolTableWithReadelf(const string& readelf_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table)
+{
+ symbol_table.clear();
+ vector<string> tempVector;
+ vector<ordinal> ordinals;
+
+ // execute readelf
+ // note: 2>NUL is used here to redirect standard error output to NULL since readelf seems to output lots of unwanted warning messages
+ string cmd = readelf_location + " -s -W \"" + lib_directory + lib_name + "\" " + CERR_TO_NULL;
+ ExecuteCommand(cmd, tempVector);
+
+
+ // parse the results of the command
+ for (unsigned int j=0; j<tempVector.size(); j++)
+ {
+ boost::cmatch matches1;
+
+ // example:
+ // 1: 00000000 4 NOTYPE GLOBAL DEFAULT 1 _ZN13CSpdiaControl10DrawShadowER9CWindowGcRK5TSize@@SpdCtrl{000a0000}[10005986].dll
+ boost::regex re1("^\\s*(\\d+)\\:.+GLOBAL.+\\d+\\s+(.*)\\@\\@.*");
+
+ if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1))
+ {
+ // match found
+ string ms1(matches1[1].first, matches1[1].second);
+ string ms2(matches1[2].first, matches1[2].second);
+
+ // append to the ordinal list
+ ordinals.push_back(ordinal(Str2Int(ms1), ms2));
+ }
+
+ } // for (int j=0; j<tempVector.size(); j++)
+
+ // convert the ordinal list into a symbol table
+ ConvertOrdinalListIntoSymbolTable(ordinals, symbol_table, lib_directory+lib_name);
+
+ // finally demangle all function names since it's not done in this case automatically
+ DemangleOrdinalsInSymbolTable(cfilt_location, symbol_table);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetSymbolTableWithArmar(const string& armar_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table)
+{
+ symbol_table.clear();
+ vector<string> tempVector;
+ vector<ordinal> ordinals;
+
+ // execute armar
+ string cmd = armar_location + " --zs \"" + lib_directory + lib_name + "\"";
+ ExecuteCommand(cmd, tempVector);
+
+ // parse the results of the command
+ for (unsigned int j=0; j<tempVector.size(); j++)
+ {
+ // find the entries, example:
+ // _ZN13TAgnWeeklyRptC1Ev from AGNMODEL{000a0000}-187.o at offset 158366
+ boost::regex re1("(\\S*)\\s+from\\s.*-(\\d+)\\.o.*");
+ boost::cmatch matches1;
+
+ if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1))
+ {
+ // match found
+ string ms1(matches1[2].first, matches1[2].second);
+ string ms2(matches1[1].first, matches1[1].second);
+
+ // append to the ordinal list
+ ordinals.push_back(ordinal(Str2Int(ms1), ms2));
+ }
+
+ } // for (int j=0; j<tempVector.size(); j++)
+
+ // convert the ordinal list into a symbol table
+ ConvertOrdinalListIntoSymbolTable(ordinals, symbol_table, lib_directory+lib_name);
+
+ // finally demangle all function names since it's not done in this case automatically
+ DemangleOrdinalsInSymbolTable(cfilt_location, symbol_table);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetSymbolTableWithFromelf(const string& fromelf_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector<string>& symbol_table)
+{
+ symbol_table.clear();
+ vector<string> tempVector;
+ vector<ordinal> ordinals;
+
+ // execute fromelf
+ string cmd = fromelf_location + " -s \"" + lib_directory + lib_name + "\"";
+ ExecuteCommand(cmd, tempVector);
+
+ // parse the results of the command
+ for (unsigned int j=0; j<tempVector.size(); j++)
+ {
+ // first find the start of the symbol table
+ // ** Section #5 '.version' (SHT_GNU_versym)
+ boost::regex re1("^.*(SHT_GNU_versym).*");
+ boost::cmatch matches1;
+
+ if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1))
+ {
+ //int previous_ordinal = 0;
+
+ while (j<tempVector.size()-1)
+ {
+ j++;
+
+ // now find the entries, examples:
+ // 7 _ZNK17CPbkContactEngine9FsSessionEv 2 PbkEng{000a0000}[101f4cce].dll
+ // 8 _ZN17CPbkContactEngine19CreateEmptyContactLEv
+ // 2 PbkEng{000a0000}[101f4cce].dll
+ // notice that line can be spread to two lines so make sure we don't accidentally get a wrong line
+
+ // first parse out any unwanted lines
+ boost::regex re2("^\\s*\\d+\\s+\\S+\\.\\w+$");
+ boost::cmatch matches2;
+ if (boost::regex_match(tempVector.at(j).c_str(), matches2, re2))
+ {
+ continue;
+ }
+
+ // now it should be the wanted line
+ boost::regex re3("^\\s*(\\d+)\\s*(\\S*).*");
+ boost::cmatch matches3;
+
+ if (boost::regex_match(tempVector.at(j).c_str(), matches3, re3))
+ {
+
+ // match found
+ string ms1(matches3[1].first, matches3[1].second);
+ string ms2(matches3[2].first, matches3[2].second);
+
+ // append to the ordinal list
+ ordinals.push_back(ordinal(Str2Int(ms1), ms2));
+ }
+
+ } //while (j<tempVector.size())
+
+
+ } //if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1))
+
+ } // for (int j=0; j<tempVector.size(); j++)
+
+ // convert the ordinal list into a symbol table
+ ConvertOrdinalListIntoSymbolTable(ordinals, symbol_table, lib_directory+lib_name);
+
+ // finally demangle all function names since it's not done in this case automatically
+ DemangleOrdinalsInSymbolTable(cfilt_location, symbol_table);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ConvertOrdinalListIntoSymbolTable(const vector<ordinal>& ordinals, vector<string>& symbol_table, const string& lib_path)
+{
+ // remove any invalid ordinals from the list
+ vector<ordinal> ordinalVectorCopy;
+ ordinalVectorCopy.reserve(ordinals.size());
+
+ for (unsigned int i=0; i<ordinals.size(); i++)
+ {
+ if (ordinals.at(i).funcpos <= 0 && ordinals.at(i).funcpos > 32000)
+ {
+ cerr << "Error: Invalid ordinal " << ordinals.at(i).funcname << " @ " << Int2Str(ordinals.at(i).funcpos) << endl;
+ }
+ else
+ {
+ ordinalVectorCopy.push_back(ordinals.at(i));
+ }
+ }
+
+ // sort the ordinal list
+ sort(ordinalVectorCopy.begin(), ordinalVectorCopy.end(), OrdinalCompare);
+
+ // now check that there are no missing ordinals in the list
+ unsigned int previous_ordnumber = 0;
+ unsigned int current_ordnumber = 1;
+ for (unsigned int i=0; i<ordinalVectorCopy.size(); i++)
+ {
+ // get the current ordinal number
+ current_ordnumber = ordinalVectorCopy.at(i).funcpos;
+
+ // the current ordinal number obviously should be one bigger than the previous one
+ if ( current_ordnumber != previous_ordnumber+1 )
+ {
+ // append a dummy ordinal to the list
+ ordinalVectorCopy.insert(ordinalVectorCopy.begin()+i, ordinal(i+1, "UnknownOrdinal-"+Int2Str(i+1)));
+ current_ordnumber = i+1;
+ }
+
+ // remember the previous ordinal number
+ previous_ordnumber = current_ordnumber;
+
+ // if the ordinal list is corrupted, it may lead to an infinite loop
+ if (i>25000)
+ {
+ cerr << endl << "Something went horribly wrong when trying to parse " << lib_path << ". Aborting." << endl;
+ exit(10);
+ }
+ }
+
+ // finally copy data from the ordinal list to the symbol table
+ if (symbol_table.size() < ordinalVectorCopy.size())
+ {
+ symbol_table.reserve(ordinalVectorCopy.size());
+ }
+ for (unsigned int i=0; i<ordinalVectorCopy.size(); i++)
+ {
+ symbol_table.push_back( ordinalVectorCopy.at(i).funcname );
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DemangleOrdinalsInSymbolTable(const string& cfilt_location, vector<string>& symbol_table)
+{
+ ofstream f(_tempfile_location.c_str(), ios::trunc);
+ if (f.is_open())
+ {
+ // create a temp file which contain all the function names
+ for (unsigned int k=0; k<symbol_table.size(); k++)
+ {
+ f << symbol_table.at(k) << endl;
+ }
+ f.close();
+
+ // execute cfilt
+ vector<string> cfilt_result_set;
+ string cmd = cfilt_location + " < " + _tempfile_location;
+ ExecuteCommand(cmd, cfilt_result_set);
+
+ // check that all functions exist and then replace the symbol table with demangled functions
+ if (cfilt_result_set.size() == symbol_table.size())
+ {
+ symbol_table = cfilt_result_set;
+ }
+ }
+ else
+ {
+ f.close();
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool OrdinalCompare(const ordinal& left, const ordinal& right)
+{
+ return left.funcpos < right.funcpos;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_otherfunc.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,708 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Other non-categorized AppDep functionality
+*
+*/
+
+
+#include "appdep.hpp"
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ParseCommandLineParameters(int argc, char* argv[])
+{
+ // loop through the command line parameters and check their usage
+ int i=1;
+ while (i<argc)
+ {
+ if (StringICmp("-?", argv[i])==0 ||
+ StringICmp("-h", argv[i])==0 ||
+ StringICmp("--help", argv[i])==0)
+ {
+ ShowCommandLineOptionsAndExit();
+ }
+
+ else if (StringICmp("GCC", argv[i])==0)
+ {
+ _cl_use_gcc = true;
+ }
+
+ else if (StringICmp("GCCE", argv[i])==0)
+ {
+ _cl_use_gcce = true;
+ }
+
+ else if (StringICmp("RVCT", argv[i])==0)
+ {
+ _cl_use_rvct = true;
+ }
+
+ else if (StringICmp("--refresh", argv[i])==0)
+ {
+ _cl_update_cache = true;
+ }
+
+ else if (StringICmp("--clean", argv[i])==0)
+ {
+ _cl_generate_clean_cache = true;
+ }
+
+ else if (StringICmp("--uselibs", argv[i])==0)
+ {
+ _cl_use_libs = true;
+ }
+
+ else if (StringICmp("--showordinals", argv[i])==0)
+ {
+ _cl_show_ordinals = true;
+ }
+
+ else if (StringICmp("--useudeb", argv[i])==0)
+ {
+ _cl_use_udeb = true;
+ }
+
+ else if (StringICmp("--debug", argv[i])==0)
+ {
+ _cl_print_debug = true;
+ }
+
+ else if (StringICmp("-tools", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_toolsdir = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-cache", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_cachedir = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-release", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_releasedir = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-targets", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_targets = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-cfilt", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_cfiltloc = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-out", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_outputfile = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-config", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_configfile = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-sisfiles", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_sisfiles = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-usestaticdepstxt", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_usestaticdepstxt = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-properties", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_properties = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-staticdeps", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_staticdeps = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-dependson", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_dependson = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-showfunctions", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_showfunctions = argv[i+1]; i++; }
+ }
+
+ else if (StringICmp("-usesfunction", argv[i])==0)
+ {
+ if (i+1<argc) { _cl_usesfunction = argv[i+1]; i++; }
+ }
+
+ // check if the parameter is illegal
+ else
+ {
+ string param = argv[i];
+
+ if (!param.empty() && param.at(0) == '-')
+ {
+ cerr << "ERROR: Illegal argument: " << param << endl;
+ cerr << "Type appdep -? for help" << endl;
+ exit(EXIT_INVALID_ARGUMENT);
+ }
+ }
+
+ i++;
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ShowCommandLineOptionsAndExit()
+{
+ cout << "AppDep v" << APPDEP_VERSION << " - " << APPDEP_DATE << "\n"
+ "Copyright (c) " << APPDEP_COPYRIGHT_YEARS << " Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n"
+ "\n"
+ "Usage: appdep GCC|GCCE|RVCT [parameters] [options] [commands]\n"
+ "\n"
+ "Where:\n"
+ " GCC Use Symbian GCC tool chain\n"
+ " GCCE Use CSL ARM tool chain\n"
+ " RVCT Use RVCT tool chain\n"
+ "\n"
+ "Parameters:\n"
+ " -targets A+B+C+... Target types from release, one or more separated with + without spaces\n"
+ "\n"
+ "Required parameters when RVCT tool chain is used:\n"
+ " -cfilt FILE Location FILE of cfilt/c++filt\n"
+ "\n"
+ "Options:\n"
+ " -tools DIRECTORY DIRECTORY where the used compiler tool chain is installed\n"
+ " -release DIRECTORY DIRECTORY where release has been installed\n"
+ " -cache DIRECTORY DIRECTORY to store cache files\n"
+ " -out FILE Prints results to FILE\n"
+ " --refresh Updates the cache, use always after making changes to the release\n"
+ " --clean Always creates a clean cache\n"
+ " --uselibs Always use LIBs instead of DSOs (not valid with GCC)\n"
+ " --showordinals Show ordinals numbers in output when appropriate\n"
+ " --useudeb Scan udeb folder for binaries instead of urel\n"
+ " -sisfiles FILE;FILE;... Includes binaries from sis FILE under analysis\n"
+ //" -usestaticdepstxt FILE Use platform generated StaticDependencies.txt instead of cache\n"
+ //" --debug Print debug messages where available\n"
+ "\n"
+ "Commands:\n"
+ " -properties FILE Show properties of binary FILE\n"
+ " -staticdeps FILE Print all static dependencies of component FILE\n"
+ " -dependson FILE Print all components that depends on component FILE\n"
+ " -showfunctions FILE Print all functions used by compoment FILE\n"
+ " -usesfunction NAME Print all components that are using function NAME (NAME can be full\n"
+ " function name or in format DLLNAME@ORDINALNUMBER)\n"
+ "\n";
+
+ exit(EXIT_NORMAL);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DoInitialChecksAndPreparations()
+{
+ // make sure the directory names have trailing directory markers
+ MakeSureTrailingDirectoryMarkerExists(_cl_toolsdir);
+ MakeSureTrailingDirectoryMarkerExists(_cl_cachedir);
+ MakeSureTrailingDirectoryMarkerExists(_cl_releasedir);
+
+ // check that both --refresh and --clean are not defined
+ if (_cl_update_cache && _cl_generate_clean_cache)
+ {
+ cerr << "Do not specify both --refresh and --clean at the same time!" << endl;
+ cerr << "Type appdep -? for help" << endl;
+ exit(EXIT_WRONG_USAGE);
+ }
+
+ // check if targets parameter has been given
+ if (_cl_targets.empty())
+ {
+ cerr << "-targets parameter not specified!" << endl;
+ cerr << "Type appdep -? for help" << endl;
+ exit(EXIT_NO_TARGETS);
+ }
+
+ // if releasedir param is not specified, assign it be the root of current drive
+ if (_cl_releasedir.empty())
+ {
+ _cl_releasedir = DIR_SEPARATOR;
+ }
+
+ // append default cache location if otherwise the cache parameter is empty
+ if (_cl_cachedir.empty())
+ {
+ _cl_cachedir = _cl_releasedir + DEFAULT_CACHE_DIR;
+ }
+
+ // check output file can be created
+ if (!_cl_outputfile.empty())
+ {
+ _outputf.open(_cl_outputfile.c_str(), ios::trunc);
+ if (!_outputf.is_open())
+ {
+ _outputf.close();
+ cerr << "ERROR: Cannot open " << _cl_outputfile << " for writing!" << endl;
+ cerr << "Please check that the directory exists and there are no write permission problems" << endl;
+ exit(EXIT_CANNOT_CREATE_OUTPUT_FILE);
+ }
+ }
+
+ // set target mode
+ if (_cl_use_udeb)
+ _target_mode = "udeb";
+ else
+ _target_mode = "urel";
+
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ParseTargets()
+{
+ // parse A+B+C+... to a vector
+ int last_found_plus_pos = -1;
+ for (unsigned int i=0; i<_cl_targets.length(); i++)
+ {
+ // try to find '+' characters
+ string::size_type plus_pos = _cl_targets.find("+", i);
+
+ target new_target;
+
+ if (plus_pos == string::npos)
+ {
+ // could not find the plus character, append last part of the list
+ string tmp = _cl_targets.substr(last_found_plus_pos+1, _cl_targets.length()-last_found_plus_pos-1);
+ new_target.name = LowerCase(tmp);
+ _targets.push_back(new_target);
+ break;
+ }
+ else
+ {
+ // found a plus character, append to the list, but needs to check if there are more
+ string tmp = _cl_targets.substr(last_found_plus_pos+1, plus_pos-last_found_plus_pos-1);
+ new_target.name = LowerCase(tmp);
+
+ if (new_target.name.length() > 0)
+ _targets.push_back(new_target);
+
+ last_found_plus_pos = plus_pos;
+ i = last_found_plus_pos;
+ }
+ }
+
+ // set more values of targets vector
+ for (unsigned int i=0; i<_targets.size(); i++)
+ {
+ // set path where release the release can be found, eg z:\epoc32\release\armv5\ .
+ _targets.at(i).release_dir = _cl_releasedir + EPOC32_RELEASE + _targets.at(i).name + DIR_SEPARATOR;
+
+ // set path where the import libraries of the release can be found, eg z:\epoc32\release\armv5\lib\ .
+ string lib_dir;
+ if (_cl_use_gcce || _cl_use_rvct)
+ lib_dir = "lib"; // lib dir used in Symbian OS 9.x
+ else
+ lib_dir = _target_mode;
+
+ _targets.at(i).release_lib_dir = _targets.at(i).release_dir + lib_dir + DIR_SEPARATOR;
+
+ // set path where the binaries of the release can be found, eg z:\epoc32\release\armv5\urel\ .
+ _targets.at(i).release_bin_dir = _targets.at(i).release_dir + _target_mode + DIR_SEPARATOR;
+
+ // set location of the cache files of this target, eg z:\caches\armv5\urel\xxx.txt
+ _targets.at(i).cache_dir = _cl_cachedir + _targets.at(i).name + DIR_SEPARATOR + _target_mode + DIR_SEPARATOR;
+ _targets.at(i).st_cache_path = _targets.at(i).cache_dir + CACHE_ST_FILENAME;
+ _targets.at(i).dep_cache_path = _targets.at(i).cache_dir + CACHE_DEP_FILENAME;
+
+ // check if those cache files exists
+ _targets.at(i).cache_files_valid = FileExists(_targets.at(i).st_cache_path) && FileExists(_targets.at(i).dep_cache_path);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void DoCacheGenerationChecksAndPreparations()
+{
+ if (!_cl_use_gcc && !_cl_use_gcce && !_cl_use_rvct)
+ {
+ cerr << "ERROR: No tool chain defined!" << endl;
+ cerr << "Type appdep -? for help" << endl;
+ exit(EXIT_WRONG_USAGE);
+ }
+
+ if (_cl_use_rvct && _cl_cfiltloc.empty())
+ {
+ cerr << "ERROR: Specify -cfilt when RVCT is defined!" << endl;
+ cerr << "Type appdep -? for help" << endl;
+ exit(EXIT_WRONG_USAGE);
+ }
+
+ if ( (_cl_use_gcc && (_cl_use_gcce || _cl_use_rvct)) || (_cl_use_gcce && (_cl_use_gcc || _cl_use_rvct)) ||
+ (_cl_use_rvct && (_cl_use_gcc || _cl_use_gcce)) )
+ {
+ cerr << "ERROR: Specify only one tool chain!" << endl;
+ cerr << "Type appdep -? for help" << endl;
+ exit(EXIT_WRONG_USAGE);
+ }
+
+ // make sure the vectors are empty when generating clean cache
+ if (_cl_generate_clean_cache)
+ {
+ for (unsigned int i=0; i<_targets.size(); i++) // loop each target
+ {
+ _targets.at(i).import_libraries.clear();
+ _targets.at(i).binaries.clear();
+ }
+ }
+
+ // if tools parameter is empty, try get it from path, otherwise check given parameter
+ if (_cl_toolsdir.empty())
+ {
+ GetToolsPathFromEnvironmentVariable();
+ }
+ else
+ {
+ // check the given tools directory parameter is valid
+ if (_cl_use_gcc)
+ {
+ _gcc_nm_location = _cl_toolsdir + GCC_NM_EXE;
+
+ if (!FileExists(_gcc_nm_location))
+ {
+ cerr << "ERROR: Unable to find " + _gcc_nm_location << ", check -tools parameter" << endl;
+ cerr << "Tip: GCC is typically installed to \\epoc32\\gcc\\bin directory" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND);
+ }
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_gcc_nm_location);
+ }
+
+ else if (_cl_use_gcce)
+ {
+ _gcce_nm_location = _cl_toolsdir + GCCE_NM_EXE;
+ _gcce_readelf_location = _cl_toolsdir + GCCE_READELF_EXE;
+ _gcce_cfilt_location = _cl_toolsdir + GCCE_CFILT_EXE;
+
+ if (!FileExists(_gcce_nm_location))
+ {
+ cerr << "ERROR: Unable to find " + _gcce_nm_location << ", check -tools param" << endl;
+ cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND);
+ }
+
+ if (!FileExists(_gcce_readelf_location))
+ {
+ cerr << "ERROR: Unable to find " + _gcce_readelf_location << ", check -tools param" << endl;
+ cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND);
+ }
+
+ if (!FileExists(_gcce_cfilt_location))
+ {
+ cerr << "ERROR: Unable to find " + _gcce_cfilt_location << ", check -tools param" << endl;
+ cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND);
+ }
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_gcce_nm_location);
+ InsertQuotesToFilePath(_gcce_readelf_location);
+ InsertQuotesToFilePath(_gcce_cfilt_location);
+
+ }
+
+ else if (_cl_use_rvct)
+ {
+ _rvct_armar_location = _cl_toolsdir + RVCT_ARMAR_EXE;
+ _rvct_fromelf_location = _cl_toolsdir + RVCT_FROMELF_EXE;
+
+ if (!FileExists(_rvct_armar_location))
+ {
+ cerr << "ERROR: Unable to find " + _rvct_armar_location << ", check -tools param" << endl;
+ cerr << "Tip: Check your environment variables to see the directory where RVCT has been installed" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND);
+ }
+
+ if (!FileExists(_rvct_fromelf_location))
+ {
+ cerr << "ERROR: Unable to find " + _rvct_fromelf_location << ", check -tools param" << endl;
+ cerr << "Tip: Check your environment variables to see the directory where RVCT has been installed" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND);
+ }
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_rvct_armar_location);
+ InsertQuotesToFilePath(_rvct_fromelf_location);
+ }
+ } // else of if (!cl_toolsdir)
+
+
+ // check path of RVCT's cfilt is correct
+ if (_cl_use_rvct)
+ {
+ _rvct_cfilt_location = _cl_cfiltloc;
+
+ if (!FileExists(_rvct_cfilt_location))
+ {
+ cerr << "ERROR: Unable to find " + _rvct_cfilt_location << ", check -cfilt param" << endl;
+ cerr << "Tip: Working cfilt.exe can be found from the same directory where appdep has been installed" << endl;
+ exit(EXIT_CFILT_NOT_FOUND);
+ }
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_rvct_cfilt_location);
+ }
+
+
+ // check Petran can be found
+ SetAndCheckPetranPath();
+
+ // loop all targets
+ for (unsigned int i=0; i<_targets.size(); i++)
+ {
+ // check directories for given targets are valid
+ if (!DirectoryExists(_targets.at(i).release_dir))
+ {
+ cerr << "ERROR: Directory " << _targets.at(i).release_dir << " not found!" << endl;
+ cerr << "Please check that -targets parameter is valid and you have a full release environment" << endl;
+ exit(EXIT_TARGETDIR_NOT_FOUND);
+ }
+ else
+ {
+ //cerr << "NOTE: " << targets.at(i) << " is a valid target in your release" << endl;
+ }
+
+ // make sure that the cache directory exists
+ MkDirAll(_targets.at(i).cache_dir);
+ }
+
+ // check that it is possible to create the temporary file under the cache directory
+ _tempfile_location = _cl_cachedir + TEMP_FILENAME;
+ ofstream tempf(_tempfile_location.c_str(), ios::trunc);
+ if (!tempf.is_open())
+ {
+ tempf.close();
+ cerr << "ERROR: Cannot open " << _tempfile_location << " for writing!" << endl;
+ cerr << "Please check that the directory exists and there are no write permission problems" << endl;
+ exit(EXIT_CANNOT_WRITE_TO_TEMP_FILE);
+ }
+ else
+ tempf.close();
+
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetToolsPathFromEnvironmentVariable()
+{
+ #ifdef WIN32
+ // get path environment variable
+ const char* env_path = getenv("PATH");
+
+ if (env_path != NULL)
+ {
+ string env_path_str = env_path;
+
+ string::size_type previous_delimpos = 0;
+ bool match_found(false);
+ string test_path;
+
+ for (unsigned int i=0; i<env_path_str.length(); i++)
+ {
+ // directories in %PATH% are separated with ';'-char
+ string::size_type delimpos = env_path_str.find(";", i);
+
+ if (delimpos != string::npos)
+ {
+ // get path
+ test_path = env_path_str.substr(previous_delimpos, delimpos-previous_delimpos);
+
+ MakeSureTrailingDirectoryMarkerExists(test_path);
+
+ // remember found position
+ previous_delimpos = delimpos + 1;
+ i = delimpos;
+
+ // do check if path is correct
+ if (_cl_use_gcc)
+ {
+ _gcc_nm_location = test_path + GCC_NM_EXE;
+
+ if (FileExists(_gcc_nm_location))
+ {
+ match_found = true;
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_gcc_nm_location);
+ }
+ }
+
+ else if (_cl_use_gcce)
+ {
+ _gcce_nm_location = test_path + GCCE_NM_EXE;
+ _gcce_readelf_location = test_path + GCCE_READELF_EXE;
+ _gcce_cfilt_location = test_path + GCCE_CFILT_EXE;
+
+ if (FileExists(_gcce_nm_location) && FileExists(_gcce_readelf_location) && FileExists(_gcce_cfilt_location))
+ {
+ match_found = true;
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_gcce_nm_location);
+ InsertQuotesToFilePath(_gcce_readelf_location);
+ InsertQuotesToFilePath(_gcce_cfilt_location);
+ }
+ }
+
+ else if (_cl_use_rvct)
+ {
+ _rvct_armar_location = test_path + RVCT_ARMAR_EXE;
+ _rvct_fromelf_location = test_path + RVCT_FROMELF_EXE;
+
+ if (FileExists(_rvct_armar_location) && FileExists(_rvct_fromelf_location))
+ {
+ match_found = true;
+
+ // extra quotes needed to prevent white space problems while executing the tool
+ InsertQuotesToFilePath(_rvct_armar_location);
+ InsertQuotesToFilePath(_rvct_fromelf_location);
+ }
+ }
+
+ }
+
+ // first matching directory found, no need to loop anymore
+ if (match_found)
+ {
+ _cl_toolsdir = test_path;
+ cerr << "Tool chain found from %PATH% at " << test_path << endl;
+ break;
+ }
+
+ if (i>5000)
+ break; // something went wrong..
+ }
+
+ if (!match_found)
+ {
+ cerr << "ERROR: Cannot find specified compiler toolset from PATH environment" << endl;
+ cerr << "Fix PATH environment variable or specify -tools parameter" << endl;
+ exit(EXIT_TOOLCHAIN_NOT_FOUND_FROM_PATH);
+ }
+
+ }
+ else
+ {
+ cerr << "ERROR: PATH environment variable not available, please specify -tools parameter" << endl;
+ exit(EXIT_PATH_VARIABLE_NOT_FOUND);
+ }
+
+ #else
+
+ cerr << "ERROR: Optional -tools parameter is only supported in Windows environment " << endl;
+ exit(EXIT_ONLY_SUPPORTED_IN_WIN32);
+
+ #endif
+
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void FindImportLibrariesAndBinariesFromReleases()
+{
+ // check if analysing .dso or .lib files
+ string lib_filter;
+ if (_cl_use_gcc || _cl_use_libs) // for GCC use always .lib files
+ lib_filter = "*.lib";
+ else
+ lib_filter = "*.dso";
+
+ for (unsigned int i=0; i<_targets.size(); i++) // loop each target
+ {
+ // get import libraries
+ GetFileNamesFromDirectory(_targets.at(i).release_lib_dir, lib_filter, _targets.at(i).lib_files);
+ _max_progress += _targets.at(i).lib_files.size();
+
+ // get binaries
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.app", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.exe", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.dll", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.prt", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.?sy", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.fep", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.agt", _targets.at(i).bin_files);
+ GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.fxt", _targets.at(i).bin_files);
+
+ // increase the value of total number of files
+ _max_progress += _targets.at(i).bin_files.size();
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void GetFileNamesFromDirectory(const string& directory, const string& filter, vector<string>& resultset)
+{
+ // get list of files from the directory by executing OS specific dir/ls command
+ string dir_command = DIR_COMMAND;
+ string cmd = dir_command + " \"" + directory + "\"" + filter + " " + CERR_TO_NULL;
+
+ vector<string> tempVector;
+ ExecuteCommand(cmd, tempVector);
+
+ // loop through all returned files
+ for (unsigned int i=0; i<tempVector.size(); i++)
+ {
+ // remove any leading and trailing white spaces
+ string file_entry = tempVector.at(i);
+ TrimAll(file_entry);
+
+ // filter out any unwanted files and append the file to the vector
+ if (!file_entry.empty() && file_entry.find("{000a0000}")==string::npos && file_entry.find(".dll55l")==string::npos)
+ {
+ // strip out any possible directory paths
+ string::size_type sep_pos = file_entry.find_last_of(DIR_SEPARATOR);
+ if (sep_pos != string::npos)
+ file_entry = file_entry.substr(sep_pos+1, file_entry.length()-sep_pos-1);
+
+ // append entry
+ resultset.push_back(file_entry);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void SetAndCheckPetranPath()
+{
+ if(_cl_use_gcc)
+ {
+ _petran_location = _cl_releasedir + PETRAN_LOCATION;
+ }
+ else
+ {
+ _petran_location = _cl_releasedir + ELFTRAN_LOCATION;
+ }
+
+ if (!FileExists(_petran_location))
+ {
+ cerr << "ERROR: Unable to find " + _petran_location << ", check -release param" << endl;
+ cerr << "Make sure you have a working development environment" << endl;
+ exit(EXIT_PETRAN_NOT_FOUND);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_sisfiles.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,324 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Handling of sis files
+*
+*/
+
+
+#include "appdep.hpp"
+
+// ----------------------------------------------------------------------------------------------------------
+// Note that in C/C++ code \ has been replaced with \\ and " with \".
+// ----------------------------------------------------------------------------------------------------------
+
+void DoInitialChecksAndPreparationsForSisFiles()
+{
+ // specify full location for dumpsis
+ _dumpsis_location = _cl_releasedir + DUMPSIS_LOCATION;
+
+ // check if dumpsis can be found
+ if (!FileExists(_dumpsis_location))
+ {
+ cerr << "ERROR: Unable to find " + _dumpsis_location << ", check -release param" << endl;
+ cerr << "Please notice that this feature is available only in Symbian OS 9.x" << endl;
+ cerr << "It is possible the user to copy dumpsis.exe from some other release under" << endl;
+ cerr << "this release to support this feature." << endl;
+ exit(EXIT_DUMPSIS_NOT_FOUND);
+ }
+
+ // insert quotes to the dumpsis location to avoid any problems caused by white spaces
+ InsertQuotesToFilePath(_dumpsis_location);
+
+ // parse commandline argument "sisfiles" from sisfile;sisfile;...
+ int last_found_semicolon_pos = -1;
+ for (unsigned int i=0; i<_cl_sisfiles.length(); i++)
+ {
+ // try to find ';' characters
+ string::size_type semicolon_pos = _cl_sisfiles.find(";", i);
+
+ if (semicolon_pos == string::npos)
+ {
+ // could not find the ';' character, append last part of the list
+ string sis_file = _cl_sisfiles.substr(last_found_semicolon_pos+1,_cl_sisfiles.length()-last_found_semicolon_pos-1);
+ _sisfiles.push_back(sis_file);
+ break;
+ }
+ else
+ {
+ // found a ';' character, append to the list, but needs to check if there are more
+ string sis_file = _cl_sisfiles.substr(last_found_semicolon_pos+1, semicolon_pos-last_found_semicolon_pos-1);
+
+ if (sis_file.length() > 0)
+ _sisfiles.push_back(sis_file);
+
+ last_found_semicolon_pos = semicolon_pos;
+ i = last_found_semicolon_pos;
+ }
+ }
+
+ // check that all given sisfiles can be found and it is supported
+ for (unsigned int i=0; i<_sisfiles.size(); i++)
+ {
+ // report an error if the file does not exist
+ if (!FileExists(_sisfiles.at(i)))
+ {
+ cerr << "ERROR: Unable to find " + _sisfiles.at(i) << ", check -sisfiles parameter" << endl;
+ exit(EXIT_SIS_FILE_NOT_FOUND);
+ }
+
+ // open the sis file for reading to check if it is supported
+ ifstream sisf(_sisfiles.at(i).c_str(), ios::binary);
+ if (sisf.is_open())
+ {
+ int c1, c2, c3, c4;
+ c1 = sisf.get();
+ c2 = sisf.get();
+ c3 = sisf.get();
+ c4 = sisf.get();
+
+ // in valid sis first four bytes of the file are 7A1A2010
+ if (c1==0x7A && c2==0x1A && c3==0x20 && c4==0x10)
+ {
+ //cerr << _sisfiles.at(i) << " is supported" << endl;
+ }
+ else
+ {
+ // if starting from offset 8, four next bytes are 19040010, the file is
+ // unsupported SIS file used in previous Symbian OS releases.
+ sisf.seekg(8, ios::beg);
+ c1 = sisf.get();
+ c2 = sisf.get();
+ c3 = sisf.get();
+ c4 = sisf.get();
+ sisf.close();
+
+ if (c1==0x19 && c2==0x04 && c3==0x00 && c4==0x10)
+ {
+ cerr << "ERROR: " + _sisfiles.at(i) << " is a pre-Symbian OS 9.x" << endl;
+ cerr << "sisfile which is not supported, check -sisfiles parameter" << endl;
+ exit(EXIT_SIS_FILE_NOT_SUPPORTED);
+ }
+ else
+ {
+ cerr << "ERROR: " + _sisfiles.at(i) << " is not a valid sis file," << endl;
+ cerr << "check -sisfiles parameter" << endl;
+ exit(EXIT_NOT_SIS_FILE);
+ }
+ }
+ sisf.close();
+ }
+ else
+ {
+ cerr << "ERROR: Cannot open " + _sisfiles.at(i) << " for reading, check -sisfiles parameter" << endl;
+ exit(EXIT_SIS_FILE_CANNOT_OPEN_FOR_READING);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void AnalyseSisFiles()
+{
+ // create a new target and set some defaults
+ target sis_target;
+ sis_target.name = "sis";
+ sis_target.cache_dir = _cl_cachedir + sis_target.name + DIR_SEPARATOR;
+ sis_target.dep_cache_path = sis_target.cache_dir + CACHE_DEP_FILENAME;
+
+ cerr << "Analysing sis files..." << endl;
+
+ // define path to a temp directory where dumpsis will extract the files
+ const string tempdir = _cl_cachedir + SIS_TEMP_DIR + DIR_SEPARATOR;
+ const string tempdir2 = _cl_cachedir + SIS_TEMP_DIR;
+
+ // do analysis for each file
+ for (unsigned int i=0; i<_sisfiles.size(); i++)
+ {
+ // create the temporary directory
+ MkDirAll(tempdir);
+
+ cerr << "Binaries in " << _sisfiles.at(i) << " are:" << endl;
+
+ // due to bugginess of a specific version of dumpsis, we need to copy the source file under the temporary directory
+ const string new_sis_loc = tempdir + "tempsis.sis";
+
+ ifstream src_sis_f(_sisfiles.at(i).c_str(), ios::binary);
+ if (src_sis_f.is_open())
+ {
+ ofstream trgt_sis_f(new_sis_loc.c_str(), ios::binary);
+ if (trgt_sis_f.is_open())
+ {
+ // read all bytes from source and write to the target
+ int c1;
+
+ while(!src_sis_f.eof())
+ {
+ c1 = src_sis_f.get();
+ trgt_sis_f.put(c1);
+ }
+
+ trgt_sis_f.close();
+
+ }
+ else
+ {
+ cerr << "ERROR: Cannot open " + new_sis_loc << " for writing, check write permissions" << endl;
+ exit(EXIT_TEMP_SIS_FILE_CANNOT_OPEN_FOR_WRITING);
+ }
+
+ src_sis_f.close();
+
+ }
+ else
+ {
+ cerr << "ERROR: Cannot open " + _sisfiles.at(i) << " for reading, check -sisfiles parameter" << endl;
+ exit(EXIT_SIS_FILE_CANNOT_OPEN_FOR_READING);
+ }
+
+
+
+ // execute dumpsis
+ string cmd = _dumpsis_location + " -x -d \"" + tempdir2 + "\" \"" + new_sis_loc + "\" " + CERR_TO_NULL;
+
+ vector<string> tempVector;
+ ExecuteCommand(cmd, tempVector);
+
+
+ // check if pkg file found
+ string pkgfile_location = tempdir + "tempsis.pkg";
+
+ if (!FileExists(pkgfile_location))
+ {
+ // try again with an alternative
+ pkgfile_location = tempdir + "tempsis.sis.pkg";
+
+ if (!FileExists(pkgfile_location))
+ {
+ RemoveDirectoryWithAllFiles(tempdir);
+ cerr << "ERROR: Dumpsis failed for " << _sisfiles.at(i) << " since it does not contain a pkg file, check -sisfiles parameter" << endl;
+ exit(EXIT_NO_PKG_FILE_FOUND);
+ }
+ }
+
+ // open the pkg file for reading
+ ifstream pkgf(pkgfile_location.c_str(), ios::binary);
+ if (pkgf.is_open())
+ {
+ int c1, c2;
+ c1 = pkgf.get();
+ c2 = pkgf.get();
+
+ // we only support unicode format
+ if (c1 == 0xFF && c2 == 0xFE)
+ {
+ string line;
+
+ // read more chars
+ while(!pkgf.eof())
+ {
+ c1 = pkgf.get();
+ c2 = pkgf.get();
+
+ // if (c1 == 0x0D && c2 == 0x00) // new line marker #1
+ // {
+ // c1 = pkgf.get();
+ // c2 = pkgf.get();
+
+ if (c1 == 0x0A && c2 == 0x00) // new line marker #2
+ {
+ // full line is now available, parse it
+
+ boost::regex re1("^\\\"(.+)\\\"-\\\".*\\\\(\\S+)\\\",.*$");
+ boost::cmatch matches1;
+ if (boost::regex_match(line.c_str(), matches1, re1))
+ {
+ // match found
+ string ms1(matches1[1].first, matches1[1].second); // source name
+ string ms2(matches1[2].first, matches1[2].second); // target name
+
+ binary_info b_info;
+ b_info.directory = tempdir;
+ b_info.filename = ms1;
+
+ GetImportTableWithPetran(_petran_location, b_info);
+
+ // make sure that Petran succeeded for this file since we don't do any file
+ // extension checks when parsering the file
+ if (b_info.binary_format != UNKNOWN)
+ {
+ // print name of the destination binary
+ cerr << ms2 << endl;
+
+ b_info.directory = "";
+ b_info.filename = ms2;
+
+ // get statistics of the file and set the modification time
+ struct stat stat_p;
+ stat((tempdir + ms1).c_str(), &stat_p);
+ b_info.mod_time = stat_p.st_mtime;
+
+ // create a new entry to list of binary files
+ sis_target.binaries.push_back( b_info );
+ }
+
+ }
+
+ // clear the buffer since we start scanning another line
+ line = "";
+ }
+ //}
+ else
+ {
+ char c(c1); // simple unicode to ascii conversion, just ignore c2
+ line += c; // append the char to end of the line
+ }
+ }
+ }
+ else
+ {
+ pkgf.close();
+ RemoveDirectoryWithAllFiles(tempdir);
+ cerr << "ERROR: Pkg file " + pkgfile_location << " is not supported, check -sisfiles parameter" << endl;
+ exit(EXIT_PKG_FILE_CANNOT_OPEN_FOR_READING);
+ }
+
+ }
+ else
+ {
+ RemoveDirectoryWithAllFiles(tempdir);
+ cerr << "ERROR: Cannot open " + pkgfile_location << " for reading, check -sisfiles parameter" << endl;
+ exit(EXIT_PKG_FILE_CANNOT_OPEN_FOR_READING);
+ }
+
+ // close handles and clear any temp files
+ pkgf.close();
+ RemoveDirectoryWithAllFiles(tempdir);
+ }
+
+ // make sure that the cache directory exists
+ MkDirAll(sis_target.cache_dir);
+
+ // write the dependencies cache of the sis files
+ WriteDataToDependenciesCacheFile(sis_target);
+
+ // append to targets
+ _targets.push_back(sis_target);
+
+ cerr << endl;
+
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_statdeps.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,189 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Handling of StaticDependencies.txt
+*
+*/
+
+
+#include "appdep.hpp"
+
+
+// ----------------------------------------------------------------------------------------------------------
+// Note that in C/C++ code \ has been replaced with \\ and " with \".
+// ----------------------------------------------------------------------------------------------------------
+
+void GetDataFromStaticDependenciesTxt()
+{
+ // read cache data from given StaticDependencies.txt
+ if (!FileExists(_cl_usestaticdepstxt))
+ {
+ cerr << "ERROR: Unable to find " + _cl_usestaticdepstxt << ", check -usestaticdepstxt param" << endl;
+ cerr << "Please note that this parameter is required only if you use StaticDependencies.txt." << endl;
+ exit(EXIT_CANNOT_OPEN_STATIC_DEPENDENCIES_TXT);
+ }
+
+ ifstream staticdepsf(_cl_usestaticdepstxt.c_str());
+ string line;
+
+ getline(staticdepsf, line);
+ if (line != "# Full direct component mapping:")
+ {
+ cerr << "ERROR: " << _cl_usestaticdepstxt << " is not a supported StaticDependencies.txt file!" << endl;
+ staticdepsf.close();
+ exit(EXIT_OPENED_STATIC_DEPENDENCIES_TXT_NOT_SUPPORTED);
+ }
+ else
+ {
+ cerr << "Warning: Use of StaticDependencies.txt may provide incomplete results..." << endl;
+
+ bool line_was_consumed = true;
+
+ // loop through all lines in the file
+ while(!staticdepsf.eof())
+ {
+ // get a line
+ if (line_was_consumed)
+ getline(staticdepsf, line);
+
+ if (line == "# Full inverse component mapping:")
+ {
+ // no interesting lines in this file anymore, break the loop
+ break;
+ }
+
+ // first line is the executable type, eg
+ // armv5::screengrabber (exe)
+ boost::regex re1("^(\\S+)::(\\S+)\\s\\((\\S+)\\).*");
+ boost::cmatch matches1;
+ if (boost::regex_match(line.c_str(), matches1, re1))
+ {
+ // match found
+ string ms1(matches1[1].first, matches1[1].second); // binary type
+ string ms2(matches1[2].first, matches1[2].second); // filename
+ string ms3(matches1[3].first, matches1[3].second); // extension
+
+ line_was_consumed = true;
+
+ binary_info b_info;
+ b_info.directory = UNKNOWN;
+ b_info.filename = ms2 + "." + ms3;
+ b_info.binary_format = ms1 + " " +ms3;
+ b_info.uid1 = UNKNOWN;
+ b_info.uid2 = UNKNOWN;
+ b_info.uid3 = UNKNOWN;
+ b_info.secureid = UNKNOWN;
+ b_info.vendorid = UNKNOWN;
+ b_info.capabilities = 0;
+ b_info.min_heap_size = 0;
+ b_info.max_heap_size = 0;
+ b_info.stack_size = 0;
+ b_info.mod_time = 0;
+
+ vector<dependency> deps;
+ for (;;)
+ {
+ // get a line
+ if (line_was_consumed)
+ getline(staticdepsf, line);
+
+ // check for dependency line, eg
+ // screengrabber -> euser
+ boost::regex re2("^\\s\\s\\s(\\S+)\\s->\\s(\\S+).*");
+ boost::cmatch matches2;
+ if (boost::regex_match(line.c_str(), matches2, re2))
+ {
+ // match found
+ string ms1(matches2[1].first, matches2[1].second); // filename
+ string ms2(matches2[2].first, matches2[2].second); // dependency
+
+ line_was_consumed = true;
+
+ dependency dep;
+ dep.filename = ms2 + ".dll"; // assumming that the file extension is always .dll
+
+ vector<import> imps;
+ for (;;)
+ {
+ if (line_was_consumed)
+ getline(staticdepsf, line);
+
+ // check for function names, eg
+ // fref::screengrabber->euser.CActive::Cancel (1)
+ boost::regex re3("^\\s\\s\\s\\s\\s\\sfref::(\\S+)->(\\S+)\\.(\\S+)\\s\\((\\S+)\\).*");
+ boost::cmatch matches3;
+ if (boost::regex_match(line.c_str(), matches3, re3))
+ {
+ // match found
+ string ms1(matches3[1].first, matches3[1].second); // filename
+ string ms2(matches3[2].first, matches3[2].second); // dependency
+ string ms3(matches3[3].first, matches3[3].second); // functionname
+ string ms4(matches3[4].first, matches3[4].second); // ???
+
+ line_was_consumed = true;
+
+ import imp;
+ imp.funcpos = 0;
+ imp.funcname = ms3;
+ imp.is_vtable = false;
+ imp.vtable_offset = 0;
+
+ // append to the import info vector
+ imps.push_back( imp );
+ }
+ else
+ {
+ // the line does not match, break the loop
+ line_was_consumed = false;
+ break;
+ }
+
+ } // for (;;)
+
+ // now we have import info too
+ dep.imports = imps;
+
+ // append to the deps info vector
+ deps.push_back( dep );
+
+ }
+ else
+ {
+ // the line does not match, break the loop
+ line_was_consumed = false;
+ break;
+ }
+ } // for (;;)
+
+ // now we have the dep info too
+ b_info.dependencies = deps;
+
+ // apppend binary info to the vectory
+ _all_binary_infos.push_back( b_info );
+
+ }
+ else
+ {
+ // no match found, line was consumed anyway
+ line_was_consumed = true;
+ } // else of if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1))
+
+ } // while(!staticdepsf.eof())
+ } // else of if (line != "# Full direct component mapping:")
+
+ // close handle to the cache file
+ staticdepsf.close();
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/appdep_utils.cpp Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,379 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Misc utility functions
+*
+*/
+
+
+#include "appdep.hpp"
+
+// ----------------------------------------------------------------------------------------------------------
+
+void PrintOutputLn(const string& s)
+{
+ // check if printing to a file or directory to STDOUT
+ if (!_cl_outputfile.empty())
+ {
+ _outputf << s << endl;
+ }
+ else
+ {
+ cout << s << endl;
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void MakeSureTrailingDirectoryMarkerExists(string& path)
+{
+ if (!path.empty() && path.at(path.length()-1) != DIR_SEPARATOR2)
+ {
+ path.insert(path.length(), DIR_SEPARATOR);
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool FileExists(const string& path)
+{
+ if (!path.empty())
+ {
+ struct stat stat_p;
+ if (stat(path.c_str(), &stat_p) == 0)
+ return !S_ISDIR(stat_p.st_mode); // return true if not a directory
+ else
+ return false; // cannot find entry
+ }
+ else
+ return false;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool DirectoryExists(const string& path)
+{
+ if (!path.empty())
+ {
+ string temp_path = path;
+
+ // remove trailing directory marker if exists
+ if (path.at(path.length()-1) == DIR_SEPARATOR2)
+ temp_path = path.substr(0, path.length()-1);
+
+ struct stat stat_p;
+ if (stat(temp_path.c_str(), &stat_p) == 0)
+ return S_ISDIR(stat_p.st_mode); // return true if a directory
+ else
+ return false; // cannot find entry
+ }
+ else
+ return false;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool RemoveFile(const string& path)
+{
+ return _unlink(path.c_str()) == 0;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool RemoveDirectoryWithAllFiles(const string& path)
+{
+ string temp_path = path;
+ MakeSureTrailingDirectoryMarkerExists(temp_path);
+
+ // remove all files in the directory via OS call
+ string del_command = DEL_ALL_COMMAND;
+ string cmd = del_command + " " + temp_path + "* " + CERR_TO_NULL;
+
+ vector<string> tempVector;
+ ExecuteCommand(cmd, tempVector);
+
+ // finally tries to remove the directory, fails if not empty
+ return _rmdir(path.c_str()) == 0;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+string LowerCase(const string& s)
+{
+ char* buf = new char[s.length()];
+ s.copy(buf, s.length());
+
+ for(unsigned int i = 0; i < s.length(); i++)
+ buf[i] = tolower(buf[i]);
+
+ string r(buf, s.length());
+ delete buf;
+ return r;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void MkDirAll(const string& path)
+{
+ if (!path.empty() && !DirectoryExists(path))
+ {
+ string target_path = path;
+
+ // make sure that the directory has a trailing directory marker
+ MakeSureTrailingDirectoryMarkerExists(target_path);
+
+ // loop through each character in the string and try to find directory delimeters
+ for (unsigned int i=0; i<target_path.length(); i++)
+ {
+ string::size_type pos = target_path.find(DIR_SEPARATOR, i);
+
+ if (pos != string::npos)
+ {
+ // construct the base directory name
+ string base_directory = target_path.substr(0, pos+1);
+
+ if (!DirectoryExists(base_directory))
+ {
+ _mkdir(base_directory.c_str());
+ }
+
+ i=pos;
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool ExecuteCommand(const string& command, vector<string>& resultset)
+{
+ // note, cannot use compiler parameters "-std=c++98" because of popen/pclose
+ // also cannot compile this code is MSVC because usage of popen/pclose
+
+ FILE* fp;
+ char buffer[1024];
+ string tempstr;
+
+ resultset.clear();
+
+ if ((fp = _popen(command.c_str(), "r")) == NULL)
+ {
+ return false;
+ }
+
+ while (fgets(buffer, sizeof(buffer), fp))
+ {
+ tempstr = buffer;
+ resultset.push_back(tempstr.substr(0, tempstr.size()-1));
+ }
+
+ _pclose(fp);
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+string& TrimRight(string& s)
+{
+ int pos(s.size());
+ for (; pos && (s[pos-1]==' ' || s[pos-1]=='\t'); --pos);
+ s.erase(pos, s.size()-pos);
+ return s;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+string& TrimLeft(string& s)
+{
+ int pos(0);
+ for (; s[pos]==' ' || s[pos]=='\t'; ++pos);
+ s.erase(0, pos);
+ return s;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+string& TrimAll(string& s)
+{
+ return TrimLeft(TrimRight(s));
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+int StringICmp(const string& s1, const string& s2)
+{
+ string ss1 = LowerCase(s1);
+ string ss2 = LowerCase(s2);
+
+ return ss1.compare(ss2);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+int StringICmpFileNamesWithoutExtension(const string& s1, const string& s2)
+{
+ // remove extension and then compare
+ string ss1;
+ string ss2;
+
+ string::size_type dot_pos1 = s1.find_last_of('.');
+ if (dot_pos1 == string::npos)
+ ss1 = s1;
+ else
+ ss1 = s1.substr(0, dot_pos1);
+
+ string::size_type dot_pos2 = s2.find_last_of('.');
+ if (dot_pos2 == string::npos)
+ ss2 = s2;
+ else
+ ss2 = s2.substr(0, dot_pos2);
+
+ return StringICmp(ss1, ss2);
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+bool TimestampsMatches(const time_t& orginal_time, const time_t& new_time)
+{
+ // allow two second difference to both directions
+ if (new_time-2 <= orginal_time && orginal_time <= new_time+2)
+ return true;
+ else
+ return false;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+string Int2Str(int value)
+{
+ ostringstream os;
+ if (os << value)
+ return os.str();
+ else
+ return "";
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+int Str2Int(const string& s)
+{
+ int res(0);
+
+ // return 0 for empty string
+ if (s.empty())
+ {
+ }
+
+ // hex conversion if the string begings with 0x...
+ else if (s.length() >= 3 && s.at(0) == '0' && s.at(1) == 'x')
+ {
+ istringstream is(s);
+ is >> hex >> res;
+ if(!is || !is.eof())
+ res = 0;
+ }
+
+ // normal integer
+ else
+ {
+ istringstream is(s);
+ is >> res;
+ if(!is || !is.eof())
+ res = 0;
+ }
+
+ return res;
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void InsertQuotesToFilePath(string& s)
+{
+ // example C:\Program Files\do something.exe -> C:\"Program Files"\"do something.exe"
+
+ bool firstBacklashFound = false;
+ bool anyQuoteInserted = false;
+
+ if (!s.empty())
+ {
+ int s_length = s.length();
+
+ for (int i=0; i<s_length; i++)
+ {
+ string::size_type pos = s.find(DIR_SEPARATOR, i);
+
+ if (pos != string::npos)
+ {
+ if (!firstBacklashFound)
+ {
+ // replace \ -> \"
+ s.insert(pos+1, "\"");
+
+ anyQuoteInserted = true;
+ firstBacklashFound = true;
+ s_length++;
+ i = pos+1;
+ }
+ else
+ {
+ // replace \ -> "\"
+ s.insert(pos, "\"");
+ s.insert(pos+2, "\"");
+
+ anyQuoteInserted = true;
+ s_length += 2;
+ i = pos+2;
+ }
+ }
+
+ if (i>255)
+ return; // something went wrong..
+ }
+
+ // append extra quote to the end if needed
+ if (anyQuoteInserted)
+ s.insert(s.length(), "\"");
+ }
+}
+
+// ----------------------------------------------------------------------------------------------------------
+
+void ShowProgressInfo(unsigned int& current_progress_percentage, unsigned int& current_progress, unsigned int& max_progress, bool print_initial_value)
+{
+ if (print_initial_value)
+ {
+ cerr << "( 0% complete)";
+ }
+ else
+ {
+ current_progress++;
+
+ unsigned int temp_percentage = int( (double) current_progress / (double) max_progress * 100 );
+
+ if (temp_percentage > current_progress_percentage)
+ {
+ current_progress_percentage = temp_percentage;
+ cerr << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
+
+ if (current_progress_percentage < 10)
+ cerr << " ";
+ else if (current_progress_percentage < 100)
+ cerr << " ";
+ cerr << current_progress_percentage << "% complete)";
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/srcanamdw/appdep/src/building_instructions.txt Sat Jan 09 10:04:12 2010 +0530
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+
+
+AppDep building instructions
+============================
+
+Windows platform
+----------------
+
+1) Set up MinGW and MSYS compiling environments
+ - Download MinGW installer 5.0.2 (or newer) from http://www.mingw.org
+ - Install MinGW including GCC compiler with version number at least 3.4.2
+ - Download and install MSYS environment from http://www.mingw.org with
+ version number at least 1.0.11
+ - Set "bin"-directories of both MinGW and MSYS to your path environment, eg
+ SET PATH=C:\APPS\MinGW\bin;C:\APPS\MSYS\bin;%PATH%
+
+2) Download Boost v1.33.1 from http://www.boost.org or directly from
+ http://sourceforge.net/project/showfiles.php?group_id=7586. Install it to any
+ folder
+
+3) Modify "BOOSTHOME"-variable in a file "group/MakeFile" in AppDep installation to
+ point to the directory where you installed Boost.
+
+4) With command prompt, go to the same "group" directory and type "make".
+
+
+
+Any other platform
+------------------
+
+Set up GCC compiling environment as usually and follow steps 2-4 just like in the
+instructions for Windows platform.
+