GDB commands for WinDbg users

Most of the debugging I’ve done has been on Windows using WinDbg (or kd, cdb, ntsd). Now I’m doing some GDB debugging on Linux, so I’m trying overcome my muscle memory of typing WinDbg commands. I’m sharing my table for translating WinDbg commands to GDB.

Action WinDbg GDB
Set breakpoint bp [addr]
bp [name]
b[reak] *[addr]
b[reak] [name]
List breakpoints bl i[nfo] b[reakpoints]
Enable breakpoint be [n] en[able] [n]
Disable breakpoint bd [n] dis[able] [n]
Clear one breakpoint bc [n] d[elete] [n]
Clear all breakpoints bc * d[elete]
Disassemble u
u [addr]
disas[semble] /r
disas[semble] /r [addr]
Run g
g [addr]
r[un]
sta[rt]
Continue g
gc
c[ontinue]
Restart .restart r[un]
Trace (into calls) t s[tep]
Step (over calls) p n[ext]
Trace (into calls)
by machine instruction
t s[tep]i
Step (over calls)
by machine instruction
p n[ext]i
Toggle source mode
for stepping
l+t
l-t
n/a - See above.
(use si and ni
)
List modules lm i[nfo] sh[aredlibrary]
View registers r
r [name]
i[nfo] r
i[nfo] r [name]
View call stack k[b|v|p] i s[tack]
bt f[ull]
View threads ~ i[nfo] th[reads]
Switch thread ~[n]s thr[ead] [n]
View all thread stacks ~*k thread apply all bt
Switch frame .frame [n] f[rame] [n]
View memory (8 bytes) dq [addr] L[n] x/[n]xg [addr]
View memory (4 bytes) dd [addr] L[n] x/[n]xw [addr]
View memory (2 bytes) dw [addr] L[n] x/[n]xh [addr]
View memory (1 byte) db [addr] L[n] x/[n]xb [addr]
View memory (ascii) da [addr] L[n] p[rint] (char*)[addr]
x/s [addr]
x/20c [addr]
View memory (stacked) dds [addr] L[n] x/xw [addr]
repeat Enter key
View local variables dv /v
x
i[nfo] lo[cals]
print [var_name]
x &[var_name]
View global variables x [mod]!* i[nfo] va[riables]
info address [g_name]
print [g_name]
x &[g_name]
View frame args x
kP L1
i[nfo] ar[gs]
View type dt [type] explore [type]
Break on syscall catch syscall [i]
catch syscall [name]
Set register r [name]=[value] set $[name]=[value]
Evaluate ? [expr]
e.g. ? rax+5
p [expr]
e.g. p $r11+5
Quit q q

Notes:

  • GDB: Prefix breakpoint memory addresses with *
  • GDB: “set disassembly-flavor intel” for disassembly more like WinDbg
  • GDB: “start” runs to the entry point (if named “main”)
  • In the View memory commands, “n” represents the number of values
  • For viewing local variables, be sure to compile with symbolic information:
      • gcc -g
      • cl /Zi

     

Advertisements

The Desktop Heap Guy

When I worked at Microsoft as an Escalation Engineer, I spent my days analyzing various failures in Windows. My team was called CPR, Critical Problem Resolution, and we were there to debug issues discovered in Windows by Microsoft’s customers. These problems came to my team because they were either “critical situations” for a business customer, or because the issue was particularly technically challenging.

In this role I worked on all kinds of weird failures, but one type of issue became a regular thing for me: desktop heap failures. I didn’t set out to be an expert on desktop heap, but when a more senior engineer on my team decided that someone else needed to understand desktop heap, I was asked to become the subject matter expert.

I started investigating every customer case that looked like the root cause might be a desktop heap failure. The symptoms were usually one of two things:

1. Processes would fail to start altogether.
2. An application would run but certain windows would fail to display.

This was perplexing for users and developers alike. The underlying cause wasn’t obvious, and the same software that had previously worked without issue would suddenly start failing. There was already some limited documentation on this problem, including a KB article, but I needed more information if I was going to really understand the problem and help customers.

I quickly learned that only a handful of people at Microsoft actually knew anything about desktop heap! So I studied the Windows source code, reached out to some other engineers on the Windows team, and began to pull together an understanding of the problem. I continued to get involved with every reported desktop heap failure, and eventually I became the unofficial Desktop Heap Guy. Within Microsoft support, people had learned that there was this person who actually wanted to help with desktop heap issues! This of course led to me getting even more cases to investigate.

