The document provides an overview of MSIL (Microsoft Intermediate Language):
- MSIL is a CPU-independent bytecode that is generated by .NET compilers instead of native code. It targets the CLR for execution.
- The article explains MSIL's stack-based approach, data types, instruction types, and how instructions are executed. It also demonstrates simple MSIL code examples from C# code.
- The Ildasm tool can be used to examine the MSIL code generated from C# programs, and help debug issues by viewing the low-level operations.
How to capture a variable in C# and not to shoot yourself in the footSofia Fateeva
Back in 2005, with the release of C# 2.0 standard we got a possibility to pass a variable to the body of an anonymous delegate by capturing it from the current context. In 2008 the C# 3.0 brought us lambdas, user anonymous classes, LINQ requests and much more. Now it January, 2017 and the majority of C# developers are looking forward to the release of the C# 7.0 standard that should provide us a bunch of new useful features. However, there are still old features that need to be fixed. That's why there are plenty of ways to shoot yourself in the foot. Today we are going to speak about one of them, and it is related with quite an unobvious mechanism of variable capture in the body of anonymous functions in C#.
A Collection of Examples of 64-bit Errors in Real ProgramsPVS-Studio
This article is the most complete collection of examples of 64-bit errors in the C and C++ languages. The article is intended for Windows-application developers who use Visual C++, however, it will be useful for other programmers as well.
Before the 30th of May 2012 attackers were exploiting a new Microsoft Internet explorer 0day... See more at source page: https://www.htbridge.com/publications/cve_2012_1889_microsoft_xml_core_services_uninitialized_memory_vulnerability.html
ESET’s guide to deobfuscating and devirtualizing FinFisherESET Middle East
To help malware analysts and security researchers overcome FinFisher’s advanced anti-disassembly obfuscation and virtualization features, ESET researchers have framed some clever tricks into a whitepaper.
How to capture a variable in C# and not to shoot yourself in the footSofia Fateeva
Back in 2005, with the release of C# 2.0 standard we got a possibility to pass a variable to the body of an anonymous delegate by capturing it from the current context. In 2008 the C# 3.0 brought us lambdas, user anonymous classes, LINQ requests and much more. Now it January, 2017 and the majority of C# developers are looking forward to the release of the C# 7.0 standard that should provide us a bunch of new useful features. However, there are still old features that need to be fixed. That's why there are plenty of ways to shoot yourself in the foot. Today we are going to speak about one of them, and it is related with quite an unobvious mechanism of variable capture in the body of anonymous functions in C#.
A Collection of Examples of 64-bit Errors in Real ProgramsPVS-Studio
This article is the most complete collection of examples of 64-bit errors in the C and C++ languages. The article is intended for Windows-application developers who use Visual C++, however, it will be useful for other programmers as well.
Before the 30th of May 2012 attackers were exploiting a new Microsoft Internet explorer 0day... See more at source page: https://www.htbridge.com/publications/cve_2012_1889_microsoft_xml_core_services_uninitialized_memory_vulnerability.html
ESET’s guide to deobfuscating and devirtualizing FinFisherESET Middle East
To help malware analysts and security researchers overcome FinFisher’s advanced anti-disassembly obfuscation and virtualization features, ESET researchers have framed some clever tricks into a whitepaper.
The article is a report about testing of portability of Loki library with 64-bit systems with the help of Viva64 code analyzer performed by OOO "Program Verification Systems" Company. It contains recommendations for users of the library. The article will be also useful for the users of other libraries built on templates for it describes the peculiarities of analysis of such libraries.
Bangalore Container Conference 2017 (BCC '17) is the first conference on container technologies in India. Organizations are increasingly adopting containers and related technologies in production. Hence, the main focus of this conference is “Containers in Production”. This one-day conference sets the perfect stage for container enthusiasts, developers, users and experts to meet together and learn from each others experiences.
Presented in Bangalore Open Java User Group on 21st Jan 2017
Awareness of design smells - Design comes before code. A care at design level can solve lot of problems.
Indicators of common design problems - helps developers or software engineers understand mistakes made while designing and apply design principles for creating high-quality designs. This presentation provides insights gained from performing refactoring in real-world projects to improve refactoring and reduce the time and costs of managing software projects. The talk also presents insightful anecdotes and case studies drawn from the trenches of real-world projects. By attending this talk, you will know pragmatic techniques for refactoring design smells to manage technical debt and to create and maintain high-quality software in practice. All the examples in this talk are in Java.
Bangalore Container Conference 2017 (BCC '17) is the first conference on container technologies in India happening on 07th April. Organizations are increasingly adopting containers and related technologies in production.Hence, the main focus of this conference is “Containers in Production”. This one-day conference sets the perfect stage for container enthusiasts, developers, users and experts to meet together and learn from each others experiences.
Consequences of using the Copy-Paste method in C++ programming and how to dea...Andrey Karpov
I create the PVS-Studio analyzer detecting errors in source code of C/C++/C++0x software. So I have to review a large amount of source code of various applications where we detected suspicious code fragments with the help of PVS-Studio. I have collected a lot of examples demonstrating that an error occurred because of copying and modifying a code fragment. Of course, it has been known for a long time that using Copy-Paste in programming is a bad thing. But let's try to investigate this problem closely instead of limiting ourselves to just saying "do not copy the code".
In February 2014, the Argentinian studio OKAM made public the source code of their multi-platform game engine Godot Engine and not so long ago, version 1.0 was released. As you have already guessed, in this article we will talk about the analysis of this project's source code and its results. Analysis was done with the PVS-Studio static code analyzer. Besides the introductory purpose, this article also pursues some practical aims: the readers can learn something new while the project developers can fix errors and bottlenecks. But first things first.
How to capture a variable in C# and not to shoot yourself in the footPVS-Studio
Back in 2005, with the release of C# 2.0 standard we got a possibility to pass a variable to the body of an anonymous delegate by capturing it from the current context. In 2008 the C# 3.0 brought us lambdas, user anonymous classes, LINQ requests and much more. Now it January, 2017 and the majority of C# developers are looking forward to the release of the C# 7.0 standard that should provide us a bunch of new useful features. However, there are still old features that need to be fixed. That's why there are plenty of ways to shoot yourself in the foot. Today we are going to speak about one of them, and it is related with quite an unobvious mechanism of variable capture in the body of anonymous functions in C#.
The article is a report about testing of portability of Loki library with 64-bit systems with the help of Viva64 code analyzer performed by OOO "Program Verification Systems" Company. It contains recommendations for users of the library. The article will be also useful for the users of other libraries built on templates for it describes the peculiarities of analysis of such libraries.
Bangalore Container Conference 2017 (BCC '17) is the first conference on container technologies in India. Organizations are increasingly adopting containers and related technologies in production. Hence, the main focus of this conference is “Containers in Production”. This one-day conference sets the perfect stage for container enthusiasts, developers, users and experts to meet together and learn from each others experiences.
Presented in Bangalore Open Java User Group on 21st Jan 2017
Awareness of design smells - Design comes before code. A care at design level can solve lot of problems.
Indicators of common design problems - helps developers or software engineers understand mistakes made while designing and apply design principles for creating high-quality designs. This presentation provides insights gained from performing refactoring in real-world projects to improve refactoring and reduce the time and costs of managing software projects. The talk also presents insightful anecdotes and case studies drawn from the trenches of real-world projects. By attending this talk, you will know pragmatic techniques for refactoring design smells to manage technical debt and to create and maintain high-quality software in practice. All the examples in this talk are in Java.
Bangalore Container Conference 2017 (BCC '17) is the first conference on container technologies in India happening on 07th April. Organizations are increasingly adopting containers and related technologies in production.Hence, the main focus of this conference is “Containers in Production”. This one-day conference sets the perfect stage for container enthusiasts, developers, users and experts to meet together and learn from each others experiences.
Consequences of using the Copy-Paste method in C++ programming and how to dea...Andrey Karpov
I create the PVS-Studio analyzer detecting errors in source code of C/C++/C++0x software. So I have to review a large amount of source code of various applications where we detected suspicious code fragments with the help of PVS-Studio. I have collected a lot of examples demonstrating that an error occurred because of copying and modifying a code fragment. Of course, it has been known for a long time that using Copy-Paste in programming is a bad thing. But let's try to investigate this problem closely instead of limiting ourselves to just saying "do not copy the code".
In February 2014, the Argentinian studio OKAM made public the source code of their multi-platform game engine Godot Engine and not so long ago, version 1.0 was released. As you have already guessed, in this article we will talk about the analysis of this project's source code and its results. Analysis was done with the PVS-Studio static code analyzer. Besides the introductory purpose, this article also pursues some practical aims: the readers can learn something new while the project developers can fix errors and bottlenecks. But first things first.
How to capture a variable in C# and not to shoot yourself in the footPVS-Studio
Back in 2005, with the release of C# 2.0 standard we got a possibility to pass a variable to the body of an anonymous delegate by capturing it from the current context. In 2008 the C# 3.0 brought us lambdas, user anonymous classes, LINQ requests and much more. Now it January, 2017 and the majority of C# developers are looking forward to the release of the C# 7.0 standard that should provide us a bunch of new useful features. However, there are still old features that need to be fixed. That's why there are plenty of ways to shoot yourself in the foot. Today we are going to speak about one of them, and it is related with quite an unobvious mechanism of variable capture in the body of anonymous functions in C#.
We are regularly asked to check various open-source projects with the PVS-Studio analyzer. If you want to offer some project for us to analyze too, please follow this link. Another project we have checked is Dolphin-emu.
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardGaurav Verma
This programming manual is providing the complete details of programming the STM32 Value-line discovery (a low-cost) evaluation board for Value-line of STM32 microcontrollers from STMicroelectronics.
SFO15-500: VIXL
Speaker: Amaury Le Leyzour
Date: September 25, 2015
★ Session Description ★
VIXL is dynamic code generation toolkit for ARMv8 that we hope will enable JIT creators to rapidly target the ARM instruction set.
Over the past few years we (the ARM JIT team) have worked on the code generators of many of the leading JIT compilers for the JavaScript and Java languages. During that time we built up a strong knowledge base on some of the pitfalls and time-sinks involved in creating a good JIT compiler backend. This led us to develop some tools to help improve our productivity. With ARM announcing the new Cortex-A range of processors supporting the AArch64 execution state we decided that we would focus our efforts on A64 tooling to enable developers to rapidly port programming language virtual machines for this new processor range. Soon after we decided to support Aarch32 as well.
This presentation will introduce you to what VIXL is, what’s new in VIXL and how to use it and take advantage of all its components that cover all the aspects of software development on ARM CPUs.
★ Resources ★
Video: https://www.youtube.com/watch?v=XxMTSO4clQY
Etherpad: pad.linaro.org/p/sfo15-500
Pathable: https://sfo15.pathable.com/meetings/303091
★ Event Details ★
Linaro Connect San Francisco 2015 - #SFO15
September 21-25, 2015
Hyatt Regency Hotel
http://www.linaro.org
http://connect.linaro.org
Zero, one, two, Freddy's coming for youAndrey Karpov
This post continues the series of articles, which can well be called "horrors for developers". This time it will also touch upon a typical pattern of typos related to the usage of numbers 0, 1, 2. The language you're writing in doesn't really matter: it can be C, C++, C#, or Java. If you're using constants 0, 1, 2 or variables' names contain these numbers, most likely, Freddy will come to visit you at night. Go on, read and don't say we didn't warn you.
How to make fewer errors at the stage of code writing. Part N1.PVS-Studio
I've arrived at the source code of a widely know instant messenger Miranda IM. Together with various plugins, this is a rather large project whose size is about 950 thousand code lines in C and C++. And like any other considerable project with a long development history, it has rather many errors and misprints.
How to make fewer errors at the stage of code writing. Part N1Andrey Karpov
I've arrived at the source code of a widely know instant messenger Miranda IM. Together with various plugins, this is a rather large project whose size is about 950 thousand code lines in C and C++. And like any other considerable project with a long development history, it has rather many errors and misprints.
A Collection of Examples of 64-bit Errors in Real ProgramsAndrey Karpov
This article is the most complete collection of examples of 64-bit errors in the C and C++ languages. The article is intended for Windows-application developers who use Visual C++, however, it will be useful for other programmers as well.
Almost everything can be done using refactoring tools:
* How to get buy-in for refactoring? (use Technical Debt quantification tools)
* How to identify refactoring candidates? (use smell detection tools)
* How to prioritize / identify what to refactor first? (use reports from design analysis tools)
* How do I identify dependencies and evaluate impact of refactoring? (use visulization tools)
* How to I actually perform refactoring? (Use IDE support for automated refactoring and use them!)
Deriving from a rich experience in using tools for refactoring in real-world projects, this talk takes you through a whirl-wind tour of refactoring tools (of course for Java). What's more, this talk includes quick demos of some of these tools so you can see them in action.
Presented in BoJUG meetup on 19th Jan in Bangalore - https://www.meetup.com/BangaloreOpenJUG/events/257183518/
Please check out the workshop "AI meets Blockchain" at HIPC 2018, in Bangalore: http://hipc.org/ai-blockchain/
HIPC is a premier conference and hence getting a paper accepted in HIPC workshop would be quite an accomplishment for any blockchain/AI enthusiast. Check out the details in this poster on submissions.
I have been fortunate to have worked with some geeks with incredible coding skills. I felt amazed at how they can play games with compilers, perform magic with their incantations on the shell, and solve some insanely complex algorithm problems with ease. I naively assumed that they are going to achieve greatness in near future. Alas, I was wrong. Really wrong. [Read the rest of the article ... ]
Many students reach out to me asking for project ideas they can do as a summer project for learning. Here is an interesting project idea - implement your own java disassembler (and expand it to a VM later).
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
This presentation takes a case-study based approach to design patterns. A purposefully simplified example of expression trees is used to explain how different design patterns can be used in practice. Examples are in C#, but is relevant for anyone who is from object oriented background.
This presentation provides an overview of recently concluded Bangalore Container Conference (07-April-2017). See www.containerconf.in for more details.
This presentation covers quiz questions prepared for the Core Java meetup on 1st October in Accion Labs. It has questions from "Java best practices", "bytecodes", and "elastic search".
This presentation is on advanced debugging using Java bytecodes (presented in Core Java meetup on 1st October in Accion Labs). If you are a Java developer and are interested in knowing advanced debugging techniques or understanding bytecodes, this presentation is for you.
Refactoring for Software Architecture Smells - International Workshop on Refa...Ganesh Samarthyam
Code smells and refactoring have received considerable interest from the academia as well as from the industry in the past two decades. The interest has given birth to various tools, processes, techniques, and practices to identify smells and refactor them. Despite the high interest, architecture smells and corresponding refactorings haven't received as much focus and adoption from the software engineering community. In this presentation, we motivate the need of architecture refactoring, discuss the current related research, and present a few potential research directions for architecture refactoring.
Refactoring for Software Architecture Smells - International Workshop on Refa...Ganesh Samarthyam
Code smells and refactoring have received considerable interest from the academia as well as from the industry in
the past two decades. The interest has given birth to var-
ious tools, processes, techniques, and practices to identify
smells and refactor them. Despite the high interest, architecture smells and corresponding refactorings haven't received
as much focus and adoption from the software engineering
community. In this paper, we motivate the need of architecture refactoring, discuss the current related research, and
present a few potential research directions for architecture
refactoring.
For more information, visit www.designsmells.com or http://www.softrefactoring.com/
Refactoring for Software Design Smells - XP Conference - August 20th 2016Ganesh Samarthyam
Awareness of design smells - indicators of common design problems - helps developers or software engineers understand mistakes made while designing and apply design principles for creating high-quality designs. This talk provides insights gained from performing refactoring in real-world projects to improve refactoring and reduce the time and costs of managing software projects. The talk also presents insightful anecdotes and case studies drawn from the trenches of real-world projects. Bonus: A comprehensive listing of smell detection tools and refactoring tools (40!). Contents overview: * Why care about design principles, design quality, or design smells? * Refactoring as the primary means for repaying technical debt * Smells that violate abstraction, encapsulation, modularisation, or hierarchy * Tools and techniques for refactoring
Presented in XP Conf 2016: http://xpconference.in/2016/schedule/
Writing an Abstract - Template (for research papers) Ganesh Samarthyam
Recently I presented to software developers / techies on writing papers and abstract in an IT company. I though this might be useful for other techies & geeks so making it publicly available.
Here is the supporting template document I created for the workshop. Presentation is available here: http://www.slideshare.net/sgganesh/how-to-write-abstracts-for-white-papers-research-papers
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
1. An Overview of MSIL
The .NET architecture addresses an important need - language interoperability. Instead of generating
native code that is specific to one platform, programming languages can generate code in MSIL
(Microsoft Intermediate Language) targeting the Common Language Runtime (CLR) to reap the rich
benefits provided by .NET.
Advanced programmers occasionally peek into MSIL code when they are in doubt of what is
happening under the hood (using the Ildasm tool). Therefore, it is essential that the C# programmer
understands the basics of MSIL. This beginner-level article gives an overview of MSIL and debugging
with the Ildasm tool.
System Requirements
The programming examples in this article use C# as the source language for generating MSIL code,
and so the reader is expected to have some basic understanding of C#. No prior exposure to MSIL is
necessary. In addition, the reader is assumed to know what a stack data structure is. It is preferable that
the reader has access to the Ildasm tool and the C# compiler.
Article Structure
The article has three main sections:
● An Overview of MSIL: The basics of MSIL, the data types, instruction types, and the way that
the instructions are executed are explained.
● Examining MSIL: This section covers MSIL using simple example programs.
● Debugging Using the Ildasm tool: Explains the use of the intermediate language disassembler
(Ildasm) and the way it can be used for debugging.
.NET supports several high-level languages such as C#, VB.NET and Managed C++.NET. The MSIL is
designed to accommodate a wide range of languages. In .NET, the unit of deployment is the PE
(Portable Executable) file - a predefined binary standard (similar to the class files of Java). MSIL,
along with metadata, is stored inside the PE files generated by the compiler. MSIL is such a simple
language that it doesn't require much effort to understand. Metadata describes the types - its definition,
signature, etc - that are useful at runtime.
An Overview of MSIL
MSIL is a CPU independent, stack-based instruction set that can be efficiently converted to the native
code of a specific platform. In this stack-based approach, the representation assumes the presence of a
run-time stack and the code is generated keeping the stack in mind. The runtime environment may use
the stack for evaluation of expressions, and store the intermediate values in the stack itself. Such an
evaluation using a runtime stack is a form of interpretation. In practice, the MSIL is not interpreted -
there is a Just-In-Time (JIT) compiler that translates the intermediate code to native code to execute in
a particular platform at runtime. The stack-based code facilitates maximum portability across the
platforms and is easy to verify.
The MSIL:
2. ● Supports object oriented programming.
● Works in terms of the data types available in the .NET Framework, for example, System.String
and System.Int32.
● Instructions can be classified into various types such as: loading (ld*), storing (st*), method
invocation, arithmetic operations, logical operations, control flow, memory allocation, and
exception handling. The following section covers basic instructions using examples.
Examining MSIL
Let us start with the following simple C# code, and see how it is compiled to intermediate code.
Console.WriteLine(quot;hello worldquot;);
The MSIL code looks like this (using the Ildasm tool that is discussed later).
// disassembled code using ildasm tool
ldstr quot;hello worldquot;
call void [mscorlib]System.Console::WriteLine(string)
Now let us examine how it works:
The ldstr (standing for 'load string') instruction indicates that the string constant quot;hello worldquot; be
pushed onto the evaluation stack.
● The call instruction is for calling a method. Here, the call is made for the static WriteLine
method of the Console class that is available in mscorlib.dll, in the System namespace. The
WriteLine method takes a string as the argument and its return type is void.
It executes as follows:
● The ldstr instruction pushes the reference to the constant quot;hello worldquot; into the stack.
● The call method calls the WriteLine method, which looks for a string argument, and pops it
from the stack. Now the stack contains nothing. The WriteLine method now executes to print
the message quot; hello world quot; on the screen and returns.
As you can see, understanding the MSIL code is far from difficult! If you have prior exposure to any
assembly language, it will be very easy for you to learn MSIL.
From this simple program, let us move on to a program illustrating branching and arithmetic
instructions.
// C# source code
int i = 10;
if(i!=20)
i = i*20;
Console.WriteLine(i);
// disassembled MSIL code using ildasm tool
IL_0000: ldc.i4.s 10
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: ldc.i4.s 20
IL_0006: beq.s IL_000d
IL_0008: ldloc.0
IL_0009: ldc.i4.s 20
IL_000b: mul
IL_000c: stloc.0
IL_000d: ldloc.0
3. IL_000e: call void [mscorlib]System.Console::WriteLine(int32)
You can see that lots of MSIL code has been generated for this simple C# code, but it is simple once
you understand what the instructions do. You can see that the instructions are preceded by IL_xxxx: -
these are labels used so that it is possible to 'jump' from one part of the code to another.
The ldc.i4.s (stands for 'load constant'.'four byte integer'.'single byte argument') instruction pushes the
integer constant 10 onto the stack.
The stloc.0 (stands for 'store in location'.'zeroeth variable') instruction pops the integer constant 10 from
the stack and stores it in the variable number 0 (local variables are remembered by counting them from
0).
The ldloc.0 (stands for 'load from location'.'zeroeth variable') instruction loads the value of the variable
from location zero (i.e. variable i in the source code) and push it onto the stack.
The ldc.i4.s instruction pushes the integer constant 20 onto the stack.
The beq.s (stands for 'branch if equal to'.' single byte argument') instruction pops two items from the
stack and checks if they are equal and if so, it transfers the control to the instruction at the location
identified by the label IL_000d.
The ldloc.0 instruction pushes the value of variable i onto the stack.
The ldc.i4.s instruction pushes the integer constant 0 onto the stack.
The mul (stands for 'multiply') instruction pops two items from the stack, multiplies the values, and
pushes the result back to the stack. Now the result of the multiplication is at the top of the stack.
The stloc.0 instruction pops the top value from the stack (the result of the multiplication in this case)
and stores it in variable i.
The ldloc.0 instruction pushes the value of i onto the stack
The call (stands for 'call the method') instruction calls the WriteLine method that takes an integer as an
argument. The WriteLine method pops the value from the stack and displays it on the screen.
Debugging Using ILDASM Tool
Microsoft's .NET SDK is shipped with an IL disassembler, Ildasm.exe (usually located in the
directory Program FilesMicrosoft.NetFrameworkSDKBin). A disassembler loads your assemblies
and shows the MSIL code with other details in the assembly.
This tool can be handy in debugging code once you become proficient at understanding MSIL code.
How can MSIL help in debugging?
Bugs happen in code when there is a mismatch between what we expect the code to do and what the
code actually does. If we can dig down to a lower level and see what the machine is actually doing with
our code, it is easier to spot the mismatch. That is the idea behind using ILDASM for debugging. Let us
look at an example and see how we can debug the code. The following innocent looking code doesn't
work as you'd expect. It doesn't print quot; yes, o1 == o2 quot; as we'd expect, even though the code is
straightforward.
int i = 10;
object o1 = i, o2 = i;
if(o1 == o2)
Console.WriteLine(quot;yes, o1 == o2quot;);
4. Now let us dig a little deeper and see what the machine is actually doing by looking at the MSIL code
generated by the Ildasm tool:
IL_0000: ldc.i4.s 10
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: box [mscorlib]System.Int32
IL_0009: stloc.1
IL_000a: ldloc.0
IL_000b: box [mscorlib]System.Int32
IL_0010: stloc.2
IL_0011: ldloc.1
IL_0012: ldloc.2
IL_0013: bne.un.s IL_001f
IL_0015: ldstr quot;yes, o1 == o2quot;
IL_001a: call void [mscorlib]System.Console::WriteLine(string)
IL_001f: ret
There lies the clue. Can you see that the boxing operation from int to object type is taking place twice?
As the value type is converted to a reference type, the object is allocated on the heap. Since boxing is
done twice, the two objects o1 and o2 are allocated in two different places on the heap. We have found
where things went wrong, and this means we can make a simple correction to our code:
int i = 10;
object o1 = i, o2 = o1;
if(o1 == o2)
Console.WriteLine(quot;yes, o1 == o2quot;);
Now when we look at the resulting MSIL code (again disassembling using the Ildasm tool), the boxing
is done only once, and both the references are pointing to the same object now. So, the program now
works as expected.
IL_0000: ldc.i4.s 10
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: box [mscorlib]System.Int32
IL_0009: stloc.1
IL_000a: ldloc.1
IL_000b: stloc.2
IL_000c: ldloc.1
IL_000d: ldloc.2
IL_000e: bne.un.s IL_001a
IL_0010: ldstr quot;yes, o1 == o2quot;
IL_0015: call void [mscorlib]System.Console::WriteLine(string)
IL_001a: ret
The example shown here is simple, but it shows how the tool can be employed effectively for
debugging code.
Article Review
In this article we have explained the basics of MSIL, and using this knowledge, looked into how the
Ildasm tool can be used to help debug your code. This is only a beginner-level article, and so interested
readers are encouraged to look further into MSIL and the Ildasm tool.
All rights reserved. Copyright Jan 2004.