Posts Tagged ‘unix to windows porting’

Debugging Fortran Programs Using IDB How To Debug Fortran Code Ifort Commands

how to debug fortran code using idb
debugging Fortran programs.

Compiling your Fortran program for debugging

To prepare your program for debugging when using the command line (ifort command):
In a command window, (such as the Fortran command window available from the Intel Fortran program folder), compile and link the program with full debug information and no optimization:

      ifort -g file.f90 (Linux OS and Mac OS X)

      ifort /debug:full file.f90 (Windows OS)

On Windows OS, specify the /debug:full compiler option to produce full debugging information. It produces symbol table information needed for full symbolic debugging of unoptimized code and global symbol information needed for linking.
How to use Intel idb as debugger.
IDB comes with good help information
eg, (idb) help run
Run the debugger program.

Usage:

    run   (arguments) (redirections)

Arguments:

     Run the program with the specified arguments.

                Run the program with the specified input and output
                redirections.

If no arguments and redirections are specified, program is run with arguments
and redirections specified by previous “run” command with arguments or by “set
args” command.

Synonyms: “r”.
To run the exe in debug mode from command line, use devenv with debugexe option.. read more for How To Run .exe In Debug Mode Microsoft Visual Studio.

Eg. > devenv /DebugExe r280test01.exe

After windows debugger starts Hit F10 key to start debugging.
Check out How to use dbx as debugger for fortan debugging here.
Check out Debugging Fortran programs with gdb here
Intel® Debugger (IDB) Manual

Number of View :5400

Tags: , , ,

1 Comment


How To Run .exe In Debug Mode Microsoft Visual Studio 2008

How to run .exe in debug mode microsoft visual studio 2008?
Here are few solutions I got for Running .exe in debug mode using the Windows debugger.

Using Devenv

Devenv allows you to set various options for the integrated development environment (IDE);

/DebugExe

Loads a Visual C++ executable under the control of the debugger. This switch is not available for Visual Basic or Visual C# executable.

Example : if your win32 binary executable name is test.exe then, to run this win32 binary in debug mode use this command on windows command prompt.

C:\tmp>devenv /DebugExe test.exe

Your default debugger will start and loads this binary for debug mode. Then just hit F10 Key to go to main function. For Now on your debugging starts, ie to step into function use F11 key, you can put breakpoints and all debugging stuff.
I assume that you have compiled the binary test.exe with debug flag enabled, else debugger will not find the debug symbols and will not load the code.

Using Image File Execution Options

To setup an application to launch the debugger automatically.
How to: Launch the Debugger Automatically
the Image File Execution Options folder, locate the name of the application you want to debug, such as myapp.exe. If you cannot find the application you want to debug:

  1. right-click the Image File Execution Options folder, and on the shortcut menu, click New Key.
  2. Right-click the new key, and on the shortcut menu, click Rename.
  3. Edit the key name to the name of your application; myapp.exe, in this example.

read more
How to open a file, and go to a line number
devenv /edit E:\code.cpp /command “edit.goto 45”

In this example, devenv will open the code.cpp file, and go to line 45.

Number of View :4115

Tags: , ,

No Comments


How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler

Was getting Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler.
check out complete man pgcpp – The Portland Group Inc. C++ compiler

Building an application software using pgcc compiler, developed by C++ Language generates two external references of symbols [__curr_eh_stack_entry] and [__eh_curr_region], and results in kink error. Why?

How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler?

Answer:
Compiler automatically generates these symbols when -exception (C++ exception handling) and -rtti=on (Runtime type information) options are used. If these option is not required to use, Please do not enable them.
source

-rtti(default) –no_rtti An pgcc compiler option switch.
Enable (disable) support for RTTI (runtime type Information) features: dynamic_cast, typeid.

Number of View :2818

Tags: , , ,

No Comments


How To _access Function For Long File Names As Path In Winddows Programming Use UNC

I use the function _access to check for file/directory existence in my program,
Problem definition: I have noticed that the function can’t deal with long file names.  I wanted to check if file is available or not at path located “C:\Documents and Settings\0001”, did Google search on how to give long file names in windows..

How To _access Function For Long File Names As Path In Winddows Programming make Use of UNC standards

Solution use the UNC(Universal Naming Convention) conventions for path to be specified while working with windows programs.

ie the path should be “C:\\Documents and Settings\\0001”

Now The next problem is wanted to use period ie . in file name path,

Eg. I need to use the path as “C:\\Documents and Settings\\.test\\0001”
So tried with something like “\\.\” But The “\\.\” prefix will access the Win32 device namespace instead of the Win32 file namespace.