Eventually I decided that we really needed some documentation on desktop heap. This led to me writing series of blog posts, and recording a Channel 9 video. Even better, changes were made to the memory manager in Windows Vista and Windows Server 2008 that helped avoid the problem altogether, and the problem mostly became of thing of the past. Even so, for years after I left the Escalation Engineer role at Microsoft I would still get questions about desktop heap. Once the Desktop Heap Guy, always the Desktop Heap Guy, I guess!

explaining_desktop_heap
That’s me, explaining desktop heap in 2007

Luke Skywalker Needs a Wife

luke_wife_blog

Star Wars: The Last Jedi was beautifully filmed and full of surprises. I enjoyed the film, but it had some issues. There’s a lot I could say about it, but for now I want to talk about one character: Luke Skywalker. When we met Luke in the original trilogy, he was full of hope, willing to rush off to save his friends, and ready to confront evil on the slim chance that he could redeem his father. Luke didn’t give up easily. Who is this guy in The Last Jedi? Scared, in hiding, selfish. Sure, he arguably gets his act together by the end of the movie, but really, I’m disappointed in you, Luke.

While discussing this with my spouse, it became clear what went wrong with this version of Luke. He needs a wife! Specifically, he needs Mara Jade! Would Mara have allowed Luke to wallow in self-pity? No, she would have kicked him in the head and said “Get up farm boy; you are better than this!” Would Mara Jade have let Luke’s nephew to go dark without confronting him? No! She would have ambushed him in her StealthX starfighter and fought him in the tunnels of Kavan! OK, that’s a very specific reference and it didn’t end well, but you get the idea! Would Luke have been so self-centered if he had a wife? Of course not! Would Mara have allowed Luke to seemingly waste 30 years after the battle of Endor? No, she would have pushed him, challenged him, and made very sure he was able to continue the Jedi Order!

Life is so much better with an awesome wife. Poor Luke in The Last Jedi; if only he had a wife.

Why I’m leaving my job at Microsoft

My last day working at Microsoft will be December 1, 2017. I’m not taking another job right away. Instead, I’m blocking off time to pray, to invest in my family, to study, and to work on some projects. As I’ve shared this news in recent weeks, I sometimes get confused looks. “Why?” is the general question. “Why leave a perfectly good job with no other work lined up?” Great question! What follows is my answer.

I began working at Microsoft in the fall of 2000, a few months after finishing a degree in Electrical Engineering from the University of Tennessee. My first role was as a Support Engineer for Windows. I can easily remember how excited I was to get this job! Microsoft was the only software company I interviewed with; all the other companies I considered were hardware-focused, which was more aligned with my education. And yet… Microsoft… what an opportunity! This was a company that was changing the world, and I wanted to be a part of it.

Over the next 17 years my career at Microsoft as a software engineer took a variety of interesting turns. Some highlights: I debugged Windows and worked on hotfixes, helped develop “Fix it”, led a team of engineers who built diagnostic tools and services, and led an engineering team building services for Microsoft’s financial systems. Through all of this I found that not only is Microsoft a place to do incredible technical work, but perhaps more importantly the people at this company are amazing. They are intelligent, technical, collaborative, driven… these are my kind of people, and I’ve learned so much from them over the years.

Why would I want to leave a company like that? There are actually several reasons, but when distilled down it comes to one thing: I want to be intentional. Microsoft has been incredible, but I came to realize that I’ve allowed myself to be swept along in my career, taking each opportunity as it came, without stopping to consider where I’m going.

I’m choosing to be intentional in how I spend time with my family. My wife and children are the most important people in my life, and they deserve more of my time and attention than they have received in recent years. As I’ve taken on more responsibility at work I’ve found it increasingly difficult to maintain a healthy work / life balance (or just “life balance” as a leader I respect calls it). Right now, all four of my kids are at home, and I’ve come to realize just how precious, and limited, this time is. It won’t be long before my oldest kids are in college. If I wait until normal retirement age to take a career break, my kids will be grown. I’m choosing to spend time with them now, even if it means I have to work more years overall.

I’m choosing to be intentional in what work I do. Software engineering has been a good fit for me, but right now I’ve lost much of my passion for it. I still have a love of technology, but I’m no longer excited about the day to day details of my work. As a manager at Microsoft, I cannot lead effectively if I’m not genuinely excited and passionate about my team’s work. I have other interests and abilities outside of software, and I plan to use my time to study and grow those skills, and consider other career paths. Or perhaps doing so will lead me back to software engineering as my true calling, and I will be happy in the knowledge that I took the time to make a deliberate career choice.

I’m choosing to be intentional in how I seek after God. I’m a Christian, but too often I trust in my own abilities rather than in God. I make too many decisions just based on my own logic, and not on faith. As I leave my job and step out of the comfort of regular income and a clear plan for my career, my intent is to be more deliberate in the time I spend in prayer and study of the Bible, seeking God in how I may be involved with the work of his kingdom.

All of that said, I realize that leaving full-time employment is not a prerequisite for being intentional! However, as mentioned above, I need a change. While I could jump to another similar position at Microsoft or elsewhere, in doing so I would miss the opportunity to pause, fully consider what is next, invest in my family, and seek God.

I’m thankful that I had the chance to work at Microsoft; it truly is a great company full of exceptional people. I don’t take my decision to leave such an organization lightly, and I recognize that I am blessed to even have the option to take time off from regular work. I plan to make the most of the opportunity!

Reading Star Wars

sw_books

Since the release of The Force Awakens, I’ve had some people ask me about the Star Wars books: where should a new reader begin? Well, it depends. Which continuity are you interested in? If you aren’t familiar with Star Wars continuity, check out my earlier post, Star Wars Continuity Explained. If you want to read Disney’s new canon, then the number of books available to you is relatively small (at least as of May 2017).

On the other hand, if you want to read the Legends continuity, things are a bit more complicated. There are over 150 novels in Legends, and that isn’t including comic books, young adult fiction, etc. You could read through the books chronologically, starting with Dawn of the Jedi: Into the Void and ending with Crucible. I wouldn’t recommend it. That is a lot of books, and you are likely to get bogged down at some point.

A second option is to read the books in the order they were published. I would also advise against this, for similar reasons.

Instead, I’d recommend you start with the book that fundamentally shaped the Legends continuity, Timothy Zahn’s 1991 novel, Heir to the Empire. Don’t stop there – it is a trilogy! Once you have read Heir to the Empire, Dark Force Rising, and The Last Command, then you have many options to choose from. My recommendations and some brief commentary are below…

Disney Canon
This is for those who want to stick with the new canon. Read these in any order:

  • Thrawn – My favorite in the new canon so far, but then again I was already a fan of the character.
  • Lost Stars – This one is actually a YA novel, but is very good. It gives differing perspectives on the Galactic Civil War from two compelling characters.
  • Ahsoka – Another YA book, but if you are a fan of Clone Wars or Rebels, you’ll want to check this out.
  • Bloodline – A nice look into Leia’s life before The Force Awakens.
  • Tarkin – An interesting look into Tarkin’s background
  • Catalyst – A prequel to Rogue One… Read it, and watch Rogue One again!
  • Aftermath Trilogy – I’m honestly not a fan of this author’s writing, and the first book in particular I found disappointing. That said, the second and third books were intriguing and provide some hints at how things progress towards The Force Awakens.

Legends: New Republic
A reading list for those who want to stay in the timeframe and continuity of Heir to the Empire. This list is exactly what I read my daughters when they expressed an interest in Star Wars novels.

  1. Thrawn Trilogy (Heir to the Empire, Dark Force Rising, The Last Command) – start here; these are fantastic.
  2. Dark Empire Trilogy – Contains what is probably the most fan-contested plot point in Legends, but worth a read. This is the only comic book series I’m including in this post. There’s actually a ton of great Star Wars comics, but I’ll save that for another post. I’m including this one because it was an early influencer of the Legends continuity.
  3. The Jedi Academy Trilogy – Fans like to criticize the writing and stories of these books, but I enjoyed them as a youngster. They are fun and contain a lot of details that are referenced and built upon later.
  4. The Courtship of Princess Leia – Reading this is actually jumping back in (Star Wars) time, but this book is worth reading. It has some important universe-building concepts, and it is just fun, although the fundamental premise is a bit wacky.
  5. Hand of Thrawn Duology (Specter of the Past, Vision of the Future) – Honestly, these are my least favorite of Timothy Zahn’s Star Wars books, but they were still enjoyable. They continue the mythology of Thrawn, and establish some important aspects of Legends continuity.

Legends: The New Jedi Order
If you’ve completed the New Republic books, this is the next chronological series. Summary: a extra-galactic species that exists outside of the Force invades the Star Wars galaxy. It is a contentious story among fans: some fans hate the premise, but I personally love it, although the series was too long…19 books! As a bonus, read Rogue Planet, set between Episodes 1 and 2 as a prequel era tie-in. 20 books is a big commitment!