Then how to Turns off automatic expansion of the path string? Use  the “\\?\” prefix also allows the use of “..” and “.” in the path names. To specify an extended-length path, use the “\\?\” prefix. For example, “\\?\D:\<very long path>”.  Read more about Naming Files, Paths, and Namespaces

That did not help much, and tried directly with “C:\\Documents and Settings\\.test\\0001” It works.
you can also try the PathFileExists function

access function Return Value

Each function returns 0 if the file has the given mode. The function returns –1 if the named file does not exist or is not accessible in the given mode;

Do share your questions and views..

Number of View :1748

Tags: , , ,

No Comments


How To Debug Err This Application Has Failed To Start Because MSVCR90.dll Was Not Found

Debugging for MSVCR90.DLL was not found error

This application has failed to start because MSVCR90.dll was not found. Re-installing the application may fix this problem.

why is it looking for MSVCR90.DLL while running debug? Shouldn’t it be looking for MSVCR90D.DLL?
While I did not compile it in debug mode.

A quick look using Dependency Walker
And doing windows dog sniffing got the location of msvcr90.dll location, at

C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\dll\x86

If your application linking to both MSVCR90D.DLL and MSVCR90.DLL, then solution is simple, you need to ignore MSVCR90 (and if necessary, MSVCRT) when linking.
Now getting coredll.dll error, since msvcd90.dll links to this dll..
Well What is coredll.dll? I can’t find this dll on my PC and Windows CE device too. coredll.dll is roughly equivalent to kernel32.dll on a PC,
then its asking for mmvcr70.dll and mmvcp70.dll ;

Got downloaded all these dll from this site.
You may also use “dumpbin /imports” to debug dll in windows imports API list and find the category for any dll.

Number of View :2510

Tags: , ,

No Comments


Fork Implementation In Windows Operating System Vfork Implement in Win32

With little understanding of fork basics here are few more findings on how to vfork implementation in windows operating system and
fork implementation on win32
AT&T Labs Research – Software Tools pick out UWIN: Unix on Windows 95 and NT Machines
Major difference in Linux/Unix functionality and WIN32 applications
Process control and management:
Fork implementation
processes can be created using the fork(2) function, in win32 includes a spawn family of functions that combines the functionality of fork/exec for efficiency.
File descriptor
Open files, pipes, sockets, fifos, and character and block special devices files have file descriptors associated with them. In windows it is called handle.
signals
Most of the unix/linux signals are absent in windows, like SIGALRM
SIGCHLD
SIGHUP
SIGINT
SIGKILL
SIGPIPE
SIGQUIT
SIGUSR1
SIGUSR2
these can be implemented using replacement methods like SIGALRM Time-out alarm can be implemented using SetTimer – WM_TIMER – CreateWaitableTimer
SIGCHLD Change in status of child can be implemented using WaitForSingleObject
Terminal interface for consoles, sockets, and serial lines

sockets based on WINSOCK:

File control locking:

Memory mapping and shared memory
mmap()

System V IPC
semaphore; Shmget can be implemented using CreateFileMaping or
OpenFileMapping
shmdt can be implemented using UnmapViewOfFile
shmat can be implemented using MapViewOfFile
Pipe to _pipe
Close to _close

Runtime linking of dynamically linked libraries : like The dlopen(), dlsym() interface
Error mapping from Windows to UNIX

Symbolic links
Symbolic links to files and directories can be created and can be implemented as Windows shortcuts.

Few Good References for Unix2Win porting

  1. Porting Socket Applications to Winsock
  2. Process and Thread Functions
  3. Winsock Programmer’s FAQ Articles: BSD Sockets Compatibility
  4. LibGW32C for GNU C library for Windows
  5. Unix to Windows Porting Dictionary for HPC
  6. UNIX Application Migration Guide
Number of View :2485

Tags: , ,

No Comments


Solution – C Requires That a Struct Or Union Has At Least One Member

Windows errors are strange,
I have one header file in which one structure is declared,
as

typedef struct {
key_t xyz;
——
}INFO;

For this When I compile using cl.exe I get following list of errors.

: error C2016: C requires that a struct or union has at least one member
: error C2061: syntax error : identifier 'key_t'
: error C2059: syntax error : '}'

Well I am doing Code migration from Unix system to Windows system so key_t is not known in windows.

It does not make sense for the

Compiler Error C2016

which says no closing single quotation mark. Scratching my head and going around with the error.
I do not see any mistake in struct declaration,
Solution – C requires that a struct or union has at least one member
Just add the declaration of key_t in same header file before structure declaration.

typedef int key_t;

And compile again you are done.

Number of View :3699

Tags: , , , ,

No Comments



SetPageWidth
Content Protected Using Blog Protector By: PcDrome.

Mahol Dot Org is Stephen Fry proof thanks to caching by WP Super Cache