Legends: Legacy of the Force
If you make it through The New Jedi Order, this is the next chronological series. Summary: the galaxy is torn apart as… well, really anything more is a spoiler. I’m a fan of the core storyline here, although some of side stories I could do without – the Mandalorian story in particular didn’t hold my interest. There’s a lot of interpersonal strife here, which I think is good for character development, but it is a rough ride for the Skywalkers and Solos.

Legends: Fate of the Jedi
After Legacy of the Force, this is the next chronological series. Summary: a lost civilization of Sith come into contact with the larger galaxy, and an ancient powerful Force being emerges. This series starts off slowly, and has some odd aspects, but overall it was worth a read. I really enjoyed seeing an ancient Sith culture thrust into the Star Wars galaxy, and one character in particular was a great addition: Vestara Khai. Bonus: read Lost Tribe of the Sith (a short story collection) for some “historical” context.

Legends: Crucible
If you read all of Fate of the Jedi, wrap things up with Crucible. It is the last novel, Star Wars chronology-wise, in Legends.

Legends: X-Wing series
These are fan favorites, written by two authors. I personally prefer the books by Michael Stackpole, and I’ll admit not finishing this series after Aaron Allston took over the writing. These are set in the New Republic era, but they can be read independently of everything else.

Legends: Darth Bane Trilogy
This trilogy describes the beginnings of the Sith’s rule of two. Great characters, set very early in the timeline. Kind of dark, as you’d expect.

Legends: Various
Here are some recommendations that mostly can be read independently of everything else.

  • Darth Plagueis – Excellent book, includes Palpatine’s backstory
  • Cloak of Deception – Nice lead in to The Phantom Menace. Palpatine at his manipulative best (or worst?)
  • Survivor’s Quest – Mara and Luke investigate Outbound Flight. This is set several years after Vision of the Future, but before The New Jedi Order. Best when read after the New Republic books.
  • Outbound Flight – Great backstory on Outbound Flight, Jorus C’Baoth, and Thrawn. Ties in nicely with the new canon’s Thrawn. Best when read after the New Republic books and Survivor’s Quest.
  • Revenge of the Sith trilogy (Labyrinth of Evil, Revenge of the Sith, Dark Lord) – A book before and a book after Revenge of the Sith makes for a more complete and interesting story of the Empire’s and Vader’s beginnings.
  • Kenobi – One of my favorites. An awesome look at Kenobi on Tatooine.
  • Death Star – An inside look at the Death Star, before Catalyst and Rogue One gave us a new story.
  • Allegiance and Choices of One – A Zahn duology set between A New Hope and Empire. Cool to see Mara and Thrawn in a different time period.
  • Shadows of the Empire – Fills in the details of what happens between Empire and Jedi. This book was a big deal when it was released, with a comic book, toy line, soundtrack, and so forth.

I hope you find this post useful if you are a new Star Wars reader!

A Review of Star Wars: Thrawn

Last year when it was announced that Grand Admiral Thrawn would be appearing in season 3 of Star Wars Rebels, I was excited. When that announcement was followed with news of a new Thrawn novel by Thrawn’s creator, Timothy Zahn, I realized I was looking forward to the novel much more than the television season. As it turns out, my anticipation was properly placed. Seeing Thrawn in Rebels was fun, but somewhat underwhelming. Star Wars: Thrawn, on the other hand, was great!

Timothy Zahn has always been one of my favorite Star Wars authors, and he didn’t disappoint here. The story was fun and engaging, and it brought a new depth to several characters. This book is set in Disney’s new continuity, but it is written in such a way that it can mostly fit into the previous Legends continuity. In particular the events of Outbound Flight are not contradicted, and the first chapter of Thrawn is very similar to Mist Encounter. That said, the book is firmly in the new canon, and leads directly into the events of Rebels Season 3. References to evils lurking in the Unknown Regions applies equally well to Legends (the Yuuzhan Vong) and whatever is being alluded to in the new canon (see Aftermath: Empire’s End).

A few other highlights for me: the reader gets into Thrawn’s head to understand how he thinks, the Chiss Ascendancy is now canon, H’sishi is back in canon, Governor Pryce is given an interesting backstory, and Sy Bisti returns as a language.  Overall, a fun read that stands on its own but really shines if the reader is familiar with Legends or with Star Wars Rebels.